babylon.module.d.ts 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691
  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/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static readonly Now: number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. /**
  486. * Returns client's state
  487. */
  488. readonly readyState: number;
  489. /**
  490. * Returns client's status
  491. */
  492. readonly status: number;
  493. /**
  494. * Returns client's status as a text
  495. */
  496. readonly statusText: string;
  497. /**
  498. * Returns client's response
  499. */
  500. readonly response: any;
  501. /**
  502. * Returns client's response url
  503. */
  504. readonly responseURL: string;
  505. /**
  506. * Returns client's response as text
  507. */
  508. readonly responseText: string;
  509. /**
  510. * Gets or sets the expected response type
  511. */
  512. responseType: XMLHttpRequestResponseType;
  513. /** @hidden */
  514. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  515. /** @hidden */
  516. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  517. /**
  518. * Cancels any network activity
  519. */
  520. abort(): void;
  521. /**
  522. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  523. * @param body defines an optional request body
  524. */
  525. send(body?: Document | BodyInit | null): void;
  526. /**
  527. * Sets the request method, request URL
  528. * @param method defines the method to use (GET, POST, etc..)
  529. * @param url defines the url to connect with
  530. */
  531. open(method: string, url: string): void;
  532. /**
  533. * Sets the value of a request header.
  534. * @param name The name of the header whose value is to be set
  535. * @param value The value to set as the body of the header
  536. */
  537. setRequestHeader(name: string, value: string): void;
  538. /**
  539. * Get the string containing the text of a particular header's value.
  540. * @param name The name of the header
  541. * @returns The string containing the text of the given header name
  542. */
  543. getResponseHeader(name: string): Nullable<string>;
  544. }
  545. }
  546. declare module "babylonjs/Misc/fileRequest" {
  547. import { Observable } from "babylonjs/Misc/observable";
  548. /**
  549. * File request interface
  550. */
  551. export interface IFileRequest {
  552. /**
  553. * Raised when the request is complete (success or error).
  554. */
  555. onCompleteObservable: Observable<IFileRequest>;
  556. /**
  557. * Aborts the request for a file.
  558. */
  559. abort: () => void;
  560. }
  561. }
  562. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  563. /**
  564. * Define options used to create a render target texture
  565. */
  566. export class RenderTargetCreationOptions {
  567. /**
  568. * Specifies is mipmaps must be generated
  569. */
  570. generateMipMaps?: boolean;
  571. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  572. generateDepthBuffer?: boolean;
  573. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  574. generateStencilBuffer?: boolean;
  575. /** Defines texture type (int by default) */
  576. type?: number;
  577. /** Defines sampling mode (trilinear by default) */
  578. samplingMode?: number;
  579. /** Defines format (RGBA by default) */
  580. format?: number;
  581. }
  582. }
  583. declare module "babylonjs/Instrumentation/timeToken" {
  584. import { Nullable } from "babylonjs/types";
  585. /**
  586. * @hidden
  587. **/
  588. export class _TimeToken {
  589. _startTimeQuery: Nullable<WebGLQuery>;
  590. _endTimeQuery: Nullable<WebGLQuery>;
  591. _timeElapsedQuery: Nullable<WebGLQuery>;
  592. _timeElapsedQueryEnded: boolean;
  593. }
  594. }
  595. declare module "babylonjs/Engines/constants" {
  596. /** Defines the cross module used constants to avoid circular dependncies */
  597. export class Constants {
  598. /** Defines that alpha blending is disabled */
  599. static readonly ALPHA_DISABLE: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  601. static readonly ALPHA_ADD: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_COMBINE: number;
  604. /** Defines that alpha blending is DEST - SRC * DEST */
  605. static readonly ALPHA_SUBTRACT: number;
  606. /** Defines that alpha blending is SRC * DEST */
  607. static readonly ALPHA_MULTIPLY: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  609. static readonly ALPHA_MAXIMIZED: number;
  610. /** Defines that alpha blending is SRC + DEST */
  611. static readonly ALPHA_ONEONE: number;
  612. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  613. static readonly ALPHA_PREMULTIPLIED: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  616. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  619. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  620. static readonly ALPHA_INTERPOLATE: number;
  621. /**
  622. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  623. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  624. */
  625. static readonly ALPHA_SCREENMODE: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST
  628. * Alpha will be set to SRC ALPHA + DST ALPHA
  629. */
  630. static readonly ALPHA_ONEONE_ONEONE: number;
  631. /**
  632. * Defines that alpha blending is SRC * DST ALPHA + DST
  633. * Alpha will be set to 0
  634. */
  635. static readonly ALPHA_ALPHATOCOLOR: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. */
  639. static readonly ALPHA_REVERSEONEMINUS: number;
  640. /**
  641. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  642. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  643. */
  644. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  645. /**
  646. * Defines that alpha blending is SRC + DST
  647. * Alpha will be set to SRC ALPHA
  648. */
  649. static readonly ALPHA_ONEONE_ONEZERO: number;
  650. /**
  651. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  652. * Alpha will be set to DST ALPHA
  653. */
  654. static readonly ALPHA_EXCLUSION: number;
  655. /** Defines that alpha blending equation a SUM */
  656. static readonly ALPHA_EQUATION_ADD: number;
  657. /** Defines that alpha blending equation a SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  659. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  661. /** Defines that alpha blending equation a MAX operation */
  662. static readonly ALPHA_EQUATION_MAX: number;
  663. /** Defines that alpha blending equation a MIN operation */
  664. static readonly ALPHA_EQUATION_MIN: number;
  665. /**
  666. * Defines that alpha blending equation a DARKEN operation:
  667. * It takes the min of the src and sums the alpha channels.
  668. */
  669. static readonly ALPHA_EQUATION_DARKEN: number;
  670. /** Defines that the ressource is not delayed*/
  671. static readonly DELAYLOADSTATE_NONE: number;
  672. /** Defines that the ressource was successfully delay loaded */
  673. static readonly DELAYLOADSTATE_LOADED: number;
  674. /** Defines that the ressource is currently delay loading */
  675. static readonly DELAYLOADSTATE_LOADING: number;
  676. /** Defines that the ressource is delayed and has not started loading */
  677. static readonly DELAYLOADSTATE_NOTLOADED: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  679. static readonly NEVER: number;
  680. /** 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 */
  681. static readonly ALWAYS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  683. static readonly LESS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  685. static readonly EQUAL: number;
  686. /** 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 */
  687. static readonly LEQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  689. static readonly GREATER: number;
  690. /** 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 */
  691. static readonly GEQUAL: number;
  692. /** 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 */
  693. static readonly NOTEQUAL: number;
  694. /** Passed to stencilOperation to specify that stencil value must be kept */
  695. static readonly KEEP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be replaced */
  697. static readonly REPLACE: number;
  698. /** Passed to stencilOperation to specify that stencil value must be incremented */
  699. static readonly INCR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be decremented */
  701. static readonly DECR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be inverted */
  703. static readonly INVERT: number;
  704. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  705. static readonly INCR_WRAP: number;
  706. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  707. static readonly DECR_WRAP: number;
  708. /** Texture is not repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  710. /** Texture is repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  712. /** Texture is repeating and mirrored */
  713. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  714. /** ALPHA */
  715. static readonly TEXTUREFORMAT_ALPHA: number;
  716. /** LUMINANCE */
  717. static readonly TEXTUREFORMAT_LUMINANCE: number;
  718. /** LUMINANCE_ALPHA */
  719. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  720. /** RGB */
  721. static readonly TEXTUREFORMAT_RGB: number;
  722. /** RGBA */
  723. static readonly TEXTUREFORMAT_RGBA: number;
  724. /** RED */
  725. static readonly TEXTUREFORMAT_RED: number;
  726. /** RED (2nd reference) */
  727. static readonly TEXTUREFORMAT_R: number;
  728. /** RG */
  729. static readonly TEXTUREFORMAT_RG: number;
  730. /** RED_INTEGER */
  731. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  732. /** RED_INTEGER (2nd reference) */
  733. static readonly TEXTUREFORMAT_R_INTEGER: number;
  734. /** RG_INTEGER */
  735. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  736. /** RGB_INTEGER */
  737. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  738. /** RGBA_INTEGER */
  739. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  740. /** UNSIGNED_BYTE */
  741. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  742. /** UNSIGNED_BYTE (2nd reference) */
  743. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  744. /** FLOAT */
  745. static readonly TEXTURETYPE_FLOAT: number;
  746. /** HALF_FLOAT */
  747. static readonly TEXTURETYPE_HALF_FLOAT: number;
  748. /** BYTE */
  749. static readonly TEXTURETYPE_BYTE: number;
  750. /** SHORT */
  751. static readonly TEXTURETYPE_SHORT: number;
  752. /** UNSIGNED_SHORT */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  754. /** INT */
  755. static readonly TEXTURETYPE_INT: number;
  756. /** UNSIGNED_INT */
  757. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  758. /** UNSIGNED_SHORT_4_4_4_4 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  760. /** UNSIGNED_SHORT_5_5_5_1 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  762. /** UNSIGNED_SHORT_5_6_5 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  764. /** UNSIGNED_INT_2_10_10_10_REV */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  766. /** UNSIGNED_INT_24_8 */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  768. /** UNSIGNED_INT_10F_11F_11F_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  770. /** UNSIGNED_INT_5_9_9_9_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  772. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  773. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  774. /** nearest is mag = nearest and min = nearest and mip = nearest */
  775. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  776. /** Bilinear is mag = linear and min = linear and mip = nearest */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** Trilinear is mag = linear and min = linear and mip = linear */
  779. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** Bilinear is mag = linear and min = linear and mip = nearest */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  786. /** mag = nearest and min = nearest and mip = nearest */
  787. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = nearest */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = linear */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  792. /** mag = nearest and min = linear and mip = none */
  793. static readonly TEXTURE_NEAREST_LINEAR: number;
  794. /** mag = nearest and min = nearest and mip = none */
  795. static readonly TEXTURE_NEAREST_NEAREST: number;
  796. /** mag = linear and min = nearest and mip = nearest */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  798. /** mag = linear and min = nearest and mip = linear */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = linear and mip = none */
  801. static readonly TEXTURE_LINEAR_LINEAR: number;
  802. /** mag = linear and min = nearest and mip = none */
  803. static readonly TEXTURE_LINEAR_NEAREST: number;
  804. /** Explicit coordinates mode */
  805. static readonly TEXTURE_EXPLICIT_MODE: number;
  806. /** Spherical coordinates mode */
  807. static readonly TEXTURE_SPHERICAL_MODE: number;
  808. /** Planar coordinates mode */
  809. static readonly TEXTURE_PLANAR_MODE: number;
  810. /** Cubic coordinates mode */
  811. static readonly TEXTURE_CUBIC_MODE: number;
  812. /** Projection coordinates mode */
  813. static readonly TEXTURE_PROJECTION_MODE: number;
  814. /** Skybox coordinates mode */
  815. static readonly TEXTURE_SKYBOX_MODE: number;
  816. /** Inverse Cubic coordinates mode */
  817. static readonly TEXTURE_INVCUBIC_MODE: number;
  818. /** Equirectangular coordinates mode */
  819. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed Mirrored coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  824. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  825. static readonly SCALEMODE_FLOOR: number;
  826. /** Defines that texture rescaling will look for the nearest power of 2 size */
  827. static readonly SCALEMODE_NEAREST: number;
  828. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  829. static readonly SCALEMODE_CEILING: number;
  830. /**
  831. * The dirty texture flag value
  832. */
  833. static readonly MATERIAL_TextureDirtyFlag: number;
  834. /**
  835. * The dirty light flag value
  836. */
  837. static readonly MATERIAL_LightDirtyFlag: number;
  838. /**
  839. * The dirty fresnel flag value
  840. */
  841. static readonly MATERIAL_FresnelDirtyFlag: number;
  842. /**
  843. * The dirty attribute flag value
  844. */
  845. static readonly MATERIAL_AttributesDirtyFlag: number;
  846. /**
  847. * The dirty misc flag value
  848. */
  849. static readonly MATERIAL_MiscDirtyFlag: number;
  850. /**
  851. * The all dirty flag value
  852. */
  853. static readonly MATERIAL_AllDirtyFlag: number;
  854. /**
  855. * Returns the triangle fill mode
  856. */
  857. static readonly MATERIAL_TriangleFillMode: number;
  858. /**
  859. * Returns the wireframe mode
  860. */
  861. static readonly MATERIAL_WireFrameFillMode: number;
  862. /**
  863. * Returns the point fill mode
  864. */
  865. static readonly MATERIAL_PointFillMode: number;
  866. /**
  867. * Returns the point list draw mode
  868. */
  869. static readonly MATERIAL_PointListDrawMode: number;
  870. /**
  871. * Returns the line list draw mode
  872. */
  873. static readonly MATERIAL_LineListDrawMode: number;
  874. /**
  875. * Returns the line loop draw mode
  876. */
  877. static readonly MATERIAL_LineLoopDrawMode: number;
  878. /**
  879. * Returns the line strip draw mode
  880. */
  881. static readonly MATERIAL_LineStripDrawMode: number;
  882. /**
  883. * Returns the triangle strip draw mode
  884. */
  885. static readonly MATERIAL_TriangleStripDrawMode: number;
  886. /**
  887. * Returns the triangle fan draw mode
  888. */
  889. static readonly MATERIAL_TriangleFanDrawMode: number;
  890. /**
  891. * Stores the clock-wise side orientation
  892. */
  893. static readonly MATERIAL_ClockWiseSideOrientation: number;
  894. /**
  895. * Stores the counter clock-wise side orientation
  896. */
  897. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  898. /**
  899. * Nothing
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_NothingTrigger: number;
  903. /**
  904. * On pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPickTrigger: number;
  908. /**
  909. * On left pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnLeftPickTrigger: number;
  913. /**
  914. * On right pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnRightPickTrigger: number;
  918. /**
  919. * On center pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnCenterPickTrigger: number;
  923. /**
  924. * On pick down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickDownTrigger: number;
  928. /**
  929. * On double pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnDoublePickTrigger: number;
  933. /**
  934. * On pick up
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickUpTrigger: number;
  938. /**
  939. * On pick out.
  940. * This trigger will only be raised if you also declared a OnPickDown
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickOutTrigger: number;
  944. /**
  945. * On long press
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnLongPressTrigger: number;
  949. /**
  950. * On pointer over
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPointerOverTrigger: number;
  954. /**
  955. * On pointer out
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnPointerOutTrigger: number;
  959. /**
  960. * On every frame
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnEveryFrameTrigger: number;
  964. /**
  965. * On intersection enter
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnIntersectionEnterTrigger: number;
  969. /**
  970. * On intersection exit
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnIntersectionExitTrigger: number;
  974. /**
  975. * On key down
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnKeyDownTrigger: number;
  979. /**
  980. * On key up
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnKeyUpTrigger: number;
  984. /**
  985. * Billboard mode will only apply to Y axis
  986. */
  987. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  988. /**
  989. * Billboard mode will apply to all axes
  990. */
  991. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  992. /**
  993. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  994. */
  995. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  996. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  997. * Test order :
  998. * Is the bounding sphere outside the frustum ?
  999. * If not, are the bounding box vertices outside the frustum ?
  1000. * It not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1003. /** Culling strategy : Bounding Sphere Only.
  1004. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1005. * It's also less accurate than the standard because some not visible objects can still be selected.
  1006. * Test : is the bounding sphere outside the frustum ?
  1007. * If not, then the cullable object is in the frustum.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1010. /** Culling strategy : Optimistic Inclusion.
  1011. * This in an inclusion test first, then the standard exclusion test.
  1012. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1013. * 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.
  1014. * Anyway, it's as accurate as the standard strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the default culling strategy.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1020. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1021. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1022. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1030. /**
  1031. * No logging while loading
  1032. */
  1033. static readonly SCENELOADER_NO_LOGGING: number;
  1034. /**
  1035. * Minimal logging while loading
  1036. */
  1037. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1038. /**
  1039. * Summary logging while loading
  1040. */
  1041. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1042. /**
  1043. * Detailled logging while loading
  1044. */
  1045. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1046. }
  1047. }
  1048. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1049. import { Nullable } from "babylonjs/types";
  1050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1051. /**
  1052. * This represents the required contract to create a new type of texture loader.
  1053. */
  1054. export interface IInternalTextureLoader {
  1055. /**
  1056. * Defines wether the loader supports cascade loading the different faces.
  1057. */
  1058. supportCascades: boolean;
  1059. /**
  1060. * This returns if the loader support the current file information.
  1061. * @param extension defines the file extension of the file being loaded
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @param fallback defines the fallback internal texture if any
  1064. * @param isBase64 defines whether the texture is encoded as a base64
  1065. * @param isBuffer defines whether the texture data are stored as a buffer
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1069. /**
  1070. * Transform the url before loading if required.
  1071. * @param rootUrl the url of the texture
  1072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1073. * @returns the transformed texture
  1074. */
  1075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1076. /**
  1077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1078. * @param rootUrl the url of the texture
  1079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1080. * @returns the fallback texture
  1081. */
  1082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1083. /**
  1084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1085. * @param data contains the texture data
  1086. * @param texture defines the BabylonJS internal texture
  1087. * @param createPolynomials will be true if polynomials have been requested
  1088. * @param onLoad defines the callback to trigger once the texture is ready
  1089. * @param onError defines the callback to trigger in case of error
  1090. */
  1091. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1092. /**
  1093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param callback defines the method to call once ready to upload
  1097. */
  1098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Engines/IPipelineContext" {
  1102. /**
  1103. * Class used to store and describe the pipeline context associated with an effect
  1104. */
  1105. export interface IPipelineContext {
  1106. /**
  1107. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1108. */
  1109. isAsync: boolean;
  1110. /**
  1111. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1112. */
  1113. isReady: boolean;
  1114. /** @hidden */
  1115. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1116. }
  1117. }
  1118. declare module "babylonjs/Meshes/dataBuffer" {
  1119. /**
  1120. * Class used to store gfx data (like WebGLBuffer)
  1121. */
  1122. export class DataBuffer {
  1123. /**
  1124. * Gets or sets the number of objects referencing this buffer
  1125. */
  1126. references: number;
  1127. /** Gets or sets the size of the underlying buffer */
  1128. capacity: number;
  1129. /**
  1130. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1131. */
  1132. is32Bits: boolean;
  1133. /**
  1134. * Gets the underlying buffer
  1135. */
  1136. readonly underlyingResource: any;
  1137. }
  1138. }
  1139. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1140. /** @hidden */
  1141. export interface IShaderProcessor {
  1142. attributeProcessor?: (attribute: string) => string;
  1143. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1144. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1145. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1146. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1147. lineProcessor?: (line: string, isFragment: boolean) => string;
  1148. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1149. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1153. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1154. /** @hidden */
  1155. export interface ProcessingOptions {
  1156. defines: string[];
  1157. indexParameters: any;
  1158. isFragment: boolean;
  1159. shouldUseHighPrecisionShader: boolean;
  1160. supportsUniformBuffers: boolean;
  1161. shadersRepository: string;
  1162. includesShadersStore: {
  1163. [key: string]: string;
  1164. };
  1165. processor?: IShaderProcessor;
  1166. version: string;
  1167. platformName: string;
  1168. lookForClosingBracketForUniformBuffer?: boolean;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1172. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1173. /** @hidden */
  1174. export class ShaderCodeNode {
  1175. line: string;
  1176. children: ShaderCodeNode[];
  1177. additionalDefineKey?: string;
  1178. additionalDefineValue?: string;
  1179. isValid(preprocessors: {
  1180. [key: string]: string;
  1181. }): boolean;
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1188. /** @hidden */
  1189. export class ShaderCodeCursor {
  1190. private _lines;
  1191. lineIndex: number;
  1192. readonly currentLine: string;
  1193. readonly canRead: boolean;
  1194. lines: string[];
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1198. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1199. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1200. /** @hidden */
  1201. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1202. process(preprocessors: {
  1203. [key: string]: string;
  1204. }, options: ProcessingOptions): string;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1208. /** @hidden */
  1209. export class ShaderDefineExpression {
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. 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>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. /** @hidden */
  1474. export class ShaderProcessor {
  1475. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1476. private static _ProcessPrecision;
  1477. private static _ExtractOperation;
  1478. private static _BuildSubExpression;
  1479. private static _BuildExpression;
  1480. private static _MoveCursorWithinIf;
  1481. private static _MoveCursor;
  1482. private static _EvaluatePreProcessors;
  1483. private static _PreparePreProcessors;
  1484. private static _ProcessShaderConversion;
  1485. private static _ProcessIncludes;
  1486. }
  1487. }
  1488. declare module "babylonjs/Maths/math.like" {
  1489. import { float, int, DeepImmutable } from "babylonjs/types";
  1490. /**
  1491. * @hidden
  1492. */
  1493. export interface IColor4Like {
  1494. r: float;
  1495. g: float;
  1496. b: float;
  1497. a: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IColor3Like {
  1503. r: float;
  1504. g: float;
  1505. b: float;
  1506. }
  1507. /**
  1508. * @hidden
  1509. */
  1510. export interface IVector4Like {
  1511. x: float;
  1512. y: float;
  1513. z: float;
  1514. w: float;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IVector3Like {
  1520. x: float;
  1521. y: float;
  1522. z: float;
  1523. }
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IVector2Like {
  1528. x: float;
  1529. y: float;
  1530. }
  1531. /**
  1532. * @hidden
  1533. */
  1534. export interface IMatrixLike {
  1535. toArray(): DeepImmutable<Float32Array>;
  1536. updateFlag: int;
  1537. }
  1538. /**
  1539. * @hidden
  1540. */
  1541. export interface IViewportLike {
  1542. x: float;
  1543. y: float;
  1544. width: float;
  1545. height: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IPlaneLike {
  1551. normal: IVector3Like;
  1552. d: float;
  1553. normalize(): void;
  1554. }
  1555. }
  1556. declare module "babylonjs/Materials/iEffectFallbacks" {
  1557. import { Effect } from "babylonjs/Materials/effect";
  1558. /**
  1559. * Interface used to define common properties for effect fallbacks
  1560. */
  1561. export interface IEffectFallbacks {
  1562. /**
  1563. * Removes the defines that should be removed when falling back.
  1564. * @param currentDefines defines the current define statements for the shader.
  1565. * @param effect defines the current effect we try to compile
  1566. * @returns The resulting defines with defines of the current rank removed.
  1567. */
  1568. reduce(currentDefines: string, effect: Effect): string;
  1569. /**
  1570. * Removes the fallback from the bound mesh.
  1571. */
  1572. unBindMesh(): void;
  1573. /**
  1574. * Checks to see if more fallbacks are still availible.
  1575. */
  1576. hasMoreFallbacks: boolean;
  1577. }
  1578. }
  1579. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1580. /**
  1581. * Class used to evalaute queries containing `and` and `or` operators
  1582. */
  1583. export class AndOrNotEvaluator {
  1584. /**
  1585. * Evaluate a query
  1586. * @param query defines the query to evaluate
  1587. * @param evaluateCallback defines the callback used to filter result
  1588. * @returns true if the query matches
  1589. */
  1590. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1591. private static _HandleParenthesisContent;
  1592. private static _SimplifyNegation;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/tags" {
  1596. /**
  1597. * Class used to store custom tags
  1598. */
  1599. export class Tags {
  1600. /**
  1601. * Adds support for tags on the given object
  1602. * @param obj defines the object to use
  1603. */
  1604. static EnableFor(obj: any): void;
  1605. /**
  1606. * Removes tags support
  1607. * @param obj defines the object to use
  1608. */
  1609. static DisableFor(obj: any): void;
  1610. /**
  1611. * Gets a boolean indicating if the given object has tags
  1612. * @param obj defines the object to use
  1613. * @returns a boolean
  1614. */
  1615. static HasTags(obj: any): boolean;
  1616. /**
  1617. * Gets the tags available on a given object
  1618. * @param obj defines the object to use
  1619. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1620. * @returns the tags
  1621. */
  1622. static GetTags(obj: any, asString?: boolean): any;
  1623. /**
  1624. * Adds tags to an object
  1625. * @param obj defines the object to use
  1626. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1627. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1628. */
  1629. static AddTagsTo(obj: any, tagsString: string): void;
  1630. /**
  1631. * @hidden
  1632. */
  1633. static _AddTagTo(obj: any, tag: string): void;
  1634. /**
  1635. * Removes specific tags from a specific object
  1636. * @param obj defines the object to use
  1637. * @param tagsString defines the tags to remove
  1638. */
  1639. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1640. /**
  1641. * @hidden
  1642. */
  1643. static _RemoveTagFrom(obj: any, tag: string): void;
  1644. /**
  1645. * Defines if tags hosted on an object match a given query
  1646. * @param obj defines the object to use
  1647. * @param tagsQuery defines the tag query
  1648. * @returns a boolean
  1649. */
  1650. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1651. }
  1652. }
  1653. declare module "babylonjs/Maths/math.scalar" {
  1654. /**
  1655. * Scalar computation library
  1656. */
  1657. export class Scalar {
  1658. /**
  1659. * Two pi constants convenient for computation.
  1660. */
  1661. static TwoPi: number;
  1662. /**
  1663. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1664. * @param a number
  1665. * @param b number
  1666. * @param epsilon (default = 1.401298E-45)
  1667. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. */
  1669. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1670. /**
  1671. * Returns a string : the upper case translation of the number i to hexadecimal.
  1672. * @param i number
  1673. * @returns the upper case translation of the number i to hexadecimal.
  1674. */
  1675. static ToHex(i: number): string;
  1676. /**
  1677. * Returns -1 if value is negative and +1 is value is positive.
  1678. * @param value the value
  1679. * @returns the value itself if it's equal to zero.
  1680. */
  1681. static Sign(value: number): number;
  1682. /**
  1683. * Returns the value itself if it's between min and max.
  1684. * Returns min if the value is lower than min.
  1685. * Returns max if the value is greater than max.
  1686. * @param value the value to clmap
  1687. * @param min the min value to clamp to (default: 0)
  1688. * @param max the max value to clamp to (default: 1)
  1689. * @returns the clamped value
  1690. */
  1691. static Clamp(value: number, min?: number, max?: number): number;
  1692. /**
  1693. * the log2 of value.
  1694. * @param value the value to compute log2 of
  1695. * @returns the log2 of value.
  1696. */
  1697. static Log2(value: number): number;
  1698. /**
  1699. * Loops the value, so that it is never larger than length and never smaller than 0.
  1700. *
  1701. * This is similar to the modulo operator but it works with floating point numbers.
  1702. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1703. * With t = 5 and length = 2.5, the result would be 0.0.
  1704. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1705. * @param value the value
  1706. * @param length the length
  1707. * @returns the looped value
  1708. */
  1709. static Repeat(value: number, length: number): number;
  1710. /**
  1711. * Normalize the value between 0.0 and 1.0 using min and max values
  1712. * @param value value to normalize
  1713. * @param min max to normalize between
  1714. * @param max min to normalize between
  1715. * @returns the normalized value
  1716. */
  1717. static Normalize(value: number, min: number, max: number): number;
  1718. /**
  1719. * Denormalize the value from 0.0 and 1.0 using min and max values
  1720. * @param normalized value to denormalize
  1721. * @param min max to denormalize between
  1722. * @param max min to denormalize between
  1723. * @returns the denormalized value
  1724. */
  1725. static Denormalize(normalized: number, min: number, max: number): number;
  1726. /**
  1727. * Calculates the shortest difference between two given angles given in degrees.
  1728. * @param current current angle in degrees
  1729. * @param target target angle in degrees
  1730. * @returns the delta
  1731. */
  1732. static DeltaAngle(current: number, target: number): number;
  1733. /**
  1734. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1735. * @param tx value
  1736. * @param length length
  1737. * @returns The returned value will move back and forth between 0 and length
  1738. */
  1739. static PingPong(tx: number, length: number): number;
  1740. /**
  1741. * Interpolates between min and max with smoothing at the limits.
  1742. *
  1743. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1744. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1745. * @param from from
  1746. * @param to to
  1747. * @param tx value
  1748. * @returns the smooth stepped value
  1749. */
  1750. static SmoothStep(from: number, to: number, tx: number): number;
  1751. /**
  1752. * Moves a value current towards target.
  1753. *
  1754. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1755. * Negative values of maxDelta pushes the value away from target.
  1756. * @param current current value
  1757. * @param target target value
  1758. * @param maxDelta max distance to move
  1759. * @returns resulting value
  1760. */
  1761. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1762. /**
  1763. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1764. *
  1765. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1766. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1767. * @param current current value
  1768. * @param target target value
  1769. * @param maxDelta max distance to move
  1770. * @returns resulting angle
  1771. */
  1772. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1773. /**
  1774. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1775. * @param start start value
  1776. * @param end target value
  1777. * @param amount amount to lerp between
  1778. * @returns the lerped value
  1779. */
  1780. static Lerp(start: number, end: number, amount: number): number;
  1781. /**
  1782. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1783. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1784. * @param start start value
  1785. * @param end target value
  1786. * @param amount amount to lerp between
  1787. * @returns the lerped value
  1788. */
  1789. static LerpAngle(start: number, end: number, amount: number): number;
  1790. /**
  1791. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1792. * @param a start value
  1793. * @param b target value
  1794. * @param value value between a and b
  1795. * @returns the inverseLerp value
  1796. */
  1797. static InverseLerp(a: number, b: number, value: number): number;
  1798. /**
  1799. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1800. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1801. * @param value1 spline value
  1802. * @param tangent1 spline value
  1803. * @param value2 spline value
  1804. * @param tangent2 spline value
  1805. * @param amount input value
  1806. * @returns hermite result
  1807. */
  1808. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1809. /**
  1810. * Returns a random float number between and min and max values
  1811. * @param min min value of random
  1812. * @param max max value of random
  1813. * @returns random value
  1814. */
  1815. static RandomRange(min: number, max: number): number;
  1816. /**
  1817. * This function returns percentage of a number in a given range.
  1818. *
  1819. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1820. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1821. * @param number to convert to percentage
  1822. * @param min min range
  1823. * @param max max range
  1824. * @returns the percentage
  1825. */
  1826. static RangeToPercent(number: number, min: number, max: number): number;
  1827. /**
  1828. * This function returns number that corresponds to the percentage in a given range.
  1829. *
  1830. * PercentToRange(0.34,0,100) will return 34.
  1831. * @param percent to convert to number
  1832. * @param min min range
  1833. * @param max max range
  1834. * @returns the number
  1835. */
  1836. static PercentToRange(percent: number, min: number, max: number): number;
  1837. /**
  1838. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1839. * @param angle The angle to normalize in radian.
  1840. * @return The converted angle.
  1841. */
  1842. static NormalizeRadians(angle: number): number;
  1843. }
  1844. }
  1845. declare module "babylonjs/Maths/math.constants" {
  1846. /**
  1847. * Constant used to convert a value to gamma space
  1848. * @ignorenaming
  1849. */
  1850. export const ToGammaSpace: number;
  1851. /**
  1852. * Constant used to convert a value to linear space
  1853. * @ignorenaming
  1854. */
  1855. export const ToLinearSpace = 2.2;
  1856. /**
  1857. * Constant used to define the minimal number value in Babylon.js
  1858. * @ignorenaming
  1859. */
  1860. let Epsilon: number;
  1861. export { Epsilon };
  1862. }
  1863. declare module "babylonjs/Maths/math.viewport" {
  1864. /**
  1865. * Class used to represent a viewport on screen
  1866. */
  1867. export class Viewport {
  1868. /** viewport left coordinate */
  1869. x: number;
  1870. /** viewport top coordinate */
  1871. y: number;
  1872. /**viewport width */
  1873. width: number;
  1874. /** viewport height */
  1875. height: number;
  1876. /**
  1877. * Creates a Viewport object located at (x, y) and sized (width, height)
  1878. * @param x defines viewport left coordinate
  1879. * @param y defines viewport top coordinate
  1880. * @param width defines the viewport width
  1881. * @param height defines the viewport height
  1882. */
  1883. constructor(
  1884. /** viewport left coordinate */
  1885. x: number,
  1886. /** viewport top coordinate */
  1887. y: number,
  1888. /**viewport width */
  1889. width: number,
  1890. /** viewport height */
  1891. height: number);
  1892. /**
  1893. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1894. * @param renderWidth defines the rendering width
  1895. * @param renderHeight defines the rendering height
  1896. * @returns a new Viewport
  1897. */
  1898. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1899. /**
  1900. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1901. * @param renderWidth defines the rendering width
  1902. * @param renderHeight defines the rendering height
  1903. * @param ref defines the target viewport
  1904. * @returns the current viewport
  1905. */
  1906. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1907. /**
  1908. * Returns a new Viewport copied from the current one
  1909. * @returns a new Viewport
  1910. */
  1911. clone(): Viewport;
  1912. }
  1913. }
  1914. declare module "babylonjs/Misc/arrayTools" {
  1915. /**
  1916. * Class containing a set of static utilities functions for arrays.
  1917. */
  1918. export class ArrayTools {
  1919. /**
  1920. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1921. * @param size the number of element to construct and put in the array
  1922. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1923. * @returns a new array filled with new objects
  1924. */
  1925. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1926. }
  1927. }
  1928. declare module "babylonjs/Maths/math.vector" {
  1929. import { Viewport } from "babylonjs/Maths/math.viewport";
  1930. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1931. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1932. /**
  1933. * Class representing a vector containing 2 coordinates
  1934. */
  1935. export class Vector2 {
  1936. /** defines the first coordinate */
  1937. x: number;
  1938. /** defines the second coordinate */
  1939. y: number;
  1940. /**
  1941. * Creates a new Vector2 from the given x and y coordinates
  1942. * @param x defines the first coordinate
  1943. * @param y defines the second coordinate
  1944. */
  1945. constructor(
  1946. /** defines the first coordinate */
  1947. x?: number,
  1948. /** defines the second coordinate */
  1949. y?: number);
  1950. /**
  1951. * Gets a string with the Vector2 coordinates
  1952. * @returns a string with the Vector2 coordinates
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Gets class name
  1957. * @returns the string "Vector2"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Gets current vector hash code
  1962. * @returns the Vector2 hash code as a number
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1967. * @param array defines the source array
  1968. * @param index defines the offset in source array
  1969. * @returns the current Vector2
  1970. */
  1971. toArray(array: FloatArray, index?: number): Vector2;
  1972. /**
  1973. * Copy the current vector to an array
  1974. * @returns a new array with 2 elements: the Vector2 coordinates.
  1975. */
  1976. asArray(): number[];
  1977. /**
  1978. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1979. * @param source defines the source Vector2
  1980. * @returns the current updated Vector2
  1981. */
  1982. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1983. /**
  1984. * Sets the Vector2 coordinates with the given floats
  1985. * @param x defines the first coordinate
  1986. * @param y defines the second coordinate
  1987. * @returns the current updated Vector2
  1988. */
  1989. copyFromFloats(x: number, y: number): Vector2;
  1990. /**
  1991. * Sets the Vector2 coordinates with the given floats
  1992. * @param x defines the first coordinate
  1993. * @param y defines the second coordinate
  1994. * @returns the current updated Vector2
  1995. */
  1996. set(x: number, y: number): Vector2;
  1997. /**
  1998. * Add another vector with the current one
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2001. */
  2002. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns a new Vector2
  2020. */
  2021. addVector3(otherVector: Vector3): Vector2;
  2022. /**
  2023. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. subtract(otherVector: Vector2): Vector2;
  2028. /**
  2029. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns the current updated Vector2
  2039. */
  2040. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Multiplies in place the current Vector2 coordinates by the given ones
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2049. * @param otherVector defines the other vector
  2050. * @returns a new Vector2
  2051. */
  2052. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @param result defines the target vector
  2057. * @returns the unmodified current Vector2
  2058. */
  2059. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2060. /**
  2061. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2062. * @param x defines the first coordinate
  2063. * @param y defines the second coordinate
  2064. * @returns a new Vector2
  2065. */
  2066. multiplyByFloats(x: number, y: number): Vector2;
  2067. /**
  2068. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2069. * @param otherVector defines the other vector
  2070. * @returns a new Vector2
  2071. */
  2072. divide(otherVector: Vector2): Vector2;
  2073. /**
  2074. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @param result defines the target vector
  2077. * @returns the unmodified current Vector2
  2078. */
  2079. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2080. /**
  2081. * Divides the current Vector2 coordinates by the given ones
  2082. * @param otherVector defines the other vector
  2083. * @returns the current updated Vector2
  2084. */
  2085. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Gets a new Vector2 with current Vector2 negated coordinates
  2088. * @returns a new Vector2
  2089. */
  2090. negate(): Vector2;
  2091. /**
  2092. * Multiply the Vector2 coordinates by scale
  2093. * @param scale defines the scaling factor
  2094. * @returns the current updated Vector2
  2095. */
  2096. scaleInPlace(scale: number): Vector2;
  2097. /**
  2098. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2099. * @param scale defines the scaling factor
  2100. * @returns a new Vector2
  2101. */
  2102. scale(scale: number): Vector2;
  2103. /**
  2104. * Scale the current Vector2 values by a factor to a given Vector2
  2105. * @param scale defines the scale factor
  2106. * @param result defines the Vector2 object where to store the result
  2107. * @returns the unmodified current Vector2
  2108. */
  2109. scaleToRef(scale: number, result: Vector2): Vector2;
  2110. /**
  2111. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2112. * @param scale defines the scale factor
  2113. * @param result defines the Vector2 object where to store the result
  2114. * @returns the unmodified current Vector2
  2115. */
  2116. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2117. /**
  2118. * Gets a boolean if two vectors are equals
  2119. * @param otherVector defines the other vector
  2120. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2121. */
  2122. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2123. /**
  2124. * Gets a boolean if two vectors are equals (using an epsilon value)
  2125. * @param otherVector defines the other vector
  2126. * @param epsilon defines the minimal distance to consider equality
  2127. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2128. */
  2129. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2130. /**
  2131. * Gets a new Vector2 from current Vector2 floored values
  2132. * @returns a new Vector2
  2133. */
  2134. floor(): Vector2;
  2135. /**
  2136. * Gets a new Vector2 from current Vector2 floored values
  2137. * @returns a new Vector2
  2138. */
  2139. fract(): Vector2;
  2140. /**
  2141. * Gets the length of the vector
  2142. * @returns the vector length (float)
  2143. */
  2144. length(): number;
  2145. /**
  2146. * Gets the vector squared length
  2147. * @returns the vector squared length (float)
  2148. */
  2149. lengthSquared(): number;
  2150. /**
  2151. * Normalize the vector
  2152. * @returns the current updated Vector2
  2153. */
  2154. normalize(): Vector2;
  2155. /**
  2156. * Gets a new Vector2 copied from the Vector2
  2157. * @returns a new Vector2
  2158. */
  2159. clone(): Vector2;
  2160. /**
  2161. * Gets a new Vector2(0, 0)
  2162. * @returns a new Vector2
  2163. */
  2164. static Zero(): Vector2;
  2165. /**
  2166. * Gets a new Vector2(1, 1)
  2167. * @returns a new Vector2
  2168. */
  2169. static One(): Vector2;
  2170. /**
  2171. * Gets a new Vector2 set from the given index element of the given array
  2172. * @param array defines the data source
  2173. * @param offset defines the offset in the data source
  2174. * @returns a new Vector2
  2175. */
  2176. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2177. /**
  2178. * Sets "result" from the given index element of the given array
  2179. * @param array defines the data source
  2180. * @param offset defines the offset in the data source
  2181. * @param result defines the target vector
  2182. */
  2183. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2184. /**
  2185. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2186. * @param value1 defines 1st point of control
  2187. * @param value2 defines 2nd point of control
  2188. * @param value3 defines 3rd point of control
  2189. * @param value4 defines 4th point of control
  2190. * @param amount defines the interpolation factor
  2191. * @returns a new Vector2
  2192. */
  2193. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2194. /**
  2195. * 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".
  2196. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2197. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2198. * @param value defines the value to clamp
  2199. * @param min defines the lower limit
  2200. * @param max defines the upper limit
  2201. * @returns a new Vector2
  2202. */
  2203. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2204. /**
  2205. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2206. * @param value1 defines the 1st control point
  2207. * @param tangent1 defines the outgoing tangent
  2208. * @param value2 defines the 2nd control point
  2209. * @param tangent2 defines the incoming tangent
  2210. * @param amount defines the interpolation factor
  2211. * @returns a new Vector2
  2212. */
  2213. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2214. /**
  2215. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2216. * @param start defines the start vector
  2217. * @param end defines the end vector
  2218. * @param amount defines the interpolation factor
  2219. * @returns a new Vector2
  2220. */
  2221. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2222. /**
  2223. * Gets the dot product of the vector "left" and the vector "right"
  2224. * @param left defines first vector
  2225. * @param right defines second vector
  2226. * @returns the dot product (float)
  2227. */
  2228. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2229. /**
  2230. * Returns a new Vector2 equal to the normalized given vector
  2231. * @param vector defines the vector to normalize
  2232. * @returns a new Vector2
  2233. */
  2234. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2237. * @param left defines 1st vector
  2238. * @param right defines 2nd vector
  2239. * @returns a new Vector2
  2240. */
  2241. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2244. * @param left defines 1st vector
  2245. * @param right defines 2nd vector
  2246. * @returns a new Vector2
  2247. */
  2248. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2251. * @param vector defines the vector to transform
  2252. * @param transformation defines the matrix to apply
  2253. * @returns a new Vector2
  2254. */
  2255. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2256. /**
  2257. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2258. * @param vector defines the vector to transform
  2259. * @param transformation defines the matrix to apply
  2260. * @param result defines the target vector
  2261. */
  2262. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2263. /**
  2264. * Determines if a given vector is included in a triangle
  2265. * @param p defines the vector to test
  2266. * @param p0 defines 1st triangle point
  2267. * @param p1 defines 2nd triangle point
  2268. * @param p2 defines 3rd triangle point
  2269. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2270. */
  2271. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2272. /**
  2273. * Gets the distance between the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns the distance between vectors
  2277. */
  2278. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2279. /**
  2280. * Returns the squared distance between the vectors "value1" and "value2"
  2281. * @param value1 defines first vector
  2282. * @param value2 defines second vector
  2283. * @returns the squared distance between vectors
  2284. */
  2285. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2286. /**
  2287. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2288. * @param value1 defines first vector
  2289. * @param value2 defines second vector
  2290. * @returns a new Vector2
  2291. */
  2292. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2293. /**
  2294. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2295. * @param p defines the middle point
  2296. * @param segA defines one point of the segment
  2297. * @param segB defines the other point of the segment
  2298. * @returns the shortest distance
  2299. */
  2300. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2301. }
  2302. /**
  2303. * Class used to store (x,y,z) vector representation
  2304. * A Vector3 is the main object used in 3D geometry
  2305. * It can represent etiher the coordinates of a point the space, either a direction
  2306. * Reminder: js uses a left handed forward facing system
  2307. */
  2308. export class Vector3 {
  2309. /**
  2310. * Defines the first coordinates (on X axis)
  2311. */
  2312. x: number;
  2313. /**
  2314. * Defines the second coordinates (on Y axis)
  2315. */
  2316. y: number;
  2317. /**
  2318. * Defines the third coordinates (on Z axis)
  2319. */
  2320. z: number;
  2321. private static _UpReadOnly;
  2322. private static _ZeroReadOnly;
  2323. /**
  2324. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2325. * @param x defines the first coordinates (on X axis)
  2326. * @param y defines the second coordinates (on Y axis)
  2327. * @param z defines the third coordinates (on Z axis)
  2328. */
  2329. constructor(
  2330. /**
  2331. * Defines the first coordinates (on X axis)
  2332. */
  2333. x?: number,
  2334. /**
  2335. * Defines the second coordinates (on Y axis)
  2336. */
  2337. y?: number,
  2338. /**
  2339. * Defines the third coordinates (on Z axis)
  2340. */
  2341. z?: number);
  2342. /**
  2343. * Creates a string representation of the Vector3
  2344. * @returns a string with the Vector3 coordinates.
  2345. */
  2346. toString(): string;
  2347. /**
  2348. * Gets the class name
  2349. * @returns the string "Vector3"
  2350. */
  2351. getClassName(): string;
  2352. /**
  2353. * Creates the Vector3 hash code
  2354. * @returns a number which tends to be unique between Vector3 instances
  2355. */
  2356. getHashCode(): number;
  2357. /**
  2358. * Creates an array containing three elements : the coordinates of the Vector3
  2359. * @returns a new array of numbers
  2360. */
  2361. asArray(): number[];
  2362. /**
  2363. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2364. * @param array defines the destination array
  2365. * @param index defines the offset in the destination array
  2366. * @returns the current Vector3
  2367. */
  2368. toArray(array: FloatArray, index?: number): Vector3;
  2369. /**
  2370. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2371. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2372. */
  2373. toQuaternion(): Quaternion;
  2374. /**
  2375. * Adds the given vector to the current Vector3
  2376. * @param otherVector defines the second operand
  2377. * @returns the current updated Vector3
  2378. */
  2379. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the given coordinates to the current Vector3
  2382. * @param x defines the x coordinate of the operand
  2383. * @param y defines the y coordinate of the operand
  2384. * @param z defines the z coordinate of the operand
  2385. * @returns the current updated Vector3
  2386. */
  2387. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2388. /**
  2389. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2390. * @param otherVector defines the second operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2396. * @param otherVector defines the second operand
  2397. * @param result defines the Vector3 object where to store the result
  2398. * @returns the current Vector3
  2399. */
  2400. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2401. /**
  2402. * Subtract the given vector from the current Vector3
  2403. * @param otherVector defines the second operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2407. /**
  2408. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2409. * @param otherVector defines the second operand
  2410. * @returns the resulting Vector3
  2411. */
  2412. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns the resulting Vector3
  2426. */
  2427. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2428. /**
  2429. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2430. * @param x defines the x coordinate of the operand
  2431. * @param y defines the y coordinate of the operand
  2432. * @param z defines the z coordinate of the operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2437. /**
  2438. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2439. * @returns a new Vector3
  2440. */
  2441. negate(): Vector3;
  2442. /**
  2443. * Multiplies the Vector3 coordinates by the float "scale"
  2444. * @param scale defines the multiplier factor
  2445. * @returns the current updated Vector3
  2446. */
  2447. scaleInPlace(scale: number): Vector3;
  2448. /**
  2449. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2450. * @param scale defines the multiplier factor
  2451. * @returns a new Vector3
  2452. */
  2453. scale(scale: number): Vector3;
  2454. /**
  2455. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2456. * @param scale defines the multiplier factor
  2457. * @param result defines the Vector3 object where to store the result
  2458. * @returns the current Vector3
  2459. */
  2460. scaleToRef(scale: number, result: Vector3): Vector3;
  2461. /**
  2462. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2463. * @param scale defines the scale factor
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the unmodified current Vector3
  2466. */
  2467. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2468. /**
  2469. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2470. * @param otherVector defines the second operand
  2471. * @returns true if both vectors are equals
  2472. */
  2473. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2474. /**
  2475. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2476. * @param otherVector defines the second operand
  2477. * @param epsilon defines the minimal distance to define values as equals
  2478. * @returns true if both vectors are distant less than epsilon
  2479. */
  2480. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2481. /**
  2482. * Returns true if the current Vector3 coordinates equals the given floats
  2483. * @param x defines the x coordinate of the operand
  2484. * @param y defines the y coordinate of the operand
  2485. * @param z defines the z coordinate of the operand
  2486. * @returns true if both vectors are equals
  2487. */
  2488. equalsToFloats(x: number, y: number, z: number): boolean;
  2489. /**
  2490. * Multiplies the current Vector3 coordinates by the given ones
  2491. * @param otherVector defines the second operand
  2492. * @returns the current updated Vector3
  2493. */
  2494. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2495. /**
  2496. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2497. * @param otherVector defines the second operand
  2498. * @returns the new Vector3
  2499. */
  2500. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2503. * @param otherVector defines the second operand
  2504. * @param result defines the Vector3 object where to store the result
  2505. * @returns the current Vector3
  2506. */
  2507. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2508. /**
  2509. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2510. * @param x defines the x coordinate of the operand
  2511. * @param y defines the y coordinate of the operand
  2512. * @param z defines the z coordinate of the operand
  2513. * @returns the new Vector3
  2514. */
  2515. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2516. /**
  2517. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2518. * @param otherVector defines the second operand
  2519. * @returns the new Vector3
  2520. */
  2521. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2522. /**
  2523. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2524. * @param otherVector defines the second operand
  2525. * @param result defines the Vector3 object where to store the result
  2526. * @returns the current Vector3
  2527. */
  2528. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2529. /**
  2530. * Divides the current Vector3 coordinates by the given ones.
  2531. * @param otherVector defines the second operand
  2532. * @returns the current updated Vector3
  2533. */
  2534. divideInPlace(otherVector: Vector3): Vector3;
  2535. /**
  2536. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2537. * @param other defines the second operand
  2538. * @returns the current updated Vector3
  2539. */
  2540. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2541. /**
  2542. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2543. * @param other defines the second operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2557. * @param x defines the x coordinate of the operand
  2558. * @param y defines the y coordinate of the operand
  2559. * @param z defines the z coordinate of the operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2563. /**
  2564. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2565. * Check if is non uniform within a certain amount of decimal places to account for this
  2566. * @param epsilon the amount the values can differ
  2567. * @returns if the the vector is non uniform to a certain number of decimal places
  2568. */
  2569. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2570. /**
  2571. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2572. */
  2573. readonly isNonUniform: boolean;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. floor(): Vector3;
  2579. /**
  2580. * Gets a new Vector3 from current Vector3 floored values
  2581. * @returns a new Vector3
  2582. */
  2583. fract(): Vector3;
  2584. /**
  2585. * Gets the length of the Vector3
  2586. * @returns the length of the Vector3
  2587. */
  2588. length(): number;
  2589. /**
  2590. * Gets the squared length of the Vector3
  2591. * @returns squared length of the Vector3
  2592. */
  2593. lengthSquared(): number;
  2594. /**
  2595. * Normalize the current Vector3.
  2596. * Please note that this is an in place operation.
  2597. * @returns the current updated Vector3
  2598. */
  2599. normalize(): Vector3;
  2600. /**
  2601. * Reorders the x y z properties of the vector in place
  2602. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2603. * @returns the current updated vector
  2604. */
  2605. reorderInPlace(order: string): this;
  2606. /**
  2607. * Rotates the vector around 0,0,0 by a quaternion
  2608. * @param quaternion the rotation quaternion
  2609. * @param result vector to store the result
  2610. * @returns the resulting vector
  2611. */
  2612. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2613. /**
  2614. * Rotates a vector around a given point
  2615. * @param quaternion the rotation quaternion
  2616. * @param point the point to rotate around
  2617. * @param result vector to store the result
  2618. * @returns the resulting vector
  2619. */
  2620. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2621. /**
  2622. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2623. * The cross product is then orthogonal to both current and "other"
  2624. * @param other defines the right operand
  2625. * @returns the cross product
  2626. */
  2627. cross(other: Vector3): Vector3;
  2628. /**
  2629. * Normalize the current Vector3 with the given input length.
  2630. * Please note that this is an in place operation.
  2631. * @param len the length of the vector
  2632. * @returns the current updated Vector3
  2633. */
  2634. normalizeFromLength(len: number): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to a new vector
  2637. * @returns the new Vector3
  2638. */
  2639. normalizeToNew(): Vector3;
  2640. /**
  2641. * Normalize the current Vector3 to the reference
  2642. * @param reference define the Vector3 to update
  2643. * @returns the updated Vector3
  2644. */
  2645. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2646. /**
  2647. * Creates a new Vector3 copied from the current Vector3
  2648. * @returns the new Vector3
  2649. */
  2650. clone(): Vector3;
  2651. /**
  2652. * Copies the given vector coordinates to the current Vector3 ones
  2653. * @param source defines the source Vector3
  2654. * @returns the current updated Vector3
  2655. */
  2656. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2657. /**
  2658. * Copies the given floats to the current Vector3 coordinates
  2659. * @param x defines the x coordinate of the operand
  2660. * @param y defines the y coordinate of the operand
  2661. * @param z defines the z coordinate of the operand
  2662. * @returns the current updated Vector3
  2663. */
  2664. copyFromFloats(x: number, y: number, z: number): Vector3;
  2665. /**
  2666. * Copies the given floats to the current Vector3 coordinates
  2667. * @param x defines the x coordinate of the operand
  2668. * @param y defines the y coordinate of the operand
  2669. * @param z defines the z coordinate of the operand
  2670. * @returns the current updated Vector3
  2671. */
  2672. set(x: number, y: number, z: number): Vector3;
  2673. /**
  2674. * Copies the given float to the current Vector3 coordinates
  2675. * @param v defines the x, y and z coordinates of the operand
  2676. * @returns the current updated Vector3
  2677. */
  2678. setAll(v: number): Vector3;
  2679. /**
  2680. * Get the clip factor between two vectors
  2681. * @param vector0 defines the first operand
  2682. * @param vector1 defines the second operand
  2683. * @param axis defines the axis to use
  2684. * @param size defines the size along the axis
  2685. * @returns the clip factor
  2686. */
  2687. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2688. /**
  2689. * Get angle between two vectors
  2690. * @param vector0 angle between vector0 and vector1
  2691. * @param vector1 angle between vector0 and vector1
  2692. * @param normal direction of the normal
  2693. * @return the angle between vector0 and vector1
  2694. */
  2695. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2696. /**
  2697. * Returns a new Vector3 set from the index "offset" of the given array
  2698. * @param array defines the source array
  2699. * @param offset defines the offset in the source array
  2700. * @returns the new Vector3
  2701. */
  2702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2705. * @param array defines the source array
  2706. * @param offset defines the offset in the source array
  2707. * @returns the new Vector3
  2708. * @deprecated Please use FromArray instead.
  2709. */
  2710. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2711. /**
  2712. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2713. * @param array defines the source array
  2714. * @param offset defines the offset in the source array
  2715. * @param result defines the Vector3 where to store the result
  2716. */
  2717. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2718. /**
  2719. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2720. * @param array defines the source array
  2721. * @param offset defines the offset in the source array
  2722. * @param result defines the Vector3 where to store the result
  2723. * @deprecated Please use FromArrayToRef instead.
  2724. */
  2725. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2726. /**
  2727. * Sets the given vector "result" with the given floats.
  2728. * @param x defines the x coordinate of the source
  2729. * @param y defines the y coordinate of the source
  2730. * @param z defines the z coordinate of the source
  2731. * @param result defines the Vector3 where to store the result
  2732. */
  2733. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2734. /**
  2735. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2736. * @returns a new empty Vector3
  2737. */
  2738. static Zero(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2741. * @returns a new unit Vector3
  2742. */
  2743. static One(): Vector3;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2746. * @returns a new up Vector3
  2747. */
  2748. static Up(): Vector3;
  2749. /**
  2750. * Gets a up Vector3 that must not be updated
  2751. */
  2752. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2753. /**
  2754. * Gets a zero Vector3 that must not be updated
  2755. */
  2756. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2759. * @returns a new down Vector3
  2760. */
  2761. static Down(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Forward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2769. * @returns a new forward Vector3
  2770. */
  2771. static Backward(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2774. * @returns a new right Vector3
  2775. */
  2776. static Right(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2779. * @returns a new left Vector3
  2780. */
  2781. static Left(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2785. * @param vector defines the Vector3 to transform
  2786. * @param transformation defines the transformation matrix
  2787. * @returns the transformed Vector3
  2788. */
  2789. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2790. /**
  2791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2792. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2793. * @param vector defines the Vector3 to transform
  2794. * @param transformation defines the transformation matrix
  2795. * @param result defines the Vector3 where to store the result
  2796. */
  2797. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2798. /**
  2799. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2800. * This method computes tranformed coordinates only, not transformed direction vectors
  2801. * @param x define the x coordinate of the source vector
  2802. * @param y define the y coordinate of the source vector
  2803. * @param z define the z coordinate of the source vector
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @returns the new Vector3
  2814. */
  2815. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2816. /**
  2817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2819. * @param vector defines the Vector3 to transform
  2820. * @param transformation defines the transformation matrix
  2821. * @param result defines the Vector3 where to store the result
  2822. */
  2823. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2824. /**
  2825. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2826. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2827. * @param x define the x coordinate of the source vector
  2828. * @param y define the y coordinate of the source vector
  2829. * @param z define the z coordinate of the source vector
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2836. * @param value1 defines the first control point
  2837. * @param value2 defines the second control point
  2838. * @param value3 defines the third control point
  2839. * @param value4 defines the fourth control point
  2840. * @param amount defines the amount on the spline to use
  2841. * @returns the new Vector3
  2842. */
  2843. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2844. /**
  2845. * 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"
  2846. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2847. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2848. * @param value defines the current value
  2849. * @param min defines the lower range value
  2850. * @param max defines the upper range value
  2851. * @returns the new Vector3
  2852. */
  2853. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2854. /**
  2855. * 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"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2864. /**
  2865. * Checks if a given vector is inside a specific range
  2866. * @param v defines the vector to test
  2867. * @param min defines the minimum range
  2868. * @param max defines the maximum range
  2869. */
  2870. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2871. /**
  2872. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2873. * @param value1 defines the first control point
  2874. * @param tangent1 defines the first tangent vector
  2875. * @param value2 defines the second control point
  2876. * @param tangent2 defines the second tangent vector
  2877. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2878. * @returns the new Vector3
  2879. */
  2880. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2883. * @param start defines the start value
  2884. * @param end defines the end value
  2885. * @param amount max defines amount between both (between 0 and 1)
  2886. * @returns the new Vector3
  2887. */
  2888. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2889. /**
  2890. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2891. * @param start defines the start value
  2892. * @param end defines the end value
  2893. * @param amount max defines amount between both (between 0 and 1)
  2894. * @param result defines the Vector3 where to store the result
  2895. */
  2896. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2897. /**
  2898. * Returns the dot product (float) between the vectors "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @returns the dot product
  2902. */
  2903. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2904. /**
  2905. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2906. * The cross product is then orthogonal to both "left" and "right"
  2907. * @param left defines the left operand
  2908. * @param right defines the right operand
  2909. * @returns the cross product
  2910. */
  2911. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the cross product of "left" and "right"
  2914. * The cross product is then orthogonal to both "left" and "right"
  2915. * @param left defines the left operand
  2916. * @param right defines the right operand
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2920. /**
  2921. * Returns a new Vector3 as the normalization of the given vector
  2922. * @param vector defines the Vector3 to normalize
  2923. * @returns the new Vector3
  2924. */
  2925. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2926. /**
  2927. * Sets the given vector "result" with the normalization of the given first vector
  2928. * @param vector defines the Vector3 to normalize
  2929. * @param result defines the Vector3 where to store the result
  2930. */
  2931. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2932. /**
  2933. * Project a Vector3 onto screen space
  2934. * @param vector defines the Vector3 to project
  2935. * @param world defines the world matrix to use
  2936. * @param transform defines the transform (view x projection) matrix to use
  2937. * @param viewport defines the screen viewport to use
  2938. * @returns the new Vector3
  2939. */
  2940. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2941. /** @hidden */
  2942. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2943. /**
  2944. * Unproject from screen space to object space
  2945. * @param source defines the screen space Vector3 to use
  2946. * @param viewportWidth defines the current width of the viewport
  2947. * @param viewportHeight defines the current height of the viewport
  2948. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2949. * @param transform defines the transform (view x projection) matrix to use
  2950. * @returns the new Vector3
  2951. */
  2952. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param view defines the view matrix to use
  2960. * @param projection defines the projection matrix to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2964. /**
  2965. * Unproject from screen space to object space
  2966. * @param source defines the screen space Vector3 to use
  2967. * @param viewportWidth defines the current width of the viewport
  2968. * @param viewportHeight defines the current height of the viewport
  2969. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2970. * @param view defines the view matrix to use
  2971. * @param projection defines the projection matrix to use
  2972. * @param result defines the Vector3 where to store the result
  2973. */
  2974. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2975. /**
  2976. * Unproject from screen space to object space
  2977. * @param sourceX defines the screen space x coordinate to use
  2978. * @param sourceY defines the screen space y coordinate to use
  2979. * @param sourceZ defines the screen space z coordinate to use
  2980. * @param viewportWidth defines the current width of the viewport
  2981. * @param viewportHeight defines the current height of the viewport
  2982. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2983. * @param view defines the view matrix to use
  2984. * @param projection defines the projection matrix to use
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Gets the minimal coordinate values between two Vector3
  2990. * @param left defines the first operand
  2991. * @param right defines the second operand
  2992. * @returns the new Vector3
  2993. */
  2994. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2995. /**
  2996. * Gets the maximal coordinate values between two Vector3
  2997. * @param left defines the first operand
  2998. * @param right defines the second operand
  2999. * @returns the new Vector3
  3000. */
  3001. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3002. /**
  3003. * Returns the distance between the vectors "value1" and "value2"
  3004. * @param value1 defines the first operand
  3005. * @param value2 defines the second operand
  3006. * @returns the distance
  3007. */
  3008. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3009. /**
  3010. * Returns the squared distance between the vectors "value1" and "value2"
  3011. * @param value1 defines the first operand
  3012. * @param value2 defines the second operand
  3013. * @returns the squared distance
  3014. */
  3015. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3016. /**
  3017. * Returns a new Vector3 located at the center between "value1" and "value2"
  3018. * @param value1 defines the first operand
  3019. * @param value2 defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3025. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3026. * to something in order to rotate it from its local system to the given target system
  3027. * Note: axis1, axis2 and axis3 are normalized during this operation
  3028. * @param axis1 defines the first axis
  3029. * @param axis2 defines the second axis
  3030. * @param axis3 defines the third axis
  3031. * @returns a new Vector3
  3032. */
  3033. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3036. * @param axis1 defines the first axis
  3037. * @param axis2 defines the second axis
  3038. * @param axis3 defines the third axis
  3039. * @param ref defines the Vector3 where to store the result
  3040. */
  3041. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3042. }
  3043. /**
  3044. * Vector4 class created for EulerAngle class conversion to Quaternion
  3045. */
  3046. export class Vector4 {
  3047. /** x value of the vector */
  3048. x: number;
  3049. /** y value of the vector */
  3050. y: number;
  3051. /** z value of the vector */
  3052. z: number;
  3053. /** w value of the vector */
  3054. w: number;
  3055. /**
  3056. * Creates a Vector4 object from the given floats.
  3057. * @param x x value of the vector
  3058. * @param y y value of the vector
  3059. * @param z z value of the vector
  3060. * @param w w value of the vector
  3061. */
  3062. constructor(
  3063. /** x value of the vector */
  3064. x: number,
  3065. /** y value of the vector */
  3066. y: number,
  3067. /** z value of the vector */
  3068. z: number,
  3069. /** w value of the vector */
  3070. w: number);
  3071. /**
  3072. * Returns the string with the Vector4 coordinates.
  3073. * @returns a string containing all the vector values
  3074. */
  3075. toString(): string;
  3076. /**
  3077. * Returns the string "Vector4".
  3078. * @returns "Vector4"
  3079. */
  3080. getClassName(): string;
  3081. /**
  3082. * Returns the Vector4 hash code.
  3083. * @returns a unique hash code
  3084. */
  3085. getHashCode(): number;
  3086. /**
  3087. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3088. * @returns the resulting array
  3089. */
  3090. asArray(): number[];
  3091. /**
  3092. * Populates the given array from the given index with the Vector4 coordinates.
  3093. * @param array array to populate
  3094. * @param index index of the array to start at (default: 0)
  3095. * @returns the Vector4.
  3096. */
  3097. toArray(array: FloatArray, index?: number): Vector4;
  3098. /**
  3099. * Adds the given vector to the current Vector4.
  3100. * @param otherVector the vector to add
  3101. * @returns the updated Vector4.
  3102. */
  3103. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3104. /**
  3105. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3106. * @param otherVector the vector to add
  3107. * @returns the resulting vector
  3108. */
  3109. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3110. /**
  3111. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3112. * @param otherVector the vector to add
  3113. * @param result the vector to store the result
  3114. * @returns the current Vector4.
  3115. */
  3116. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3117. /**
  3118. * Subtract in place the given vector from the current Vector4.
  3119. * @param otherVector the vector to subtract
  3120. * @returns the updated Vector4.
  3121. */
  3122. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3123. /**
  3124. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3125. * @param otherVector the vector to add
  3126. * @returns the new vector with the result
  3127. */
  3128. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3131. * @param otherVector the vector to subtract
  3132. * @param result the vector to store the result
  3133. * @returns the current Vector4.
  3134. */
  3135. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. */
  3139. /**
  3140. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3141. * @param x value to subtract
  3142. * @param y value to subtract
  3143. * @param z value to subtract
  3144. * @param w value to subtract
  3145. * @returns new vector containing the result
  3146. */
  3147. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3148. /**
  3149. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3150. * @param x value to subtract
  3151. * @param y value to subtract
  3152. * @param z value to subtract
  3153. * @param w value to subtract
  3154. * @param result the vector to store the result in
  3155. * @returns the current Vector4.
  3156. */
  3157. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3160. * @returns a new vector with the negated values
  3161. */
  3162. negate(): Vector4;
  3163. /**
  3164. * Multiplies the current Vector4 coordinates by scale (float).
  3165. * @param scale the number to scale with
  3166. * @returns the updated Vector4.
  3167. */
  3168. scaleInPlace(scale: number): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns a new vector with the result
  3173. */
  3174. scale(scale: number): Vector4;
  3175. /**
  3176. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @param result a vector to store the result in
  3179. * @returns the current Vector4.
  3180. */
  3181. scaleToRef(scale: number, result: Vector4): Vector4;
  3182. /**
  3183. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3184. * @param scale defines the scale factor
  3185. * @param result defines the Vector4 object where to store the result
  3186. * @returns the unmodified current Vector4
  3187. */
  3188. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3189. /**
  3190. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3191. * @param otherVector the vector to compare against
  3192. * @returns true if they are equal
  3193. */
  3194. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3197. * @param otherVector vector to compare against
  3198. * @param epsilon (Default: very small number)
  3199. * @returns true if they are equal
  3200. */
  3201. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3202. /**
  3203. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3204. * @param x x value to compare against
  3205. * @param y y value to compare against
  3206. * @param z z value to compare against
  3207. * @param w w value to compare against
  3208. * @returns true if equal
  3209. */
  3210. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3211. /**
  3212. * Multiplies in place the current Vector4 by the given one.
  3213. * @param otherVector vector to multiple with
  3214. * @returns the updated Vector4.
  3215. */
  3216. multiplyInPlace(otherVector: Vector4): Vector4;
  3217. /**
  3218. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns resulting new vector
  3221. */
  3222. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3223. /**
  3224. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @param result vector to store the result
  3227. * @returns the current Vector4.
  3228. */
  3229. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3230. /**
  3231. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3232. * @param x x value multiply with
  3233. * @param y y value multiply with
  3234. * @param z z value multiply with
  3235. * @param w w value multiply with
  3236. * @returns resulting new vector
  3237. */
  3238. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3239. /**
  3240. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3241. * @param otherVector vector to devide with
  3242. * @returns resulting new vector
  3243. */
  3244. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @param result vector to store the result
  3249. * @returns the current Vector4.
  3250. */
  3251. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3252. /**
  3253. * Divides the current Vector3 coordinates by the given ones.
  3254. * @param otherVector vector to devide with
  3255. * @returns the updated Vector3.
  3256. */
  3257. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3260. * @param other defines the second operand
  3261. * @returns the current updated Vector4
  3262. */
  3263. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Gets a new Vector4 from current Vector4 floored values
  3272. * @returns a new Vector4
  3273. */
  3274. floor(): Vector4;
  3275. /**
  3276. * Gets a new Vector4 from current Vector3 floored values
  3277. * @returns a new Vector4
  3278. */
  3279. fract(): Vector4;
  3280. /**
  3281. * Returns the Vector4 length (float).
  3282. * @returns the length
  3283. */
  3284. length(): number;
  3285. /**
  3286. * Returns the Vector4 squared length (float).
  3287. * @returns the length squared
  3288. */
  3289. lengthSquared(): number;
  3290. /**
  3291. * Normalizes in place the Vector4.
  3292. * @returns the updated Vector4.
  3293. */
  3294. normalize(): Vector4;
  3295. /**
  3296. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3297. * @returns this converted to a new vector3
  3298. */
  3299. toVector3(): Vector3;
  3300. /**
  3301. * Returns a new Vector4 copied from the current one.
  3302. * @returns the new cloned vector
  3303. */
  3304. clone(): Vector4;
  3305. /**
  3306. * Updates the current Vector4 with the given one coordinates.
  3307. * @param source the source vector to copy from
  3308. * @returns the updated Vector4.
  3309. */
  3310. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3311. /**
  3312. * Updates the current Vector4 coordinates with the given floats.
  3313. * @param x float to copy from
  3314. * @param y float to copy from
  3315. * @param z float to copy from
  3316. * @param w float to copy from
  3317. * @returns the updated Vector4.
  3318. */
  3319. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3320. /**
  3321. * Updates the current Vector4 coordinates with the given floats.
  3322. * @param x float to set from
  3323. * @param y float to set from
  3324. * @param z float to set from
  3325. * @param w float to set from
  3326. * @returns the updated Vector4.
  3327. */
  3328. set(x: number, y: number, z: number, w: number): Vector4;
  3329. /**
  3330. * Copies the given float to the current Vector3 coordinates
  3331. * @param v defines the x, y, z and w coordinates of the operand
  3332. * @returns the current updated Vector3
  3333. */
  3334. setAll(v: number): Vector4;
  3335. /**
  3336. * Returns a new Vector4 set from the starting index of the given array.
  3337. * @param array the array to pull values from
  3338. * @param offset the offset into the array to start at
  3339. * @returns the new vector
  3340. */
  3341. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3342. /**
  3343. * Updates the given vector "result" from the starting index of the given array.
  3344. * @param array the array to pull values from
  3345. * @param offset the offset into the array to start at
  3346. * @param result the vector to store the result in
  3347. */
  3348. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3349. /**
  3350. * Updates the given vector "result" from the starting index of the given Float32Array.
  3351. * @param array the array to pull values from
  3352. * @param offset the offset into the array to start at
  3353. * @param result the vector to store the result in
  3354. */
  3355. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3356. /**
  3357. * Updates the given vector "result" coordinates from the given floats.
  3358. * @param x float to set from
  3359. * @param y float to set from
  3360. * @param z float to set from
  3361. * @param w float to set from
  3362. * @param result the vector to the floats in
  3363. */
  3364. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3365. /**
  3366. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3367. * @returns the new vector
  3368. */
  3369. static Zero(): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3372. * @returns the new vector
  3373. */
  3374. static One(): Vector4;
  3375. /**
  3376. * Returns a new normalized Vector4 from the given one.
  3377. * @param vector the vector to normalize
  3378. * @returns the vector
  3379. */
  3380. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the normalization of the given one.
  3383. * @param vector the vector to normalize
  3384. * @param result the vector to store the result in
  3385. */
  3386. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3387. /**
  3388. * Returns a vector with the minimum values from the left and right vectors
  3389. * @param left left vector to minimize
  3390. * @param right right vector to minimize
  3391. * @returns a new vector with the minimum of the left and right vector values
  3392. */
  3393. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3394. /**
  3395. * Returns a vector with the maximum values from the left and right vectors
  3396. * @param left left vector to maximize
  3397. * @param right right vector to maximize
  3398. * @returns a new vector with the maximum of the left and right vector values
  3399. */
  3400. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3401. /**
  3402. * Returns the distance (float) between the vectors "value1" and "value2".
  3403. * @param value1 value to calulate the distance between
  3404. * @param value2 value to calulate the distance between
  3405. * @return the distance between the two vectors
  3406. */
  3407. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3408. /**
  3409. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3410. * @param value1 value to calulate the distance between
  3411. * @param value2 value to calulate the distance between
  3412. * @return the distance between the two vectors squared
  3413. */
  3414. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3415. /**
  3416. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3417. * @param value1 value to calulate the center between
  3418. * @param value2 value to calulate the center between
  3419. * @return the center between the two vectors
  3420. */
  3421. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3424. * This methods computes transformed normalized direction vectors only.
  3425. * @param vector the vector to transform
  3426. * @param transformation the transformation matrix to apply
  3427. * @returns the new vector
  3428. */
  3429. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @param result the vector to store the result in
  3436. */
  3437. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param x value to transform
  3442. * @param y value to transform
  3443. * @param z value to transform
  3444. * @param w value to transform
  3445. * @param transformation the transformation matrix to apply
  3446. * @param result the vector to store the results in
  3447. */
  3448. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3449. /**
  3450. * Creates a new Vector4 from a Vector3
  3451. * @param source defines the source data
  3452. * @param w defines the 4th component (default is 0)
  3453. * @returns a new Vector4
  3454. */
  3455. static FromVector3(source: Vector3, w?: number): Vector4;
  3456. }
  3457. /**
  3458. * Class used to store quaternion data
  3459. * @see https://en.wikipedia.org/wiki/Quaternion
  3460. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3461. */
  3462. export class Quaternion {
  3463. /** defines the first component (0 by default) */
  3464. x: number;
  3465. /** defines the second component (0 by default) */
  3466. y: number;
  3467. /** defines the third component (0 by default) */
  3468. z: number;
  3469. /** defines the fourth component (1.0 by default) */
  3470. w: number;
  3471. /**
  3472. * Creates a new Quaternion from the given floats
  3473. * @param x defines the first component (0 by default)
  3474. * @param y defines the second component (0 by default)
  3475. * @param z defines the third component (0 by default)
  3476. * @param w defines the fourth component (1.0 by default)
  3477. */
  3478. constructor(
  3479. /** defines the first component (0 by default) */
  3480. x?: number,
  3481. /** defines the second component (0 by default) */
  3482. y?: number,
  3483. /** defines the third component (0 by default) */
  3484. z?: number,
  3485. /** defines the fourth component (1.0 by default) */
  3486. w?: number);
  3487. /**
  3488. * Gets a string representation for the current quaternion
  3489. * @returns a string with the Quaternion coordinates
  3490. */
  3491. toString(): string;
  3492. /**
  3493. * Gets the class name of the quaternion
  3494. * @returns the string "Quaternion"
  3495. */
  3496. getClassName(): string;
  3497. /**
  3498. * Gets a hash code for this quaternion
  3499. * @returns the quaternion hash code
  3500. */
  3501. getHashCode(): number;
  3502. /**
  3503. * Copy the quaternion to an array
  3504. * @returns a new array populated with 4 elements from the quaternion coordinates
  3505. */
  3506. asArray(): number[];
  3507. /**
  3508. * Check if two quaternions are equals
  3509. * @param otherQuaternion defines the second operand
  3510. * @return true if the current quaternion and the given one coordinates are strictly equals
  3511. */
  3512. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3513. /**
  3514. * Clone the current quaternion
  3515. * @returns a new quaternion copied from the current one
  3516. */
  3517. clone(): Quaternion;
  3518. /**
  3519. * Copy a quaternion to the current one
  3520. * @param other defines the other quaternion
  3521. * @returns the updated current quaternion
  3522. */
  3523. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3524. /**
  3525. * Updates the current quaternion with the given float coordinates
  3526. * @param x defines the x coordinate
  3527. * @param y defines the y coordinate
  3528. * @param z defines the z coordinate
  3529. * @param w defines the w coordinate
  3530. * @returns the updated current quaternion
  3531. */
  3532. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3533. /**
  3534. * Updates the current quaternion from the given float coordinates
  3535. * @param x defines the x coordinate
  3536. * @param y defines the y coordinate
  3537. * @param z defines the z coordinate
  3538. * @param w defines the w coordinate
  3539. * @returns the updated current quaternion
  3540. */
  3541. set(x: number, y: number, z: number, w: number): Quaternion;
  3542. /**
  3543. * Adds two quaternions
  3544. * @param other defines the second operand
  3545. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3546. */
  3547. add(other: DeepImmutable<Quaternion>): Quaternion;
  3548. /**
  3549. * Add a quaternion to the current one
  3550. * @param other defines the quaternion to add
  3551. * @returns the current quaternion
  3552. */
  3553. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Subtract two quaternions
  3556. * @param other defines the second operand
  3557. * @returns a new quaternion as the subtraction result of the given one from the current one
  3558. */
  3559. subtract(other: Quaternion): Quaternion;
  3560. /**
  3561. * Multiplies the current quaternion by a scale factor
  3562. * @param value defines the scale factor
  3563. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3564. */
  3565. scale(value: number): Quaternion;
  3566. /**
  3567. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3568. * @param scale defines the scale factor
  3569. * @param result defines the Quaternion object where to store the result
  3570. * @returns the unmodified current quaternion
  3571. */
  3572. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies in place the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns the current modified quaternion
  3577. */
  3578. scaleInPlace(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies two quaternions
  3588. * @param q1 defines the second operand
  3589. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3590. */
  3591. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3592. /**
  3593. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3594. * @param q1 defines the second operand
  3595. * @param result defines the target quaternion
  3596. * @returns the current quaternion
  3597. */
  3598. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3599. /**
  3600. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3601. * @param q1 defines the second operand
  3602. * @returns the currentupdated quaternion
  3603. */
  3604. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3607. * @param ref defines the target quaternion
  3608. * @returns the current quaternion
  3609. */
  3610. conjugateToRef(ref: Quaternion): Quaternion;
  3611. /**
  3612. * Conjugates in place (1-q) the current quaternion
  3613. * @returns the current updated quaternion
  3614. */
  3615. conjugateInPlace(): Quaternion;
  3616. /**
  3617. * Conjugates in place (1-q) the current quaternion
  3618. * @returns a new quaternion
  3619. */
  3620. conjugate(): Quaternion;
  3621. /**
  3622. * Gets length of current quaternion
  3623. * @returns the quaternion length (float)
  3624. */
  3625. length(): number;
  3626. /**
  3627. * Normalize in place the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. normalize(): Quaternion;
  3631. /**
  3632. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3633. * @param order is a reserved parameter and is ignore for now
  3634. * @returns a new Vector3 containing the Euler angles
  3635. */
  3636. toEulerAngles(order?: string): Vector3;
  3637. /**
  3638. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3639. * @param result defines the vector which will be filled with the Euler angles
  3640. * @param order is a reserved parameter and is ignore for now
  3641. * @returns the current unchanged quaternion
  3642. */
  3643. toEulerAnglesToRef(result: Vector3): Quaternion;
  3644. /**
  3645. * Updates the given rotation matrix with the current quaternion values
  3646. * @param result defines the target matrix
  3647. * @returns the current unchanged quaternion
  3648. */
  3649. toRotationMatrix(result: Matrix): Quaternion;
  3650. /**
  3651. * Updates the current quaternion from the given rotation matrix values
  3652. * @param matrix defines the source matrix
  3653. * @returns the current updated quaternion
  3654. */
  3655. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3656. /**
  3657. * Creates a new quaternion from a rotation matrix
  3658. * @param matrix defines the source matrix
  3659. * @returns a new quaternion created from the given rotation matrix values
  3660. */
  3661. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3662. /**
  3663. * Updates the given quaternion with the given rotation matrix values
  3664. * @param matrix defines the source matrix
  3665. * @param result defines the target quaternion
  3666. */
  3667. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3668. /**
  3669. * Returns the dot product (float) between the quaternions "left" and "right"
  3670. * @param left defines the left operand
  3671. * @param right defines the right operand
  3672. * @returns the dot product
  3673. */
  3674. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3675. /**
  3676. * Checks if the two quaternions are close to each other
  3677. * @param quat0 defines the first quaternion to check
  3678. * @param quat1 defines the second quaternion to check
  3679. * @returns true if the two quaternions are close to each other
  3680. */
  3681. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3682. /**
  3683. * Creates an empty quaternion
  3684. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3685. */
  3686. static Zero(): Quaternion;
  3687. /**
  3688. * Inverse a given quaternion
  3689. * @param q defines the source quaternion
  3690. * @returns a new quaternion as the inverted current quaternion
  3691. */
  3692. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Inverse a given quaternion
  3695. * @param q defines the source quaternion
  3696. * @param result the quaternion the result will be stored in
  3697. * @returns the result quaternion
  3698. */
  3699. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3700. /**
  3701. * Creates an identity quaternion
  3702. * @returns the identity quaternion
  3703. */
  3704. static Identity(): Quaternion;
  3705. /**
  3706. * Gets a boolean indicating if the given quaternion is identity
  3707. * @param quaternion defines the quaternion to check
  3708. * @returns true if the quaternion is identity
  3709. */
  3710. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3711. /**
  3712. * Creates a quaternion from a rotation around an axis
  3713. * @param axis defines the axis to use
  3714. * @param angle defines the angle to use
  3715. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3716. */
  3717. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3718. /**
  3719. * Creates a rotation around an axis and stores it into the given quaternion
  3720. * @param axis defines the axis to use
  3721. * @param angle defines the angle to use
  3722. * @param result defines the target quaternion
  3723. * @returns the target quaternion
  3724. */
  3725. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from data stored into an array
  3728. * @param array defines the data source
  3729. * @param offset defines the offset in the source array where the data starts
  3730. * @returns a new quaternion
  3731. */
  3732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3733. /**
  3734. * Create a quaternion from Euler rotation angles
  3735. * @param x Pitch
  3736. * @param y Yaw
  3737. * @param z Roll
  3738. * @returns the new Quaternion
  3739. */
  3740. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3741. /**
  3742. * Updates a quaternion from Euler rotation angles
  3743. * @param x Pitch
  3744. * @param y Yaw
  3745. * @param z Roll
  3746. * @param result the quaternion to store the result
  3747. * @returns the updated quaternion
  3748. */
  3749. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3750. /**
  3751. * Create a quaternion from Euler rotation vector
  3752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3753. * @returns the new Quaternion
  3754. */
  3755. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3756. /**
  3757. * Updates a quaternion from Euler rotation vector
  3758. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3763. /**
  3764. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3765. * @param yaw defines the rotation around Y axis
  3766. * @param pitch defines the rotation around X axis
  3767. * @param roll defines the rotation around Z axis
  3768. * @returns the new quaternion
  3769. */
  3770. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3771. /**
  3772. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3773. * @param yaw defines the rotation around Y axis
  3774. * @param pitch defines the rotation around X axis
  3775. * @param roll defines the rotation around Z axis
  3776. * @param result defines the target quaternion
  3777. */
  3778. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3779. /**
  3780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3781. * @param alpha defines the rotation around first axis
  3782. * @param beta defines the rotation around second axis
  3783. * @param gamma defines the rotation around third axis
  3784. * @returns the new quaternion
  3785. */
  3786. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3787. /**
  3788. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3789. * @param alpha defines the rotation around first axis
  3790. * @param beta defines the rotation around second axis
  3791. * @param gamma defines the rotation around third axis
  3792. * @param result defines the target quaternion
  3793. */
  3794. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3795. /**
  3796. * 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)
  3797. * @param axis1 defines the first axis
  3798. * @param axis2 defines the second axis
  3799. * @param axis3 defines the third axis
  3800. * @returns the new quaternion
  3801. */
  3802. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3803. /**
  3804. * 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
  3805. * @param axis1 defines the first axis
  3806. * @param axis2 defines the second axis
  3807. * @param axis3 defines the third axis
  3808. * @param ref defines the target quaternion
  3809. */
  3810. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3811. /**
  3812. * Interpolates between two quaternions
  3813. * @param left defines first quaternion
  3814. * @param right defines second quaternion
  3815. * @param amount defines the gradient to use
  3816. * @returns the new interpolated quaternion
  3817. */
  3818. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3819. /**
  3820. * Interpolates between two quaternions and stores it into a target quaternion
  3821. * @param left defines first quaternion
  3822. * @param right defines second quaternion
  3823. * @param amount defines the gradient to use
  3824. * @param result defines the target quaternion
  3825. */
  3826. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3827. /**
  3828. * Interpolate between two quaternions using Hermite interpolation
  3829. * @param value1 defines first quaternion
  3830. * @param tangent1 defines the incoming tangent
  3831. * @param value2 defines second quaternion
  3832. * @param tangent2 defines the outgoing tangent
  3833. * @param amount defines the target quaternion
  3834. * @returns the new interpolated quaternion
  3835. */
  3836. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3837. }
  3838. /**
  3839. * Class used to store matrix data (4x4)
  3840. */
  3841. export class Matrix {
  3842. private static _updateFlagSeed;
  3843. private static _identityReadOnly;
  3844. private _isIdentity;
  3845. private _isIdentityDirty;
  3846. private _isIdentity3x2;
  3847. private _isIdentity3x2Dirty;
  3848. /**
  3849. * Gets the update flag of the matrix which is an unique number for the matrix.
  3850. * It will be incremented every time the matrix data change.
  3851. * You can use it to speed the comparison between two versions of the same matrix.
  3852. */
  3853. updateFlag: number;
  3854. private readonly _m;
  3855. /**
  3856. * Gets the internal data of the matrix
  3857. */
  3858. readonly m: DeepImmutable<Float32Array>;
  3859. /** @hidden */
  3860. _markAsUpdated(): void;
  3861. /** @hidden */
  3862. private _updateIdentityStatus;
  3863. /**
  3864. * Creates an empty matrix (filled with zeros)
  3865. */
  3866. constructor();
  3867. /**
  3868. * Check if the current matrix is identity
  3869. * @returns true is the matrix is the identity matrix
  3870. */
  3871. isIdentity(): boolean;
  3872. /**
  3873. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3874. * @returns true is the matrix is the identity matrix
  3875. */
  3876. isIdentityAs3x2(): boolean;
  3877. /**
  3878. * Gets the determinant of the matrix
  3879. * @returns the matrix determinant
  3880. */
  3881. determinant(): number;
  3882. /**
  3883. * Returns the matrix as a Float32Array
  3884. * @returns the matrix underlying array
  3885. */
  3886. toArray(): DeepImmutable<Float32Array>;
  3887. /**
  3888. * Returns the matrix as a Float32Array
  3889. * @returns the matrix underlying array.
  3890. */
  3891. asArray(): DeepImmutable<Float32Array>;
  3892. /**
  3893. * Inverts the current matrix in place
  3894. * @returns the current inverted matrix
  3895. */
  3896. invert(): Matrix;
  3897. /**
  3898. * Sets all the matrix elements to zero
  3899. * @returns the current matrix
  3900. */
  3901. reset(): Matrix;
  3902. /**
  3903. * Adds the current matrix with a second one
  3904. * @param other defines the matrix to add
  3905. * @returns a new matrix as the addition of the current matrix and the given one
  3906. */
  3907. add(other: DeepImmutable<Matrix>): Matrix;
  3908. /**
  3909. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3910. * @param other defines the matrix to add
  3911. * @param result defines the target matrix
  3912. * @returns the current matrix
  3913. */
  3914. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3915. /**
  3916. * Adds in place the given matrix to the current matrix
  3917. * @param other defines the second operand
  3918. * @returns the current updated matrix
  3919. */
  3920. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix to the current inverted Matrix
  3923. * @param other defines the target matrix
  3924. * @returns the unmodified current matrix
  3925. */
  3926. invertToRef(other: Matrix): Matrix;
  3927. /**
  3928. * add a value at the specified position in the current Matrix
  3929. * @param index the index of the value within the matrix. between 0 and 15.
  3930. * @param value the value to be added
  3931. * @returns the current updated matrix
  3932. */
  3933. addAtIndex(index: number, value: number): Matrix;
  3934. /**
  3935. * mutiply the specified position in the current Matrix by a value
  3936. * @param index the index of the value within the matrix. between 0 and 15.
  3937. * @param value the value to be added
  3938. * @returns the current updated matrix
  3939. */
  3940. multiplyAtIndex(index: number, value: number): Matrix;
  3941. /**
  3942. * Inserts the translation vector (using 3 floats) in the current matrix
  3943. * @param x defines the 1st component of the translation
  3944. * @param y defines the 2nd component of the translation
  3945. * @param z defines the 3rd component of the translation
  3946. * @returns the current updated matrix
  3947. */
  3948. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3949. /**
  3950. * Adds the translation vector (using 3 floats) in the current matrix
  3951. * @param x defines the 1st component of the translation
  3952. * @param y defines the 2nd component of the translation
  3953. * @param z defines the 3rd component of the translation
  3954. * @returns the current updated matrix
  3955. */
  3956. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3957. /**
  3958. * Inserts the translation vector in the current matrix
  3959. * @param vector3 defines the translation to insert
  3960. * @returns the current updated matrix
  3961. */
  3962. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3963. /**
  3964. * Gets the translation value of the current matrix
  3965. * @returns a new Vector3 as the extracted translation from the matrix
  3966. */
  3967. getTranslation(): Vector3;
  3968. /**
  3969. * Fill a Vector3 with the extracted translation from the matrix
  3970. * @param result defines the Vector3 where to store the translation
  3971. * @returns the current matrix
  3972. */
  3973. getTranslationToRef(result: Vector3): Matrix;
  3974. /**
  3975. * Remove rotation and scaling part from the matrix
  3976. * @returns the updated matrix
  3977. */
  3978. removeRotationAndScaling(): Matrix;
  3979. /**
  3980. * Multiply two matrices
  3981. * @param other defines the second operand
  3982. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3983. */
  3984. multiply(other: DeepImmutable<Matrix>): Matrix;
  3985. /**
  3986. * Copy the current matrix from the given one
  3987. * @param other defines the source matrix
  3988. * @returns the current updated matrix
  3989. */
  3990. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3991. /**
  3992. * Populates the given array from the starting index with the current matrix values
  3993. * @param array defines the target array
  3994. * @param offset defines the offset in the target array where to start storing values
  3995. * @returns the current matrix
  3996. */
  3997. copyToArray(array: Float32Array, offset?: number): Matrix;
  3998. /**
  3999. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4000. * @param other defines the second operand
  4001. * @param result defines the matrix where to store the multiplication
  4002. * @returns the current matrix
  4003. */
  4004. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4005. /**
  4006. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4007. * @param other defines the second operand
  4008. * @param result defines the array where to store the multiplication
  4009. * @param offset defines the offset in the target array where to start storing values
  4010. * @returns the current matrix
  4011. */
  4012. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4013. /**
  4014. * Check equality between this matrix and a second one
  4015. * @param value defines the second matrix to compare
  4016. * @returns true is the current matrix and the given one values are strictly equal
  4017. */
  4018. equals(value: DeepImmutable<Matrix>): boolean;
  4019. /**
  4020. * Clone the current matrix
  4021. * @returns a new matrix from the current matrix
  4022. */
  4023. clone(): Matrix;
  4024. /**
  4025. * Returns the name of the current matrix class
  4026. * @returns the string "Matrix"
  4027. */
  4028. getClassName(): string;
  4029. /**
  4030. * Gets the hash code of the current matrix
  4031. * @returns the hash code
  4032. */
  4033. getHashCode(): number;
  4034. /**
  4035. * Decomposes the current Matrix into a translation, rotation and scaling components
  4036. * @param scale defines the scale vector3 given as a reference to update
  4037. * @param rotation defines the rotation quaternion given as a reference to update
  4038. * @param translation defines the translation vector3 given as a reference to update
  4039. * @returns true if operation was successful
  4040. */
  4041. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4042. /**
  4043. * Gets specific row of the matrix
  4044. * @param index defines the number of the row to get
  4045. * @returns the index-th row of the current matrix as a new Vector4
  4046. */
  4047. getRow(index: number): Nullable<Vector4>;
  4048. /**
  4049. * Sets the index-th row of the current matrix to the vector4 values
  4050. * @param index defines the number of the row to set
  4051. * @param row defines the target vector4
  4052. * @returns the updated current matrix
  4053. */
  4054. setRow(index: number, row: Vector4): Matrix;
  4055. /**
  4056. * Compute the transpose of the matrix
  4057. * @returns the new transposed matrix
  4058. */
  4059. transpose(): Matrix;
  4060. /**
  4061. * Compute the transpose of the matrix and store it in a given matrix
  4062. * @param result defines the target matrix
  4063. * @returns the current matrix
  4064. */
  4065. transposeToRef(result: Matrix): Matrix;
  4066. /**
  4067. * Sets the index-th row of the current matrix with the given 4 x float values
  4068. * @param index defines the row index
  4069. * @param x defines the x component to set
  4070. * @param y defines the y component to set
  4071. * @param z defines the z component to set
  4072. * @param w defines the w component to set
  4073. * @returns the updated current matrix
  4074. */
  4075. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4076. /**
  4077. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4078. * @param scale defines the scale factor
  4079. * @returns a new matrix
  4080. */
  4081. scale(scale: number): Matrix;
  4082. /**
  4083. * Scale the current matrix values by a factor to a given result matrix
  4084. * @param scale defines the scale factor
  4085. * @param result defines the matrix to store the result
  4086. * @returns the current matrix
  4087. */
  4088. scaleToRef(scale: number, result: Matrix): Matrix;
  4089. /**
  4090. * Scale the current matrix values by a factor and add the result to a given matrix
  4091. * @param scale defines the scale factor
  4092. * @param result defines the Matrix to store the result
  4093. * @returns the current matrix
  4094. */
  4095. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4096. /**
  4097. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4098. * @param ref matrix to store the result
  4099. */
  4100. toNormalMatrix(ref: Matrix): void;
  4101. /**
  4102. * Gets only rotation part of the current matrix
  4103. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4104. */
  4105. getRotationMatrix(): Matrix;
  4106. /**
  4107. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4108. * @param result defines the target matrix to store data to
  4109. * @returns the current matrix
  4110. */
  4111. getRotationMatrixToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Toggles model matrix from being right handed to left handed in place and vice versa
  4114. */
  4115. toggleModelMatrixHandInPlace(): void;
  4116. /**
  4117. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4118. */
  4119. toggleProjectionMatrixHandInPlace(): void;
  4120. /**
  4121. * Creates a matrix from an array
  4122. * @param array defines the source array
  4123. * @param offset defines an offset in the source array
  4124. * @returns a new Matrix set from the starting index of the given array
  4125. */
  4126. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4127. /**
  4128. * Copy the content of an array into a given matrix
  4129. * @param array defines the source array
  4130. * @param offset defines an offset in the source array
  4131. * @param result defines the target matrix
  4132. */
  4133. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4134. /**
  4135. * Stores an array into a matrix after having multiplied each component by a given factor
  4136. * @param array defines the source array
  4137. * @param offset defines the offset in the source array
  4138. * @param scale defines the scaling factor
  4139. * @param result defines the target matrix
  4140. */
  4141. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4142. /**
  4143. * Gets an identity matrix that must not be updated
  4144. */
  4145. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4146. /**
  4147. * Stores a list of values (16) inside a given matrix
  4148. * @param initialM11 defines 1st value of 1st row
  4149. * @param initialM12 defines 2nd value of 1st row
  4150. * @param initialM13 defines 3rd value of 1st row
  4151. * @param initialM14 defines 4th value of 1st row
  4152. * @param initialM21 defines 1st value of 2nd row
  4153. * @param initialM22 defines 2nd value of 2nd row
  4154. * @param initialM23 defines 3rd value of 2nd row
  4155. * @param initialM24 defines 4th value of 2nd row
  4156. * @param initialM31 defines 1st value of 3rd row
  4157. * @param initialM32 defines 2nd value of 3rd row
  4158. * @param initialM33 defines 3rd value of 3rd row
  4159. * @param initialM34 defines 4th value of 3rd row
  4160. * @param initialM41 defines 1st value of 4th row
  4161. * @param initialM42 defines 2nd value of 4th row
  4162. * @param initialM43 defines 3rd value of 4th row
  4163. * @param initialM44 defines 4th value of 4th row
  4164. * @param result defines the target matrix
  4165. */
  4166. 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;
  4167. /**
  4168. * Creates new matrix from a list of values (16)
  4169. * @param initialM11 defines 1st value of 1st row
  4170. * @param initialM12 defines 2nd value of 1st row
  4171. * @param initialM13 defines 3rd value of 1st row
  4172. * @param initialM14 defines 4th value of 1st row
  4173. * @param initialM21 defines 1st value of 2nd row
  4174. * @param initialM22 defines 2nd value of 2nd row
  4175. * @param initialM23 defines 3rd value of 2nd row
  4176. * @param initialM24 defines 4th value of 2nd row
  4177. * @param initialM31 defines 1st value of 3rd row
  4178. * @param initialM32 defines 2nd value of 3rd row
  4179. * @param initialM33 defines 3rd value of 3rd row
  4180. * @param initialM34 defines 4th value of 3rd row
  4181. * @param initialM41 defines 1st value of 4th row
  4182. * @param initialM42 defines 2nd value of 4th row
  4183. * @param initialM43 defines 3rd value of 4th row
  4184. * @param initialM44 defines 4th value of 4th row
  4185. * @returns the new matrix
  4186. */
  4187. 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;
  4188. /**
  4189. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4190. * @param scale defines the scale vector3
  4191. * @param rotation defines the rotation quaternion
  4192. * @param translation defines the translation vector3
  4193. * @returns a new matrix
  4194. */
  4195. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4196. /**
  4197. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4198. * @param scale defines the scale vector3
  4199. * @param rotation defines the rotation quaternion
  4200. * @param translation defines the translation vector3
  4201. * @param result defines the target matrix
  4202. */
  4203. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4204. /**
  4205. * Creates a new identity matrix
  4206. * @returns a new identity matrix
  4207. */
  4208. static Identity(): Matrix;
  4209. /**
  4210. * Creates a new identity matrix and stores the result in a given matrix
  4211. * @param result defines the target matrix
  4212. */
  4213. static IdentityToRef(result: Matrix): void;
  4214. /**
  4215. * Creates a new zero matrix
  4216. * @returns a new zero matrix
  4217. */
  4218. static Zero(): Matrix;
  4219. /**
  4220. * Creates a new rotation matrix for "angle" radians around the X axis
  4221. * @param angle defines the angle (in radians) to use
  4222. * @return the new matrix
  4223. */
  4224. static RotationX(angle: number): Matrix;
  4225. /**
  4226. * Creates a new matrix as the invert of a given matrix
  4227. * @param source defines the source matrix
  4228. * @returns the new matrix
  4229. */
  4230. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4233. * @param angle defines the angle (in radians) to use
  4234. * @param result defines the target matrix
  4235. */
  4236. static RotationXToRef(angle: number, result: Matrix): void;
  4237. /**
  4238. * Creates a new rotation matrix for "angle" radians around the Y axis
  4239. * @param angle defines the angle (in radians) to use
  4240. * @return the new matrix
  4241. */
  4242. static RotationY(angle: number): Matrix;
  4243. /**
  4244. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4245. * @param angle defines the angle (in radians) to use
  4246. * @param result defines the target matrix
  4247. */
  4248. static RotationYToRef(angle: number, result: Matrix): void;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the Z axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationZ(angle: number): Matrix;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4257. * @param angle defines the angle (in radians) to use
  4258. * @param result defines the target matrix
  4259. */
  4260. static RotationZToRef(angle: number, result: Matrix): void;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the given axis
  4263. * @param axis defines the axis to use
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4270. * @param axis defines the axis to use
  4271. * @param angle defines the angle (in radians) to use
  4272. * @param result defines the target matrix
  4273. */
  4274. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4275. /**
  4276. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4277. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4278. * @param from defines the vector to align
  4279. * @param to defines the vector to align to
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4283. /**
  4284. * Creates a rotation matrix
  4285. * @param yaw defines the yaw angle in radians (Y axis)
  4286. * @param pitch defines the pitch angle in radians (X axis)
  4287. * @param roll defines the roll angle in radians (X axis)
  4288. * @returns the new rotation matrix
  4289. */
  4290. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4291. /**
  4292. * Creates a rotation matrix and stores it in a given matrix
  4293. * @param yaw defines the yaw angle in radians (Y axis)
  4294. * @param pitch defines the pitch angle in radians (X axis)
  4295. * @param roll defines the roll angle in radians (X axis)
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4299. /**
  4300. * Creates a scaling matrix
  4301. * @param x defines the scale factor on X axis
  4302. * @param y defines the scale factor on Y axis
  4303. * @param z defines the scale factor on Z axis
  4304. * @returns the new matrix
  4305. */
  4306. static Scaling(x: number, y: number, z: number): Matrix;
  4307. /**
  4308. * Creates a scaling matrix and stores it in a given matrix
  4309. * @param x defines the scale factor on X axis
  4310. * @param y defines the scale factor on Y axis
  4311. * @param z defines the scale factor on Z axis
  4312. * @param result defines the target matrix
  4313. */
  4314. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4315. /**
  4316. * Creates a translation matrix
  4317. * @param x defines the translation on X axis
  4318. * @param y defines the translation on Y axis
  4319. * @param z defines the translationon Z axis
  4320. * @returns the new matrix
  4321. */
  4322. static Translation(x: number, y: number, z: number): Matrix;
  4323. /**
  4324. * Creates a translation matrix and stores it in a given matrix
  4325. * @param x defines the translation on X axis
  4326. * @param y defines the translation on Y axis
  4327. * @param z defines the translationon Z axis
  4328. * @param result defines the target matrix
  4329. */
  4330. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4331. /**
  4332. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4333. * @param startValue defines the start value
  4334. * @param endValue defines the end value
  4335. * @param gradient defines the gradient factor
  4336. * @returns the new matrix
  4337. */
  4338. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4339. /**
  4340. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4341. * @param startValue defines the start value
  4342. * @param endValue defines the end value
  4343. * @param gradient defines the gradient factor
  4344. * @param result defines the Matrix object where to store data
  4345. */
  4346. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4347. /**
  4348. * Builds a new matrix whose values are computed by:
  4349. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4350. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4351. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4352. * @param startValue defines the first matrix
  4353. * @param endValue defines the second matrix
  4354. * @param gradient defines the gradient between the two matrices
  4355. * @returns the new matrix
  4356. */
  4357. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4358. /**
  4359. * Update a matrix to values which are computed by:
  4360. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4361. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4362. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4363. * @param startValue defines the first matrix
  4364. * @param endValue defines the second matrix
  4365. * @param gradient defines the gradient between the two matrices
  4366. * @param result defines the target matrix
  4367. */
  4368. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * 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"
  4371. * This function works in left handed mode
  4372. * @param eye defines the final position of the entity
  4373. * @param target defines where the entity should look at
  4374. * @param up defines the up vector for the entity
  4375. * @returns the new matrix
  4376. */
  4377. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4378. /**
  4379. * 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".
  4380. * This function works in left handed mode
  4381. * @param eye defines the final position of the entity
  4382. * @param target defines where the entity should look at
  4383. * @param up defines the up vector for the entity
  4384. * @param result defines the target matrix
  4385. */
  4386. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4387. /**
  4388. * 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"
  4389. * This function works in right handed mode
  4390. * @param eye defines the final position of the entity
  4391. * @param target defines where the entity should look at
  4392. * @param up defines the up vector for the entity
  4393. * @returns the new matrix
  4394. */
  4395. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4396. /**
  4397. * 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".
  4398. * This function works in right handed mode
  4399. * @param eye defines the final position of the entity
  4400. * @param target defines where the entity should look at
  4401. * @param up defines the up vector for the entity
  4402. * @param result defines the target matrix
  4403. */
  4404. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4405. /**
  4406. * Create a left-handed orthographic projection matrix
  4407. * @param width defines the viewport width
  4408. * @param height defines the viewport height
  4409. * @param znear defines the near clip plane
  4410. * @param zfar defines the far clip plane
  4411. * @returns a new matrix as a left-handed orthographic projection matrix
  4412. */
  4413. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4414. /**
  4415. * Store a left-handed orthographic projection to a given matrix
  4416. * @param width defines the viewport width
  4417. * @param height defines the viewport height
  4418. * @param znear defines the near clip plane
  4419. * @param zfar defines the far clip plane
  4420. * @param result defines the target matrix
  4421. */
  4422. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4423. /**
  4424. * Create a left-handed orthographic projection matrix
  4425. * @param left defines the viewport left coordinate
  4426. * @param right defines the viewport right coordinate
  4427. * @param bottom defines the viewport bottom coordinate
  4428. * @param top defines the viewport top coordinate
  4429. * @param znear defines the near clip plane
  4430. * @param zfar defines the far clip plane
  4431. * @returns a new matrix as a left-handed orthographic projection matrix
  4432. */
  4433. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4434. /**
  4435. * Stores a left-handed orthographic projection into a given matrix
  4436. * @param left defines the viewport left coordinate
  4437. * @param right defines the viewport right coordinate
  4438. * @param bottom defines the viewport bottom coordinate
  4439. * @param top defines the viewport top coordinate
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Creates a right-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a right-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a right-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a left-handed perspective projection matrix
  4469. * @param width defines the viewport width
  4470. * @param height defines the viewport height
  4471. * @param znear defines the near clip plane
  4472. * @param zfar defines the far clip plane
  4473. * @returns a new matrix as a left-handed perspective projection matrix
  4474. */
  4475. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4476. /**
  4477. * Creates a left-handed perspective projection matrix
  4478. * @param fov defines the horizontal field of view
  4479. * @param aspect defines the aspect ratio
  4480. * @param znear defines the near clip plane
  4481. * @param zfar defines the far clip plane
  4482. * @returns a new matrix as a left-handed perspective projection matrix
  4483. */
  4484. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4485. /**
  4486. * Stores a left-handed perspective projection into a given matrix
  4487. * @param fov defines the horizontal field of view
  4488. * @param aspect defines the aspect ratio
  4489. * @param znear defines the near clip plane
  4490. * @param zfar defines the far clip plane
  4491. * @param result defines the target matrix
  4492. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4493. */
  4494. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4495. /**
  4496. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4497. * @param fov defines the horizontal field of view
  4498. * @param aspect defines the aspect ratio
  4499. * @param znear defines the near clip plane
  4500. * @param zfar not used as infinity is used as far clip
  4501. * @param result defines the target matrix
  4502. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4503. */
  4504. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4505. /**
  4506. * Creates a right-handed perspective projection matrix
  4507. * @param fov defines the horizontal field of view
  4508. * @param aspect defines the aspect ratio
  4509. * @param znear defines the near clip plane
  4510. * @param zfar defines the far clip plane
  4511. * @returns a new matrix as a right-handed perspective projection matrix
  4512. */
  4513. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4514. /**
  4515. * Stores a right-handed perspective projection into a given matrix
  4516. * @param fov defines the horizontal field of view
  4517. * @param aspect defines the aspect ratio
  4518. * @param znear defines the near clip plane
  4519. * @param zfar defines the far clip plane
  4520. * @param result defines the target matrix
  4521. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4522. */
  4523. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4524. /**
  4525. * Stores a right-handed perspective projection into a given matrix
  4526. * @param fov defines the horizontal field of view
  4527. * @param aspect defines the aspect ratio
  4528. * @param znear defines the near clip plane
  4529. * @param zfar not used as infinity is used as far clip
  4530. * @param result defines the target matrix
  4531. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4532. */
  4533. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4534. /**
  4535. * Stores a perspective projection for WebVR info a given matrix
  4536. * @param fov defines the field of view
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @param result defines the target matrix
  4540. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4541. */
  4542. static PerspectiveFovWebVRToRef(fov: {
  4543. upDegrees: number;
  4544. downDegrees: number;
  4545. leftDegrees: number;
  4546. rightDegrees: number;
  4547. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4548. /**
  4549. * Computes a complete transformation matrix
  4550. * @param viewport defines the viewport to use
  4551. * @param world defines the world matrix
  4552. * @param view defines the view matrix
  4553. * @param projection defines the projection matrix
  4554. * @param zmin defines the near clip plane
  4555. * @param zmax defines the far clip plane
  4556. * @returns the transformation matrix
  4557. */
  4558. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4559. /**
  4560. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4561. * @param matrix defines the matrix to use
  4562. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4563. */
  4564. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4565. /**
  4566. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4567. * @param matrix defines the matrix to use
  4568. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4569. */
  4570. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4571. /**
  4572. * Compute the transpose of a given matrix
  4573. * @param matrix defines the matrix to transpose
  4574. * @returns the new matrix
  4575. */
  4576. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4577. /**
  4578. * Compute the transpose of a matrix and store it in a target matrix
  4579. * @param matrix defines the matrix to transpose
  4580. * @param result defines the target matrix
  4581. */
  4582. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4583. /**
  4584. * Computes a reflection matrix from a plane
  4585. * @param plane defines the reflection plane
  4586. * @returns a new matrix
  4587. */
  4588. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4589. /**
  4590. * Computes a reflection matrix from a plane
  4591. * @param plane defines the reflection plane
  4592. * @param result defines the target matrix
  4593. */
  4594. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4595. /**
  4596. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4597. * @param xaxis defines the value of the 1st axis
  4598. * @param yaxis defines the value of the 2nd axis
  4599. * @param zaxis defines the value of the 3rd axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4603. /**
  4604. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4605. * @param quat defines the quaternion to use
  4606. * @param result defines the target matrix
  4607. */
  4608. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4609. }
  4610. /**
  4611. * @hidden
  4612. */
  4613. export class TmpVectors {
  4614. static Vector2: Vector2[];
  4615. static Vector3: Vector3[];
  4616. static Vector4: Vector4[];
  4617. static Quaternion: Quaternion[];
  4618. static Matrix: Matrix[];
  4619. }
  4620. }
  4621. declare module "babylonjs/Maths/math.path" {
  4622. import { DeepImmutable, Nullable } from "babylonjs/types";
  4623. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4624. /**
  4625. * Defines potential orientation for back face culling
  4626. */
  4627. export enum Orientation {
  4628. /**
  4629. * Clockwise
  4630. */
  4631. CW = 0,
  4632. /** Counter clockwise */
  4633. CCW = 1
  4634. }
  4635. /** Class used to represent a Bezier curve */
  4636. export class BezierCurve {
  4637. /**
  4638. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4639. * @param t defines the time
  4640. * @param x1 defines the left coordinate on X axis
  4641. * @param y1 defines the left coordinate on Y axis
  4642. * @param x2 defines the right coordinate on X axis
  4643. * @param y2 defines the right coordinate on Y axis
  4644. * @returns the interpolated value
  4645. */
  4646. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4647. }
  4648. /**
  4649. * Defines angle representation
  4650. */
  4651. export class Angle {
  4652. private _radians;
  4653. /**
  4654. * Creates an Angle object of "radians" radians (float).
  4655. * @param radians the angle in radians
  4656. */
  4657. constructor(radians: number);
  4658. /**
  4659. * Get value in degrees
  4660. * @returns the Angle value in degrees (float)
  4661. */
  4662. degrees(): number;
  4663. /**
  4664. * Get value in radians
  4665. * @returns the Angle value in radians (float)
  4666. */
  4667. radians(): number;
  4668. /**
  4669. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4670. * @param a defines first vector
  4671. * @param b defines second vector
  4672. * @returns a new Angle
  4673. */
  4674. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4675. /**
  4676. * Gets a new Angle object from the given float in radians
  4677. * @param radians defines the angle value in radians
  4678. * @returns a new Angle
  4679. */
  4680. static FromRadians(radians: number): Angle;
  4681. /**
  4682. * Gets a new Angle object from the given float in degrees
  4683. * @param degrees defines the angle value in degrees
  4684. * @returns a new Angle
  4685. */
  4686. static FromDegrees(degrees: number): Angle;
  4687. }
  4688. /**
  4689. * This represents an arc in a 2d space.
  4690. */
  4691. export class Arc2 {
  4692. /** Defines the start point of the arc */
  4693. startPoint: Vector2;
  4694. /** Defines the mid point of the arc */
  4695. midPoint: Vector2;
  4696. /** Defines the end point of the arc */
  4697. endPoint: Vector2;
  4698. /**
  4699. * Defines the center point of the arc.
  4700. */
  4701. centerPoint: Vector2;
  4702. /**
  4703. * Defines the radius of the arc.
  4704. */
  4705. radius: number;
  4706. /**
  4707. * Defines the angle of the arc (from mid point to end point).
  4708. */
  4709. angle: Angle;
  4710. /**
  4711. * Defines the start angle of the arc (from start point to middle point).
  4712. */
  4713. startAngle: Angle;
  4714. /**
  4715. * Defines the orientation of the arc (clock wise/counter clock wise).
  4716. */
  4717. orientation: Orientation;
  4718. /**
  4719. * Creates an Arc object from the three given points : start, middle and end.
  4720. * @param startPoint Defines the start point of the arc
  4721. * @param midPoint Defines the midlle point of the arc
  4722. * @param endPoint Defines the end point of the arc
  4723. */
  4724. constructor(
  4725. /** Defines the start point of the arc */
  4726. startPoint: Vector2,
  4727. /** Defines the mid point of the arc */
  4728. midPoint: Vector2,
  4729. /** Defines the end point of the arc */
  4730. endPoint: Vector2);
  4731. }
  4732. /**
  4733. * Represents a 2D path made up of multiple 2D points
  4734. */
  4735. export class Path2 {
  4736. private _points;
  4737. private _length;
  4738. /**
  4739. * If the path start and end point are the same
  4740. */
  4741. closed: boolean;
  4742. /**
  4743. * Creates a Path2 object from the starting 2D coordinates x and y.
  4744. * @param x the starting points x value
  4745. * @param y the starting points y value
  4746. */
  4747. constructor(x: number, y: number);
  4748. /**
  4749. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4750. * @param x the added points x value
  4751. * @param y the added points y value
  4752. * @returns the updated Path2.
  4753. */
  4754. addLineTo(x: number, y: number): Path2;
  4755. /**
  4756. * 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.
  4757. * @param midX middle point x value
  4758. * @param midY middle point y value
  4759. * @param endX end point x value
  4760. * @param endY end point y value
  4761. * @param numberOfSegments (default: 36)
  4762. * @returns the updated Path2.
  4763. */
  4764. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4765. /**
  4766. * Closes the Path2.
  4767. * @returns the Path2.
  4768. */
  4769. close(): Path2;
  4770. /**
  4771. * Gets the sum of the distance between each sequential point in the path
  4772. * @returns the Path2 total length (float).
  4773. */
  4774. length(): number;
  4775. /**
  4776. * Gets the points which construct the path
  4777. * @returns the Path2 internal array of points.
  4778. */
  4779. getPoints(): Vector2[];
  4780. /**
  4781. * Retreives the point at the distance aways from the starting point
  4782. * @param normalizedLengthPosition the length along the path to retreive the point from
  4783. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4784. */
  4785. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4786. /**
  4787. * Creates a new path starting from an x and y position
  4788. * @param x starting x value
  4789. * @param y starting y value
  4790. * @returns a new Path2 starting at the coordinates (x, y).
  4791. */
  4792. static StartingAt(x: number, y: number): Path2;
  4793. }
  4794. /**
  4795. * Represents a 3D path made up of multiple 3D points
  4796. */
  4797. export class Path3D {
  4798. /**
  4799. * an array of Vector3, the curve axis of the Path3D
  4800. */
  4801. path: Vector3[];
  4802. private _curve;
  4803. private _distances;
  4804. private _tangents;
  4805. private _normals;
  4806. private _binormals;
  4807. private _raw;
  4808. private _alignTangentsWithPath;
  4809. private readonly _pointAtData;
  4810. /**
  4811. * new Path3D(path, normal, raw)
  4812. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4813. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4814. * @param path an array of Vector3, the curve axis of the Path3D
  4815. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4816. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4817. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4818. */
  4819. constructor(
  4820. /**
  4821. * an array of Vector3, the curve axis of the Path3D
  4822. */
  4823. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getCurve(): Vector3[];
  4829. /**
  4830. * Returns the Path3D array of successive Vector3 designing its curve.
  4831. * @returns the Path3D array of successive Vector3 designing its curve.
  4832. */
  4833. getPoints(): Vector3[];
  4834. /**
  4835. * @returns the computed length (float) of the path.
  4836. */
  4837. length(): number;
  4838. /**
  4839. * Returns an array populated with tangent vectors on each Path3D curve point.
  4840. * @returns an array populated with tangent vectors on each Path3D curve point.
  4841. */
  4842. getTangents(): Vector3[];
  4843. /**
  4844. * Returns an array populated with normal vectors on each Path3D curve point.
  4845. * @returns an array populated with normal vectors on each Path3D curve point.
  4846. */
  4847. getNormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with binormal vectors on each Path3D curve point.
  4850. * @returns an array populated with binormal vectors on each Path3D curve point.
  4851. */
  4852. getBinormals(): Vector3[];
  4853. /**
  4854. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4855. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4856. */
  4857. getDistances(): number[];
  4858. /**
  4859. * Returns an interpolated point along this path
  4860. * @param position the position of the point along this path, from 0.0 to 1.0
  4861. * @returns a new Vector3 as the point
  4862. */
  4863. getPointAt(position: number): Vector3;
  4864. /**
  4865. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4866. * @param position the position of the point along this path, from 0.0 to 1.0
  4867. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4868. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4869. */
  4870. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4871. /**
  4872. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4873. * @param position the position of the point along this path, from 0.0 to 1.0
  4874. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4875. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4876. */
  4877. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4878. /**
  4879. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4882. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4883. */
  4884. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4885. /**
  4886. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4887. * @param position the position of the point along this path, from 0.0 to 1.0
  4888. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4889. */
  4890. getDistanceAt(position: number): number;
  4891. /**
  4892. * Returns the array index of the previous point of an interpolated point along this path
  4893. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4894. * @returns the array index
  4895. */
  4896. getPreviousPointIndexAt(position: number): number;
  4897. /**
  4898. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4899. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4900. * @returns the sub position
  4901. */
  4902. getSubPositionAt(position: number): number;
  4903. /**
  4904. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4905. * @param target the vector of which to get the closest position to
  4906. * @returns the position of the closest virtual point on this path to the target vector
  4907. */
  4908. getClosestPositionTo(target: Vector3): number;
  4909. /**
  4910. * Returns a sub path (slice) of this path
  4911. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4912. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4913. * @returns a sub path (slice) of this path
  4914. */
  4915. slice(start?: number, end?: number): Path3D;
  4916. /**
  4917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4918. * @param path path which all values are copied into the curves points
  4919. * @param firstNormal which should be projected onto the curve
  4920. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4921. * @returns the same object updated.
  4922. */
  4923. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4924. private _compute;
  4925. private _getFirstNonNullVector;
  4926. private _getLastNonNullVector;
  4927. private _normalVector;
  4928. /**
  4929. * Updates the point at data for an interpolated point along this curve
  4930. * @param position the position of the point along this curve, from 0.0 to 1.0
  4931. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4932. * @returns the (updated) point at data
  4933. */
  4934. private _updatePointAtData;
  4935. /**
  4936. * Updates the point at data from the specified parameters
  4937. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4938. * @param point the interpolated point
  4939. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4940. */
  4941. private _setPointAtData;
  4942. /**
  4943. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4944. */
  4945. private _updateInterpolationMatrix;
  4946. }
  4947. /**
  4948. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4949. * A Curve3 is designed from a series of successive Vector3.
  4950. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4951. */
  4952. export class Curve3 {
  4953. private _points;
  4954. private _length;
  4955. /**
  4956. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4957. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4958. * @param v1 (Vector3) the control point
  4959. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4960. * @param nbPoints (integer) the wanted number of points in the curve
  4961. * @returns the created Curve3
  4962. */
  4963. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4964. /**
  4965. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4966. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4967. * @param v1 (Vector3) the first control point
  4968. * @param v2 (Vector3) the second control point
  4969. * @param v3 (Vector3) the end point of the Cubic Bezier
  4970. * @param nbPoints (integer) the wanted number of points in the curve
  4971. * @returns the created Curve3
  4972. */
  4973. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4974. /**
  4975. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4976. * @param p1 (Vector3) the origin point of the Hermite Spline
  4977. * @param t1 (Vector3) the tangent vector at the origin point
  4978. * @param p2 (Vector3) the end point of the Hermite Spline
  4979. * @param t2 (Vector3) the tangent vector at the end point
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a CatmullRom Spline curve :
  4986. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4987. * @param nbPoints (integer) the wanted number of points between each curve control points
  4988. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4992. /**
  4993. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4994. * A Curve3 is designed from a series of successive Vector3.
  4995. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4996. * @param points points which make up the curve
  4997. */
  4998. constructor(points: Vector3[]);
  4999. /**
  5000. * @returns the Curve3 stored array of successive Vector3
  5001. */
  5002. getPoints(): Vector3[];
  5003. /**
  5004. * @returns the computed length (float) of the curve.
  5005. */
  5006. length(): number;
  5007. /**
  5008. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5009. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5010. * curveA and curveB keep unchanged.
  5011. * @param curve the curve to continue from this curve
  5012. * @returns the newly constructed curve
  5013. */
  5014. continue(curve: DeepImmutable<Curve3>): Curve3;
  5015. private _computeLength;
  5016. }
  5017. }
  5018. declare module "babylonjs/Animations/easing" {
  5019. /**
  5020. * This represents the main contract an easing function should follow.
  5021. * Easing functions are used throughout the animation system.
  5022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5023. */
  5024. export interface IEasingFunction {
  5025. /**
  5026. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5027. * of the easing function.
  5028. * The link below provides some of the most common examples of easing functions.
  5029. * @see https://easings.net/
  5030. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5031. * @returns the corresponding value on the curve defined by the easing function
  5032. */
  5033. ease(gradient: number): number;
  5034. }
  5035. /**
  5036. * Base class used for every default easing function.
  5037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5038. */
  5039. export class EasingFunction implements IEasingFunction {
  5040. /**
  5041. * Interpolation follows the mathematical formula associated with the easing function.
  5042. */
  5043. static readonly EASINGMODE_EASEIN: number;
  5044. /**
  5045. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5046. */
  5047. static readonly EASINGMODE_EASEOUT: number;
  5048. /**
  5049. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5050. */
  5051. static readonly EASINGMODE_EASEINOUT: number;
  5052. private _easingMode;
  5053. /**
  5054. * Sets the easing mode of the current function.
  5055. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5056. */
  5057. setEasingMode(easingMode: number): void;
  5058. /**
  5059. * Gets the current easing mode.
  5060. * @returns the easing mode
  5061. */
  5062. getEasingMode(): number;
  5063. /**
  5064. * @hidden
  5065. */
  5066. easeInCore(gradient: number): number;
  5067. /**
  5068. * Given an input gradient between 0 and 1, this returns the corresponding value
  5069. * of the easing function.
  5070. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5071. * @returns the corresponding value on the curve defined by the easing function
  5072. */
  5073. ease(gradient: number): number;
  5074. }
  5075. /**
  5076. * Easing function with a circle shape (see link below).
  5077. * @see https://easings.net/#easeInCirc
  5078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5079. */
  5080. export class CircleEase extends EasingFunction implements IEasingFunction {
  5081. /** @hidden */
  5082. easeInCore(gradient: number): number;
  5083. }
  5084. /**
  5085. * Easing function with a ease back shape (see link below).
  5086. * @see https://easings.net/#easeInBack
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class BackEase extends EasingFunction implements IEasingFunction {
  5090. /** Defines the amplitude of the function */
  5091. amplitude: number;
  5092. /**
  5093. * Instantiates a back ease easing
  5094. * @see https://easings.net/#easeInBack
  5095. * @param amplitude Defines the amplitude of the function
  5096. */
  5097. constructor(
  5098. /** Defines the amplitude of the function */
  5099. amplitude?: number);
  5100. /** @hidden */
  5101. easeInCore(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a bouncing shape (see link below).
  5105. * @see https://easings.net/#easeInBounce
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class BounceEase extends EasingFunction implements IEasingFunction {
  5109. /** Defines the number of bounces */
  5110. bounces: number;
  5111. /** Defines the amplitude of the bounce */
  5112. bounciness: number;
  5113. /**
  5114. * Instantiates a bounce easing
  5115. * @see https://easings.net/#easeInBounce
  5116. * @param bounces Defines the number of bounces
  5117. * @param bounciness Defines the amplitude of the bounce
  5118. */
  5119. constructor(
  5120. /** Defines the number of bounces */
  5121. bounces?: number,
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness?: number);
  5124. /** @hidden */
  5125. easeInCore(gradient: number): number;
  5126. }
  5127. /**
  5128. * Easing function with a power of 3 shape (see link below).
  5129. * @see https://easings.net/#easeInCubic
  5130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5131. */
  5132. export class CubicEase extends EasingFunction implements IEasingFunction {
  5133. /** @hidden */
  5134. easeInCore(gradient: number): number;
  5135. }
  5136. /**
  5137. * Easing function with an elastic shape (see link below).
  5138. * @see https://easings.net/#easeInElastic
  5139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5140. */
  5141. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5142. /** Defines the number of oscillations*/
  5143. oscillations: number;
  5144. /** Defines the amplitude of the oscillations*/
  5145. springiness: number;
  5146. /**
  5147. * Instantiates an elastic easing function
  5148. * @see https://easings.net/#easeInElastic
  5149. * @param oscillations Defines the number of oscillations
  5150. * @param springiness Defines the amplitude of the oscillations
  5151. */
  5152. constructor(
  5153. /** Defines the number of oscillations*/
  5154. oscillations?: number,
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness?: number);
  5157. /** @hidden */
  5158. easeInCore(gradient: number): number;
  5159. }
  5160. /**
  5161. * Easing function with an exponential shape (see link below).
  5162. * @see https://easings.net/#easeInExpo
  5163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5164. */
  5165. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5166. /** Defines the exponent of the function */
  5167. exponent: number;
  5168. /**
  5169. * Instantiates an exponential easing function
  5170. * @see https://easings.net/#easeInExpo
  5171. * @param exponent Defines the exponent of the function
  5172. */
  5173. constructor(
  5174. /** Defines the exponent of the function */
  5175. exponent?: number);
  5176. /** @hidden */
  5177. easeInCore(gradient: number): number;
  5178. }
  5179. /**
  5180. * Easing function with a power shape (see link below).
  5181. * @see https://easings.net/#easeInQuad
  5182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5183. */
  5184. export class PowerEase extends EasingFunction implements IEasingFunction {
  5185. /** Defines the power of the function */
  5186. power: number;
  5187. /**
  5188. * Instantiates an power base easing function
  5189. * @see https://easings.net/#easeInQuad
  5190. * @param power Defines the power of the function
  5191. */
  5192. constructor(
  5193. /** Defines the power of the function */
  5194. power?: number);
  5195. /** @hidden */
  5196. easeInCore(gradient: number): number;
  5197. }
  5198. /**
  5199. * Easing function with a power of 2 shape (see link below).
  5200. * @see https://easings.net/#easeInQuad
  5201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5202. */
  5203. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power of 4 shape (see link below).
  5209. * @see https://easings.net/#easeInQuart
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5213. /** @hidden */
  5214. easeInCore(gradient: number): number;
  5215. }
  5216. /**
  5217. * Easing function with a power of 5 shape (see link below).
  5218. * @see https://easings.net/#easeInQuint
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a sin shape (see link below).
  5227. * @see https://easings.net/#easeInSine
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class SineEase extends EasingFunction implements IEasingFunction {
  5231. /** @hidden */
  5232. easeInCore(gradient: number): number;
  5233. }
  5234. /**
  5235. * Easing function with a bezier shape (see link below).
  5236. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5238. */
  5239. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5240. /** Defines the x component of the start tangent in the bezier curve */
  5241. x1: number;
  5242. /** Defines the y component of the start tangent in the bezier curve */
  5243. y1: number;
  5244. /** Defines the x component of the end tangent in the bezier curve */
  5245. x2: number;
  5246. /** Defines the y component of the end tangent in the bezier curve */
  5247. y2: number;
  5248. /**
  5249. * Instantiates a bezier function
  5250. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5251. * @param x1 Defines the x component of the start tangent in the bezier curve
  5252. * @param y1 Defines the y component of the start tangent in the bezier curve
  5253. * @param x2 Defines the x component of the end tangent in the bezier curve
  5254. * @param y2 Defines the y component of the end tangent in the bezier curve
  5255. */
  5256. constructor(
  5257. /** Defines the x component of the start tangent in the bezier curve */
  5258. x1?: number,
  5259. /** Defines the y component of the start tangent in the bezier curve */
  5260. y1?: number,
  5261. /** Defines the x component of the end tangent in the bezier curve */
  5262. x2?: number,
  5263. /** Defines the y component of the end tangent in the bezier curve */
  5264. y2?: number);
  5265. /** @hidden */
  5266. easeInCore(gradient: number): number;
  5267. }
  5268. }
  5269. declare module "babylonjs/Maths/math.color" {
  5270. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5271. /**
  5272. * Class used to hold a RBG color
  5273. */
  5274. export class Color3 {
  5275. /**
  5276. * Defines the red component (between 0 and 1, default is 0)
  5277. */
  5278. r: number;
  5279. /**
  5280. * Defines the green component (between 0 and 1, default is 0)
  5281. */
  5282. g: number;
  5283. /**
  5284. * Defines the blue component (between 0 and 1, default is 0)
  5285. */
  5286. b: number;
  5287. /**
  5288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5289. * @param r defines the red component (between 0 and 1, default is 0)
  5290. * @param g defines the green component (between 0 and 1, default is 0)
  5291. * @param b defines the blue component (between 0 and 1, default is 0)
  5292. */
  5293. constructor(
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r?: number,
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g?: number,
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b?: number);
  5306. /**
  5307. * Creates a string with the Color3 current values
  5308. * @returns the string representation of the Color3 object
  5309. */
  5310. toString(): string;
  5311. /**
  5312. * Returns the string "Color3"
  5313. * @returns "Color3"
  5314. */
  5315. getClassName(): string;
  5316. /**
  5317. * Compute the Color3 hash code
  5318. * @returns an unique number that can be used to hash Color3 objects
  5319. */
  5320. getHashCode(): number;
  5321. /**
  5322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5323. * @param array defines the array where to store the r,g,b components
  5324. * @param index defines an optional index in the target array to define where to start storing values
  5325. * @returns the current Color3 object
  5326. */
  5327. toArray(array: FloatArray, index?: number): Color3;
  5328. /**
  5329. * Returns a new Color4 object from the current Color3 and the given alpha
  5330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5331. * @returns a new Color4 object
  5332. */
  5333. toColor4(alpha?: number): Color4;
  5334. /**
  5335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5336. * @returns the new array
  5337. */
  5338. asArray(): number[];
  5339. /**
  5340. * Returns the luminance value
  5341. * @returns a float value
  5342. */
  5343. toLuminance(): number;
  5344. /**
  5345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5346. * @param otherColor defines the second operand
  5347. * @returns the new Color3 object
  5348. */
  5349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5350. /**
  5351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5352. * @param otherColor defines the second operand
  5353. * @param result defines the Color3 object where to store the result
  5354. * @returns the current Color3
  5355. */
  5356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5357. /**
  5358. * Determines equality between Color3 objects
  5359. * @param otherColor defines the second operand
  5360. * @returns true if the rgb values are equal to the given ones
  5361. */
  5362. equals(otherColor: DeepImmutable<Color3>): boolean;
  5363. /**
  5364. * Determines equality between the current Color3 object and a set of r,b,g values
  5365. * @param r defines the red component to check
  5366. * @param g defines the green component to check
  5367. * @param b defines the blue component to check
  5368. * @returns true if the rgb values are equal to the given ones
  5369. */
  5370. equalsFloats(r: number, g: number, b: number): boolean;
  5371. /**
  5372. * Multiplies in place each rgb value by scale
  5373. * @param scale defines the scaling factor
  5374. * @returns the updated Color3
  5375. */
  5376. scale(scale: number): Color3;
  5377. /**
  5378. * Multiplies the rgb values by scale and stores the result into "result"
  5379. * @param scale defines the scaling factor
  5380. * @param result defines the Color3 object where to store the result
  5381. * @returns the unmodified current Color3
  5382. */
  5383. scaleToRef(scale: number, result: Color3): Color3;
  5384. /**
  5385. * Scale the current Color3 values by a factor and add the result to a given Color3
  5386. * @param scale defines the scale factor
  5387. * @param result defines color to store the result into
  5388. * @returns the unmodified current Color3
  5389. */
  5390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5391. /**
  5392. * Clamps the rgb values by the min and max values and stores the result into "result"
  5393. * @param min defines minimum clamping value (default is 0)
  5394. * @param max defines maximum clamping value (default is 1)
  5395. * @param result defines color to store the result into
  5396. * @returns the original Color3
  5397. */
  5398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5399. /**
  5400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5401. * @param otherColor defines the second operand
  5402. * @returns the new Color3
  5403. */
  5404. add(otherColor: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5407. * @param otherColor defines the second operand
  5408. * @param result defines Color3 object to store the result into
  5409. * @returns the unmodified current Color3
  5410. */
  5411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5412. /**
  5413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5414. * @param otherColor defines the second operand
  5415. * @returns the new Color3
  5416. */
  5417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5418. /**
  5419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5420. * @param otherColor defines the second operand
  5421. * @param result defines Color3 object to store the result into
  5422. * @returns the unmodified current Color3
  5423. */
  5424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5425. /**
  5426. * Copy the current object
  5427. * @returns a new Color3 copied the current one
  5428. */
  5429. clone(): Color3;
  5430. /**
  5431. * Copies the rgb values from the source in the current Color3
  5432. * @param source defines the source Color3 object
  5433. * @returns the updated Color3 object
  5434. */
  5435. copyFrom(source: DeepImmutable<Color3>): Color3;
  5436. /**
  5437. * Updates the Color3 rgb values from the given floats
  5438. * @param r defines the red component to read from
  5439. * @param g defines the green component to read from
  5440. * @param b defines the blue component to read from
  5441. * @returns the current Color3 object
  5442. */
  5443. copyFromFloats(r: number, g: number, b: number): Color3;
  5444. /**
  5445. * Updates the Color3 rgb values from the given floats
  5446. * @param r defines the red component to read from
  5447. * @param g defines the green component to read from
  5448. * @param b defines the blue component to read from
  5449. * @returns the current Color3 object
  5450. */
  5451. set(r: number, g: number, b: number): Color3;
  5452. /**
  5453. * Compute the Color3 hexadecimal code as a string
  5454. * @returns a string containing the hexadecimal representation of the Color3 object
  5455. */
  5456. toHexString(): string;
  5457. /**
  5458. * Computes a new Color3 converted from the current one to linear space
  5459. * @returns a new Color3 object
  5460. */
  5461. toLinearSpace(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @returns a new color3 representing the HSV values
  5465. */
  5466. toHSV(): Color3;
  5467. /**
  5468. * Converts current color in rgb space to HSV values
  5469. * @param result defines the Color3 where to store the HSV values
  5470. */
  5471. toHSVToRef(result: Color3): void;
  5472. /**
  5473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5474. * @param convertedColor defines the Color3 object where to store the linear space version
  5475. * @returns the unmodified Color3
  5476. */
  5477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5478. /**
  5479. * Computes a new Color3 converted from the current one to gamma space
  5480. * @returns a new Color3 object
  5481. */
  5482. toGammaSpace(): Color3;
  5483. /**
  5484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5485. * @param convertedColor defines the Color3 object where to store the gamma space version
  5486. * @returns the unmodified Color3
  5487. */
  5488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5489. private static _BlackReadOnly;
  5490. /**
  5491. * Convert Hue, saturation and value to a Color3 (RGB)
  5492. * @param hue defines the hue
  5493. * @param saturation defines the saturation
  5494. * @param value defines the value
  5495. * @param result defines the Color3 where to store the RGB values
  5496. */
  5497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5498. /**
  5499. * Creates a new Color3 from the string containing valid hexadecimal values
  5500. * @param hex defines a string containing valid hexadecimal values
  5501. * @returns a new Color3 object
  5502. */
  5503. static FromHexString(hex: string): Color3;
  5504. /**
  5505. * Creates a new Color3 from the starting index of the given array
  5506. * @param array defines the source array
  5507. * @param offset defines an offset in the source array
  5508. * @returns a new Color3 object
  5509. */
  5510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5511. /**
  5512. * Creates a new Color3 from integer values (< 256)
  5513. * @param r defines the red component to read from (value between 0 and 255)
  5514. * @param g defines the green component to read from (value between 0 and 255)
  5515. * @param b defines the blue component to read from (value between 0 and 255)
  5516. * @returns a new Color3 object
  5517. */
  5518. static FromInts(r: number, g: number, b: number): Color3;
  5519. /**
  5520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5521. * @param start defines the start Color3 value
  5522. * @param end defines the end Color3 value
  5523. * @param amount defines the gradient value between start and end
  5524. * @returns a new Color3 object
  5525. */
  5526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5527. /**
  5528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5529. * @param left defines the start value
  5530. * @param right defines the end value
  5531. * @param amount defines the gradient factor
  5532. * @param result defines the Color3 object where to store the result
  5533. */
  5534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5535. /**
  5536. * Returns a Color3 value containing a red color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Red(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a green color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Green(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a blue color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Blue(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a black color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Black(): Color3;
  5555. /**
  5556. * Gets a Color3 value containing a black color that must not be updated
  5557. */
  5558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5559. /**
  5560. * Returns a Color3 value containing a white color
  5561. * @returns a new Color3 object
  5562. */
  5563. static White(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a purple color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Purple(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a magenta color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Magenta(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a yellow color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Yellow(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a gray color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Gray(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a teal color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Teal(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a random color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Random(): Color3;
  5594. }
  5595. /**
  5596. * Class used to hold a RBGA color
  5597. */
  5598. export class Color4 {
  5599. /**
  5600. * Defines the red component (between 0 and 1, default is 0)
  5601. */
  5602. r: number;
  5603. /**
  5604. * Defines the green component (between 0 and 1, default is 0)
  5605. */
  5606. g: number;
  5607. /**
  5608. * Defines the blue component (between 0 and 1, default is 0)
  5609. */
  5610. b: number;
  5611. /**
  5612. * Defines the alpha component (between 0 and 1, default is 1)
  5613. */
  5614. a: number;
  5615. /**
  5616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5617. * @param r defines the red component (between 0 and 1, default is 0)
  5618. * @param g defines the green component (between 0 and 1, default is 0)
  5619. * @param b defines the blue component (between 0 and 1, default is 0)
  5620. * @param a defines the alpha component (between 0 and 1, default is 1)
  5621. */
  5622. constructor(
  5623. /**
  5624. * Defines the red component (between 0 and 1, default is 0)
  5625. */
  5626. r?: number,
  5627. /**
  5628. * Defines the green component (between 0 and 1, default is 0)
  5629. */
  5630. g?: number,
  5631. /**
  5632. * Defines the blue component (between 0 and 1, default is 0)
  5633. */
  5634. b?: number,
  5635. /**
  5636. * Defines the alpha component (between 0 and 1, default is 1)
  5637. */
  5638. a?: number);
  5639. /**
  5640. * Adds in place the given Color4 values to the current Color4 object
  5641. * @param right defines the second operand
  5642. * @returns the current updated Color4 object
  5643. */
  5644. addInPlace(right: DeepImmutable<Color4>): Color4;
  5645. /**
  5646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5647. * @returns the new array
  5648. */
  5649. asArray(): number[];
  5650. /**
  5651. * Stores from the starting index in the given array the Color4 successive values
  5652. * @param array defines the array where to store the r,g,b components
  5653. * @param index defines an optional index in the target array to define where to start storing values
  5654. * @returns the current Color4 object
  5655. */
  5656. toArray(array: number[], index?: number): Color4;
  5657. /**
  5658. * Determines equality between Color4 objects
  5659. * @param otherColor defines the second operand
  5660. * @returns true if the rgba values are equal to the given ones
  5661. */
  5662. equals(otherColor: DeepImmutable<Color4>): boolean;
  5663. /**
  5664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5665. * @param right defines the second operand
  5666. * @returns a new Color4 object
  5667. */
  5668. add(right: DeepImmutable<Color4>): Color4;
  5669. /**
  5670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5671. * @param right defines the second operand
  5672. * @returns a new Color4 object
  5673. */
  5674. subtract(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5677. * @param right defines the second operand
  5678. * @param result defines the Color4 object where to store the result
  5679. * @returns the current Color4 object
  5680. */
  5681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5682. /**
  5683. * Creates a new Color4 with the current Color4 values multiplied by scale
  5684. * @param scale defines the scaling factor to apply
  5685. * @returns a new Color4 object
  5686. */
  5687. scale(scale: number): Color4;
  5688. /**
  5689. * Multiplies the current Color4 values by scale and stores the result in "result"
  5690. * @param scale defines the scaling factor to apply
  5691. * @param result defines the Color4 object where to store the result
  5692. * @returns the current unmodified Color4
  5693. */
  5694. scaleToRef(scale: number, result: Color4): Color4;
  5695. /**
  5696. * Scale the current Color4 values by a factor and add the result to a given Color4
  5697. * @param scale defines the scale factor
  5698. * @param result defines the Color4 object where to store the result
  5699. * @returns the unmodified current Color4
  5700. */
  5701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5702. /**
  5703. * Clamps the rgb values by the min and max values and stores the result into "result"
  5704. * @param min defines minimum clamping value (default is 0)
  5705. * @param max defines maximum clamping value (default is 1)
  5706. * @param result defines color to store the result into.
  5707. * @returns the cuurent Color4
  5708. */
  5709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5710. /**
  5711. * Multipy an Color4 value by another and return a new Color4 object
  5712. * @param color defines the Color4 value to multiply by
  5713. * @returns a new Color4 object
  5714. */
  5715. multiply(color: Color4): Color4;
  5716. /**
  5717. * Multipy a Color4 value by another and push the result in a reference value
  5718. * @param color defines the Color4 value to multiply by
  5719. * @param result defines the Color4 to fill the result in
  5720. * @returns the result Color4
  5721. */
  5722. multiplyToRef(color: Color4, result: Color4): Color4;
  5723. /**
  5724. * Creates a string with the Color4 current values
  5725. * @returns the string representation of the Color4 object
  5726. */
  5727. toString(): string;
  5728. /**
  5729. * Returns the string "Color4"
  5730. * @returns "Color4"
  5731. */
  5732. getClassName(): string;
  5733. /**
  5734. * Compute the Color4 hash code
  5735. * @returns an unique number that can be used to hash Color4 objects
  5736. */
  5737. getHashCode(): number;
  5738. /**
  5739. * Creates a new Color4 copied from the current one
  5740. * @returns a new Color4 object
  5741. */
  5742. clone(): Color4;
  5743. /**
  5744. * Copies the given Color4 values into the current one
  5745. * @param source defines the source Color4 object
  5746. * @returns the current updated Color4 object
  5747. */
  5748. copyFrom(source: Color4): Color4;
  5749. /**
  5750. * Copies the given float values into the current one
  5751. * @param r defines the red component to read from
  5752. * @param g defines the green component to read from
  5753. * @param b defines the blue component to read from
  5754. * @param a defines the alpha component to read from
  5755. * @returns the current updated Color4 object
  5756. */
  5757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5758. /**
  5759. * Copies the given float values into the current one
  5760. * @param r defines the red component to read from
  5761. * @param g defines the green component to read from
  5762. * @param b defines the blue component to read from
  5763. * @param a defines the alpha component to read from
  5764. * @returns the current updated Color4 object
  5765. */
  5766. set(r: number, g: number, b: number, a: number): Color4;
  5767. /**
  5768. * Compute the Color4 hexadecimal code as a string
  5769. * @returns a string containing the hexadecimal representation of the Color4 object
  5770. */
  5771. toHexString(): string;
  5772. /**
  5773. * Computes a new Color4 converted from the current one to linear space
  5774. * @returns a new Color4 object
  5775. */
  5776. toLinearSpace(): Color4;
  5777. /**
  5778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5779. * @param convertedColor defines the Color4 object where to store the linear space version
  5780. * @returns the unmodified Color4
  5781. */
  5782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5783. /**
  5784. * Computes a new Color4 converted from the current one to gamma space
  5785. * @returns a new Color4 object
  5786. */
  5787. toGammaSpace(): Color4;
  5788. /**
  5789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5790. * @param convertedColor defines the Color4 object where to store the gamma space version
  5791. * @returns the unmodified Color4
  5792. */
  5793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5794. /**
  5795. * Creates a new Color4 from the string containing valid hexadecimal values
  5796. * @param hex defines a string containing valid hexadecimal values
  5797. * @returns a new Color4 object
  5798. */
  5799. static FromHexString(hex: string): Color4;
  5800. /**
  5801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5802. * @param left defines the start value
  5803. * @param right defines the end value
  5804. * @param amount defines the gradient factor
  5805. * @returns a new Color4 object
  5806. */
  5807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5808. /**
  5809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5810. * @param left defines the start value
  5811. * @param right defines the end value
  5812. * @param amount defines the gradient factor
  5813. * @param result defines the Color4 object where to store data
  5814. */
  5815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5816. /**
  5817. * Creates a new Color4 from a Color3 and an alpha value
  5818. * @param color3 defines the source Color3 to read from
  5819. * @param alpha defines the alpha component (1.0 by default)
  5820. * @returns a new Color4 object
  5821. */
  5822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5823. /**
  5824. * Creates a new Color4 from the starting index element of the given array
  5825. * @param array defines the source array to read from
  5826. * @param offset defines the offset in the source array
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5830. /**
  5831. * Creates a new Color3 from integer values (< 256)
  5832. * @param r defines the red component to read from (value between 0 and 255)
  5833. * @param g defines the green component to read from (value between 0 and 255)
  5834. * @param b defines the blue component to read from (value between 0 and 255)
  5835. * @param a defines the alpha component to read from (value between 0 and 255)
  5836. * @returns a new Color3 object
  5837. */
  5838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5839. /**
  5840. * Check the content of a given array and convert it to an array containing RGBA data
  5841. * If the original array was already containing count * 4 values then it is returned directly
  5842. * @param colors defines the array to check
  5843. * @param count defines the number of RGBA data to expect
  5844. * @returns an array containing count * 4 values (RGBA)
  5845. */
  5846. static CheckColors4(colors: number[], count: number): number[];
  5847. }
  5848. /**
  5849. * @hidden
  5850. */
  5851. export class TmpColors {
  5852. static Color3: Color3[];
  5853. static Color4: Color4[];
  5854. }
  5855. }
  5856. declare module "babylonjs/Animations/animationKey" {
  5857. /**
  5858. * Defines an interface which represents an animation key frame
  5859. */
  5860. export interface IAnimationKey {
  5861. /**
  5862. * Frame of the key frame
  5863. */
  5864. frame: number;
  5865. /**
  5866. * Value at the specifies key frame
  5867. */
  5868. value: any;
  5869. /**
  5870. * The input tangent for the cubic hermite spline
  5871. */
  5872. inTangent?: any;
  5873. /**
  5874. * The output tangent for the cubic hermite spline
  5875. */
  5876. outTangent?: any;
  5877. /**
  5878. * The animation interpolation type
  5879. */
  5880. interpolation?: AnimationKeyInterpolation;
  5881. }
  5882. /**
  5883. * Enum for the animation key frame interpolation type
  5884. */
  5885. export enum AnimationKeyInterpolation {
  5886. /**
  5887. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5888. */
  5889. STEP = 1
  5890. }
  5891. }
  5892. declare module "babylonjs/Animations/animationRange" {
  5893. /**
  5894. * Represents the range of an animation
  5895. */
  5896. export class AnimationRange {
  5897. /**The name of the animation range**/
  5898. name: string;
  5899. /**The starting frame of the animation */
  5900. from: number;
  5901. /**The ending frame of the animation*/
  5902. to: number;
  5903. /**
  5904. * Initializes the range of an animation
  5905. * @param name The name of the animation range
  5906. * @param from The starting frame of the animation
  5907. * @param to The ending frame of the animation
  5908. */
  5909. constructor(
  5910. /**The name of the animation range**/
  5911. name: string,
  5912. /**The starting frame of the animation */
  5913. from: number,
  5914. /**The ending frame of the animation*/
  5915. to: number);
  5916. /**
  5917. * Makes a copy of the animation range
  5918. * @returns A copy of the animation range
  5919. */
  5920. clone(): AnimationRange;
  5921. }
  5922. }
  5923. declare module "babylonjs/Animations/animationEvent" {
  5924. /**
  5925. * Composed of a frame, and an action function
  5926. */
  5927. export class AnimationEvent {
  5928. /** The frame for which the event is triggered **/
  5929. frame: number;
  5930. /** The event to perform when triggered **/
  5931. action: (currentFrame: number) => void;
  5932. /** Specifies if the event should be triggered only once**/
  5933. onlyOnce?: boolean | undefined;
  5934. /**
  5935. * Specifies if the animation event is done
  5936. */
  5937. isDone: boolean;
  5938. /**
  5939. * Initializes the animation event
  5940. * @param frame The frame for which the event is triggered
  5941. * @param action The event to perform when triggered
  5942. * @param onlyOnce Specifies if the event should be triggered only once
  5943. */
  5944. constructor(
  5945. /** The frame for which the event is triggered **/
  5946. frame: number,
  5947. /** The event to perform when triggered **/
  5948. action: (currentFrame: number) => void,
  5949. /** Specifies if the event should be triggered only once**/
  5950. onlyOnce?: boolean | undefined);
  5951. /** @hidden */
  5952. _clone(): AnimationEvent;
  5953. }
  5954. }
  5955. declare module "babylonjs/Behaviors/behavior" {
  5956. import { Nullable } from "babylonjs/types";
  5957. /**
  5958. * Interface used to define a behavior
  5959. */
  5960. export interface Behavior<T> {
  5961. /** gets or sets behavior's name */
  5962. name: string;
  5963. /**
  5964. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5965. */
  5966. init(): void;
  5967. /**
  5968. * Called when the behavior is attached to a target
  5969. * @param target defines the target where the behavior is attached to
  5970. */
  5971. attach(target: T): void;
  5972. /**
  5973. * Called when the behavior is detached from its target
  5974. */
  5975. detach(): void;
  5976. }
  5977. /**
  5978. * Interface implemented by classes supporting behaviors
  5979. */
  5980. export interface IBehaviorAware<T> {
  5981. /**
  5982. * Attach a behavior
  5983. * @param behavior defines the behavior to attach
  5984. * @returns the current host
  5985. */
  5986. addBehavior(behavior: Behavior<T>): T;
  5987. /**
  5988. * Remove a behavior from the current object
  5989. * @param behavior defines the behavior to detach
  5990. * @returns the current host
  5991. */
  5992. removeBehavior(behavior: Behavior<T>): T;
  5993. /**
  5994. * Gets a behavior using its name to search
  5995. * @param name defines the name to search
  5996. * @returns the behavior or null if not found
  5997. */
  5998. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5999. }
  6000. }
  6001. declare module "babylonjs/Misc/smartArray" {
  6002. /**
  6003. * Defines an array and its length.
  6004. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6005. */
  6006. export interface ISmartArrayLike<T> {
  6007. /**
  6008. * The data of the array.
  6009. */
  6010. data: Array<T>;
  6011. /**
  6012. * The active length of the array.
  6013. */
  6014. length: number;
  6015. }
  6016. /**
  6017. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6018. */
  6019. export class SmartArray<T> implements ISmartArrayLike<T> {
  6020. /**
  6021. * The full set of data from the array.
  6022. */
  6023. data: Array<T>;
  6024. /**
  6025. * The active length of the array.
  6026. */
  6027. length: number;
  6028. protected _id: number;
  6029. /**
  6030. * Instantiates a Smart Array.
  6031. * @param capacity defines the default capacity of the array.
  6032. */
  6033. constructor(capacity: number);
  6034. /**
  6035. * Pushes a value at the end of the active data.
  6036. * @param value defines the object to push in the array.
  6037. */
  6038. push(value: T): void;
  6039. /**
  6040. * Iterates over the active data and apply the lambda to them.
  6041. * @param func defines the action to apply on each value.
  6042. */
  6043. forEach(func: (content: T) => void): void;
  6044. /**
  6045. * Sorts the full sets of data.
  6046. * @param compareFn defines the comparison function to apply.
  6047. */
  6048. sort(compareFn: (a: T, b: T) => number): void;
  6049. /**
  6050. * Resets the active data to an empty array.
  6051. */
  6052. reset(): void;
  6053. /**
  6054. * Releases all the data from the array as well as the array.
  6055. */
  6056. dispose(): void;
  6057. /**
  6058. * Concats the active data with a given array.
  6059. * @param array defines the data to concatenate with.
  6060. */
  6061. concat(array: any): void;
  6062. /**
  6063. * Returns the position of a value in the active data.
  6064. * @param value defines the value to find the index for
  6065. * @returns the index if found in the active data otherwise -1
  6066. */
  6067. indexOf(value: T): number;
  6068. /**
  6069. * Returns whether an element is part of the active data.
  6070. * @param value defines the value to look for
  6071. * @returns true if found in the active data otherwise false
  6072. */
  6073. contains(value: T): boolean;
  6074. private static _GlobalId;
  6075. }
  6076. /**
  6077. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6078. * The data in this array can only be present once
  6079. */
  6080. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6081. private _duplicateId;
  6082. /**
  6083. * Pushes a value at the end of the active data.
  6084. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6085. * @param value defines the object to push in the array.
  6086. */
  6087. push(value: T): void;
  6088. /**
  6089. * Pushes a value at the end of the active data.
  6090. * If the data is already present, it won t be added again
  6091. * @param value defines the object to push in the array.
  6092. * @returns true if added false if it was already present
  6093. */
  6094. pushNoDuplicate(value: T): boolean;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Concats the active data with a given array.
  6101. * This ensures no dupplicate will be present in the result.
  6102. * @param array defines the data to concatenate with.
  6103. */
  6104. concatWithNoDuplicate(array: any): void;
  6105. }
  6106. }
  6107. declare module "babylonjs/Cameras/cameraInputsManager" {
  6108. import { Nullable } from "babylonjs/types";
  6109. import { Camera } from "babylonjs/Cameras/camera";
  6110. /**
  6111. * @ignore
  6112. * This is a list of all the different input types that are available in the application.
  6113. * Fo instance: ArcRotateCameraGamepadInput...
  6114. */
  6115. export var CameraInputTypes: {};
  6116. /**
  6117. * This is the contract to implement in order to create a new input class.
  6118. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6119. */
  6120. export interface ICameraInput<TCamera extends Camera> {
  6121. /**
  6122. * Defines the camera the input is attached to.
  6123. */
  6124. camera: Nullable<TCamera>;
  6125. /**
  6126. * Gets the class name of the current intput.
  6127. * @returns the class name
  6128. */
  6129. getClassName(): string;
  6130. /**
  6131. * Get the friendly name associated with the input class.
  6132. * @returns the input friendly name
  6133. */
  6134. getSimpleName(): string;
  6135. /**
  6136. * Attach the input controls to a specific dom element to get the input from.
  6137. * @param element Defines the element the controls should be listened from
  6138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6139. */
  6140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6141. /**
  6142. * Detach the current controls from the specified dom element.
  6143. * @param element Defines the element to stop listening the inputs from
  6144. */
  6145. detachControl(element: Nullable<HTMLElement>): void;
  6146. /**
  6147. * Update the current camera state depending on the inputs that have been used this frame.
  6148. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6149. */
  6150. checkInputs?: () => void;
  6151. }
  6152. /**
  6153. * Represents a map of input types to input instance or input index to input instance.
  6154. */
  6155. export interface CameraInputsMap<TCamera extends Camera> {
  6156. /**
  6157. * Accessor to the input by input type.
  6158. */
  6159. [name: string]: ICameraInput<TCamera>;
  6160. /**
  6161. * Accessor to the input by input index.
  6162. */
  6163. [idx: number]: ICameraInput<TCamera>;
  6164. }
  6165. /**
  6166. * This represents the input manager used within a camera.
  6167. * It helps dealing with all the different kind of input attached to a camera.
  6168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6169. */
  6170. export class CameraInputsManager<TCamera extends Camera> {
  6171. /**
  6172. * Defines the list of inputs attahed to the camera.
  6173. */
  6174. attached: CameraInputsMap<TCamera>;
  6175. /**
  6176. * Defines the dom element the camera is collecting inputs from.
  6177. * This is null if the controls have not been attached.
  6178. */
  6179. attachedElement: Nullable<HTMLElement>;
  6180. /**
  6181. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6182. */
  6183. noPreventDefault: boolean;
  6184. /**
  6185. * Defined the camera the input manager belongs to.
  6186. */
  6187. camera: TCamera;
  6188. /**
  6189. * Update the current camera state depending on the inputs that have been used this frame.
  6190. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6191. */
  6192. checkInputs: () => void;
  6193. /**
  6194. * Instantiate a new Camera Input Manager.
  6195. * @param camera Defines the camera the input manager blongs to
  6196. */
  6197. constructor(camera: TCamera);
  6198. /**
  6199. * Add an input method to a camera
  6200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6201. * @param input camera input method
  6202. */
  6203. add(input: ICameraInput<TCamera>): void;
  6204. /**
  6205. * Remove a specific input method from a camera
  6206. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6207. * @param inputToRemove camera input method
  6208. */
  6209. remove(inputToRemove: ICameraInput<TCamera>): void;
  6210. /**
  6211. * Remove a specific input type from a camera
  6212. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6213. * @param inputType the type of the input to remove
  6214. */
  6215. removeByType(inputType: string): void;
  6216. private _addCheckInputs;
  6217. /**
  6218. * Attach the input controls to the currently attached dom element to listen the events from.
  6219. * @param input Defines the input to attach
  6220. */
  6221. attachInput(input: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6224. * @param element Defines the dom element to collect the events from
  6225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6226. */
  6227. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6228. /**
  6229. * Detach the current manager inputs controls from a specific dom element.
  6230. * @param element Defines the dom element to collect the events from
  6231. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6232. */
  6233. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6234. /**
  6235. * Rebuild the dynamic inputCheck function from the current list of
  6236. * defined inputs in the manager.
  6237. */
  6238. rebuildInputCheck(): void;
  6239. /**
  6240. * Remove all attached input methods from a camera
  6241. */
  6242. clear(): void;
  6243. /**
  6244. * Serialize the current input manager attached to a camera.
  6245. * This ensures than once parsed,
  6246. * the input associated to the camera will be identical to the current ones
  6247. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6248. */
  6249. serialize(serializedCamera: any): void;
  6250. /**
  6251. * Parses an input manager serialized JSON to restore the previous list of inputs
  6252. * and states associated to a camera.
  6253. * @param parsedCamera Defines the JSON to parse
  6254. */
  6255. parse(parsedCamera: any): void;
  6256. }
  6257. }
  6258. declare module "babylonjs/Meshes/buffer" {
  6259. import { Nullable, DataArray } from "babylonjs/types";
  6260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6261. /**
  6262. * Class used to store data that will be store in GPU memory
  6263. */
  6264. export class Buffer {
  6265. private _engine;
  6266. private _buffer;
  6267. /** @hidden */
  6268. _data: Nullable<DataArray>;
  6269. private _updatable;
  6270. private _instanced;
  6271. private _divisor;
  6272. /**
  6273. * Gets the byte stride.
  6274. */
  6275. readonly byteStride: number;
  6276. /**
  6277. * Constructor
  6278. * @param engine the engine
  6279. * @param data the data to use for this buffer
  6280. * @param updatable whether the data is updatable
  6281. * @param stride the stride (optional)
  6282. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6283. * @param instanced whether the buffer is instanced (optional)
  6284. * @param useBytes set to true if the stride in in bytes (optional)
  6285. * @param divisor sets an optional divisor for instances (1 by default)
  6286. */
  6287. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6288. /**
  6289. * Create a new VertexBuffer based on the current buffer
  6290. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6291. * @param offset defines offset in the buffer (0 by default)
  6292. * @param size defines the size in floats of attributes (position is 3 for instance)
  6293. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6294. * @param instanced defines if the vertex buffer contains indexed data
  6295. * @param useBytes defines if the offset and stride are in bytes *
  6296. * @param divisor sets an optional divisor for instances (1 by default)
  6297. * @returns the new vertex buffer
  6298. */
  6299. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6300. /**
  6301. * Gets a boolean indicating if the Buffer is updatable?
  6302. * @returns true if the buffer is updatable
  6303. */
  6304. isUpdatable(): boolean;
  6305. /**
  6306. * Gets current buffer's data
  6307. * @returns a DataArray or null
  6308. */
  6309. getData(): Nullable<DataArray>;
  6310. /**
  6311. * Gets underlying native buffer
  6312. * @returns underlying native buffer
  6313. */
  6314. getBuffer(): Nullable<DataBuffer>;
  6315. /**
  6316. * Gets the stride in float32 units (i.e. byte stride / 4).
  6317. * May not be an integer if the byte stride is not divisible by 4.
  6318. * @returns the stride in float32 units
  6319. * @deprecated Please use byteStride instead.
  6320. */
  6321. getStrideSize(): number;
  6322. /**
  6323. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6324. * @param data defines the data to store
  6325. */
  6326. create(data?: Nullable<DataArray>): void;
  6327. /** @hidden */
  6328. _rebuild(): void;
  6329. /**
  6330. * Update current buffer data
  6331. * @param data defines the data to store
  6332. */
  6333. update(data: DataArray): void;
  6334. /**
  6335. * Updates the data directly.
  6336. * @param data the new data
  6337. * @param offset the new offset
  6338. * @param vertexCount the vertex count (optional)
  6339. * @param useBytes set to true if the offset is in bytes
  6340. */
  6341. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6342. /**
  6343. * Release all resources
  6344. */
  6345. dispose(): void;
  6346. }
  6347. /**
  6348. * Specialized buffer used to store vertex data
  6349. */
  6350. export class VertexBuffer {
  6351. /** @hidden */
  6352. _buffer: Buffer;
  6353. private _kind;
  6354. private _size;
  6355. private _ownsBuffer;
  6356. private _instanced;
  6357. private _instanceDivisor;
  6358. /**
  6359. * The byte type.
  6360. */
  6361. static readonly BYTE: number;
  6362. /**
  6363. * The unsigned byte type.
  6364. */
  6365. static readonly UNSIGNED_BYTE: number;
  6366. /**
  6367. * The short type.
  6368. */
  6369. static readonly SHORT: number;
  6370. /**
  6371. * The unsigned short type.
  6372. */
  6373. static readonly UNSIGNED_SHORT: number;
  6374. /**
  6375. * The integer type.
  6376. */
  6377. static readonly INT: number;
  6378. /**
  6379. * The unsigned integer type.
  6380. */
  6381. static readonly UNSIGNED_INT: number;
  6382. /**
  6383. * The float type.
  6384. */
  6385. static readonly FLOAT: number;
  6386. /**
  6387. * Gets or sets the instance divisor when in instanced mode
  6388. */
  6389. instanceDivisor: number;
  6390. /**
  6391. * Gets the byte stride.
  6392. */
  6393. readonly byteStride: number;
  6394. /**
  6395. * Gets the byte offset.
  6396. */
  6397. readonly byteOffset: number;
  6398. /**
  6399. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6400. */
  6401. readonly normalized: boolean;
  6402. /**
  6403. * Gets the data type of each component in the array.
  6404. */
  6405. readonly type: number;
  6406. /**
  6407. * Constructor
  6408. * @param engine the engine
  6409. * @param data the data to use for this vertex buffer
  6410. * @param kind the vertex buffer kind
  6411. * @param updatable whether the data is updatable
  6412. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6413. * @param stride the stride (optional)
  6414. * @param instanced whether the buffer is instanced (optional)
  6415. * @param offset the offset of the data (optional)
  6416. * @param size the number of components (optional)
  6417. * @param type the type of the component (optional)
  6418. * @param normalized whether the data contains normalized data (optional)
  6419. * @param useBytes set to true if stride and offset are in bytes (optional)
  6420. * @param divisor defines the instance divisor to use (1 by default)
  6421. */
  6422. 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);
  6423. /** @hidden */
  6424. _rebuild(): void;
  6425. /**
  6426. * Returns the kind of the VertexBuffer (string)
  6427. * @returns a string
  6428. */
  6429. getKind(): string;
  6430. /**
  6431. * Gets a boolean indicating if the VertexBuffer is updatable?
  6432. * @returns true if the buffer is updatable
  6433. */
  6434. isUpdatable(): boolean;
  6435. /**
  6436. * Gets current buffer's data
  6437. * @returns a DataArray or null
  6438. */
  6439. getData(): Nullable<DataArray>;
  6440. /**
  6441. * Gets underlying native buffer
  6442. * @returns underlying native buffer
  6443. */
  6444. getBuffer(): Nullable<DataBuffer>;
  6445. /**
  6446. * Gets the stride in float32 units (i.e. byte stride / 4).
  6447. * May not be an integer if the byte stride is not divisible by 4.
  6448. * @returns the stride in float32 units
  6449. * @deprecated Please use byteStride instead.
  6450. */
  6451. getStrideSize(): number;
  6452. /**
  6453. * Returns the offset as a multiple of the type byte length.
  6454. * @returns the offset in bytes
  6455. * @deprecated Please use byteOffset instead.
  6456. */
  6457. getOffset(): number;
  6458. /**
  6459. * Returns the number of components per vertex attribute (integer)
  6460. * @returns the size in float
  6461. */
  6462. getSize(): number;
  6463. /**
  6464. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6465. * @returns true if this buffer is instanced
  6466. */
  6467. getIsInstanced(): boolean;
  6468. /**
  6469. * Returns the instancing divisor, zero for non-instanced (integer).
  6470. * @returns a number
  6471. */
  6472. getInstanceDivisor(): number;
  6473. /**
  6474. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6475. * @param data defines the data to store
  6476. */
  6477. create(data?: DataArray): void;
  6478. /**
  6479. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6480. * This function will create a new buffer if the current one is not updatable
  6481. * @param data defines the data to store
  6482. */
  6483. update(data: DataArray): void;
  6484. /**
  6485. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6486. * Returns the directly updated WebGLBuffer.
  6487. * @param data the new data
  6488. * @param offset the new offset
  6489. * @param useBytes set to true if the offset is in bytes
  6490. */
  6491. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6492. /**
  6493. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6494. */
  6495. dispose(): void;
  6496. /**
  6497. * Enumerates each value of this vertex buffer as numbers.
  6498. * @param count the number of values to enumerate
  6499. * @param callback the callback function called for each value
  6500. */
  6501. forEach(count: number, callback: (value: number, index: number) => void): void;
  6502. /**
  6503. * Positions
  6504. */
  6505. static readonly PositionKind: string;
  6506. /**
  6507. * Normals
  6508. */
  6509. static readonly NormalKind: string;
  6510. /**
  6511. * Tangents
  6512. */
  6513. static readonly TangentKind: string;
  6514. /**
  6515. * Texture coordinates
  6516. */
  6517. static readonly UVKind: string;
  6518. /**
  6519. * Texture coordinates 2
  6520. */
  6521. static readonly UV2Kind: string;
  6522. /**
  6523. * Texture coordinates 3
  6524. */
  6525. static readonly UV3Kind: string;
  6526. /**
  6527. * Texture coordinates 4
  6528. */
  6529. static readonly UV4Kind: string;
  6530. /**
  6531. * Texture coordinates 5
  6532. */
  6533. static readonly UV5Kind: string;
  6534. /**
  6535. * Texture coordinates 6
  6536. */
  6537. static readonly UV6Kind: string;
  6538. /**
  6539. * Colors
  6540. */
  6541. static readonly ColorKind: string;
  6542. /**
  6543. * Matrix indices (for bones)
  6544. */
  6545. static readonly MatricesIndicesKind: string;
  6546. /**
  6547. * Matrix weights (for bones)
  6548. */
  6549. static readonly MatricesWeightsKind: string;
  6550. /**
  6551. * Additional matrix indices (for bones)
  6552. */
  6553. static readonly MatricesIndicesExtraKind: string;
  6554. /**
  6555. * Additional matrix weights (for bones)
  6556. */
  6557. static readonly MatricesWeightsExtraKind: string;
  6558. /**
  6559. * Deduces the stride given a kind.
  6560. * @param kind The kind string to deduce
  6561. * @returns The deduced stride
  6562. */
  6563. static DeduceStride(kind: string): number;
  6564. /**
  6565. * Gets the byte length of the given type.
  6566. * @param type the type
  6567. * @returns the number of bytes
  6568. */
  6569. static GetTypeByteLength(type: number): number;
  6570. /**
  6571. * Enumerates each value of the given parameters as numbers.
  6572. * @param data the data to enumerate
  6573. * @param byteOffset the byte offset of the data
  6574. * @param byteStride the byte stride of the data
  6575. * @param componentCount the number of components per element
  6576. * @param componentType the type of the component
  6577. * @param count the number of values to enumerate
  6578. * @param normalized whether the data is normalized
  6579. * @param callback the callback function called for each value
  6580. */
  6581. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6582. private static _GetFloatValue;
  6583. }
  6584. }
  6585. declare module "babylonjs/Collisions/intersectionInfo" {
  6586. import { Nullable } from "babylonjs/types";
  6587. /**
  6588. * @hidden
  6589. */
  6590. export class IntersectionInfo {
  6591. bu: Nullable<number>;
  6592. bv: Nullable<number>;
  6593. distance: number;
  6594. faceId: number;
  6595. subMeshId: number;
  6596. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6597. }
  6598. }
  6599. declare module "babylonjs/Maths/math.plane" {
  6600. import { DeepImmutable } from "babylonjs/types";
  6601. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6602. /**
  6603. * Represens a plane by the equation ax + by + cz + d = 0
  6604. */
  6605. export class Plane {
  6606. private static _TmpMatrix;
  6607. /**
  6608. * Normal of the plane (a,b,c)
  6609. */
  6610. normal: Vector3;
  6611. /**
  6612. * d component of the plane
  6613. */
  6614. d: number;
  6615. /**
  6616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6617. * @param a a component of the plane
  6618. * @param b b component of the plane
  6619. * @param c c component of the plane
  6620. * @param d d component of the plane
  6621. */
  6622. constructor(a: number, b: number, c: number, d: number);
  6623. /**
  6624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6625. */
  6626. asArray(): number[];
  6627. /**
  6628. * @returns a new plane copied from the current Plane.
  6629. */
  6630. clone(): Plane;
  6631. /**
  6632. * @returns the string "Plane".
  6633. */
  6634. getClassName(): string;
  6635. /**
  6636. * @returns the Plane hash code.
  6637. */
  6638. getHashCode(): number;
  6639. /**
  6640. * Normalize the current Plane in place.
  6641. * @returns the updated Plane.
  6642. */
  6643. normalize(): Plane;
  6644. /**
  6645. * Applies a transformation the plane and returns the result
  6646. * @param transformation the transformation matrix to be applied to the plane
  6647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6648. */
  6649. transform(transformation: DeepImmutable<Matrix>): Plane;
  6650. /**
  6651. * Calcualtte the dot product between the point and the plane normal
  6652. * @param point point to calculate the dot product with
  6653. * @returns the dot product (float) of the point coordinates and the plane normal.
  6654. */
  6655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6656. /**
  6657. * Updates the current Plane from the plane defined by the three given points.
  6658. * @param point1 one of the points used to contruct the plane
  6659. * @param point2 one of the points used to contruct the plane
  6660. * @param point3 one of the points used to contruct the plane
  6661. * @returns the updated Plane.
  6662. */
  6663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6664. /**
  6665. * Checks if the plane is facing a given direction
  6666. * @param direction the direction to check if the plane is facing
  6667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6668. * @returns True is the vector "direction" is the same side than the plane normal.
  6669. */
  6670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6671. /**
  6672. * Calculates the distance to a point
  6673. * @param point point to calculate distance to
  6674. * @returns the signed distance (float) from the given point to the Plane.
  6675. */
  6676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6677. /**
  6678. * Creates a plane from an array
  6679. * @param array the array to create a plane from
  6680. * @returns a new Plane from the given array.
  6681. */
  6682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6683. /**
  6684. * Creates a plane from three points
  6685. * @param point1 point used to create the plane
  6686. * @param point2 point used to create the plane
  6687. * @param point3 point used to create the plane
  6688. * @returns a new Plane defined by the three given points.
  6689. */
  6690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6691. /**
  6692. * Creates a plane from an origin point and a normal
  6693. * @param origin origin of the plane to be constructed
  6694. * @param normal normal of the plane to be constructed
  6695. * @returns a new Plane the normal vector to this plane at the given origin point.
  6696. * Note : the vector "normal" is updated because normalized.
  6697. */
  6698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6699. /**
  6700. * Calculates the distance from a plane and a point
  6701. * @param origin origin of the plane to be constructed
  6702. * @param normal normal of the plane to be constructed
  6703. * @param point point to calculate distance to
  6704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6705. */
  6706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6707. }
  6708. }
  6709. declare module "babylonjs/Culling/boundingSphere" {
  6710. import { DeepImmutable } from "babylonjs/types";
  6711. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6712. import { Plane } from "babylonjs/Maths/math.plane";
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module "babylonjs/Culling/boundingBox" {
  6799. import { DeepImmutable } from "babylonjs/types";
  6800. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6801. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6802. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6803. import { Plane } from "babylonjs/Maths/math.plane";
  6804. /**
  6805. * Class used to store bounding box information
  6806. */
  6807. export class BoundingBox implements ICullable {
  6808. /**
  6809. * Gets the 8 vectors representing the bounding box in local space
  6810. */
  6811. readonly vectors: Vector3[];
  6812. /**
  6813. * Gets the center of the bounding box in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Gets the center of the bounding box in world space
  6818. */
  6819. readonly centerWorld: Vector3;
  6820. /**
  6821. * Gets the extend size in local space
  6822. */
  6823. readonly extendSize: Vector3;
  6824. /**
  6825. * Gets the extend size in world space
  6826. */
  6827. readonly extendSizeWorld: Vector3;
  6828. /**
  6829. * Gets the OBB (object bounding box) directions
  6830. */
  6831. readonly directions: Vector3[];
  6832. /**
  6833. * Gets the 8 vectors representing the bounding box in world space
  6834. */
  6835. readonly vectorsWorld: Vector3[];
  6836. /**
  6837. * Gets the minimum vector in world space
  6838. */
  6839. readonly minimumWorld: Vector3;
  6840. /**
  6841. * Gets the maximum vector in world space
  6842. */
  6843. readonly maximumWorld: Vector3;
  6844. /**
  6845. * Gets the minimum vector in local space
  6846. */
  6847. readonly minimum: Vector3;
  6848. /**
  6849. * Gets the maximum vector in local space
  6850. */
  6851. readonly maximum: Vector3;
  6852. private _worldMatrix;
  6853. private static readonly TmpVector3;
  6854. /**
  6855. * @hidden
  6856. */
  6857. _tag: number;
  6858. /**
  6859. * Creates a new bounding box
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding box by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingBox;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(world: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding box is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding box is entirely inside the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an inclusion
  6895. */
  6896. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if a point is inside the bounding box
  6899. * @param point defines the point to test
  6900. * @returns true if the point is inside the bounding box
  6901. */
  6902. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6903. /**
  6904. * Tests if the bounding box intersects with a bounding sphere
  6905. * @param sphere defines the sphere to test
  6906. * @returns true if there is an intersection
  6907. */
  6908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6911. * @param min defines the min vector to use
  6912. * @param max defines the max vector to use
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6916. /**
  6917. * Tests if two bounding boxes are intersections
  6918. * @param box0 defines the first box to test
  6919. * @param box1 defines the second box to test
  6920. * @returns true if there is an intersection
  6921. */
  6922. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6923. /**
  6924. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6925. * @param minPoint defines the minimum vector of the bounding box
  6926. * @param maxPoint defines the maximum vector of the bounding box
  6927. * @param sphereCenter defines the sphere center
  6928. * @param sphereRadius defines the sphere radius
  6929. * @returns true if there is an intersection
  6930. */
  6931. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6932. /**
  6933. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6934. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @return true if there is an inclusion
  6937. */
  6938. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an intersection
  6944. */
  6945. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. }
  6947. }
  6948. declare module "babylonjs/Collisions/collider" {
  6949. import { Nullable, IndicesArray } from "babylonjs/types";
  6950. import { Vector3 } from "babylonjs/Maths/math.vector";
  6951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6952. import { Plane } from "babylonjs/Maths/math.plane";
  6953. /** @hidden */
  6954. export class Collider {
  6955. /** Define if a collision was found */
  6956. collisionFound: boolean;
  6957. /**
  6958. * Define last intersection point in local space
  6959. */
  6960. intersectionPoint: Vector3;
  6961. /**
  6962. * Define last collided mesh
  6963. */
  6964. collidedMesh: Nullable<AbstractMesh>;
  6965. private _collisionPoint;
  6966. private _planeIntersectionPoint;
  6967. private _tempVector;
  6968. private _tempVector2;
  6969. private _tempVector3;
  6970. private _tempVector4;
  6971. private _edge;
  6972. private _baseToVertex;
  6973. private _destinationPoint;
  6974. private _slidePlaneNormal;
  6975. private _displacementVector;
  6976. /** @hidden */
  6977. _radius: Vector3;
  6978. /** @hidden */
  6979. _retry: number;
  6980. private _velocity;
  6981. private _basePoint;
  6982. private _epsilon;
  6983. /** @hidden */
  6984. _velocityWorldLength: number;
  6985. /** @hidden */
  6986. _basePointWorld: Vector3;
  6987. private _velocityWorld;
  6988. private _normalizedVelocity;
  6989. /** @hidden */
  6990. _initialVelocity: Vector3;
  6991. /** @hidden */
  6992. _initialPosition: Vector3;
  6993. private _nearestDistance;
  6994. private _collisionMask;
  6995. collisionMask: number;
  6996. /**
  6997. * Gets the plane normal used to compute the sliding response (in local space)
  6998. */
  6999. readonly slidePlaneNormal: Vector3;
  7000. /** @hidden */
  7001. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7002. /** @hidden */
  7003. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7004. /** @hidden */
  7005. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7006. /** @hidden */
  7007. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7008. /** @hidden */
  7009. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _getResponse(pos: Vector3, vel: Vector3): void;
  7012. }
  7013. }
  7014. declare module "babylonjs/Culling/boundingInfo" {
  7015. import { DeepImmutable } from "babylonjs/types";
  7016. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7017. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7018. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7019. import { Plane } from "babylonjs/Maths/math.plane";
  7020. import { Collider } from "babylonjs/Collisions/collider";
  7021. /**
  7022. * Interface for cullable objects
  7023. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7024. */
  7025. export interface ICullable {
  7026. /**
  7027. * Checks if the object or part of the object is in the frustum
  7028. * @param frustumPlanes Camera near/planes
  7029. * @returns true if the object is in frustum otherwise false
  7030. */
  7031. isInFrustum(frustumPlanes: Plane[]): boolean;
  7032. /**
  7033. * Checks if a cullable object (mesh...) is in the camera frustum
  7034. * Unlike isInFrustum this cheks the full bounding box
  7035. * @param frustumPlanes Camera near/planes
  7036. * @returns true if the object is in frustum otherwise false
  7037. */
  7038. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7039. }
  7040. /**
  7041. * Info for a bounding data of a mesh
  7042. */
  7043. export class BoundingInfo implements ICullable {
  7044. /**
  7045. * Bounding box for the mesh
  7046. */
  7047. readonly boundingBox: BoundingBox;
  7048. /**
  7049. * Bounding sphere for the mesh
  7050. */
  7051. readonly boundingSphere: BoundingSphere;
  7052. private _isLocked;
  7053. private static readonly TmpVector3;
  7054. /**
  7055. * Constructs bounding info
  7056. * @param minimum min vector of the bounding box/sphere
  7057. * @param maximum max vector of the bounding box/sphere
  7058. * @param worldMatrix defines the new world matrix
  7059. */
  7060. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7061. /**
  7062. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7063. * @param min defines the new minimum vector (in local space)
  7064. * @param max defines the new maximum vector (in local space)
  7065. * @param worldMatrix defines the new world matrix
  7066. */
  7067. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7068. /**
  7069. * min vector of the bounding box/sphere
  7070. */
  7071. readonly minimum: Vector3;
  7072. /**
  7073. * max vector of the bounding box/sphere
  7074. */
  7075. readonly maximum: Vector3;
  7076. /**
  7077. * If the info is locked and won't be updated to avoid perf overhead
  7078. */
  7079. isLocked: boolean;
  7080. /**
  7081. * Updates the bounding sphere and box
  7082. * @param world world matrix to be used to update
  7083. */
  7084. update(world: DeepImmutable<Matrix>): void;
  7085. /**
  7086. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7087. * @param center New center of the bounding info
  7088. * @param extend New extend of the bounding info
  7089. * @returns the current bounding info
  7090. */
  7091. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7092. /**
  7093. * Scale the current bounding info by applying a scale factor
  7094. * @param factor defines the scale factor to apply
  7095. * @returns the current bounding info
  7096. */
  7097. scale(factor: number): BoundingInfo;
  7098. /**
  7099. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7100. * @param frustumPlanes defines the frustum to test
  7101. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7102. * @returns true if the bounding info is in the frustum planes
  7103. */
  7104. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7105. /**
  7106. * Gets the world distance between the min and max points of the bounding box
  7107. */
  7108. readonly diagonalLength: number;
  7109. /**
  7110. * Checks if a cullable object (mesh...) is in the camera frustum
  7111. * Unlike isInFrustum this cheks the full bounding box
  7112. * @param frustumPlanes Camera near/planes
  7113. * @returns true if the object is in frustum otherwise false
  7114. */
  7115. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. /** @hidden */
  7117. _checkCollision(collider: Collider): boolean;
  7118. /**
  7119. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7120. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7121. * @param point the point to check intersection with
  7122. * @returns if the point intersects
  7123. */
  7124. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7127. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7128. * @param boundingInfo the bounding info to check intersection with
  7129. * @param precise if the intersection should be done using OBB
  7130. * @returns if the bounding info intersects
  7131. */
  7132. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7133. }
  7134. }
  7135. declare module "babylonjs/Maths/math.functions" {
  7136. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7137. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7138. /**
  7139. * Extracts minimum and maximum values from a list of indexed positions
  7140. * @param positions defines the positions to use
  7141. * @param indices defines the indices to the positions
  7142. * @param indexStart defines the start index
  7143. * @param indexCount defines the end index
  7144. * @param bias defines bias value to add to the result
  7145. * @return minimum and maximum values
  7146. */
  7147. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7148. minimum: Vector3;
  7149. maximum: Vector3;
  7150. };
  7151. /**
  7152. * Extracts minimum and maximum values from a list of positions
  7153. * @param positions defines the positions to use
  7154. * @param start defines the start index in the positions array
  7155. * @param count defines the number of positions to handle
  7156. * @param bias defines bias value to add to the result
  7157. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7158. * @return minimum and maximum values
  7159. */
  7160. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7161. minimum: Vector3;
  7162. maximum: Vector3;
  7163. };
  7164. }
  7165. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7166. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7167. /** @hidden */
  7168. export class WebGLDataBuffer extends DataBuffer {
  7169. private _buffer;
  7170. constructor(resource: WebGLBuffer);
  7171. readonly underlyingResource: any;
  7172. }
  7173. }
  7174. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7175. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7176. import { Nullable } from "babylonjs/types";
  7177. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7178. /** @hidden */
  7179. export class WebGLPipelineContext implements IPipelineContext {
  7180. engine: ThinEngine;
  7181. program: Nullable<WebGLProgram>;
  7182. context?: WebGLRenderingContext;
  7183. vertexShader?: WebGLShader;
  7184. fragmentShader?: WebGLShader;
  7185. isParallelCompiled: boolean;
  7186. onCompiled?: () => void;
  7187. transformFeedback?: WebGLTransformFeedback | null;
  7188. readonly isAsync: boolean;
  7189. readonly isReady: boolean;
  7190. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7191. }
  7192. }
  7193. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7194. import { FloatArray, Nullable } from "babylonjs/types";
  7195. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7196. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7197. module "babylonjs/Engines/thinEngine" {
  7198. interface ThinEngine {
  7199. /**
  7200. * Create an uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Create a dynamic uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param elements defines the content of the uniform buffer
  7210. * @returns the webGL uniform buffer
  7211. */
  7212. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7213. /**
  7214. * Update an existing uniform buffer
  7215. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7216. * @param uniformBuffer defines the target uniform buffer
  7217. * @param elements defines the content to update
  7218. * @param offset defines the offset in the uniform buffer where update should start
  7219. * @param count defines the size of the data to update
  7220. */
  7221. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7222. /**
  7223. * Bind an uniform buffer to the current webGL context
  7224. * @param buffer defines the buffer to bind
  7225. */
  7226. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7227. /**
  7228. * Bind a buffer to the current webGL context at a given location
  7229. * @param buffer defines the buffer to bind
  7230. * @param location defines the index where to bind the buffer
  7231. */
  7232. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7233. /**
  7234. * Bind a specific block at a given index in a specific shader program
  7235. * @param pipelineContext defines the pipeline context to use
  7236. * @param blockName defines the block name
  7237. * @param index defines the index where to bind the block
  7238. */
  7239. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7240. }
  7241. }
  7242. }
  7243. declare module "babylonjs/Materials/uniformBuffer" {
  7244. import { Nullable, FloatArray } from "babylonjs/types";
  7245. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7246. import { Engine } from "babylonjs/Engines/engine";
  7247. import { Effect } from "babylonjs/Materials/effect";
  7248. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7249. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7250. import { Color3 } from "babylonjs/Maths/math.color";
  7251. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. readonly useUbo: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. readonly isSync: boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/iInspectable" {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module "babylonjs/Misc/timingTools" {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module "babylonjs/Misc/instantiationTools" {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7626. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7627. import { Nullable } from "babylonjs/types";
  7628. import { Scene } from "babylonjs/scene";
  7629. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7630. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7631. module "babylonjs/Engines/thinEngine" {
  7632. interface ThinEngine {
  7633. /**
  7634. * Creates a depth stencil cube texture.
  7635. * This is only available in WebGL 2.
  7636. * @param size The size of face edge in the cube texture.
  7637. * @param options The options defining the cube texture.
  7638. * @returns The cube texture
  7639. */
  7640. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7641. /**
  7642. * Creates a cube texture
  7643. * @param rootUrl defines the url where the files to load is located
  7644. * @param scene defines the current scene
  7645. * @param files defines the list of files to load (1 per face)
  7646. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7647. * @param onLoad defines an optional callback raised when the texture is loaded
  7648. * @param onError defines an optional callback raised if there is an issue to load the texture
  7649. * @param format defines the format of the data
  7650. * @param forcedExtension defines the extension to use to pick the right loader
  7651. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7654. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7655. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7656. * @returns the cube texture as an InternalTexture
  7657. */
  7658. 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;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @returns the cube texture as an InternalTexture
  7670. */
  7671. 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;
  7672. /**
  7673. * Creates a cube texture
  7674. * @param rootUrl defines the url where the files to load is located
  7675. * @param scene defines the current scene
  7676. * @param files defines the list of files to load (1 per face)
  7677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7678. * @param onLoad defines an optional callback raised when the texture is loaded
  7679. * @param onError defines an optional callback raised if there is an issue to load the texture
  7680. * @param format defines the format of the data
  7681. * @param forcedExtension defines the extension to use to pick the right loader
  7682. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7685. * @returns the cube texture as an InternalTexture
  7686. */
  7687. 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;
  7688. /** @hidden */
  7689. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7690. /** @hidden */
  7691. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7692. /** @hidden */
  7693. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7694. /** @hidden */
  7695. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7696. /**
  7697. * @hidden
  7698. */
  7699. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7700. }
  7701. }
  7702. }
  7703. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7704. import { Nullable } from "babylonjs/types";
  7705. import { Scene } from "babylonjs/scene";
  7706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7708. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7709. /**
  7710. * Class for creating a cube texture
  7711. */
  7712. export class CubeTexture extends BaseTexture {
  7713. private _delayedOnLoad;
  7714. /**
  7715. * The url of the texture
  7716. */
  7717. url: string;
  7718. /**
  7719. * Gets or sets the center of the bounding box associated with the cube texture.
  7720. * It must define where the camera used to render the texture was set
  7721. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7722. */
  7723. boundingBoxPosition: Vector3;
  7724. private _boundingBoxSize;
  7725. /**
  7726. * Gets or sets the size of the bounding box associated with the cube texture
  7727. * When defined, the cubemap will switch to local mode
  7728. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7729. * @example https://www.babylonjs-playground.com/#RNASML
  7730. */
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. boundingBoxSize: Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. /**
  7741. * Gets texture matrix rotation angle around Y axis radians.
  7742. */
  7743. rotationY: number;
  7744. /**
  7745. * Are mip maps generated for this texture or not.
  7746. */
  7747. readonly noMipmap: boolean;
  7748. private _noMipmap;
  7749. private _files;
  7750. protected _forcedExtension: Nullable<string>;
  7751. private _extensions;
  7752. private _textureMatrix;
  7753. private _format;
  7754. private _createPolynomials;
  7755. /** @hidden */
  7756. _prefiltered: boolean;
  7757. /**
  7758. * Creates a cube texture from an array of image urls
  7759. * @param files defines an array of image urls
  7760. * @param scene defines the hosting scene
  7761. * @param noMipmap specifies if mip maps are not used
  7762. * @returns a cube texture
  7763. */
  7764. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7765. /**
  7766. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7767. * @param url defines the url of the prefiltered texture
  7768. * @param scene defines the scene the texture is attached to
  7769. * @param forcedExtension defines the extension of the file if different from the url
  7770. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7771. * @return the prefiltered texture
  7772. */
  7773. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7774. /**
  7775. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7776. * as prefiltered data.
  7777. * @param rootUrl defines the url of the texture or the root name of the six images
  7778. * @param scene defines the scene the texture is attached to
  7779. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7780. * @param noMipmap defines if mipmaps should be created or not
  7781. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7782. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7783. * @param onError defines a callback triggered in case of error during load
  7784. * @param format defines the internal format to use for the texture once loaded
  7785. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7786. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7787. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7788. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7789. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7790. * @return the cube texture
  7791. */
  7792. 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);
  7793. /**
  7794. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7795. */
  7796. readonly isPrefiltered: boolean;
  7797. /**
  7798. * Get the current class name of the texture useful for serialization or dynamic coding.
  7799. * @returns "CubeTexture"
  7800. */
  7801. getClassName(): string;
  7802. /**
  7803. * Update the url (and optional buffer) of this texture if url was null during construction.
  7804. * @param url the url of the texture
  7805. * @param forcedExtension defines the extension to use
  7806. * @param onLoad callback called when the texture is loaded (defaults to null)
  7807. */
  7808. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7809. /**
  7810. * Delays loading of the cube texture
  7811. * @param forcedExtension defines the extension to use
  7812. */
  7813. delayLoad(forcedExtension?: string): void;
  7814. /**
  7815. * Returns the reflection texture matrix
  7816. * @returns the reflection texture matrix
  7817. */
  7818. getReflectionTextureMatrix(): Matrix;
  7819. /**
  7820. * Sets the reflection texture matrix
  7821. * @param value Reflection texture matrix
  7822. */
  7823. setReflectionTextureMatrix(value: Matrix): void;
  7824. /**
  7825. * Parses text to create a cube texture
  7826. * @param parsedTexture define the serialized text to read from
  7827. * @param scene defines the hosting scene
  7828. * @param rootUrl defines the root url of the cube texture
  7829. * @returns a cube texture
  7830. */
  7831. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7832. /**
  7833. * Makes a clone, or deep copy, of the cube texture
  7834. * @returns a new cube texture
  7835. */
  7836. clone(): CubeTexture;
  7837. }
  7838. }
  7839. declare module "babylonjs/Materials/materialDefines" {
  7840. /**
  7841. * Manages the defines for the Material
  7842. */
  7843. export class MaterialDefines {
  7844. /** @hidden */
  7845. protected _keys: string[];
  7846. private _isDirty;
  7847. /** @hidden */
  7848. _renderId: number;
  7849. /** @hidden */
  7850. _areLightsDirty: boolean;
  7851. /** @hidden */
  7852. _areLightsDisposed: boolean;
  7853. /** @hidden */
  7854. _areAttributesDirty: boolean;
  7855. /** @hidden */
  7856. _areTexturesDirty: boolean;
  7857. /** @hidden */
  7858. _areFresnelDirty: boolean;
  7859. /** @hidden */
  7860. _areMiscDirty: boolean;
  7861. /** @hidden */
  7862. _areImageProcessingDirty: boolean;
  7863. /** @hidden */
  7864. _normals: boolean;
  7865. /** @hidden */
  7866. _uvs: boolean;
  7867. /** @hidden */
  7868. _needNormals: boolean;
  7869. /** @hidden */
  7870. _needUVs: boolean;
  7871. [id: string]: any;
  7872. /**
  7873. * Specifies if the material needs to be re-calculated
  7874. */
  7875. readonly isDirty: boolean;
  7876. /**
  7877. * Marks the material to indicate that it has been re-calculated
  7878. */
  7879. markAsProcessed(): void;
  7880. /**
  7881. * Marks the material to indicate that it needs to be re-calculated
  7882. */
  7883. markAsUnprocessed(): void;
  7884. /**
  7885. * Marks the material to indicate all of its defines need to be re-calculated
  7886. */
  7887. markAllAsDirty(): void;
  7888. /**
  7889. * Marks the material to indicate that image processing needs to be re-calculated
  7890. */
  7891. markAsImageProcessingDirty(): void;
  7892. /**
  7893. * Marks the material to indicate the lights need to be re-calculated
  7894. * @param disposed Defines whether the light is dirty due to dispose or not
  7895. */
  7896. markAsLightDirty(disposed?: boolean): void;
  7897. /**
  7898. * Marks the attribute state as changed
  7899. */
  7900. markAsAttributesDirty(): void;
  7901. /**
  7902. * Marks the texture state as changed
  7903. */
  7904. markAsTexturesDirty(): void;
  7905. /**
  7906. * Marks the fresnel state as changed
  7907. */
  7908. markAsFresnelDirty(): void;
  7909. /**
  7910. * Marks the misc state as changed
  7911. */
  7912. markAsMiscDirty(): void;
  7913. /**
  7914. * Rebuilds the material defines
  7915. */
  7916. rebuild(): void;
  7917. /**
  7918. * Specifies if two material defines are equal
  7919. * @param other - A material define instance to compare to
  7920. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7921. */
  7922. isEqual(other: MaterialDefines): boolean;
  7923. /**
  7924. * Clones this instance's defines to another instance
  7925. * @param other - material defines to clone values to
  7926. */
  7927. cloneTo(other: MaterialDefines): void;
  7928. /**
  7929. * Resets the material define values
  7930. */
  7931. reset(): void;
  7932. /**
  7933. * Converts the material define values to a string
  7934. * @returns - String of material define information
  7935. */
  7936. toString(): string;
  7937. }
  7938. }
  7939. declare module "babylonjs/Materials/colorCurves" {
  7940. import { Effect } from "babylonjs/Materials/effect";
  7941. /**
  7942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7944. * 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;
  7945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7946. */
  7947. export class ColorCurves {
  7948. private _dirty;
  7949. private _tempColor;
  7950. private _globalCurve;
  7951. private _highlightsCurve;
  7952. private _midtonesCurve;
  7953. private _shadowsCurve;
  7954. private _positiveCurve;
  7955. private _negativeCurve;
  7956. private _globalHue;
  7957. private _globalDensity;
  7958. private _globalSaturation;
  7959. private _globalExposure;
  7960. /**
  7961. * Gets the global Hue value.
  7962. * 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).
  7963. */
  7964. /**
  7965. * Sets the global Hue value.
  7966. * 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).
  7967. */
  7968. globalHue: number;
  7969. /**
  7970. * Gets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. /**
  7975. * Sets the global Density value.
  7976. * 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.
  7977. * Values less than zero provide a filter of opposite hue.
  7978. */
  7979. globalDensity: number;
  7980. /**
  7981. * Gets the global Saturation value.
  7982. * 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.
  7983. */
  7984. /**
  7985. * Sets the global Saturation value.
  7986. * 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.
  7987. */
  7988. globalSaturation: number;
  7989. /**
  7990. * Gets the global Exposure value.
  7991. * 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.
  7992. */
  7993. /**
  7994. * Sets the global Exposure value.
  7995. * 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.
  7996. */
  7997. globalExposure: number;
  7998. private _highlightsHue;
  7999. private _highlightsDensity;
  8000. private _highlightsSaturation;
  8001. private _highlightsExposure;
  8002. /**
  8003. * Gets the highlights Hue value.
  8004. * 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).
  8005. */
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. highlightsHue: number;
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. /**
  8017. * Sets the highlights Density value.
  8018. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. highlightsDensity: number;
  8022. /**
  8023. * Gets the highlights Saturation value.
  8024. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8025. */
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * 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.
  8029. */
  8030. highlightsSaturation: number;
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * 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.
  8034. */
  8035. /**
  8036. * Sets the highlights Exposure value.
  8037. * 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.
  8038. */
  8039. highlightsExposure: number;
  8040. private _midtonesHue;
  8041. private _midtonesDensity;
  8042. private _midtonesSaturation;
  8043. private _midtonesExposure;
  8044. /**
  8045. * Gets the midtones Hue value.
  8046. * 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).
  8047. */
  8048. /**
  8049. * Sets the midtones Hue value.
  8050. * 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).
  8051. */
  8052. midtonesHue: number;
  8053. /**
  8054. * Gets the midtones Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. /**
  8059. * Sets the midtones Density value.
  8060. * 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.
  8061. * Values less than zero provide a filter of opposite hue.
  8062. */
  8063. midtonesDensity: number;
  8064. /**
  8065. * Gets the midtones Saturation value.
  8066. * 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.
  8067. */
  8068. /**
  8069. * Sets the midtones Saturation value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8071. */
  8072. midtonesSaturation: number;
  8073. /**
  8074. * Gets the midtones Exposure value.
  8075. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8076. */
  8077. /**
  8078. * Sets the midtones Exposure value.
  8079. * 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.
  8080. */
  8081. midtonesExposure: number;
  8082. private _shadowsHue;
  8083. private _shadowsDensity;
  8084. private _shadowsSaturation;
  8085. private _shadowsExposure;
  8086. /**
  8087. * Gets the shadows Hue value.
  8088. * 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).
  8089. */
  8090. /**
  8091. * Sets the shadows Hue value.
  8092. * 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).
  8093. */
  8094. shadowsHue: number;
  8095. /**
  8096. * Gets the shadows Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. /**
  8101. * Sets the shadows Density value.
  8102. * 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.
  8103. * Values less than zero provide a filter of opposite hue.
  8104. */
  8105. shadowsDensity: number;
  8106. /**
  8107. * Gets the shadows Saturation value.
  8108. * 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.
  8109. */
  8110. /**
  8111. * Sets the shadows Saturation value.
  8112. * 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.
  8113. */
  8114. shadowsSaturation: number;
  8115. /**
  8116. * Gets the shadows Exposure value.
  8117. * 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.
  8118. */
  8119. /**
  8120. * Sets the shadows Exposure value.
  8121. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8122. */
  8123. shadowsExposure: number;
  8124. /**
  8125. * Returns the class name
  8126. * @returns The class name
  8127. */
  8128. getClassName(): string;
  8129. /**
  8130. * Binds the color curves to the shader.
  8131. * @param colorCurves The color curve to bind
  8132. * @param effect The effect to bind to
  8133. * @param positiveUniform The positive uniform shader parameter
  8134. * @param neutralUniform The neutral uniform shader parameter
  8135. * @param negativeUniform The negative uniform shader parameter
  8136. */
  8137. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8138. /**
  8139. * Prepare the list of uniforms associated with the ColorCurves effects.
  8140. * @param uniformsList The list of uniforms used in the effect
  8141. */
  8142. static PrepareUniforms(uniformsList: string[]): void;
  8143. /**
  8144. * Returns color grading data based on a hue, density, saturation and exposure value.
  8145. * @param filterHue The hue of the color filter.
  8146. * @param filterDensity The density of the color filter.
  8147. * @param saturation The saturation.
  8148. * @param exposure The exposure.
  8149. * @param result The result data container.
  8150. */
  8151. private getColorGradingDataToRef;
  8152. /**
  8153. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8154. * @param value The input slider value in range [-100,100].
  8155. * @returns Adjusted value.
  8156. */
  8157. private static applyColorGradingSliderNonlinear;
  8158. /**
  8159. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8160. * @param hue The hue (H) input.
  8161. * @param saturation The saturation (S) input.
  8162. * @param brightness The brightness (B) input.
  8163. * @result An RGBA color represented as Vector4.
  8164. */
  8165. private static fromHSBToRef;
  8166. /**
  8167. * Returns a value clamped between min and max
  8168. * @param value The value to clamp
  8169. * @param min The minimum of value
  8170. * @param max The maximum of value
  8171. * @returns The clamped value.
  8172. */
  8173. private static clamp;
  8174. /**
  8175. * Clones the current color curve instance.
  8176. * @return The cloned curves
  8177. */
  8178. clone(): ColorCurves;
  8179. /**
  8180. * Serializes the current color curve instance to a json representation.
  8181. * @return a JSON representation
  8182. */
  8183. serialize(): any;
  8184. /**
  8185. * Parses the color curve from a json representation.
  8186. * @param source the JSON source to parse
  8187. * @return The parsed curves
  8188. */
  8189. static Parse(source: any): ColorCurves;
  8190. }
  8191. }
  8192. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8193. import { Observable } from "babylonjs/Misc/observable";
  8194. import { Nullable } from "babylonjs/types";
  8195. import { Color4 } from "babylonjs/Maths/math.color";
  8196. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8197. import { Effect } from "babylonjs/Materials/effect";
  8198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8199. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8200. /**
  8201. * Interface to follow in your material defines to integrate easily the
  8202. * Image proccessing functions.
  8203. * @hidden
  8204. */
  8205. export interface IImageProcessingConfigurationDefines {
  8206. IMAGEPROCESSING: boolean;
  8207. VIGNETTE: boolean;
  8208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8209. VIGNETTEBLENDMODEOPAQUE: boolean;
  8210. TONEMAPPING: boolean;
  8211. TONEMAPPING_ACES: boolean;
  8212. CONTRAST: boolean;
  8213. EXPOSURE: boolean;
  8214. COLORCURVES: boolean;
  8215. COLORGRADING: boolean;
  8216. COLORGRADING3D: boolean;
  8217. SAMPLER3DGREENDEPTH: boolean;
  8218. SAMPLER3DBGRMAP: boolean;
  8219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8220. }
  8221. /**
  8222. * @hidden
  8223. */
  8224. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8225. IMAGEPROCESSING: boolean;
  8226. VIGNETTE: boolean;
  8227. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8228. VIGNETTEBLENDMODEOPAQUE: boolean;
  8229. TONEMAPPING: boolean;
  8230. TONEMAPPING_ACES: boolean;
  8231. CONTRAST: boolean;
  8232. COLORCURVES: boolean;
  8233. COLORGRADING: boolean;
  8234. COLORGRADING3D: boolean;
  8235. SAMPLER3DGREENDEPTH: boolean;
  8236. SAMPLER3DBGRMAP: boolean;
  8237. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8238. EXPOSURE: boolean;
  8239. constructor();
  8240. }
  8241. /**
  8242. * This groups together the common properties used for image processing either in direct forward pass
  8243. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8244. * or not.
  8245. */
  8246. export class ImageProcessingConfiguration {
  8247. /**
  8248. * Default tone mapping applied in BabylonJS.
  8249. */
  8250. static readonly TONEMAPPING_STANDARD: number;
  8251. /**
  8252. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8253. * to other engines rendering to increase portability.
  8254. */
  8255. static readonly TONEMAPPING_ACES: number;
  8256. /**
  8257. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8258. */
  8259. colorCurves: Nullable<ColorCurves>;
  8260. private _colorCurvesEnabled;
  8261. /**
  8262. * Gets wether the color curves effect is enabled.
  8263. */
  8264. /**
  8265. * Sets wether the color curves effect is enabled.
  8266. */
  8267. colorCurvesEnabled: boolean;
  8268. private _colorGradingTexture;
  8269. /**
  8270. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8271. */
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. colorGradingTexture: Nullable<BaseTexture>;
  8276. private _colorGradingEnabled;
  8277. /**
  8278. * Gets wether the color grading effect is enabled.
  8279. */
  8280. /**
  8281. * Sets wether the color grading effect is enabled.
  8282. */
  8283. colorGradingEnabled: boolean;
  8284. private _colorGradingWithGreenDepth;
  8285. /**
  8286. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8287. */
  8288. /**
  8289. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8290. */
  8291. colorGradingWithGreenDepth: boolean;
  8292. private _colorGradingBGR;
  8293. /**
  8294. * Gets wether the color grading texture contains BGR values.
  8295. */
  8296. /**
  8297. * Sets wether the color grading texture contains BGR values.
  8298. */
  8299. colorGradingBGR: boolean;
  8300. /** @hidden */
  8301. _exposure: number;
  8302. /**
  8303. * Gets the Exposure used in the effect.
  8304. */
  8305. /**
  8306. * Sets the Exposure used in the effect.
  8307. */
  8308. exposure: number;
  8309. private _toneMappingEnabled;
  8310. /**
  8311. * Gets wether the tone mapping effect is enabled.
  8312. */
  8313. /**
  8314. * Sets wether the tone mapping effect is enabled.
  8315. */
  8316. toneMappingEnabled: boolean;
  8317. private _toneMappingType;
  8318. /**
  8319. * Gets the type of tone mapping effect.
  8320. */
  8321. /**
  8322. * Sets the type of tone mapping effect used in BabylonJS.
  8323. */
  8324. toneMappingType: number;
  8325. protected _contrast: number;
  8326. /**
  8327. * Gets the contrast used in the effect.
  8328. */
  8329. /**
  8330. * Sets the contrast used in the effect.
  8331. */
  8332. contrast: number;
  8333. /**
  8334. * Vignette stretch size.
  8335. */
  8336. vignetteStretch: number;
  8337. /**
  8338. * Vignette centre X Offset.
  8339. */
  8340. vignetteCentreX: number;
  8341. /**
  8342. * Vignette centre Y Offset.
  8343. */
  8344. vignetteCentreY: number;
  8345. /**
  8346. * Vignette weight or intensity of the vignette effect.
  8347. */
  8348. vignetteWeight: number;
  8349. /**
  8350. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8351. * if vignetteEnabled is set to true.
  8352. */
  8353. vignetteColor: Color4;
  8354. /**
  8355. * Camera field of view used by the Vignette effect.
  8356. */
  8357. vignetteCameraFov: number;
  8358. private _vignetteBlendMode;
  8359. /**
  8360. * Gets the vignette blend mode allowing different kind of effect.
  8361. */
  8362. /**
  8363. * Sets the vignette blend mode allowing different kind of effect.
  8364. */
  8365. vignetteBlendMode: number;
  8366. private _vignetteEnabled;
  8367. /**
  8368. * Gets wether the vignette effect is enabled.
  8369. */
  8370. /**
  8371. * Sets wether the vignette effect is enabled.
  8372. */
  8373. vignetteEnabled: boolean;
  8374. private _applyByPostProcess;
  8375. /**
  8376. * Gets wether the image processing is applied through a post process or not.
  8377. */
  8378. /**
  8379. * Sets wether the image processing is applied through a post process or not.
  8380. */
  8381. applyByPostProcess: boolean;
  8382. private _isEnabled;
  8383. /**
  8384. * Gets wether the image processing is enabled or not.
  8385. */
  8386. /**
  8387. * Sets wether the image processing is enabled or not.
  8388. */
  8389. isEnabled: boolean;
  8390. /**
  8391. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8392. */
  8393. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8394. /**
  8395. * Method called each time the image processing information changes requires to recompile the effect.
  8396. */
  8397. protected _updateParameters(): void;
  8398. /**
  8399. * Gets the current class name.
  8400. * @return "ImageProcessingConfiguration"
  8401. */
  8402. getClassName(): string;
  8403. /**
  8404. * Prepare the list of uniforms associated with the Image Processing effects.
  8405. * @param uniforms The list of uniforms used in the effect
  8406. * @param defines the list of defines currently in use
  8407. */
  8408. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8409. /**
  8410. * Prepare the list of samplers associated with the Image Processing effects.
  8411. * @param samplersList The list of uniforms used in the effect
  8412. * @param defines the list of defines currently in use
  8413. */
  8414. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8415. /**
  8416. * Prepare the list of defines associated to the shader.
  8417. * @param defines the list of defines to complete
  8418. * @param forPostProcess Define if we are currently in post process mode or not
  8419. */
  8420. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8421. /**
  8422. * Returns true if all the image processing information are ready.
  8423. * @returns True if ready, otherwise, false
  8424. */
  8425. isReady(): boolean;
  8426. /**
  8427. * Binds the image processing to the shader.
  8428. * @param effect The effect to bind to
  8429. * @param overrideAspectRatio Override the aspect ratio of the effect
  8430. */
  8431. bind(effect: Effect, overrideAspectRatio?: number): void;
  8432. /**
  8433. * Clones the current image processing instance.
  8434. * @return The cloned image processing
  8435. */
  8436. clone(): ImageProcessingConfiguration;
  8437. /**
  8438. * Serializes the current image processing instance to a json representation.
  8439. * @return a JSON representation
  8440. */
  8441. serialize(): any;
  8442. /**
  8443. * Parses the image processing from a json representation.
  8444. * @param source the JSON source to parse
  8445. * @return The parsed image processing
  8446. */
  8447. static Parse(source: any): ImageProcessingConfiguration;
  8448. private static _VIGNETTEMODE_MULTIPLY;
  8449. private static _VIGNETTEMODE_OPAQUE;
  8450. /**
  8451. * Used to apply the vignette as a mix with the pixel color.
  8452. */
  8453. static readonly VIGNETTEMODE_MULTIPLY: number;
  8454. /**
  8455. * Used to apply the vignette as a replacement of the pixel color.
  8456. */
  8457. static readonly VIGNETTEMODE_OPAQUE: number;
  8458. }
  8459. }
  8460. declare module "babylonjs/Shaders/postprocess.vertex" {
  8461. /** @hidden */
  8462. export var postprocessVertexShader: {
  8463. name: string;
  8464. shader: string;
  8465. };
  8466. }
  8467. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8468. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8469. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8470. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8471. module "babylonjs/Engines/thinEngine" {
  8472. interface ThinEngine {
  8473. /**
  8474. * Creates a new render target texture
  8475. * @param size defines the size of the texture
  8476. * @param options defines the options used to create the texture
  8477. * @returns a new render target texture stored in an InternalTexture
  8478. */
  8479. createRenderTargetTexture(size: number | {
  8480. width: number;
  8481. height: number;
  8482. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8483. /**
  8484. * Creates a depth stencil texture.
  8485. * This is only available in WebGL 2 or with the depth texture extension available.
  8486. * @param size The size of face edge in the texture.
  8487. * @param options The options defining the texture.
  8488. * @returns The texture
  8489. */
  8490. createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. /** @hidden */
  8495. _createDepthStencilTexture(size: number | {
  8496. width: number;
  8497. height: number;
  8498. }, options: DepthTextureCreationOptions): InternalTexture;
  8499. }
  8500. }
  8501. }
  8502. declare module "babylonjs/Maths/math.axis" {
  8503. import { Vector3 } from "babylonjs/Maths/math.vector";
  8504. /** Defines supported spaces */
  8505. export enum Space {
  8506. /** Local (object) space */
  8507. LOCAL = 0,
  8508. /** World space */
  8509. WORLD = 1,
  8510. /** Bone space */
  8511. BONE = 2
  8512. }
  8513. /** Defines the 3 main axes */
  8514. export class Axis {
  8515. /** X axis */
  8516. static X: Vector3;
  8517. /** Y axis */
  8518. static Y: Vector3;
  8519. /** Z axis */
  8520. static Z: Vector3;
  8521. }
  8522. }
  8523. declare module "babylonjs/Cameras/targetCamera" {
  8524. import { Nullable } from "babylonjs/types";
  8525. import { Camera } from "babylonjs/Cameras/camera";
  8526. import { Scene } from "babylonjs/scene";
  8527. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8528. /**
  8529. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. */
  8533. export class TargetCamera extends Camera {
  8534. private static _RigCamTransformMatrix;
  8535. private static _TargetTransformMatrix;
  8536. private static _TargetFocalPoint;
  8537. /**
  8538. * Define the current direction the camera is moving to
  8539. */
  8540. cameraDirection: Vector3;
  8541. /**
  8542. * Define the current rotation the camera is rotating to
  8543. */
  8544. cameraRotation: Vector2;
  8545. /**
  8546. * When set, the up vector of the camera will be updated by the rotation of the camera
  8547. */
  8548. updateUpVectorFromRotation: boolean;
  8549. private _tmpQuaternion;
  8550. /**
  8551. * Define the current rotation of the camera
  8552. */
  8553. rotation: Vector3;
  8554. /**
  8555. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8556. */
  8557. rotationQuaternion: Quaternion;
  8558. /**
  8559. * Define the current speed of the camera
  8560. */
  8561. speed: number;
  8562. /**
  8563. * Add constraint to the camera to prevent it to move freely in all directions and
  8564. * around all axis.
  8565. */
  8566. noRotationConstraint: boolean;
  8567. /**
  8568. * Define the current target of the camera as an object or a position.
  8569. */
  8570. lockedTarget: any;
  8571. /** @hidden */
  8572. _currentTarget: Vector3;
  8573. /** @hidden */
  8574. _initialFocalDistance: number;
  8575. /** @hidden */
  8576. _viewMatrix: Matrix;
  8577. /** @hidden */
  8578. _camMatrix: Matrix;
  8579. /** @hidden */
  8580. _cameraTransformMatrix: Matrix;
  8581. /** @hidden */
  8582. _cameraRotationMatrix: Matrix;
  8583. /** @hidden */
  8584. _referencePoint: Vector3;
  8585. /** @hidden */
  8586. _transformedReferencePoint: Vector3;
  8587. protected _globalCurrentTarget: Vector3;
  8588. protected _globalCurrentUpVector: Vector3;
  8589. /** @hidden */
  8590. _reset: () => void;
  8591. private _defaultUp;
  8592. /**
  8593. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8594. * This is the base of the follow, arc rotate cameras and Free camera
  8595. * @see http://doc.babylonjs.com/features/cameras
  8596. * @param name Defines the name of the camera in the scene
  8597. * @param position Defines the start position of the camera in the scene
  8598. * @param scene Defines the scene the camera belongs to
  8599. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8600. */
  8601. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8602. /**
  8603. * Gets the position in front of the camera at a given distance.
  8604. * @param distance The distance from the camera we want the position to be
  8605. * @returns the position
  8606. */
  8607. getFrontPosition(distance: number): Vector3;
  8608. /** @hidden */
  8609. _getLockedTargetPosition(): Nullable<Vector3>;
  8610. private _storedPosition;
  8611. private _storedRotation;
  8612. private _storedRotationQuaternion;
  8613. /**
  8614. * Store current camera state of the camera (fov, position, rotation, etc..)
  8615. * @returns the camera
  8616. */
  8617. storeState(): Camera;
  8618. /**
  8619. * Restored camera state. You must call storeState() first
  8620. * @returns whether it was successful or not
  8621. * @hidden
  8622. */
  8623. _restoreStateValues(): boolean;
  8624. /** @hidden */
  8625. _initCache(): void;
  8626. /** @hidden */
  8627. _updateCache(ignoreParentClass?: boolean): void;
  8628. /** @hidden */
  8629. _isSynchronizedViewMatrix(): boolean;
  8630. /** @hidden */
  8631. _computeLocalCameraSpeed(): number;
  8632. /**
  8633. * Defines the target the camera should look at.
  8634. * @param target Defines the new target as a Vector or a mesh
  8635. */
  8636. setTarget(target: Vector3): void;
  8637. /**
  8638. * Return the current target position of the camera. This value is expressed in local space.
  8639. * @returns the target position
  8640. */
  8641. getTarget(): Vector3;
  8642. /** @hidden */
  8643. _decideIfNeedsToMove(): boolean;
  8644. /** @hidden */
  8645. _updatePosition(): void;
  8646. /** @hidden */
  8647. _checkInputs(): void;
  8648. protected _updateCameraRotationMatrix(): void;
  8649. /**
  8650. * 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)
  8651. * @returns the current camera
  8652. */
  8653. private _rotateUpVectorWithCameraRotationMatrix;
  8654. private _cachedRotationZ;
  8655. private _cachedQuaternionRotationZ;
  8656. /** @hidden */
  8657. _getViewMatrix(): Matrix;
  8658. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8659. /**
  8660. * @hidden
  8661. */
  8662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8663. /**
  8664. * @hidden
  8665. */
  8666. _updateRigCameras(): void;
  8667. private _getRigCamPositionAndTarget;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Events/keyboardEvents" {
  8676. /**
  8677. * Gather the list of keyboard event types as constants.
  8678. */
  8679. export class KeyboardEventTypes {
  8680. /**
  8681. * The keydown event is fired when a key becomes active (pressed).
  8682. */
  8683. static readonly KEYDOWN: number;
  8684. /**
  8685. * The keyup event is fired when a key has been released.
  8686. */
  8687. static readonly KEYUP: number;
  8688. }
  8689. /**
  8690. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8691. */
  8692. export class KeyboardInfo {
  8693. /**
  8694. * Defines the type of event (KeyboardEventTypes)
  8695. */
  8696. type: number;
  8697. /**
  8698. * Defines the related dom event
  8699. */
  8700. event: KeyboardEvent;
  8701. /**
  8702. * Instantiates a new keyboard info.
  8703. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8704. * @param type Defines the type of event (KeyboardEventTypes)
  8705. * @param event Defines the related dom event
  8706. */
  8707. constructor(
  8708. /**
  8709. * Defines the type of event (KeyboardEventTypes)
  8710. */
  8711. type: number,
  8712. /**
  8713. * Defines the related dom event
  8714. */
  8715. event: KeyboardEvent);
  8716. }
  8717. /**
  8718. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8719. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8720. */
  8721. export class KeyboardInfoPre extends KeyboardInfo {
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number;
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent;
  8730. /**
  8731. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8732. */
  8733. skipOnPointerObservable: boolean;
  8734. /**
  8735. * Instantiates a new keyboard pre info.
  8736. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8737. * @param type Defines the type of event (KeyboardEventTypes)
  8738. * @param event Defines the related dom event
  8739. */
  8740. constructor(
  8741. /**
  8742. * Defines the type of event (KeyboardEventTypes)
  8743. */
  8744. type: number,
  8745. /**
  8746. * Defines the related dom event
  8747. */
  8748. event: KeyboardEvent);
  8749. }
  8750. }
  8751. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8752. import { Nullable } from "babylonjs/types";
  8753. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8754. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8755. /**
  8756. * Manage the keyboard inputs to control the movement of a free camera.
  8757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8758. */
  8759. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8760. /**
  8761. * Defines the camera the input is attached to.
  8762. */
  8763. camera: FreeCamera;
  8764. /**
  8765. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8766. */
  8767. keysUp: number[];
  8768. /**
  8769. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8770. */
  8771. keysDown: number[];
  8772. /**
  8773. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8774. */
  8775. keysLeft: number[];
  8776. /**
  8777. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8778. */
  8779. keysRight: number[];
  8780. private _keys;
  8781. private _onCanvasBlurObserver;
  8782. private _onKeyboardObserver;
  8783. private _engine;
  8784. private _scene;
  8785. /**
  8786. * Attach the input controls to a specific dom element to get the input from.
  8787. * @param element Defines the element the controls should be listened from
  8788. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8789. */
  8790. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8791. /**
  8792. * Detach the current controls from the specified dom element.
  8793. * @param element Defines the element to stop listening the inputs from
  8794. */
  8795. detachControl(element: Nullable<HTMLElement>): void;
  8796. /**
  8797. * Update the current camera state depending on the inputs that have been used this frame.
  8798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8799. */
  8800. checkInputs(): void;
  8801. /**
  8802. * Gets the class name of the current intput.
  8803. * @returns the class name
  8804. */
  8805. getClassName(): string;
  8806. /** @hidden */
  8807. _onLostFocus(): void;
  8808. /**
  8809. * Get the friendly name associated with the input class.
  8810. * @returns the input friendly name
  8811. */
  8812. getSimpleName(): string;
  8813. }
  8814. }
  8815. declare module "babylonjs/Lights/shadowLight" {
  8816. import { Camera } from "babylonjs/Cameras/camera";
  8817. import { Scene } from "babylonjs/scene";
  8818. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8820. import { Light } from "babylonjs/Lights/light";
  8821. /**
  8822. * Interface describing all the common properties and methods a shadow light needs to implement.
  8823. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8824. * as well as binding the different shadow properties to the effects.
  8825. */
  8826. export interface IShadowLight extends Light {
  8827. /**
  8828. * The light id in the scene (used in scene.findLighById for instance)
  8829. */
  8830. id: string;
  8831. /**
  8832. * The position the shdow will be casted from.
  8833. */
  8834. position: Vector3;
  8835. /**
  8836. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8837. */
  8838. direction: Vector3;
  8839. /**
  8840. * The transformed position. Position of the light in world space taking parenting in account.
  8841. */
  8842. transformedPosition: Vector3;
  8843. /**
  8844. * The transformed direction. Direction of the light in world space taking parenting in account.
  8845. */
  8846. transformedDirection: Vector3;
  8847. /**
  8848. * The friendly name of the light in the scene.
  8849. */
  8850. name: string;
  8851. /**
  8852. * Defines the shadow projection clipping minimum z value.
  8853. */
  8854. shadowMinZ: number;
  8855. /**
  8856. * Defines the shadow projection clipping maximum z value.
  8857. */
  8858. shadowMaxZ: number;
  8859. /**
  8860. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8861. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8862. */
  8863. computeTransformedInformation(): boolean;
  8864. /**
  8865. * Gets the scene the light belongs to.
  8866. * @returns The scene
  8867. */
  8868. getScene(): Scene;
  8869. /**
  8870. * Callback defining a custom Projection Matrix Builder.
  8871. * This can be used to override the default projection matrix computation.
  8872. */
  8873. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8874. /**
  8875. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8876. * @param matrix The materix to updated with the projection information
  8877. * @param viewMatrix The transform matrix of the light
  8878. * @param renderList The list of mesh to render in the map
  8879. * @returns The current light
  8880. */
  8881. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8882. /**
  8883. * Gets the current depth scale used in ESM.
  8884. * @returns The scale
  8885. */
  8886. getDepthScale(): number;
  8887. /**
  8888. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8889. * @returns true if a cube texture needs to be use
  8890. */
  8891. needCube(): boolean;
  8892. /**
  8893. * Detects if the projection matrix requires to be recomputed this frame.
  8894. * @returns true if it requires to be recomputed otherwise, false.
  8895. */
  8896. needProjectionMatrixCompute(): boolean;
  8897. /**
  8898. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8899. */
  8900. forceProjectionMatrixCompute(): void;
  8901. /**
  8902. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8903. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8904. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8905. */
  8906. getShadowDirection(faceIndex?: number): Vector3;
  8907. /**
  8908. * Gets the minZ used for shadow according to both the scene and the light.
  8909. * @param activeCamera The camera we are returning the min for
  8910. * @returns the depth min z
  8911. */
  8912. getDepthMinZ(activeCamera: Camera): number;
  8913. /**
  8914. * Gets the maxZ used for shadow according to both the scene and the light.
  8915. * @param activeCamera The camera we are returning the max for
  8916. * @returns the depth max z
  8917. */
  8918. getDepthMaxZ(activeCamera: Camera): number;
  8919. }
  8920. /**
  8921. * Base implementation IShadowLight
  8922. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8923. */
  8924. export abstract class ShadowLight extends Light implements IShadowLight {
  8925. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8926. protected _position: Vector3;
  8927. protected _setPosition(value: Vector3): void;
  8928. /**
  8929. * Sets the position the shadow will be casted from. Also use as the light position for both
  8930. * point and spot lights.
  8931. */
  8932. /**
  8933. * Sets the position the shadow will be casted from. Also use as the light position for both
  8934. * point and spot lights.
  8935. */
  8936. position: Vector3;
  8937. protected _direction: Vector3;
  8938. protected _setDirection(value: Vector3): void;
  8939. /**
  8940. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8941. * Also use as the light direction on spot and directional lights.
  8942. */
  8943. /**
  8944. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8945. * Also use as the light direction on spot and directional lights.
  8946. */
  8947. direction: Vector3;
  8948. private _shadowMinZ;
  8949. /**
  8950. * Gets the shadow projection clipping minimum z value.
  8951. */
  8952. /**
  8953. * Sets the shadow projection clipping minimum z value.
  8954. */
  8955. shadowMinZ: number;
  8956. private _shadowMaxZ;
  8957. /**
  8958. * Sets the shadow projection clipping maximum z value.
  8959. */
  8960. /**
  8961. * Gets the shadow projection clipping maximum z value.
  8962. */
  8963. shadowMaxZ: number;
  8964. /**
  8965. * Callback defining a custom Projection Matrix Builder.
  8966. * This can be used to override the default projection matrix computation.
  8967. */
  8968. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8969. /**
  8970. * The transformed position. Position of the light in world space taking parenting in account.
  8971. */
  8972. transformedPosition: Vector3;
  8973. /**
  8974. * The transformed direction. Direction of the light in world space taking parenting in account.
  8975. */
  8976. transformedDirection: Vector3;
  8977. private _needProjectionMatrixCompute;
  8978. /**
  8979. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8980. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8981. */
  8982. computeTransformedInformation(): boolean;
  8983. /**
  8984. * Return the depth scale used for the shadow map.
  8985. * @returns the depth scale.
  8986. */
  8987. getDepthScale(): number;
  8988. /**
  8989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8992. */
  8993. getShadowDirection(faceIndex?: number): Vector3;
  8994. /**
  8995. * Returns the ShadowLight absolute position in the World.
  8996. * @returns the position vector in world space
  8997. */
  8998. getAbsolutePosition(): Vector3;
  8999. /**
  9000. * Sets the ShadowLight direction toward the passed target.
  9001. * @param target The point to target in local space
  9002. * @returns the updated ShadowLight direction
  9003. */
  9004. setDirectionToTarget(target: Vector3): Vector3;
  9005. /**
  9006. * Returns the light rotation in euler definition.
  9007. * @returns the x y z rotation in local space.
  9008. */
  9009. getRotation(): Vector3;
  9010. /**
  9011. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9012. * @returns true if a cube texture needs to be use
  9013. */
  9014. needCube(): boolean;
  9015. /**
  9016. * Detects if the projection matrix requires to be recomputed this frame.
  9017. * @returns true if it requires to be recomputed otherwise, false.
  9018. */
  9019. needProjectionMatrixCompute(): boolean;
  9020. /**
  9021. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9022. */
  9023. forceProjectionMatrixCompute(): void;
  9024. /** @hidden */
  9025. _initCache(): void;
  9026. /** @hidden */
  9027. _isSynchronized(): boolean;
  9028. /**
  9029. * Computes the world matrix of the node
  9030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9031. * @returns the world matrix
  9032. */
  9033. computeWorldMatrix(force?: boolean): Matrix;
  9034. /**
  9035. * Gets the minZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the min for
  9037. * @returns the depth min z
  9038. */
  9039. getDepthMinZ(activeCamera: Camera): number;
  9040. /**
  9041. * Gets the maxZ used for shadow according to both the scene and the light.
  9042. * @param activeCamera The camera we are returning the max for
  9043. * @returns the depth max z
  9044. */
  9045. getDepthMaxZ(activeCamera: Camera): number;
  9046. /**
  9047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9048. * @param matrix The materix to updated with the projection information
  9049. * @param viewMatrix The transform matrix of the light
  9050. * @param renderList The list of mesh to render in the map
  9051. * @returns The current light
  9052. */
  9053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9054. }
  9055. }
  9056. declare module "babylonjs/Materials/effectFallbacks" {
  9057. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9058. import { Effect } from "babylonjs/Materials/effect";
  9059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9060. /**
  9061. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9062. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9063. */
  9064. export class EffectFallbacks implements IEffectFallbacks {
  9065. private _defines;
  9066. private _currentRank;
  9067. private _maxRank;
  9068. private _mesh;
  9069. /**
  9070. * Removes the fallback from the bound mesh.
  9071. */
  9072. unBindMesh(): void;
  9073. /**
  9074. * Adds a fallback on the specified property.
  9075. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9076. * @param define The name of the define in the shader
  9077. */
  9078. addFallback(rank: number, define: string): void;
  9079. /**
  9080. * Sets the mesh to use CPU skinning when needing to fallback.
  9081. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9082. * @param mesh The mesh to use the fallbacks.
  9083. */
  9084. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9085. /**
  9086. * Checks to see if more fallbacks are still availible.
  9087. */
  9088. readonly hasMoreFallbacks: boolean;
  9089. /**
  9090. * Removes the defines that should be removed when falling back.
  9091. * @param currentDefines defines the current define statements for the shader.
  9092. * @param effect defines the current effect we try to compile
  9093. * @returns The resulting defines with defines of the current rank removed.
  9094. */
  9095. reduce(currentDefines: string, effect: Effect): string;
  9096. }
  9097. }
  9098. declare module "babylonjs/Materials/materialHelper" {
  9099. import { Nullable } from "babylonjs/types";
  9100. import { Scene } from "babylonjs/scene";
  9101. import { Engine } from "babylonjs/Engines/engine";
  9102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9103. import { Light } from "babylonjs/Lights/light";
  9104. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9105. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9107. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9108. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9109. /**
  9110. * "Static Class" containing the most commonly used helper while dealing with material for
  9111. * rendering purpose.
  9112. *
  9113. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9114. *
  9115. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9116. */
  9117. export class MaterialHelper {
  9118. /**
  9119. * Bind the current view position to an effect.
  9120. * @param effect The effect to be bound
  9121. * @param scene The scene the eyes position is used from
  9122. */
  9123. static BindEyePosition(effect: Effect, scene: Scene): void;
  9124. /**
  9125. * Helps preparing the defines values about the UVs in used in the effect.
  9126. * UVs are shared as much as we can accross channels in the shaders.
  9127. * @param texture The texture we are preparing the UVs for
  9128. * @param defines The defines to update
  9129. * @param key The channel key "diffuse", "specular"... used in the shader
  9130. */
  9131. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9132. /**
  9133. * Binds a texture matrix value to its corrsponding uniform
  9134. * @param texture The texture to bind the matrix for
  9135. * @param uniformBuffer The uniform buffer receivin the data
  9136. * @param key The channel key "diffuse", "specular"... used in the shader
  9137. */
  9138. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9139. /**
  9140. * Gets the current status of the fog (should it be enabled?)
  9141. * @param mesh defines the mesh to evaluate for fog support
  9142. * @param scene defines the hosting scene
  9143. * @returns true if fog must be enabled
  9144. */
  9145. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9146. /**
  9147. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9148. * @param mesh defines the current mesh
  9149. * @param scene defines the current scene
  9150. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9151. * @param pointsCloud defines if point cloud rendering has to be turned on
  9152. * @param fogEnabled defines if fog has to be turned on
  9153. * @param alphaTest defines if alpha testing has to be turned on
  9154. * @param defines defines the current list of defines
  9155. */
  9156. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9157. /**
  9158. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9159. * @param scene defines the current scene
  9160. * @param engine defines the current engine
  9161. * @param defines specifies the list of active defines
  9162. * @param useInstances defines if instances have to be turned on
  9163. * @param useClipPlane defines if clip plane have to be turned on
  9164. */
  9165. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9166. /**
  9167. * Prepares the defines for bones
  9168. * @param mesh The mesh containing the geometry data we will draw
  9169. * @param defines The defines to update
  9170. */
  9171. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9172. /**
  9173. * Prepares the defines for morph targets
  9174. * @param mesh The mesh containing the geometry data we will draw
  9175. * @param defines The defines to update
  9176. */
  9177. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9178. /**
  9179. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9180. * @param mesh The mesh containing the geometry data we will draw
  9181. * @param defines The defines to update
  9182. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9183. * @param useBones Precise whether bones should be used or not (override mesh info)
  9184. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9185. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9186. * @returns false if defines are considered not dirty and have not been checked
  9187. */
  9188. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9189. /**
  9190. * Prepares the defines related to multiview
  9191. * @param scene The scene we are intending to draw
  9192. * @param defines The defines to update
  9193. */
  9194. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9195. /**
  9196. * Prepares the defines related to the light information passed in parameter
  9197. * @param scene The scene we are intending to draw
  9198. * @param mesh The mesh the effect is compiling for
  9199. * @param light The light the effect is compiling for
  9200. * @param lightIndex The index of the light
  9201. * @param defines The defines to update
  9202. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9203. * @param state Defines the current state regarding what is needed (normals, etc...)
  9204. */
  9205. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9206. needNormals: boolean;
  9207. needRebuild: boolean;
  9208. shadowEnabled: boolean;
  9209. specularEnabled: boolean;
  9210. lightmapMode: boolean;
  9211. }): void;
  9212. /**
  9213. * Prepares the defines related to the light information passed in parameter
  9214. * @param scene The scene we are intending to draw
  9215. * @param mesh The mesh the effect is compiling for
  9216. * @param defines The defines to update
  9217. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9218. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9219. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9220. * @returns true if normals will be required for the rest of the effect
  9221. */
  9222. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9223. /**
  9224. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9225. * @param lightIndex defines the light index
  9226. * @param uniformsList The uniform list
  9227. * @param samplersList The sampler list
  9228. * @param projectedLightTexture defines if projected texture must be used
  9229. * @param uniformBuffersList defines an optional list of uniform buffers
  9230. */
  9231. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9232. /**
  9233. * Prepares the uniforms and samplers list to be used in the effect
  9234. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9235. * @param samplersList The sampler list
  9236. * @param defines The defines helping in the list generation
  9237. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9238. */
  9239. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9240. /**
  9241. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9242. * @param defines The defines to update while falling back
  9243. * @param fallbacks The authorized effect fallbacks
  9244. * @param maxSimultaneousLights The maximum number of lights allowed
  9245. * @param rank the current rank of the Effect
  9246. * @returns The newly affected rank
  9247. */
  9248. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9249. private static _TmpMorphInfluencers;
  9250. /**
  9251. * Prepares the list of attributes required for morph targets according to the effect defines.
  9252. * @param attribs The current list of supported attribs
  9253. * @param mesh The mesh to prepare the morph targets attributes for
  9254. * @param influencers The number of influencers
  9255. */
  9256. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9257. /**
  9258. * Prepares the list of attributes required for morph targets according to the effect defines.
  9259. * @param attribs The current list of supported attribs
  9260. * @param mesh The mesh to prepare the morph targets attributes for
  9261. * @param defines The current Defines of the effect
  9262. */
  9263. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9264. /**
  9265. * Prepares the list of attributes required for bones according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param mesh The mesh to prepare the bones attributes for
  9268. * @param defines The current Defines of the effect
  9269. * @param fallbacks The current efffect fallback strategy
  9270. */
  9271. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9272. /**
  9273. * Check and prepare the list of attributes required for instances according to the effect defines.
  9274. * @param attribs The current list of supported attribs
  9275. * @param defines The current MaterialDefines of the effect
  9276. */
  9277. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9278. /**
  9279. * Add the list of attributes required for instances to the attribs array.
  9280. * @param attribs The current list of supported attribs
  9281. */
  9282. static PushAttributesForInstances(attribs: string[]): void;
  9283. /**
  9284. * Binds the light information to the effect.
  9285. * @param light The light containing the generator
  9286. * @param effect The effect we are binding the data to
  9287. * @param lightIndex The light index in the effect used to render
  9288. */
  9289. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9290. /**
  9291. * Binds the lights information from the scene to the effect for the given mesh.
  9292. * @param light Light to bind
  9293. * @param lightIndex Light index
  9294. * @param scene The scene where the light belongs to
  9295. * @param effect The effect we are binding the data to
  9296. * @param useSpecular Defines if specular is supported
  9297. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9298. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9299. */
  9300. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9301. /**
  9302. * Binds the lights information from the scene to the effect for the given mesh.
  9303. * @param scene The scene the lights belongs to
  9304. * @param mesh The mesh we are binding the information to render
  9305. * @param effect The effect we are binding the data to
  9306. * @param defines The generated defines for the effect
  9307. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9308. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9309. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9310. */
  9311. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9312. private static _tempFogColor;
  9313. /**
  9314. * Binds the fog information from the scene to the effect for the given mesh.
  9315. * @param scene The scene the lights belongs to
  9316. * @param mesh The mesh we are binding the information to render
  9317. * @param effect The effect we are binding the data to
  9318. * @param linearSpace Defines if the fog effect is applied in linear space
  9319. */
  9320. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9321. /**
  9322. * Binds the bones information from the mesh to the effect.
  9323. * @param mesh The mesh we are binding the information to render
  9324. * @param effect The effect we are binding the data to
  9325. */
  9326. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9327. /**
  9328. * Binds the morph targets information from the mesh to the effect.
  9329. * @param abstractMesh The mesh we are binding the information to render
  9330. * @param effect The effect we are binding the data to
  9331. */
  9332. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9333. /**
  9334. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9335. * @param defines The generated defines used in the effect
  9336. * @param effect The effect we are binding the data to
  9337. * @param scene The scene we are willing to render with logarithmic scale for
  9338. */
  9339. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9340. /**
  9341. * Binds the clip plane information from the scene to the effect.
  9342. * @param scene The scene the clip plane information are extracted from
  9343. * @param effect The effect we are binding the data to
  9344. */
  9345. static BindClipPlane(effect: Effect, scene: Scene): void;
  9346. }
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9349. /** @hidden */
  9350. export var packingFunctions: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9357. /** @hidden */
  9358. export var shadowMapPixelShader: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9364. /** @hidden */
  9365. export var bonesDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9371. /** @hidden */
  9372. export var morphTargetsVertexGlobalDeclaration: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9378. /** @hidden */
  9379. export var morphTargetsVertexDeclaration: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9385. /** @hidden */
  9386. export var instancesDeclaration: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9392. /** @hidden */
  9393. export var helperFunctions: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9399. /** @hidden */
  9400. export var morphTargetsVertex: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9406. /** @hidden */
  9407. export var instancesVertex: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9413. /** @hidden */
  9414. export var bonesVertex: {
  9415. name: string;
  9416. shader: string;
  9417. };
  9418. }
  9419. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9420. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9423. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9426. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9427. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9428. /** @hidden */
  9429. export var shadowMapVertexShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9435. /** @hidden */
  9436. export var depthBoxBlurPixelShader: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9442. import { Nullable } from "babylonjs/types";
  9443. import { Scene } from "babylonjs/scene";
  9444. import { Matrix } from "babylonjs/Maths/math.vector";
  9445. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9447. import { Mesh } from "babylonjs/Meshes/mesh";
  9448. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9449. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9450. import { Effect } from "babylonjs/Materials/effect";
  9451. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9452. import "babylonjs/Shaders/shadowMap.fragment";
  9453. import "babylonjs/Shaders/shadowMap.vertex";
  9454. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9455. import { Observable } from "babylonjs/Misc/observable";
  9456. /**
  9457. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9458. */
  9459. export interface ICustomShaderOptions {
  9460. /**
  9461. * Gets or sets the custom shader name to use
  9462. */
  9463. shaderName: string;
  9464. /**
  9465. * The list of attribute names used in the shader
  9466. */
  9467. attributes?: string[];
  9468. /**
  9469. * The list of unifrom names used in the shader
  9470. */
  9471. uniforms?: string[];
  9472. /**
  9473. * The list of sampler names used in the shader
  9474. */
  9475. samplers?: string[];
  9476. /**
  9477. * The list of defines used in the shader
  9478. */
  9479. defines?: string[];
  9480. }
  9481. /**
  9482. * Interface to implement to create a shadow generator compatible with BJS.
  9483. */
  9484. export interface IShadowGenerator {
  9485. /**
  9486. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9487. * @returns The render target texture if present otherwise, null
  9488. */
  9489. getShadowMap(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9492. * @returns The render target texture if the shadow map is present otherwise, null
  9493. */
  9494. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9495. /**
  9496. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9497. * @param subMesh The submesh we want to render in the shadow map
  9498. * @param useInstances Defines wether will draw in the map using instances
  9499. * @returns true if ready otherwise, false
  9500. */
  9501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9502. /**
  9503. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9504. * @param defines Defines of the material we want to update
  9505. * @param lightIndex Index of the light in the enabled light list of the material
  9506. */
  9507. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9508. /**
  9509. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9510. * defined in the generator but impacting the effect).
  9511. * It implies the unifroms available on the materials are the standard BJS ones.
  9512. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9513. * @param effect The effect we are binfing the information for
  9514. */
  9515. bindShadowLight(lightIndex: string, effect: Effect): void;
  9516. /**
  9517. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9518. * (eq to shadow prjection matrix * light transform matrix)
  9519. * @returns The transform matrix used to create the shadow map
  9520. */
  9521. getTransformMatrix(): Matrix;
  9522. /**
  9523. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9524. * Cube and 2D textures for instance.
  9525. */
  9526. recreateShadowMap(): void;
  9527. /**
  9528. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9529. * @param onCompiled Callback triggered at the and of the effects compilation
  9530. * @param options Sets of optional options forcing the compilation with different modes
  9531. */
  9532. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9533. useInstances: boolean;
  9534. }>): void;
  9535. /**
  9536. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9537. * @param options Sets of optional options forcing the compilation with different modes
  9538. * @returns A promise that resolves when the compilation completes
  9539. */
  9540. forceCompilationAsync(options?: Partial<{
  9541. useInstances: boolean;
  9542. }>): Promise<void>;
  9543. /**
  9544. * Serializes the shadow generator setup to a json object.
  9545. * @returns The serialized JSON object
  9546. */
  9547. serialize(): any;
  9548. /**
  9549. * Disposes the Shadow map and related Textures and effects.
  9550. */
  9551. dispose(): void;
  9552. }
  9553. /**
  9554. * Default implementation IShadowGenerator.
  9555. * This is the main object responsible of generating shadows in the framework.
  9556. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9557. */
  9558. export class ShadowGenerator implements IShadowGenerator {
  9559. /**
  9560. * Shadow generator mode None: no filtering applied.
  9561. */
  9562. static readonly FILTER_NONE: number;
  9563. /**
  9564. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9565. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9566. */
  9567. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9568. /**
  9569. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9570. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9571. */
  9572. static readonly FILTER_POISSONSAMPLING: number;
  9573. /**
  9574. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9576. */
  9577. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9578. /**
  9579. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9580. * edge artifacts on steep falloff.
  9581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9582. */
  9583. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9584. /**
  9585. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9586. * edge artifacts on steep falloff.
  9587. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9588. */
  9589. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9590. /**
  9591. * Shadow generator mode PCF: Percentage Closer Filtering
  9592. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9593. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9594. */
  9595. static readonly FILTER_PCF: number;
  9596. /**
  9597. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9598. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9599. * Contact Hardening
  9600. */
  9601. static readonly FILTER_PCSS: number;
  9602. /**
  9603. * Reserved for PCF and PCSS
  9604. * Highest Quality.
  9605. *
  9606. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9607. *
  9608. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9609. */
  9610. static readonly QUALITY_HIGH: number;
  9611. /**
  9612. * Reserved for PCF and PCSS
  9613. * Good tradeoff for quality/perf cross devices
  9614. *
  9615. * Execute PCF on a 3*3 kernel.
  9616. *
  9617. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9618. */
  9619. static readonly QUALITY_MEDIUM: number;
  9620. /**
  9621. * Reserved for PCF and PCSS
  9622. * The lowest quality but the fastest.
  9623. *
  9624. * Execute PCF on a 1*1 kernel.
  9625. *
  9626. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9627. */
  9628. static readonly QUALITY_LOW: number;
  9629. /** Gets or sets the custom shader name to use */
  9630. customShaderOptions: ICustomShaderOptions;
  9631. /**
  9632. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9633. */
  9634. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9635. /**
  9636. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9637. */
  9638. onAfterShadowMapRenderObservable: Observable<Effect>;
  9639. /**
  9640. * Observable triggered before a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9642. */
  9643. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. /**
  9645. * Observable triggered after a mesh is rendered in the shadow map.
  9646. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9647. */
  9648. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9649. private _bias;
  9650. /**
  9651. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9652. */
  9653. /**
  9654. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9655. */
  9656. bias: number;
  9657. private _normalBias;
  9658. /**
  9659. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9660. */
  9661. /**
  9662. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9663. */
  9664. normalBias: number;
  9665. private _blurBoxOffset;
  9666. /**
  9667. * Gets the blur box offset: offset applied during the blur pass.
  9668. * Only useful if useKernelBlur = false
  9669. */
  9670. /**
  9671. * Sets the blur box offset: offset applied during the blur pass.
  9672. * Only useful if useKernelBlur = false
  9673. */
  9674. blurBoxOffset: number;
  9675. private _blurScale;
  9676. /**
  9677. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9678. * 2 means half of the size.
  9679. */
  9680. /**
  9681. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9682. * 2 means half of the size.
  9683. */
  9684. blurScale: number;
  9685. private _blurKernel;
  9686. /**
  9687. * Gets the blur kernel: kernel size of the blur pass.
  9688. * Only useful if useKernelBlur = true
  9689. */
  9690. /**
  9691. * Sets the blur kernel: kernel size of the blur pass.
  9692. * Only useful if useKernelBlur = true
  9693. */
  9694. blurKernel: number;
  9695. private _useKernelBlur;
  9696. /**
  9697. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9698. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9699. */
  9700. /**
  9701. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9702. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9703. */
  9704. useKernelBlur: boolean;
  9705. private _depthScale;
  9706. /**
  9707. * Gets the depth scale used in ESM mode.
  9708. */
  9709. /**
  9710. * Sets the depth scale used in ESM mode.
  9711. * This can override the scale stored on the light.
  9712. */
  9713. depthScale: number;
  9714. private _filter;
  9715. /**
  9716. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9717. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9718. */
  9719. /**
  9720. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9721. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9722. */
  9723. filter: number;
  9724. /**
  9725. * Gets if the current filter is set to Poisson Sampling.
  9726. */
  9727. /**
  9728. * Sets the current filter to Poisson Sampling.
  9729. */
  9730. usePoissonSampling: boolean;
  9731. /**
  9732. * Gets if the current filter is set to ESM.
  9733. */
  9734. /**
  9735. * Sets the current filter is to ESM.
  9736. */
  9737. useExponentialShadowMap: boolean;
  9738. /**
  9739. * Gets if the current filter is set to filtered ESM.
  9740. */
  9741. /**
  9742. * Gets if the current filter is set to filtered ESM.
  9743. */
  9744. useBlurExponentialShadowMap: boolean;
  9745. /**
  9746. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9747. * exponential to prevent steep falloff artifacts).
  9748. */
  9749. /**
  9750. * Sets the current filter to "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. useCloseExponentialShadowMap: boolean;
  9754. /**
  9755. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9756. * exponential to prevent steep falloff artifacts).
  9757. */
  9758. /**
  9759. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9760. * exponential to prevent steep falloff artifacts).
  9761. */
  9762. useBlurCloseExponentialShadowMap: boolean;
  9763. /**
  9764. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9765. */
  9766. /**
  9767. * Sets the current filter to "PCF" (percentage closer filtering).
  9768. */
  9769. usePercentageCloserFiltering: boolean;
  9770. private _filteringQuality;
  9771. /**
  9772. * Gets the PCF or PCSS Quality.
  9773. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9774. */
  9775. /**
  9776. * Sets the PCF or PCSS Quality.
  9777. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9778. */
  9779. filteringQuality: number;
  9780. /**
  9781. * Gets if the current filter is set to "PCSS" (contact hardening).
  9782. */
  9783. /**
  9784. * Sets the current filter to "PCSS" (contact hardening).
  9785. */
  9786. useContactHardeningShadow: boolean;
  9787. private _contactHardeningLightSizeUVRatio;
  9788. /**
  9789. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9790. * Using a ratio helps keeping shape stability independently of the map size.
  9791. *
  9792. * It does not account for the light projection as it was having too much
  9793. * instability during the light setup or during light position changes.
  9794. *
  9795. * Only valid if useContactHardeningShadow is true.
  9796. */
  9797. /**
  9798. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9799. * Using a ratio helps keeping shape stability independently of the map size.
  9800. *
  9801. * It does not account for the light projection as it was having too much
  9802. * instability during the light setup or during light position changes.
  9803. *
  9804. * Only valid if useContactHardeningShadow is true.
  9805. */
  9806. contactHardeningLightSizeUVRatio: number;
  9807. private _darkness;
  9808. /** Gets or sets the actual darkness of a shadow */
  9809. darkness: number;
  9810. /**
  9811. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9812. * 0 means strongest and 1 would means no shadow.
  9813. * @returns the darkness.
  9814. */
  9815. getDarkness(): number;
  9816. /**
  9817. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9818. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9819. * @returns the shadow generator allowing fluent coding.
  9820. */
  9821. setDarkness(darkness: number): ShadowGenerator;
  9822. private _transparencyShadow;
  9823. /** Gets or sets the ability to have transparent shadow */
  9824. transparencyShadow: boolean;
  9825. /**
  9826. * Sets the ability to have transparent shadow (boolean).
  9827. * @param transparent True if transparent else False
  9828. * @returns the shadow generator allowing fluent coding
  9829. */
  9830. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9831. private _shadowMap;
  9832. private _shadowMap2;
  9833. /**
  9834. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9835. * @returns The render target texture if present otherwise, null
  9836. */
  9837. getShadowMap(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9840. * @returns The render target texture if the shadow map is present otherwise, null
  9841. */
  9842. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9843. /**
  9844. * Gets the class name of that object
  9845. * @returns "ShadowGenerator"
  9846. */
  9847. getClassName(): string;
  9848. /**
  9849. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9850. * @param mesh Mesh to add
  9851. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9852. * @returns the Shadow Generator itself
  9853. */
  9854. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9855. /**
  9856. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9857. * @param mesh Mesh to remove
  9858. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9859. * @returns the Shadow Generator itself
  9860. */
  9861. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9862. /**
  9863. * Controls the extent to which the shadows fade out at the edge of the frustum
  9864. * Used only by directionals and spots
  9865. */
  9866. frustumEdgeFalloff: number;
  9867. private _light;
  9868. /**
  9869. * Returns the associated light object.
  9870. * @returns the light generating the shadow
  9871. */
  9872. getLight(): IShadowLight;
  9873. /**
  9874. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9875. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9876. * It might on the other hand introduce peter panning.
  9877. */
  9878. forceBackFacesOnly: boolean;
  9879. private _scene;
  9880. private _lightDirection;
  9881. private _effect;
  9882. private _viewMatrix;
  9883. private _projectionMatrix;
  9884. private _transformMatrix;
  9885. private _cachedPosition;
  9886. private _cachedDirection;
  9887. private _cachedDefines;
  9888. private _currentRenderID;
  9889. private _boxBlurPostprocess;
  9890. private _kernelBlurXPostprocess;
  9891. private _kernelBlurYPostprocess;
  9892. private _blurPostProcesses;
  9893. private _mapSize;
  9894. private _currentFaceIndex;
  9895. private _currentFaceIndexCache;
  9896. private _textureType;
  9897. private _defaultTextureMatrix;
  9898. private _storedUniqueId;
  9899. /** @hidden */
  9900. static _SceneComponentInitialization: (scene: Scene) => void;
  9901. /**
  9902. * Creates a ShadowGenerator object.
  9903. * A ShadowGenerator is the required tool to use the shadows.
  9904. * Each light casting shadows needs to use its own ShadowGenerator.
  9905. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9906. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9907. * @param light The light object generating the shadows.
  9908. * @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.
  9909. */
  9910. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9911. private _initializeGenerator;
  9912. private _initializeShadowMap;
  9913. private _initializeBlurRTTAndPostProcesses;
  9914. private _renderForShadowMap;
  9915. private _renderSubMeshForShadowMap;
  9916. private _applyFilterValues;
  9917. /**
  9918. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9919. * @param onCompiled Callback triggered at the and of the effects compilation
  9920. * @param options Sets of optional options forcing the compilation with different modes
  9921. */
  9922. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9923. useInstances: boolean;
  9924. }>): void;
  9925. /**
  9926. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9927. * @param options Sets of optional options forcing the compilation with different modes
  9928. * @returns A promise that resolves when the compilation completes
  9929. */
  9930. forceCompilationAsync(options?: Partial<{
  9931. useInstances: boolean;
  9932. }>): Promise<void>;
  9933. /**
  9934. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9935. * @param subMesh The submesh we want to render in the shadow map
  9936. * @param useInstances Defines wether will draw in the map using instances
  9937. * @returns true if ready otherwise, false
  9938. */
  9939. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9940. /**
  9941. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9942. * @param defines Defines of the material we want to update
  9943. * @param lightIndex Index of the light in the enabled light list of the material
  9944. */
  9945. prepareDefines(defines: any, lightIndex: number): void;
  9946. /**
  9947. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9948. * defined in the generator but impacting the effect).
  9949. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9950. * @param effect The effect we are binfing the information for
  9951. */
  9952. bindShadowLight(lightIndex: string, effect: Effect): void;
  9953. /**
  9954. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9955. * (eq to shadow prjection matrix * light transform matrix)
  9956. * @returns The transform matrix used to create the shadow map
  9957. */
  9958. getTransformMatrix(): Matrix;
  9959. /**
  9960. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9961. * Cube and 2D textures for instance.
  9962. */
  9963. recreateShadowMap(): void;
  9964. private _disposeBlurPostProcesses;
  9965. private _disposeRTTandPostProcesses;
  9966. /**
  9967. * Disposes the ShadowGenerator.
  9968. * Returns nothing.
  9969. */
  9970. dispose(): void;
  9971. /**
  9972. * Serializes the shadow generator setup to a json object.
  9973. * @returns The serialized JSON object
  9974. */
  9975. serialize(): any;
  9976. /**
  9977. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9978. * @param parsedShadowGenerator The JSON object to parse
  9979. * @param scene The scene to create the shadow map for
  9980. * @returns The parsed shadow generator
  9981. */
  9982. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9983. }
  9984. }
  9985. declare module "babylonjs/Lights/light" {
  9986. import { Nullable } from "babylonjs/types";
  9987. import { Scene } from "babylonjs/scene";
  9988. import { Vector3 } from "babylonjs/Maths/math.vector";
  9989. import { Color3 } from "babylonjs/Maths/math.color";
  9990. import { Node } from "babylonjs/node";
  9991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9992. import { Effect } from "babylonjs/Materials/effect";
  9993. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9994. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9995. /**
  9996. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9997. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9998. * 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.
  9999. */
  10000. export abstract class Light extends Node {
  10001. /**
  10002. * Falloff Default: light is falling off following the material specification:
  10003. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10004. */
  10005. static readonly FALLOFF_DEFAULT: number;
  10006. /**
  10007. * Falloff Physical: light is falling off following the inverse squared distance law.
  10008. */
  10009. static readonly FALLOFF_PHYSICAL: number;
  10010. /**
  10011. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10012. * to enhance interoperability with other engines.
  10013. */
  10014. static readonly FALLOFF_GLTF: number;
  10015. /**
  10016. * Falloff Standard: light is falling off like in the standard material
  10017. * to enhance interoperability with other materials.
  10018. */
  10019. static readonly FALLOFF_STANDARD: number;
  10020. /**
  10021. * If every light affecting the material is in this lightmapMode,
  10022. * material.lightmapTexture adds or multiplies
  10023. * (depends on material.useLightmapAsShadowmap)
  10024. * after every other light calculations.
  10025. */
  10026. static readonly LIGHTMAP_DEFAULT: number;
  10027. /**
  10028. * material.lightmapTexture as only diffuse lighting from this light
  10029. * adds only specular lighting from this light
  10030. * adds dynamic shadows
  10031. */
  10032. static readonly LIGHTMAP_SPECULAR: number;
  10033. /**
  10034. * material.lightmapTexture as only lighting
  10035. * no light calculation from this light
  10036. * only adds dynamic shadows from this light
  10037. */
  10038. static readonly LIGHTMAP_SHADOWSONLY: number;
  10039. /**
  10040. * Each light type uses the default quantity according to its type:
  10041. * point/spot lights use luminous intensity
  10042. * directional lights use illuminance
  10043. */
  10044. static readonly INTENSITYMODE_AUTOMATIC: number;
  10045. /**
  10046. * lumen (lm)
  10047. */
  10048. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10049. /**
  10050. * candela (lm/sr)
  10051. */
  10052. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10053. /**
  10054. * lux (lm/m^2)
  10055. */
  10056. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10057. /**
  10058. * nit (cd/m^2)
  10059. */
  10060. static readonly INTENSITYMODE_LUMINANCE: number;
  10061. /**
  10062. * Light type const id of the point light.
  10063. */
  10064. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10065. /**
  10066. * Light type const id of the directional light.
  10067. */
  10068. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10069. /**
  10070. * Light type const id of the spot light.
  10071. */
  10072. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10073. /**
  10074. * Light type const id of the hemispheric light.
  10075. */
  10076. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10077. /**
  10078. * Diffuse gives the basic color to an object.
  10079. */
  10080. diffuse: Color3;
  10081. /**
  10082. * Specular produces a highlight color on an object.
  10083. * Note: This is note affecting PBR materials.
  10084. */
  10085. specular: Color3;
  10086. /**
  10087. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10088. * falling off base on range or angle.
  10089. * This can be set to any values in Light.FALLOFF_x.
  10090. *
  10091. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10092. * other types of materials.
  10093. */
  10094. falloffType: number;
  10095. /**
  10096. * Strength of the light.
  10097. * Note: By default it is define in the framework own unit.
  10098. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10099. */
  10100. intensity: number;
  10101. private _range;
  10102. protected _inverseSquaredRange: number;
  10103. /**
  10104. * Defines how far from the source the light is impacting in scene units.
  10105. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10106. */
  10107. /**
  10108. * Defines how far from the source the light is impacting in scene units.
  10109. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10110. */
  10111. range: number;
  10112. /**
  10113. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10114. * of light.
  10115. */
  10116. private _photometricScale;
  10117. private _intensityMode;
  10118. /**
  10119. * Gets the photometric scale used to interpret the intensity.
  10120. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10121. */
  10122. /**
  10123. * Sets the photometric scale used to interpret the intensity.
  10124. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10125. */
  10126. intensityMode: number;
  10127. private _radius;
  10128. /**
  10129. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10130. */
  10131. /**
  10132. * sets the light radius used by PBR Materials to simulate soft area lights.
  10133. */
  10134. radius: number;
  10135. private _renderPriority;
  10136. /**
  10137. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10138. * exceeding the number allowed of the materials.
  10139. */
  10140. renderPriority: number;
  10141. private _shadowEnabled;
  10142. /**
  10143. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10144. * the current shadow generator.
  10145. */
  10146. /**
  10147. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10148. * the current shadow generator.
  10149. */
  10150. shadowEnabled: boolean;
  10151. private _includedOnlyMeshes;
  10152. /**
  10153. * Gets the only meshes impacted by this light.
  10154. */
  10155. /**
  10156. * Sets the only meshes impacted by this light.
  10157. */
  10158. includedOnlyMeshes: AbstractMesh[];
  10159. private _excludedMeshes;
  10160. /**
  10161. * Gets the meshes not impacted by this light.
  10162. */
  10163. /**
  10164. * Sets the meshes not impacted by this light.
  10165. */
  10166. excludedMeshes: AbstractMesh[];
  10167. private _excludeWithLayerMask;
  10168. /**
  10169. * Gets the layer id use to find what meshes are not impacted by the light.
  10170. * Inactive if 0
  10171. */
  10172. /**
  10173. * Sets the layer id use to find what meshes are not impacted by the light.
  10174. * Inactive if 0
  10175. */
  10176. excludeWithLayerMask: number;
  10177. private _includeOnlyWithLayerMask;
  10178. /**
  10179. * Gets the layer id use to find what meshes are impacted by the light.
  10180. * Inactive if 0
  10181. */
  10182. /**
  10183. * Sets the layer id use to find what meshes are impacted by the light.
  10184. * Inactive if 0
  10185. */
  10186. includeOnlyWithLayerMask: number;
  10187. private _lightmapMode;
  10188. /**
  10189. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10190. */
  10191. /**
  10192. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10193. */
  10194. lightmapMode: number;
  10195. /**
  10196. * Shadow generator associted to the light.
  10197. * @hidden Internal use only.
  10198. */
  10199. _shadowGenerator: Nullable<IShadowGenerator>;
  10200. /**
  10201. * @hidden Internal use only.
  10202. */
  10203. _excludedMeshesIds: string[];
  10204. /**
  10205. * @hidden Internal use only.
  10206. */
  10207. _includedOnlyMeshesIds: string[];
  10208. /**
  10209. * The current light unifom buffer.
  10210. * @hidden Internal use only.
  10211. */
  10212. _uniformBuffer: UniformBuffer;
  10213. /** @hidden */
  10214. _renderId: number;
  10215. /**
  10216. * Creates a Light object in the scene.
  10217. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10218. * @param name The firendly name of the light
  10219. * @param scene The scene the light belongs too
  10220. */
  10221. constructor(name: string, scene: Scene);
  10222. protected abstract _buildUniformLayout(): void;
  10223. /**
  10224. * Sets the passed Effect "effect" with the Light information.
  10225. * @param effect The effect to update
  10226. * @param lightIndex The index of the light in the effect to update
  10227. * @returns The light
  10228. */
  10229. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10230. /**
  10231. * Sets the passed Effect "effect" with the Light textures.
  10232. * @param effect The effect to update
  10233. * @param lightIndex The index of the light in the effect to update
  10234. * @returns The light
  10235. */
  10236. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10237. /**
  10238. * Binds the lights information from the scene to the effect for the given mesh.
  10239. * @param lightIndex Light index
  10240. * @param scene The scene where the light belongs to
  10241. * @param effect The effect we are binding the data to
  10242. * @param useSpecular Defines if specular is supported
  10243. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10244. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10245. */
  10246. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10247. /**
  10248. * Sets the passed Effect "effect" with the Light information.
  10249. * @param effect The effect to update
  10250. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10251. * @returns The light
  10252. */
  10253. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10254. /**
  10255. * Returns the string "Light".
  10256. * @returns the class name
  10257. */
  10258. getClassName(): string;
  10259. /** @hidden */
  10260. readonly _isLight: boolean;
  10261. /**
  10262. * Converts the light information to a readable string for debug purpose.
  10263. * @param fullDetails Supports for multiple levels of logging within scene loading
  10264. * @returns the human readable light info
  10265. */
  10266. toString(fullDetails?: boolean): string;
  10267. /** @hidden */
  10268. protected _syncParentEnabledState(): void;
  10269. /**
  10270. * Set the enabled state of this node.
  10271. * @param value - the new enabled state
  10272. */
  10273. setEnabled(value: boolean): void;
  10274. /**
  10275. * Returns the Light associated shadow generator if any.
  10276. * @return the associated shadow generator.
  10277. */
  10278. getShadowGenerator(): Nullable<IShadowGenerator>;
  10279. /**
  10280. * Returns a Vector3, the absolute light position in the World.
  10281. * @returns the world space position of the light
  10282. */
  10283. getAbsolutePosition(): Vector3;
  10284. /**
  10285. * Specifies if the light will affect the passed mesh.
  10286. * @param mesh The mesh to test against the light
  10287. * @return true the mesh is affected otherwise, false.
  10288. */
  10289. canAffectMesh(mesh: AbstractMesh): boolean;
  10290. /**
  10291. * Sort function to order lights for rendering.
  10292. * @param a First Light object to compare to second.
  10293. * @param b Second Light object to compare first.
  10294. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10295. */
  10296. static CompareLightsPriority(a: Light, b: Light): number;
  10297. /**
  10298. * Releases resources associated with this node.
  10299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10301. */
  10302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10303. /**
  10304. * Returns the light type ID (integer).
  10305. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10306. */
  10307. getTypeID(): number;
  10308. /**
  10309. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10310. * @returns the scaled intensity in intensity mode unit
  10311. */
  10312. getScaledIntensity(): number;
  10313. /**
  10314. * Returns a new Light object, named "name", from the current one.
  10315. * @param name The name of the cloned light
  10316. * @returns the new created light
  10317. */
  10318. clone(name: string): Nullable<Light>;
  10319. /**
  10320. * Serializes the current light into a Serialization object.
  10321. * @returns the serialized object.
  10322. */
  10323. serialize(): any;
  10324. /**
  10325. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10326. * This new light is named "name" and added to the passed scene.
  10327. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10328. * @param name The friendly name of the light
  10329. * @param scene The scene the new light will belong to
  10330. * @returns the constructor function
  10331. */
  10332. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10333. /**
  10334. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10335. * @param parsedLight The JSON representation of the light
  10336. * @param scene The scene to create the parsed light in
  10337. * @returns the created light after parsing
  10338. */
  10339. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10340. private _hookArrayForExcluded;
  10341. private _hookArrayForIncludedOnly;
  10342. private _resyncMeshes;
  10343. /**
  10344. * Forces the meshes to update their light related information in their rendering used effects
  10345. * @hidden Internal Use Only
  10346. */
  10347. _markMeshesAsLightDirty(): void;
  10348. /**
  10349. * Recomputes the cached photometric scale if needed.
  10350. */
  10351. private _computePhotometricScale;
  10352. /**
  10353. * Returns the Photometric Scale according to the light type and intensity mode.
  10354. */
  10355. private _getPhotometricScale;
  10356. /**
  10357. * Reorder the light in the scene according to their defined priority.
  10358. * @hidden Internal Use Only
  10359. */
  10360. _reorderLightsInScene(): void;
  10361. /**
  10362. * Prepares the list of defines specific to the light type.
  10363. * @param defines the list of defines
  10364. * @param lightIndex defines the index of the light for the effect
  10365. */
  10366. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10367. }
  10368. }
  10369. declare module "babylonjs/Actions/action" {
  10370. import { Observable } from "babylonjs/Misc/observable";
  10371. import { Condition } from "babylonjs/Actions/condition";
  10372. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10373. import { ActionManager } from "babylonjs/Actions/actionManager";
  10374. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10375. /**
  10376. * Interface used to define Action
  10377. */
  10378. export interface IAction {
  10379. /**
  10380. * Trigger for the action
  10381. */
  10382. trigger: number;
  10383. /** Options of the trigger */
  10384. triggerOptions: any;
  10385. /**
  10386. * Gets the trigger parameters
  10387. * @returns the trigger parameters
  10388. */
  10389. getTriggerParameter(): any;
  10390. /**
  10391. * Internal only - executes current action event
  10392. * @hidden
  10393. */
  10394. _executeCurrent(evt?: ActionEvent): void;
  10395. /**
  10396. * Serialize placeholder for child classes
  10397. * @param parent of child
  10398. * @returns the serialized object
  10399. */
  10400. serialize(parent: any): any;
  10401. /**
  10402. * Internal only
  10403. * @hidden
  10404. */
  10405. _prepare(): void;
  10406. /**
  10407. * Internal only - manager for action
  10408. * @hidden
  10409. */
  10410. _actionManager: AbstractActionManager;
  10411. /**
  10412. * Adds action to chain of actions, may be a DoNothingAction
  10413. * @param action defines the next action to execute
  10414. * @returns The action passed in
  10415. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10416. */
  10417. then(action: IAction): IAction;
  10418. }
  10419. /**
  10420. * The action to be carried out following a trigger
  10421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10422. */
  10423. export class Action implements IAction {
  10424. /** the trigger, with or without parameters, for the action */
  10425. triggerOptions: any;
  10426. /**
  10427. * Trigger for the action
  10428. */
  10429. trigger: number;
  10430. /**
  10431. * Internal only - manager for action
  10432. * @hidden
  10433. */
  10434. _actionManager: ActionManager;
  10435. private _nextActiveAction;
  10436. private _child;
  10437. private _condition?;
  10438. private _triggerParameter;
  10439. /**
  10440. * An event triggered prior to action being executed.
  10441. */
  10442. onBeforeExecuteObservable: Observable<Action>;
  10443. /**
  10444. * Creates a new Action
  10445. * @param triggerOptions the trigger, with or without parameters, for the action
  10446. * @param condition an optional determinant of action
  10447. */
  10448. constructor(
  10449. /** the trigger, with or without parameters, for the action */
  10450. triggerOptions: any, condition?: Condition);
  10451. /**
  10452. * Internal only
  10453. * @hidden
  10454. */
  10455. _prepare(): void;
  10456. /**
  10457. * Gets the trigger parameters
  10458. * @returns the trigger parameters
  10459. */
  10460. getTriggerParameter(): any;
  10461. /**
  10462. * Internal only - executes current action event
  10463. * @hidden
  10464. */
  10465. _executeCurrent(evt?: ActionEvent): void;
  10466. /**
  10467. * Execute placeholder for child classes
  10468. * @param evt optional action event
  10469. */
  10470. execute(evt?: ActionEvent): void;
  10471. /**
  10472. * Skips to next active action
  10473. */
  10474. skipToNextActiveAction(): void;
  10475. /**
  10476. * Adds action to chain of actions, may be a DoNothingAction
  10477. * @param action defines the next action to execute
  10478. * @returns The action passed in
  10479. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10480. */
  10481. then(action: Action): Action;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getProperty(propertyPath: string): string;
  10487. /**
  10488. * Internal only
  10489. * @hidden
  10490. */
  10491. _getEffectiveTarget(target: any, propertyPath: string): any;
  10492. /**
  10493. * Serialize placeholder for child classes
  10494. * @param parent of child
  10495. * @returns the serialized object
  10496. */
  10497. serialize(parent: any): any;
  10498. /**
  10499. * Internal only called by serialize
  10500. * @hidden
  10501. */
  10502. protected _serialize(serializedAction: any, parent?: any): any;
  10503. /**
  10504. * Internal only
  10505. * @hidden
  10506. */
  10507. static _SerializeValueAsString: (value: any) => string;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10513. name: string;
  10514. targetType: string;
  10515. value: string;
  10516. };
  10517. }
  10518. }
  10519. declare module "babylonjs/Actions/condition" {
  10520. import { ActionManager } from "babylonjs/Actions/actionManager";
  10521. /**
  10522. * A Condition applied to an Action
  10523. */
  10524. export class Condition {
  10525. /**
  10526. * Internal only - manager for action
  10527. * @hidden
  10528. */
  10529. _actionManager: ActionManager;
  10530. /**
  10531. * Internal only
  10532. * @hidden
  10533. */
  10534. _evaluationId: number;
  10535. /**
  10536. * Internal only
  10537. * @hidden
  10538. */
  10539. _currentResult: boolean;
  10540. /**
  10541. * Creates a new Condition
  10542. * @param actionManager the manager of the action the condition is applied to
  10543. */
  10544. constructor(actionManager: ActionManager);
  10545. /**
  10546. * Check if the current condition is valid
  10547. * @returns a boolean
  10548. */
  10549. isValid(): boolean;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */
  10554. _getProperty(propertyPath: string): string;
  10555. /**
  10556. * Internal only
  10557. * @hidden
  10558. */
  10559. _getEffectiveTarget(target: any, propertyPath: string): any;
  10560. /**
  10561. * Serialize placeholder for child classes
  10562. * @returns the serialized object
  10563. */
  10564. serialize(): any;
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. protected _serialize(serializedCondition: any): any;
  10570. }
  10571. /**
  10572. * Defines specific conditional operators as extensions of Condition
  10573. */
  10574. export class ValueCondition extends Condition {
  10575. /** path to specify the property of the target the conditional operator uses */
  10576. propertyPath: string;
  10577. /** the value compared by the conditional operator against the current value of the property */
  10578. value: any;
  10579. /** the conditional operator, default ValueCondition.IsEqual */
  10580. operator: number;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. private static _IsEqual;
  10586. /**
  10587. * Internal only
  10588. * @hidden
  10589. */
  10590. private static _IsDifferent;
  10591. /**
  10592. * Internal only
  10593. * @hidden
  10594. */
  10595. private static _IsGreater;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. private static _IsLesser;
  10601. /**
  10602. * returns the number for IsEqual
  10603. */
  10604. static readonly IsEqual: number;
  10605. /**
  10606. * Returns the number for IsDifferent
  10607. */
  10608. static readonly IsDifferent: number;
  10609. /**
  10610. * Returns the number for IsGreater
  10611. */
  10612. static readonly IsGreater: number;
  10613. /**
  10614. * Returns the number for IsLesser
  10615. */
  10616. static readonly IsLesser: number;
  10617. /**
  10618. * Internal only The action manager for the condition
  10619. * @hidden
  10620. */
  10621. _actionManager: ActionManager;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. private _target;
  10627. /**
  10628. * Internal only
  10629. * @hidden
  10630. */
  10631. private _effectiveTarget;
  10632. /**
  10633. * Internal only
  10634. * @hidden
  10635. */
  10636. private _property;
  10637. /**
  10638. * Creates a new ValueCondition
  10639. * @param actionManager manager for the action the condition applies to
  10640. * @param target for the action
  10641. * @param propertyPath path to specify the property of the target the conditional operator uses
  10642. * @param value the value compared by the conditional operator against the current value of the property
  10643. * @param operator the conditional operator, default ValueCondition.IsEqual
  10644. */
  10645. constructor(actionManager: ActionManager, target: any,
  10646. /** path to specify the property of the target the conditional operator uses */
  10647. propertyPath: string,
  10648. /** the value compared by the conditional operator against the current value of the property */
  10649. value: any,
  10650. /** the conditional operator, default ValueCondition.IsEqual */
  10651. operator?: number);
  10652. /**
  10653. * Compares the given value with the property value for the specified conditional operator
  10654. * @returns the result of the comparison
  10655. */
  10656. isValid(): boolean;
  10657. /**
  10658. * Serialize the ValueCondition into a JSON compatible object
  10659. * @returns serialization object
  10660. */
  10661. serialize(): any;
  10662. /**
  10663. * Gets the name of the conditional operator for the ValueCondition
  10664. * @param operator the conditional operator
  10665. * @returns the name
  10666. */
  10667. static GetOperatorName(operator: number): string;
  10668. }
  10669. /**
  10670. * Defines a predicate condition as an extension of Condition
  10671. */
  10672. export class PredicateCondition extends Condition {
  10673. /** defines the predicate function used to validate the condition */
  10674. predicate: () => boolean;
  10675. /**
  10676. * Internal only - manager for action
  10677. * @hidden
  10678. */
  10679. _actionManager: ActionManager;
  10680. /**
  10681. * Creates a new PredicateCondition
  10682. * @param actionManager manager for the action the condition applies to
  10683. * @param predicate defines the predicate function used to validate the condition
  10684. */
  10685. constructor(actionManager: ActionManager,
  10686. /** defines the predicate function used to validate the condition */
  10687. predicate: () => boolean);
  10688. /**
  10689. * @returns the validity of the predicate condition
  10690. */
  10691. isValid(): boolean;
  10692. }
  10693. /**
  10694. * Defines a state condition as an extension of Condition
  10695. */
  10696. export class StateCondition extends Condition {
  10697. /** Value to compare with target state */
  10698. value: string;
  10699. /**
  10700. * Internal only - manager for action
  10701. * @hidden
  10702. */
  10703. _actionManager: ActionManager;
  10704. /**
  10705. * Internal only
  10706. * @hidden
  10707. */
  10708. private _target;
  10709. /**
  10710. * Creates a new StateCondition
  10711. * @param actionManager manager for the action the condition applies to
  10712. * @param target of the condition
  10713. * @param value to compare with target state
  10714. */
  10715. constructor(actionManager: ActionManager, target: any,
  10716. /** Value to compare with target state */
  10717. value: string);
  10718. /**
  10719. * Gets a boolean indicating if the current condition is met
  10720. * @returns the validity of the state
  10721. */
  10722. isValid(): boolean;
  10723. /**
  10724. * Serialize the StateCondition into a JSON compatible object
  10725. * @returns serialization object
  10726. */
  10727. serialize(): any;
  10728. }
  10729. }
  10730. declare module "babylonjs/Actions/directActions" {
  10731. import { Action } from "babylonjs/Actions/action";
  10732. import { Condition } from "babylonjs/Actions/condition";
  10733. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10734. /**
  10735. * This defines an action responsible to toggle a boolean once triggered.
  10736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10737. */
  10738. export class SwitchBooleanAction extends Action {
  10739. /**
  10740. * The path to the boolean property in the target object
  10741. */
  10742. propertyPath: string;
  10743. private _target;
  10744. private _effectiveTarget;
  10745. private _property;
  10746. /**
  10747. * Instantiate the action
  10748. * @param triggerOptions defines the trigger options
  10749. * @param target defines the object containing the boolean
  10750. * @param propertyPath defines the path to the boolean property in the target object
  10751. * @param condition defines the trigger related conditions
  10752. */
  10753. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10754. /** @hidden */
  10755. _prepare(): void;
  10756. /**
  10757. * Execute the action toggle the boolean value.
  10758. */
  10759. execute(): void;
  10760. /**
  10761. * Serializes the actions and its related information.
  10762. * @param parent defines the object to serialize in
  10763. * @returns the serialized object
  10764. */
  10765. serialize(parent: any): any;
  10766. }
  10767. /**
  10768. * This defines an action responsible to set a the state field of the target
  10769. * to a desired value once triggered.
  10770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10771. */
  10772. export class SetStateAction extends Action {
  10773. /**
  10774. * The value to store in the state field.
  10775. */
  10776. value: string;
  10777. private _target;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the object containing the state property
  10782. * @param value defines the value to store in the state field
  10783. * @param condition defines the trigger related conditions
  10784. */
  10785. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10786. /**
  10787. * Execute the action and store the value on the target state property.
  10788. */
  10789. execute(): void;
  10790. /**
  10791. * Serializes the actions and its related information.
  10792. * @param parent defines the object to serialize in
  10793. * @returns the serialized object
  10794. */
  10795. serialize(parent: any): any;
  10796. }
  10797. /**
  10798. * This defines an action responsible to set a property of the target
  10799. * to a desired value once triggered.
  10800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10801. */
  10802. export class SetValueAction extends Action {
  10803. /**
  10804. * The path of the property to set in the target.
  10805. */
  10806. propertyPath: string;
  10807. /**
  10808. * The value to set in the property
  10809. */
  10810. value: any;
  10811. private _target;
  10812. private _effectiveTarget;
  10813. private _property;
  10814. /**
  10815. * Instantiate the action
  10816. * @param triggerOptions defines the trigger options
  10817. * @param target defines the object containing the property
  10818. * @param propertyPath defines the path of the property to set in the target
  10819. * @param value defines the value to set in the property
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and set the targetted property to the desired value.
  10827. */
  10828. execute(): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. /**
  10837. * This defines an action responsible to increment the target value
  10838. * to a desired value once triggered.
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10840. */
  10841. export class IncrementValueAction extends Action {
  10842. /**
  10843. * The path of the property to increment in the target.
  10844. */
  10845. propertyPath: string;
  10846. /**
  10847. * The value we should increment the property by.
  10848. */
  10849. value: any;
  10850. private _target;
  10851. private _effectiveTarget;
  10852. private _property;
  10853. /**
  10854. * Instantiate the action
  10855. * @param triggerOptions defines the trigger options
  10856. * @param target defines the object containing the property
  10857. * @param propertyPath defines the path of the property to increment in the target
  10858. * @param value defines the value value we should increment the property by
  10859. * @param condition defines the trigger related conditions
  10860. */
  10861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10862. /** @hidden */
  10863. _prepare(): void;
  10864. /**
  10865. * Execute the action and increment the target of the value amount.
  10866. */
  10867. execute(): void;
  10868. /**
  10869. * Serializes the actions and its related information.
  10870. * @param parent defines the object to serialize in
  10871. * @returns the serialized object
  10872. */
  10873. serialize(parent: any): any;
  10874. }
  10875. /**
  10876. * This defines an action responsible to start an animation once triggered.
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10878. */
  10879. export class PlayAnimationAction extends Action {
  10880. /**
  10881. * Where the animation should start (animation frame)
  10882. */
  10883. from: number;
  10884. /**
  10885. * Where the animation should stop (animation frame)
  10886. */
  10887. to: number;
  10888. /**
  10889. * Define if the animation should loop or stop after the first play.
  10890. */
  10891. loop?: boolean;
  10892. private _target;
  10893. /**
  10894. * Instantiate the action
  10895. * @param triggerOptions defines the trigger options
  10896. * @param target defines the target animation or animation name
  10897. * @param from defines from where the animation should start (animation frame)
  10898. * @param end defines where the animation should stop (animation frame)
  10899. * @param loop defines if the animation should loop or stop after the first play
  10900. * @param condition defines the trigger related conditions
  10901. */
  10902. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10903. /** @hidden */
  10904. _prepare(): void;
  10905. /**
  10906. * Execute the action and play the animation.
  10907. */
  10908. execute(): void;
  10909. /**
  10910. * Serializes the actions and its related information.
  10911. * @param parent defines the object to serialize in
  10912. * @returns the serialized object
  10913. */
  10914. serialize(parent: any): any;
  10915. }
  10916. /**
  10917. * This defines an action responsible to stop an animation once triggered.
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10919. */
  10920. export class StopAnimationAction extends Action {
  10921. private _target;
  10922. /**
  10923. * Instantiate the action
  10924. * @param triggerOptions defines the trigger options
  10925. * @param target defines the target animation or animation name
  10926. * @param condition defines the trigger related conditions
  10927. */
  10928. constructor(triggerOptions: any, target: any, condition?: Condition);
  10929. /** @hidden */
  10930. _prepare(): void;
  10931. /**
  10932. * Execute the action and stop the animation.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible that does nothing once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class DoNothingAction extends Action {
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param condition defines the trigger related conditions
  10951. */
  10952. constructor(triggerOptions?: any, condition?: Condition);
  10953. /**
  10954. * Execute the action and do nothing.
  10955. */
  10956. execute(): void;
  10957. /**
  10958. * Serializes the actions and its related information.
  10959. * @param parent defines the object to serialize in
  10960. * @returns the serialized object
  10961. */
  10962. serialize(parent: any): any;
  10963. }
  10964. /**
  10965. * This defines an action responsible to trigger several actions once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class CombineAction extends Action {
  10969. /**
  10970. * The list of aggregated animations to run.
  10971. */
  10972. children: Action[];
  10973. /**
  10974. * Instantiate the action
  10975. * @param triggerOptions defines the trigger options
  10976. * @param children defines the list of aggregated animations to run
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10980. /** @hidden */
  10981. _prepare(): void;
  10982. /**
  10983. * Execute the action and executes all the aggregated actions.
  10984. */
  10985. execute(evt: ActionEvent): void;
  10986. /**
  10987. * Serializes the actions and its related information.
  10988. * @param parent defines the object to serialize in
  10989. * @returns the serialized object
  10990. */
  10991. serialize(parent: any): any;
  10992. }
  10993. /**
  10994. * This defines an action responsible to run code (external event) once triggered.
  10995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10996. */
  10997. export class ExecuteCodeAction extends Action {
  10998. /**
  10999. * The callback function to run.
  11000. */
  11001. func: (evt: ActionEvent) => void;
  11002. /**
  11003. * Instantiate the action
  11004. * @param triggerOptions defines the trigger options
  11005. * @param func defines the callback function to run
  11006. * @param condition defines the trigger related conditions
  11007. */
  11008. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11009. /**
  11010. * Execute the action and run the attached code.
  11011. */
  11012. execute(evt: ActionEvent): void;
  11013. }
  11014. /**
  11015. * This defines an action responsible to set the parent property of the target once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class SetParentAction extends Action {
  11019. private _parent;
  11020. private _target;
  11021. /**
  11022. * Instantiate the action
  11023. * @param triggerOptions defines the trigger options
  11024. * @param target defines the target containing the parent property
  11025. * @param parent defines from where the animation should start (animation frame)
  11026. * @param condition defines the trigger related conditions
  11027. */
  11028. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11029. /** @hidden */
  11030. _prepare(): void;
  11031. /**
  11032. * Execute the action and set the parent property.
  11033. */
  11034. execute(): void;
  11035. /**
  11036. * Serializes the actions and its related information.
  11037. * @param parent defines the object to serialize in
  11038. * @returns the serialized object
  11039. */
  11040. serialize(parent: any): any;
  11041. }
  11042. }
  11043. declare module "babylonjs/Actions/actionManager" {
  11044. import { Nullable } from "babylonjs/types";
  11045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11046. import { Scene } from "babylonjs/scene";
  11047. import { IAction } from "babylonjs/Actions/action";
  11048. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11049. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11050. /**
  11051. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11052. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11054. */
  11055. export class ActionManager extends AbstractActionManager {
  11056. /**
  11057. * Nothing
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11059. */
  11060. static readonly NothingTrigger: number;
  11061. /**
  11062. * On pick
  11063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11064. */
  11065. static readonly OnPickTrigger: number;
  11066. /**
  11067. * On left pick
  11068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11069. */
  11070. static readonly OnLeftPickTrigger: number;
  11071. /**
  11072. * On right pick
  11073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11074. */
  11075. static readonly OnRightPickTrigger: number;
  11076. /**
  11077. * On center pick
  11078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11079. */
  11080. static readonly OnCenterPickTrigger: number;
  11081. /**
  11082. * On pick down
  11083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11084. */
  11085. static readonly OnPickDownTrigger: number;
  11086. /**
  11087. * On double pick
  11088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11089. */
  11090. static readonly OnDoublePickTrigger: number;
  11091. /**
  11092. * On pick up
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11094. */
  11095. static readonly OnPickUpTrigger: number;
  11096. /**
  11097. * On pick out.
  11098. * This trigger will only be raised if you also declared a OnPickDown
  11099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11100. */
  11101. static readonly OnPickOutTrigger: number;
  11102. /**
  11103. * On long press
  11104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11105. */
  11106. static readonly OnLongPressTrigger: number;
  11107. /**
  11108. * On pointer over
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11110. */
  11111. static readonly OnPointerOverTrigger: number;
  11112. /**
  11113. * On pointer out
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11115. */
  11116. static readonly OnPointerOutTrigger: number;
  11117. /**
  11118. * On every frame
  11119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11120. */
  11121. static readonly OnEveryFrameTrigger: number;
  11122. /**
  11123. * On intersection enter
  11124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11125. */
  11126. static readonly OnIntersectionEnterTrigger: number;
  11127. /**
  11128. * On intersection exit
  11129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11130. */
  11131. static readonly OnIntersectionExitTrigger: number;
  11132. /**
  11133. * On key down
  11134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11135. */
  11136. static readonly OnKeyDownTrigger: number;
  11137. /**
  11138. * On key up
  11139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11140. */
  11141. static readonly OnKeyUpTrigger: number;
  11142. private _scene;
  11143. /**
  11144. * Creates a new action manager
  11145. * @param scene defines the hosting scene
  11146. */
  11147. constructor(scene: Scene);
  11148. /**
  11149. * Releases all associated resources
  11150. */
  11151. dispose(): void;
  11152. /**
  11153. * Gets hosting scene
  11154. * @returns the hosting scene
  11155. */
  11156. getScene(): Scene;
  11157. /**
  11158. * Does this action manager handles actions of any of the given triggers
  11159. * @param triggers defines the triggers to be tested
  11160. * @return a boolean indicating whether one (or more) of the triggers is handled
  11161. */
  11162. hasSpecificTriggers(triggers: number[]): boolean;
  11163. /**
  11164. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11165. * speed.
  11166. * @param triggerA defines the trigger to be tested
  11167. * @param triggerB defines the trigger to be tested
  11168. * @return a boolean indicating whether one (or more) of the triggers is handled
  11169. */
  11170. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11171. /**
  11172. * Does this action manager handles actions of a given trigger
  11173. * @param trigger defines the trigger to be tested
  11174. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11175. * @return whether the trigger is handled
  11176. */
  11177. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11178. /**
  11179. * Does this action manager has pointer triggers
  11180. */
  11181. readonly hasPointerTriggers: boolean;
  11182. /**
  11183. * Does this action manager has pick triggers
  11184. */
  11185. readonly hasPickTriggers: boolean;
  11186. /**
  11187. * Registers an action to this action manager
  11188. * @param action defines the action to be registered
  11189. * @return the action amended (prepared) after registration
  11190. */
  11191. registerAction(action: IAction): Nullable<IAction>;
  11192. /**
  11193. * Unregisters an action to this action manager
  11194. * @param action defines the action to be unregistered
  11195. * @return a boolean indicating whether the action has been unregistered
  11196. */
  11197. unregisterAction(action: IAction): Boolean;
  11198. /**
  11199. * Process a specific trigger
  11200. * @param trigger defines the trigger to process
  11201. * @param evt defines the event details to be processed
  11202. */
  11203. processTrigger(trigger: number, evt?: IActionEvent): void;
  11204. /** @hidden */
  11205. _getEffectiveTarget(target: any, propertyPath: string): any;
  11206. /** @hidden */
  11207. _getProperty(propertyPath: string): string;
  11208. /**
  11209. * Serialize this manager to a JSON object
  11210. * @param name defines the property name to store this manager
  11211. * @returns a JSON representation of this manager
  11212. */
  11213. serialize(name: string): any;
  11214. /**
  11215. * Creates a new ActionManager from a JSON data
  11216. * @param parsedActions defines the JSON data to read from
  11217. * @param object defines the hosting mesh
  11218. * @param scene defines the hosting scene
  11219. */
  11220. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11221. /**
  11222. * Get a trigger name by index
  11223. * @param trigger defines the trigger index
  11224. * @returns a trigger name
  11225. */
  11226. static GetTriggerName(trigger: number): string;
  11227. }
  11228. }
  11229. declare module "babylonjs/Culling/ray" {
  11230. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11231. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11233. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11234. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11235. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11236. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11237. import { Plane } from "babylonjs/Maths/math.plane";
  11238. /**
  11239. * Class representing a ray with position and direction
  11240. */
  11241. export class Ray {
  11242. /** origin point */
  11243. origin: Vector3;
  11244. /** direction */
  11245. direction: Vector3;
  11246. /** length of the ray */
  11247. length: number;
  11248. private static readonly TmpVector3;
  11249. private _tmpRay;
  11250. /**
  11251. * Creates a new ray
  11252. * @param origin origin point
  11253. * @param direction direction
  11254. * @param length length of the ray
  11255. */
  11256. constructor(
  11257. /** origin point */
  11258. origin: Vector3,
  11259. /** direction */
  11260. direction: Vector3,
  11261. /** length of the ray */
  11262. length?: number);
  11263. /**
  11264. * Checks if the ray intersects a box
  11265. * @param minimum bound of the box
  11266. * @param maximum bound of the box
  11267. * @param intersectionTreshold extra extend to be added to the box in all direction
  11268. * @returns if the box was hit
  11269. */
  11270. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11271. /**
  11272. * Checks if the ray intersects a box
  11273. * @param box the bounding box to check
  11274. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11275. * @returns if the box was hit
  11276. */
  11277. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11278. /**
  11279. * If the ray hits a sphere
  11280. * @param sphere the bounding sphere to check
  11281. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11282. * @returns true if it hits the sphere
  11283. */
  11284. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11285. /**
  11286. * If the ray hits a triange
  11287. * @param vertex0 triangle vertex
  11288. * @param vertex1 triangle vertex
  11289. * @param vertex2 triangle vertex
  11290. * @returns intersection information if hit
  11291. */
  11292. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11293. /**
  11294. * Checks if ray intersects a plane
  11295. * @param plane the plane to check
  11296. * @returns the distance away it was hit
  11297. */
  11298. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11299. /**
  11300. * Calculate the intercept of a ray on a given axis
  11301. * @param axis to check 'x' | 'y' | 'z'
  11302. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11303. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11304. */
  11305. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11306. /**
  11307. * Checks if ray intersects a mesh
  11308. * @param mesh the mesh to check
  11309. * @param fastCheck if only the bounding box should checked
  11310. * @returns picking info of the intersecton
  11311. */
  11312. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11313. /**
  11314. * Checks if ray intersects a mesh
  11315. * @param meshes the meshes to check
  11316. * @param fastCheck if only the bounding box should checked
  11317. * @param results array to store result in
  11318. * @returns Array of picking infos
  11319. */
  11320. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11321. private _comparePickingInfo;
  11322. private static smallnum;
  11323. private static rayl;
  11324. /**
  11325. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11326. * @param sega the first point of the segment to test the intersection against
  11327. * @param segb the second point of the segment to test the intersection against
  11328. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11329. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11330. */
  11331. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11332. /**
  11333. * Update the ray from viewport position
  11334. * @param x position
  11335. * @param y y position
  11336. * @param viewportWidth viewport width
  11337. * @param viewportHeight viewport height
  11338. * @param world world matrix
  11339. * @param view view matrix
  11340. * @param projection projection matrix
  11341. * @returns this ray updated
  11342. */
  11343. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11344. /**
  11345. * Creates a ray with origin and direction of 0,0,0
  11346. * @returns the new ray
  11347. */
  11348. static Zero(): Ray;
  11349. /**
  11350. * Creates a new ray from screen space and viewport
  11351. * @param x position
  11352. * @param y y position
  11353. * @param viewportWidth viewport width
  11354. * @param viewportHeight viewport height
  11355. * @param world world matrix
  11356. * @param view view matrix
  11357. * @param projection projection matrix
  11358. * @returns new ray
  11359. */
  11360. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11361. /**
  11362. * 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
  11363. * transformed to the given world matrix.
  11364. * @param origin The origin point
  11365. * @param end The end point
  11366. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11367. * @returns the new ray
  11368. */
  11369. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11370. /**
  11371. * Transforms a ray by a matrix
  11372. * @param ray ray to transform
  11373. * @param matrix matrix to apply
  11374. * @returns the resulting new ray
  11375. */
  11376. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11377. /**
  11378. * Transforms a ray by a matrix
  11379. * @param ray ray to transform
  11380. * @param matrix matrix to apply
  11381. * @param result ray to store result in
  11382. */
  11383. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11384. /**
  11385. * Unproject a ray from screen space to object space
  11386. * @param sourceX defines the screen space x coordinate to use
  11387. * @param sourceY defines the screen space y coordinate to use
  11388. * @param viewportWidth defines the current width of the viewport
  11389. * @param viewportHeight defines the current height of the viewport
  11390. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11391. * @param view defines the view matrix to use
  11392. * @param projection defines the projection matrix to use
  11393. */
  11394. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11395. }
  11396. /**
  11397. * Type used to define predicate used to select faces when a mesh intersection is detected
  11398. */
  11399. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11400. module "babylonjs/scene" {
  11401. interface Scene {
  11402. /** @hidden */
  11403. _tempPickingRay: Nullable<Ray>;
  11404. /** @hidden */
  11405. _cachedRayForTransform: Ray;
  11406. /** @hidden */
  11407. _pickWithRayInverseMatrix: Matrix;
  11408. /** @hidden */
  11409. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11410. /** @hidden */
  11411. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11412. }
  11413. }
  11414. }
  11415. declare module "babylonjs/sceneComponent" {
  11416. import { Scene } from "babylonjs/scene";
  11417. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11418. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11419. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11420. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11421. import { Nullable } from "babylonjs/types";
  11422. import { Camera } from "babylonjs/Cameras/camera";
  11423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11424. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11425. import { AbstractScene } from "babylonjs/abstractScene";
  11426. import { Mesh } from "babylonjs/Meshes/mesh";
  11427. /**
  11428. * Groups all the scene component constants in one place to ease maintenance.
  11429. * @hidden
  11430. */
  11431. export class SceneComponentConstants {
  11432. static readonly NAME_EFFECTLAYER: string;
  11433. static readonly NAME_LAYER: string;
  11434. static readonly NAME_LENSFLARESYSTEM: string;
  11435. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11436. static readonly NAME_PARTICLESYSTEM: string;
  11437. static readonly NAME_GAMEPAD: string;
  11438. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11439. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11440. static readonly NAME_DEPTHRENDERER: string;
  11441. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11442. static readonly NAME_SPRITE: string;
  11443. static readonly NAME_OUTLINERENDERER: string;
  11444. static readonly NAME_PROCEDURALTEXTURE: string;
  11445. static readonly NAME_SHADOWGENERATOR: string;
  11446. static readonly NAME_OCTREE: string;
  11447. static readonly NAME_PHYSICSENGINE: string;
  11448. static readonly NAME_AUDIO: string;
  11449. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11450. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11451. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11452. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11453. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11454. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11455. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11456. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11457. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11458. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11459. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11460. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11461. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11462. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11463. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11464. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11465. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11466. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11467. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11468. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11469. static readonly STEP_AFTERRENDER_AUDIO: number;
  11470. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11471. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11472. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11473. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11474. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11475. static readonly STEP_POINTERMOVE_SPRITE: number;
  11476. static readonly STEP_POINTERDOWN_SPRITE: number;
  11477. static readonly STEP_POINTERUP_SPRITE: number;
  11478. }
  11479. /**
  11480. * This represents a scene component.
  11481. *
  11482. * This is used to decouple the dependency the scene is having on the different workloads like
  11483. * layers, post processes...
  11484. */
  11485. export interface ISceneComponent {
  11486. /**
  11487. * The name of the component. Each component must have a unique name.
  11488. */
  11489. name: string;
  11490. /**
  11491. * The scene the component belongs to.
  11492. */
  11493. scene: Scene;
  11494. /**
  11495. * Register the component to one instance of a scene.
  11496. */
  11497. register(): void;
  11498. /**
  11499. * Rebuilds the elements related to this component in case of
  11500. * context lost for instance.
  11501. */
  11502. rebuild(): void;
  11503. /**
  11504. * Disposes the component and the associated ressources.
  11505. */
  11506. dispose(): void;
  11507. }
  11508. /**
  11509. * This represents a SERIALIZABLE scene component.
  11510. *
  11511. * This extends Scene Component to add Serialization methods on top.
  11512. */
  11513. export interface ISceneSerializableComponent extends ISceneComponent {
  11514. /**
  11515. * Adds all the elements from the container to the scene
  11516. * @param container the container holding the elements
  11517. */
  11518. addFromContainer(container: AbstractScene): void;
  11519. /**
  11520. * Removes all the elements in the container from the scene
  11521. * @param container contains the elements to remove
  11522. * @param dispose if the removed element should be disposed (default: false)
  11523. */
  11524. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11525. /**
  11526. * Serializes the component data to the specified json object
  11527. * @param serializationObject The object to serialize to
  11528. */
  11529. serialize(serializationObject: any): void;
  11530. }
  11531. /**
  11532. * Strong typing of a Mesh related stage step action
  11533. */
  11534. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11535. /**
  11536. * Strong typing of a Evaluate Sub Mesh related stage step action
  11537. */
  11538. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11539. /**
  11540. * Strong typing of a Active Mesh related stage step action
  11541. */
  11542. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11543. /**
  11544. * Strong typing of a Camera related stage step action
  11545. */
  11546. export type CameraStageAction = (camera: Camera) => void;
  11547. /**
  11548. * Strong typing of a Camera Frame buffer related stage step action
  11549. */
  11550. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11551. /**
  11552. * Strong typing of a Render Target related stage step action
  11553. */
  11554. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11555. /**
  11556. * Strong typing of a RenderingGroup related stage step action
  11557. */
  11558. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11559. /**
  11560. * Strong typing of a Mesh Render related stage step action
  11561. */
  11562. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11563. /**
  11564. * Strong typing of a simple stage step action
  11565. */
  11566. export type SimpleStageAction = () => void;
  11567. /**
  11568. * Strong typing of a render target action.
  11569. */
  11570. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11571. /**
  11572. * Strong typing of a pointer move action.
  11573. */
  11574. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11575. /**
  11576. * Strong typing of a pointer up/down action.
  11577. */
  11578. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11579. /**
  11580. * Representation of a stage in the scene (Basically a list of ordered steps)
  11581. * @hidden
  11582. */
  11583. export class Stage<T extends Function> extends Array<{
  11584. index: number;
  11585. component: ISceneComponent;
  11586. action: T;
  11587. }> {
  11588. /**
  11589. * Hide ctor from the rest of the world.
  11590. * @param items The items to add.
  11591. */
  11592. private constructor();
  11593. /**
  11594. * Creates a new Stage.
  11595. * @returns A new instance of a Stage
  11596. */
  11597. static Create<T extends Function>(): Stage<T>;
  11598. /**
  11599. * Registers a step in an ordered way in the targeted stage.
  11600. * @param index Defines the position to register the step in
  11601. * @param component Defines the component attached to the step
  11602. * @param action Defines the action to launch during the step
  11603. */
  11604. registerStep(index: number, component: ISceneComponent, action: T): void;
  11605. /**
  11606. * Clears all the steps from the stage.
  11607. */
  11608. clear(): void;
  11609. }
  11610. }
  11611. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11612. import { Nullable } from "babylonjs/types";
  11613. import { Observable } from "babylonjs/Misc/observable";
  11614. import { Scene } from "babylonjs/scene";
  11615. import { Sprite } from "babylonjs/Sprites/sprite";
  11616. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11617. import { Ray } from "babylonjs/Culling/ray";
  11618. import { Camera } from "babylonjs/Cameras/camera";
  11619. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11620. import { ISceneComponent } from "babylonjs/sceneComponent";
  11621. module "babylonjs/scene" {
  11622. interface Scene {
  11623. /** @hidden */
  11624. _pointerOverSprite: Nullable<Sprite>;
  11625. /** @hidden */
  11626. _pickedDownSprite: Nullable<Sprite>;
  11627. /** @hidden */
  11628. _tempSpritePickingRay: Nullable<Ray>;
  11629. /**
  11630. * All of the sprite managers added to this scene
  11631. * @see http://doc.babylonjs.com/babylon101/sprites
  11632. */
  11633. spriteManagers: Array<ISpriteManager>;
  11634. /**
  11635. * An event triggered when sprites rendering is about to start
  11636. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11637. */
  11638. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11639. /**
  11640. * An event triggered when sprites rendering is done
  11641. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11642. */
  11643. onAfterSpritesRenderingObservable: Observable<Scene>;
  11644. /** @hidden */
  11645. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11646. /** Launch a ray to try to pick a sprite in the scene
  11647. * @param x position on screen
  11648. * @param y position on screen
  11649. * @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
  11650. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11651. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11652. * @returns a PickingInfo
  11653. */
  11654. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11655. /** Use the given ray to pick a sprite in the scene
  11656. * @param ray The ray (in world space) to use to pick meshes
  11657. * @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
  11658. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11659. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11660. * @returns a PickingInfo
  11661. */
  11662. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11663. /** @hidden */
  11664. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11665. /** Launch a ray to try to pick sprites in the scene
  11666. * @param x position on screen
  11667. * @param y position on screen
  11668. * @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
  11669. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11670. * @returns a PickingInfo array
  11671. */
  11672. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11673. /** Use the given ray to pick sprites in the scene
  11674. * @param ray The ray (in world space) to use to pick meshes
  11675. * @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
  11676. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11677. * @returns a PickingInfo array
  11678. */
  11679. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11680. /**
  11681. * Force the sprite under the pointer
  11682. * @param sprite defines the sprite to use
  11683. */
  11684. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11685. /**
  11686. * Gets the sprite under the pointer
  11687. * @returns a Sprite or null if no sprite is under the pointer
  11688. */
  11689. getPointerOverSprite(): Nullable<Sprite>;
  11690. }
  11691. }
  11692. /**
  11693. * Defines the sprite scene component responsible to manage sprites
  11694. * in a given scene.
  11695. */
  11696. export class SpriteSceneComponent implements ISceneComponent {
  11697. /**
  11698. * The component name helpfull to identify the component in the list of scene components.
  11699. */
  11700. readonly name: string;
  11701. /**
  11702. * The scene the component belongs to.
  11703. */
  11704. scene: Scene;
  11705. /** @hidden */
  11706. private _spritePredicate;
  11707. /**
  11708. * Creates a new instance of the component for the given scene
  11709. * @param scene Defines the scene to register the component in
  11710. */
  11711. constructor(scene: Scene);
  11712. /**
  11713. * Registers the component in a given scene
  11714. */
  11715. register(): void;
  11716. /**
  11717. * Rebuilds the elements related to this component in case of
  11718. * context lost for instance.
  11719. */
  11720. rebuild(): void;
  11721. /**
  11722. * Disposes the component and the associated ressources.
  11723. */
  11724. dispose(): void;
  11725. private _pickSpriteButKeepRay;
  11726. private _pointerMove;
  11727. private _pointerDown;
  11728. private _pointerUp;
  11729. }
  11730. }
  11731. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11732. /** @hidden */
  11733. export var fogFragmentDeclaration: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11739. /** @hidden */
  11740. export var fogFragment: {
  11741. name: string;
  11742. shader: string;
  11743. };
  11744. }
  11745. declare module "babylonjs/Shaders/sprites.fragment" {
  11746. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11747. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11748. /** @hidden */
  11749. export var spritesPixelShader: {
  11750. name: string;
  11751. shader: string;
  11752. };
  11753. }
  11754. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11755. /** @hidden */
  11756. export var fogVertexDeclaration: {
  11757. name: string;
  11758. shader: string;
  11759. };
  11760. }
  11761. declare module "babylonjs/Shaders/sprites.vertex" {
  11762. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11763. /** @hidden */
  11764. export var spritesVertexShader: {
  11765. name: string;
  11766. shader: string;
  11767. };
  11768. }
  11769. declare module "babylonjs/Sprites/spriteManager" {
  11770. import { IDisposable, Scene } from "babylonjs/scene";
  11771. import { Nullable } from "babylonjs/types";
  11772. import { Observable } from "babylonjs/Misc/observable";
  11773. import { Sprite } from "babylonjs/Sprites/sprite";
  11774. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11775. import { Camera } from "babylonjs/Cameras/camera";
  11776. import { Texture } from "babylonjs/Materials/Textures/texture";
  11777. import "babylonjs/Shaders/sprites.fragment";
  11778. import "babylonjs/Shaders/sprites.vertex";
  11779. import { Ray } from "babylonjs/Culling/ray";
  11780. /**
  11781. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11782. */
  11783. export interface ISpriteManager extends IDisposable {
  11784. /**
  11785. * Restricts the camera to viewing objects with the same layerMask.
  11786. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11787. */
  11788. layerMask: number;
  11789. /**
  11790. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11791. */
  11792. isPickable: boolean;
  11793. /**
  11794. * Specifies the rendering group id for this mesh (0 by default)
  11795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11796. */
  11797. renderingGroupId: number;
  11798. /**
  11799. * Defines the list of sprites managed by the manager.
  11800. */
  11801. sprites: Array<Sprite>;
  11802. /**
  11803. * Tests the intersection of a sprite with a specific ray.
  11804. * @param ray The ray we are sending to test the collision
  11805. * @param camera The camera space we are sending rays in
  11806. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11807. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11808. * @returns picking info or null.
  11809. */
  11810. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11811. /**
  11812. * Intersects the sprites with a ray
  11813. * @param ray defines the ray to intersect with
  11814. * @param camera defines the current active camera
  11815. * @param predicate defines a predicate used to select candidate sprites
  11816. * @returns null if no hit or a PickingInfo array
  11817. */
  11818. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11819. /**
  11820. * Renders the list of sprites on screen.
  11821. */
  11822. render(): void;
  11823. }
  11824. /**
  11825. * Class used to manage multiple sprites on the same spritesheet
  11826. * @see http://doc.babylonjs.com/babylon101/sprites
  11827. */
  11828. export class SpriteManager implements ISpriteManager {
  11829. /** defines the manager's name */
  11830. name: string;
  11831. /** Gets the list of sprites */
  11832. sprites: Sprite[];
  11833. /** Gets or sets the rendering group id (0 by default) */
  11834. renderingGroupId: number;
  11835. /** Gets or sets camera layer mask */
  11836. layerMask: number;
  11837. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11838. fogEnabled: boolean;
  11839. /** Gets or sets a boolean indicating if the sprites are pickable */
  11840. isPickable: boolean;
  11841. /** Defines the default width of a cell in the spritesheet */
  11842. cellWidth: number;
  11843. /** Defines the default height of a cell in the spritesheet */
  11844. cellHeight: number;
  11845. /** Associative array from JSON sprite data file */
  11846. private _cellData;
  11847. /** Array of sprite names from JSON sprite data file */
  11848. private _spriteMap;
  11849. /** True when packed cell data from JSON file is ready*/
  11850. private _packedAndReady;
  11851. /**
  11852. * An event triggered when the manager is disposed.
  11853. */
  11854. onDisposeObservable: Observable<SpriteManager>;
  11855. private _onDisposeObserver;
  11856. /**
  11857. * Callback called when the manager is disposed
  11858. */
  11859. onDispose: () => void;
  11860. private _capacity;
  11861. private _fromPacked;
  11862. private _spriteTexture;
  11863. private _epsilon;
  11864. private _scene;
  11865. private _vertexData;
  11866. private _buffer;
  11867. private _vertexBuffers;
  11868. private _indexBuffer;
  11869. private _effectBase;
  11870. private _effectFog;
  11871. /**
  11872. * Gets or sets the spritesheet texture
  11873. */
  11874. texture: Texture;
  11875. /**
  11876. * Creates a new sprite manager
  11877. * @param name defines the manager's name
  11878. * @param imgUrl defines the sprite sheet url
  11879. * @param capacity defines the maximum allowed number of sprites
  11880. * @param cellSize defines the size of a sprite cell
  11881. * @param scene defines the hosting scene
  11882. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11883. * @param samplingMode defines the smapling mode to use with spritesheet
  11884. * @param fromPacked set to false; do not alter
  11885. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11886. */
  11887. constructor(
  11888. /** defines the manager's name */
  11889. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11890. private _makePacked;
  11891. private _appendSpriteVertex;
  11892. /**
  11893. * Intersects the sprites with a ray
  11894. * @param ray defines the ray to intersect with
  11895. * @param camera defines the current active camera
  11896. * @param predicate defines a predicate used to select candidate sprites
  11897. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11898. * @returns null if no hit or a PickingInfo
  11899. */
  11900. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11901. /**
  11902. * Intersects the sprites with a ray
  11903. * @param ray defines the ray to intersect with
  11904. * @param camera defines the current active camera
  11905. * @param predicate defines a predicate used to select candidate sprites
  11906. * @returns null if no hit or a PickingInfo array
  11907. */
  11908. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11909. /**
  11910. * Render all child sprites
  11911. */
  11912. render(): void;
  11913. /**
  11914. * Release associated resources
  11915. */
  11916. dispose(): void;
  11917. }
  11918. }
  11919. declare module "babylonjs/Sprites/sprite" {
  11920. import { Vector3 } from "babylonjs/Maths/math.vector";
  11921. import { Nullable } from "babylonjs/types";
  11922. import { ActionManager } from "babylonjs/Actions/actionManager";
  11923. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11924. import { Color4 } from "babylonjs/Maths/math.color";
  11925. /**
  11926. * Class used to represent a sprite
  11927. * @see http://doc.babylonjs.com/babylon101/sprites
  11928. */
  11929. export class Sprite {
  11930. /** defines the name */
  11931. name: string;
  11932. /** Gets or sets the current world position */
  11933. position: Vector3;
  11934. /** Gets or sets the main color */
  11935. color: Color4;
  11936. /** Gets or sets the width */
  11937. width: number;
  11938. /** Gets or sets the height */
  11939. height: number;
  11940. /** Gets or sets rotation angle */
  11941. angle: number;
  11942. /** Gets or sets the cell index in the sprite sheet */
  11943. cellIndex: number;
  11944. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11945. cellRef: string;
  11946. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11947. invertU: number;
  11948. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11949. invertV: number;
  11950. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11951. disposeWhenFinishedAnimating: boolean;
  11952. /** Gets the list of attached animations */
  11953. animations: Animation[];
  11954. /** Gets or sets a boolean indicating if the sprite can be picked */
  11955. isPickable: boolean;
  11956. /**
  11957. * Gets or sets the associated action manager
  11958. */
  11959. actionManager: Nullable<ActionManager>;
  11960. private _animationStarted;
  11961. private _loopAnimation;
  11962. private _fromIndex;
  11963. private _toIndex;
  11964. private _delay;
  11965. private _direction;
  11966. private _manager;
  11967. private _time;
  11968. private _onAnimationEnd;
  11969. /**
  11970. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11971. */
  11972. isVisible: boolean;
  11973. /**
  11974. * Gets or sets the sprite size
  11975. */
  11976. size: number;
  11977. /**
  11978. * Creates a new Sprite
  11979. * @param name defines the name
  11980. * @param manager defines the manager
  11981. */
  11982. constructor(
  11983. /** defines the name */
  11984. name: string, manager: ISpriteManager);
  11985. /**
  11986. * Starts an animation
  11987. * @param from defines the initial key
  11988. * @param to defines the end key
  11989. * @param loop defines if the animation must loop
  11990. * @param delay defines the start delay (in ms)
  11991. * @param onAnimationEnd defines a callback to call when animation ends
  11992. */
  11993. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11994. /** Stops current animation (if any) */
  11995. stopAnimation(): void;
  11996. /** @hidden */
  11997. _animate(deltaTime: number): void;
  11998. /** Release associated resources */
  11999. dispose(): void;
  12000. }
  12001. }
  12002. declare module "babylonjs/Collisions/pickingInfo" {
  12003. import { Nullable } from "babylonjs/types";
  12004. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12006. import { Sprite } from "babylonjs/Sprites/sprite";
  12007. import { Ray } from "babylonjs/Culling/ray";
  12008. /**
  12009. * Information about the result of picking within a scene
  12010. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12011. */
  12012. export class PickingInfo {
  12013. /** @hidden */
  12014. _pickingUnavailable: boolean;
  12015. /**
  12016. * If the pick collided with an object
  12017. */
  12018. hit: boolean;
  12019. /**
  12020. * Distance away where the pick collided
  12021. */
  12022. distance: number;
  12023. /**
  12024. * The location of pick collision
  12025. */
  12026. pickedPoint: Nullable<Vector3>;
  12027. /**
  12028. * The mesh corresponding the the pick collision
  12029. */
  12030. pickedMesh: Nullable<AbstractMesh>;
  12031. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12032. bu: number;
  12033. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12034. bv: number;
  12035. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12036. faceId: number;
  12037. /** Id of the the submesh that was picked */
  12038. subMeshId: number;
  12039. /** If a sprite was picked, this will be the sprite the pick collided with */
  12040. pickedSprite: Nullable<Sprite>;
  12041. /**
  12042. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12043. */
  12044. originMesh: Nullable<AbstractMesh>;
  12045. /**
  12046. * The ray that was used to perform the picking.
  12047. */
  12048. ray: Nullable<Ray>;
  12049. /**
  12050. * Gets the normal correspodning to the face the pick collided with
  12051. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12052. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12053. * @returns The normal correspodning to the face the pick collided with
  12054. */
  12055. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12056. /**
  12057. * Gets the texture coordinates of where the pick occured
  12058. * @returns the vector containing the coordnates of the texture
  12059. */
  12060. getTextureCoordinates(): Nullable<Vector2>;
  12061. }
  12062. }
  12063. declare module "babylonjs/Events/pointerEvents" {
  12064. import { Nullable } from "babylonjs/types";
  12065. import { Vector2 } from "babylonjs/Maths/math.vector";
  12066. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12067. import { Ray } from "babylonjs/Culling/ray";
  12068. /**
  12069. * Gather the list of pointer event types as constants.
  12070. */
  12071. export class PointerEventTypes {
  12072. /**
  12073. * 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.
  12074. */
  12075. static readonly POINTERDOWN: number;
  12076. /**
  12077. * The pointerup event is fired when a pointer is no longer active.
  12078. */
  12079. static readonly POINTERUP: number;
  12080. /**
  12081. * The pointermove event is fired when a pointer changes coordinates.
  12082. */
  12083. static readonly POINTERMOVE: number;
  12084. /**
  12085. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12086. */
  12087. static readonly POINTERWHEEL: number;
  12088. /**
  12089. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12090. */
  12091. static readonly POINTERPICK: number;
  12092. /**
  12093. * The pointertap event is fired when a the object has been touched and released without drag.
  12094. */
  12095. static readonly POINTERTAP: number;
  12096. /**
  12097. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12098. */
  12099. static readonly POINTERDOUBLETAP: number;
  12100. }
  12101. /**
  12102. * Base class of pointer info types.
  12103. */
  12104. export class PointerInfoBase {
  12105. /**
  12106. * Defines the type of event (PointerEventTypes)
  12107. */
  12108. type: number;
  12109. /**
  12110. * Defines the related dom event
  12111. */
  12112. event: PointerEvent | MouseWheelEvent;
  12113. /**
  12114. * Instantiates the base class of pointers info.
  12115. * @param type Defines the type of event (PointerEventTypes)
  12116. * @param event Defines the related dom event
  12117. */
  12118. constructor(
  12119. /**
  12120. * Defines the type of event (PointerEventTypes)
  12121. */
  12122. type: number,
  12123. /**
  12124. * Defines the related dom event
  12125. */
  12126. event: PointerEvent | MouseWheelEvent);
  12127. }
  12128. /**
  12129. * This class is used to store pointer related info for the onPrePointerObservable event.
  12130. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12131. */
  12132. export class PointerInfoPre extends PointerInfoBase {
  12133. /**
  12134. * Ray from a pointer if availible (eg. 6dof controller)
  12135. */
  12136. ray: Nullable<Ray>;
  12137. /**
  12138. * Defines the local position of the pointer on the canvas.
  12139. */
  12140. localPosition: Vector2;
  12141. /**
  12142. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12143. */
  12144. skipOnPointerObservable: boolean;
  12145. /**
  12146. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12147. * @param type Defines the type of event (PointerEventTypes)
  12148. * @param event Defines the related dom event
  12149. * @param localX Defines the local x coordinates of the pointer when the event occured
  12150. * @param localY Defines the local y coordinates of the pointer when the event occured
  12151. */
  12152. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12153. }
  12154. /**
  12155. * This type contains all the data related to a pointer event in Babylon.js.
  12156. * 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.
  12157. */
  12158. export class PointerInfo extends PointerInfoBase {
  12159. /**
  12160. * Defines the picking info associated to the info (if any)\
  12161. */
  12162. pickInfo: Nullable<PickingInfo>;
  12163. /**
  12164. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12165. * @param type Defines the type of event (PointerEventTypes)
  12166. * @param event Defines the related dom event
  12167. * @param pickInfo Defines the picking info associated to the info (if any)\
  12168. */
  12169. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12170. /**
  12171. * Defines the picking info associated to the info (if any)\
  12172. */
  12173. pickInfo: Nullable<PickingInfo>);
  12174. }
  12175. /**
  12176. * Data relating to a touch event on the screen.
  12177. */
  12178. export interface PointerTouch {
  12179. /**
  12180. * X coordinate of touch.
  12181. */
  12182. x: number;
  12183. /**
  12184. * Y coordinate of touch.
  12185. */
  12186. y: number;
  12187. /**
  12188. * Id of touch. Unique for each finger.
  12189. */
  12190. pointerId: number;
  12191. /**
  12192. * Event type passed from DOM.
  12193. */
  12194. type: any;
  12195. }
  12196. }
  12197. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12198. import { Observable } from "babylonjs/Misc/observable";
  12199. import { Nullable } from "babylonjs/types";
  12200. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12201. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12202. /**
  12203. * Manage the mouse inputs to control the movement of a free camera.
  12204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12205. */
  12206. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12207. /**
  12208. * Define if touch is enabled in the mouse input
  12209. */
  12210. touchEnabled: boolean;
  12211. /**
  12212. * Defines the camera the input is attached to.
  12213. */
  12214. camera: FreeCamera;
  12215. /**
  12216. * Defines the buttons associated with the input to handle camera move.
  12217. */
  12218. buttons: number[];
  12219. /**
  12220. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12221. */
  12222. angularSensibility: number;
  12223. private _pointerInput;
  12224. private _onMouseMove;
  12225. private _observer;
  12226. private previousPosition;
  12227. /**
  12228. * Observable for when a pointer move event occurs containing the move offset
  12229. */
  12230. onPointerMovedObservable: Observable<{
  12231. offsetX: number;
  12232. offsetY: number;
  12233. }>;
  12234. /**
  12235. * @hidden
  12236. * If the camera should be rotated automatically based on pointer movement
  12237. */
  12238. _allowCameraRotation: boolean;
  12239. /**
  12240. * Manage the mouse inputs to control the movement of a free camera.
  12241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12242. * @param touchEnabled Defines if touch is enabled or not
  12243. */
  12244. constructor(
  12245. /**
  12246. * Define if touch is enabled in the mouse input
  12247. */
  12248. touchEnabled?: boolean);
  12249. /**
  12250. * Attach the input controls to a specific dom element to get the input from.
  12251. * @param element Defines the element the controls should be listened from
  12252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12253. */
  12254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12255. /**
  12256. * Called on JS contextmenu event.
  12257. * Override this method to provide functionality.
  12258. */
  12259. protected onContextMenu(evt: PointerEvent): void;
  12260. /**
  12261. * Detach the current controls from the specified dom element.
  12262. * @param element Defines the element to stop listening the inputs from
  12263. */
  12264. detachControl(element: Nullable<HTMLElement>): void;
  12265. /**
  12266. * Gets the class name of the current intput.
  12267. * @returns the class name
  12268. */
  12269. getClassName(): string;
  12270. /**
  12271. * Get the friendly name associated with the input class.
  12272. * @returns the input friendly name
  12273. */
  12274. getSimpleName(): string;
  12275. }
  12276. }
  12277. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12278. import { Nullable } from "babylonjs/types";
  12279. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12280. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12281. /**
  12282. * Manage the touch inputs to control the movement of a free camera.
  12283. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12284. */
  12285. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12286. /**
  12287. * Defines the camera the input is attached to.
  12288. */
  12289. camera: FreeCamera;
  12290. /**
  12291. * Defines the touch sensibility for rotation.
  12292. * The higher the faster.
  12293. */
  12294. touchAngularSensibility: number;
  12295. /**
  12296. * Defines the touch sensibility for move.
  12297. * The higher the faster.
  12298. */
  12299. touchMoveSensibility: number;
  12300. private _offsetX;
  12301. private _offsetY;
  12302. private _pointerPressed;
  12303. private _pointerInput;
  12304. private _observer;
  12305. private _onLostFocus;
  12306. /**
  12307. * Attach the input controls to a specific dom element to get the input from.
  12308. * @param element Defines the element the controls should be listened from
  12309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12310. */
  12311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12312. /**
  12313. * Detach the current controls from the specified dom element.
  12314. * @param element Defines the element to stop listening the inputs from
  12315. */
  12316. detachControl(element: Nullable<HTMLElement>): void;
  12317. /**
  12318. * Update the current camera state depending on the inputs that have been used this frame.
  12319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12320. */
  12321. checkInputs(): void;
  12322. /**
  12323. * Gets the class name of the current intput.
  12324. * @returns the class name
  12325. */
  12326. getClassName(): string;
  12327. /**
  12328. * Get the friendly name associated with the input class.
  12329. * @returns the input friendly name
  12330. */
  12331. getSimpleName(): string;
  12332. }
  12333. }
  12334. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12335. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12336. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12337. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12338. import { Nullable } from "babylonjs/types";
  12339. /**
  12340. * Default Inputs manager for the FreeCamera.
  12341. * It groups all the default supported inputs for ease of use.
  12342. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12343. */
  12344. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12345. /**
  12346. * @hidden
  12347. */
  12348. _mouseInput: Nullable<FreeCameraMouseInput>;
  12349. /**
  12350. * Instantiates a new FreeCameraInputsManager.
  12351. * @param camera Defines the camera the inputs belong to
  12352. */
  12353. constructor(camera: FreeCamera);
  12354. /**
  12355. * Add keyboard input support to the input manager.
  12356. * @returns the current input manager
  12357. */
  12358. addKeyboard(): FreeCameraInputsManager;
  12359. /**
  12360. * Add mouse input support to the input manager.
  12361. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12362. * @returns the current input manager
  12363. */
  12364. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12365. /**
  12366. * Removes the mouse input support from the manager
  12367. * @returns the current input manager
  12368. */
  12369. removeMouse(): FreeCameraInputsManager;
  12370. /**
  12371. * Add touch input support to the input manager.
  12372. * @returns the current input manager
  12373. */
  12374. addTouch(): FreeCameraInputsManager;
  12375. /**
  12376. * Remove all attached input methods from a camera
  12377. */
  12378. clear(): void;
  12379. }
  12380. }
  12381. declare module "babylonjs/Cameras/freeCamera" {
  12382. import { Vector3 } from "babylonjs/Maths/math.vector";
  12383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12384. import { Scene } from "babylonjs/scene";
  12385. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12386. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12387. /**
  12388. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12389. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12390. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12391. */
  12392. export class FreeCamera extends TargetCamera {
  12393. /**
  12394. * Define the collision ellipsoid of the camera.
  12395. * This is helpful to simulate a camera body like the player body around the camera
  12396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12397. */
  12398. ellipsoid: Vector3;
  12399. /**
  12400. * Define an offset for the position of the ellipsoid around the camera.
  12401. * This can be helpful to determine the center of the body near the gravity center of the body
  12402. * instead of its head.
  12403. */
  12404. ellipsoidOffset: Vector3;
  12405. /**
  12406. * Enable or disable collisions of the camera with the rest of the scene objects.
  12407. */
  12408. checkCollisions: boolean;
  12409. /**
  12410. * Enable or disable gravity on the camera.
  12411. */
  12412. applyGravity: boolean;
  12413. /**
  12414. * Define the input manager associated to the camera.
  12415. */
  12416. inputs: FreeCameraInputsManager;
  12417. /**
  12418. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12419. * Higher values reduce sensitivity.
  12420. */
  12421. /**
  12422. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12423. * Higher values reduce sensitivity.
  12424. */
  12425. angularSensibility: number;
  12426. /**
  12427. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12428. */
  12429. keysUp: number[];
  12430. /**
  12431. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12432. */
  12433. keysDown: number[];
  12434. /**
  12435. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12436. */
  12437. keysLeft: number[];
  12438. /**
  12439. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12440. */
  12441. keysRight: number[];
  12442. /**
  12443. * Event raised when the camera collide with a mesh in the scene.
  12444. */
  12445. onCollide: (collidedMesh: AbstractMesh) => void;
  12446. private _collider;
  12447. private _needMoveForGravity;
  12448. private _oldPosition;
  12449. private _diffPosition;
  12450. private _newPosition;
  12451. /** @hidden */
  12452. _localDirection: Vector3;
  12453. /** @hidden */
  12454. _transformedDirection: Vector3;
  12455. /**
  12456. * Instantiates a Free Camera.
  12457. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12458. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12460. * @param name Define the name of the camera in the scene
  12461. * @param position Define the start position of the camera in the scene
  12462. * @param scene Define the scene the camera belongs to
  12463. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12464. */
  12465. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12466. /**
  12467. * Attached controls to the current camera.
  12468. * @param element Defines the element the controls should be listened from
  12469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12470. */
  12471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12472. /**
  12473. * Detach the current controls from the camera.
  12474. * The camera will stop reacting to inputs.
  12475. * @param element Defines the element to stop listening the inputs from
  12476. */
  12477. detachControl(element: HTMLElement): void;
  12478. private _collisionMask;
  12479. /**
  12480. * Define a collision mask to limit the list of object the camera can collide with
  12481. */
  12482. collisionMask: number;
  12483. /** @hidden */
  12484. _collideWithWorld(displacement: Vector3): void;
  12485. private _onCollisionPositionChange;
  12486. /** @hidden */
  12487. _checkInputs(): void;
  12488. /** @hidden */
  12489. _decideIfNeedsToMove(): boolean;
  12490. /** @hidden */
  12491. _updatePosition(): void;
  12492. /**
  12493. * Destroy the camera and release the current resources hold by it.
  12494. */
  12495. dispose(): void;
  12496. /**
  12497. * Gets the current object class name.
  12498. * @return the class name
  12499. */
  12500. getClassName(): string;
  12501. }
  12502. }
  12503. declare module "babylonjs/Gamepads/gamepad" {
  12504. import { Observable } from "babylonjs/Misc/observable";
  12505. /**
  12506. * Represents a gamepad control stick position
  12507. */
  12508. export class StickValues {
  12509. /**
  12510. * The x component of the control stick
  12511. */
  12512. x: number;
  12513. /**
  12514. * The y component of the control stick
  12515. */
  12516. y: number;
  12517. /**
  12518. * Initializes the gamepad x and y control stick values
  12519. * @param x The x component of the gamepad control stick value
  12520. * @param y The y component of the gamepad control stick value
  12521. */
  12522. constructor(
  12523. /**
  12524. * The x component of the control stick
  12525. */
  12526. x: number,
  12527. /**
  12528. * The y component of the control stick
  12529. */
  12530. y: number);
  12531. }
  12532. /**
  12533. * An interface which manages callbacks for gamepad button changes
  12534. */
  12535. export interface GamepadButtonChanges {
  12536. /**
  12537. * Called when a gamepad has been changed
  12538. */
  12539. changed: boolean;
  12540. /**
  12541. * Called when a gamepad press event has been triggered
  12542. */
  12543. pressChanged: boolean;
  12544. /**
  12545. * Called when a touch event has been triggered
  12546. */
  12547. touchChanged: boolean;
  12548. /**
  12549. * Called when a value has changed
  12550. */
  12551. valueChanged: boolean;
  12552. }
  12553. /**
  12554. * Represents a gamepad
  12555. */
  12556. export class Gamepad {
  12557. /**
  12558. * The id of the gamepad
  12559. */
  12560. id: string;
  12561. /**
  12562. * The index of the gamepad
  12563. */
  12564. index: number;
  12565. /**
  12566. * The browser gamepad
  12567. */
  12568. browserGamepad: any;
  12569. /**
  12570. * Specifies what type of gamepad this represents
  12571. */
  12572. type: number;
  12573. private _leftStick;
  12574. private _rightStick;
  12575. /** @hidden */
  12576. _isConnected: boolean;
  12577. private _leftStickAxisX;
  12578. private _leftStickAxisY;
  12579. private _rightStickAxisX;
  12580. private _rightStickAxisY;
  12581. /**
  12582. * Triggered when the left control stick has been changed
  12583. */
  12584. private _onleftstickchanged;
  12585. /**
  12586. * Triggered when the right control stick has been changed
  12587. */
  12588. private _onrightstickchanged;
  12589. /**
  12590. * Represents a gamepad controller
  12591. */
  12592. static GAMEPAD: number;
  12593. /**
  12594. * Represents a generic controller
  12595. */
  12596. static GENERIC: number;
  12597. /**
  12598. * Represents an XBox controller
  12599. */
  12600. static XBOX: number;
  12601. /**
  12602. * Represents a pose-enabled controller
  12603. */
  12604. static POSE_ENABLED: number;
  12605. /**
  12606. * Represents an Dual Shock controller
  12607. */
  12608. static DUALSHOCK: number;
  12609. /**
  12610. * Specifies whether the left control stick should be Y-inverted
  12611. */
  12612. protected _invertLeftStickY: boolean;
  12613. /**
  12614. * Specifies if the gamepad has been connected
  12615. */
  12616. readonly isConnected: boolean;
  12617. /**
  12618. * Initializes the gamepad
  12619. * @param id The id of the gamepad
  12620. * @param index The index of the gamepad
  12621. * @param browserGamepad The browser gamepad
  12622. * @param leftStickX The x component of the left joystick
  12623. * @param leftStickY The y component of the left joystick
  12624. * @param rightStickX The x component of the right joystick
  12625. * @param rightStickY The y component of the right joystick
  12626. */
  12627. constructor(
  12628. /**
  12629. * The id of the gamepad
  12630. */
  12631. id: string,
  12632. /**
  12633. * The index of the gamepad
  12634. */
  12635. index: number,
  12636. /**
  12637. * The browser gamepad
  12638. */
  12639. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12640. /**
  12641. * Callback triggered when the left joystick has changed
  12642. * @param callback
  12643. */
  12644. onleftstickchanged(callback: (values: StickValues) => void): void;
  12645. /**
  12646. * Callback triggered when the right joystick has changed
  12647. * @param callback
  12648. */
  12649. onrightstickchanged(callback: (values: StickValues) => void): void;
  12650. /**
  12651. * Gets the left joystick
  12652. */
  12653. /**
  12654. * Sets the left joystick values
  12655. */
  12656. leftStick: StickValues;
  12657. /**
  12658. * Gets the right joystick
  12659. */
  12660. /**
  12661. * Sets the right joystick value
  12662. */
  12663. rightStick: StickValues;
  12664. /**
  12665. * Updates the gamepad joystick positions
  12666. */
  12667. update(): void;
  12668. /**
  12669. * Disposes the gamepad
  12670. */
  12671. dispose(): void;
  12672. }
  12673. /**
  12674. * Represents a generic gamepad
  12675. */
  12676. export class GenericPad extends Gamepad {
  12677. private _buttons;
  12678. private _onbuttondown;
  12679. private _onbuttonup;
  12680. /**
  12681. * Observable triggered when a button has been pressed
  12682. */
  12683. onButtonDownObservable: Observable<number>;
  12684. /**
  12685. * Observable triggered when a button has been released
  12686. */
  12687. onButtonUpObservable: Observable<number>;
  12688. /**
  12689. * Callback triggered when a button has been pressed
  12690. * @param callback Called when a button has been pressed
  12691. */
  12692. onbuttondown(callback: (buttonPressed: number) => void): void;
  12693. /**
  12694. * Callback triggered when a button has been released
  12695. * @param callback Called when a button has been released
  12696. */
  12697. onbuttonup(callback: (buttonReleased: number) => void): void;
  12698. /**
  12699. * Initializes the generic gamepad
  12700. * @param id The id of the generic gamepad
  12701. * @param index The index of the generic gamepad
  12702. * @param browserGamepad The browser gamepad
  12703. */
  12704. constructor(id: string, index: number, browserGamepad: any);
  12705. private _setButtonValue;
  12706. /**
  12707. * Updates the generic gamepad
  12708. */
  12709. update(): void;
  12710. /**
  12711. * Disposes the generic gamepad
  12712. */
  12713. dispose(): void;
  12714. }
  12715. }
  12716. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12717. import { Nullable } from "babylonjs/types";
  12718. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12719. import { Scene } from "babylonjs/scene";
  12720. module "babylonjs/Engines/engine" {
  12721. interface Engine {
  12722. /**
  12723. * Creates a raw texture
  12724. * @param data defines the data to store in the texture
  12725. * @param width defines the width of the texture
  12726. * @param height defines the height of the texture
  12727. * @param format defines the format of the data
  12728. * @param generateMipMaps defines if the engine should generate the mip levels
  12729. * @param invertY defines if data must be stored with Y axis inverted
  12730. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12731. * @param compression defines the compression used (null by default)
  12732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12733. * @returns the raw texture inside an InternalTexture
  12734. */
  12735. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12736. /**
  12737. * Update a raw texture
  12738. * @param texture defines the texture to update
  12739. * @param data defines the data to store in the texture
  12740. * @param format defines the format of the data
  12741. * @param invertY defines if data must be stored with Y axis inverted
  12742. */
  12743. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12744. /**
  12745. * Update a raw texture
  12746. * @param texture defines the texture to update
  12747. * @param data defines the data to store in the texture
  12748. * @param format defines the format of the data
  12749. * @param invertY defines if data must be stored with Y axis inverted
  12750. * @param compression defines the compression used (null by default)
  12751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12752. */
  12753. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12754. /**
  12755. * Creates a new raw cube texture
  12756. * @param data defines the array of data to use to create each face
  12757. * @param size defines the size of the textures
  12758. * @param format defines the format of the data
  12759. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12760. * @param generateMipMaps defines if the engine should generate the mip levels
  12761. * @param invertY defines if data must be stored with Y axis inverted
  12762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12763. * @param compression defines the compression used (null by default)
  12764. * @returns the cube texture as an InternalTexture
  12765. */
  12766. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12767. /**
  12768. * Update a raw cube texture
  12769. * @param texture defines the texture to udpdate
  12770. * @param data defines the data to store
  12771. * @param format defines the data format
  12772. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12773. * @param invertY defines if data must be stored with Y axis inverted
  12774. */
  12775. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12776. /**
  12777. * Update a raw cube texture
  12778. * @param texture defines the texture to udpdate
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12782. * @param invertY defines if data must be stored with Y axis inverted
  12783. * @param compression defines the compression used (null by default)
  12784. */
  12785. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12786. /**
  12787. * Update a raw cube texture
  12788. * @param texture defines the texture to udpdate
  12789. * @param data defines the data to store
  12790. * @param format defines the data format
  12791. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12792. * @param invertY defines if data must be stored with Y axis inverted
  12793. * @param compression defines the compression used (null by default)
  12794. * @param level defines which level of the texture to update
  12795. */
  12796. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12797. /**
  12798. * Creates a new raw cube texture from a specified url
  12799. * @param url defines the url where the data is located
  12800. * @param scene defines the current scene
  12801. * @param size defines the size of the textures
  12802. * @param format defines the format of the data
  12803. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12804. * @param noMipmap defines if the engine should avoid generating the mip levels
  12805. * @param callback defines a callback used to extract texture data from loaded data
  12806. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12807. * @param onLoad defines a callback called when texture is loaded
  12808. * @param onError defines a callback called if there is an error
  12809. * @returns the cube texture as an InternalTexture
  12810. */
  12811. 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;
  12812. /**
  12813. * Creates a new raw cube texture from a specified url
  12814. * @param url defines the url where the data is located
  12815. * @param scene defines the current scene
  12816. * @param size defines the size of the textures
  12817. * @param format defines the format of the data
  12818. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12819. * @param noMipmap defines if the engine should avoid generating the mip levels
  12820. * @param callback defines a callback used to extract texture data from loaded data
  12821. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12822. * @param onLoad defines a callback called when texture is loaded
  12823. * @param onError defines a callback called if there is an error
  12824. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12825. * @param invertY defines if data must be stored with Y axis inverted
  12826. * @returns the cube texture as an InternalTexture
  12827. */
  12828. 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;
  12829. /**
  12830. * Creates a new raw 3D texture
  12831. * @param data defines the data used to create the texture
  12832. * @param width defines the width of the texture
  12833. * @param height defines the height of the texture
  12834. * @param depth defines the depth of the texture
  12835. * @param format defines the format of the texture
  12836. * @param generateMipMaps defines if the engine must generate mip levels
  12837. * @param invertY defines if data must be stored with Y axis inverted
  12838. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12839. * @param compression defines the compressed used (can be null)
  12840. * @param textureType defines the compressed used (can be null)
  12841. * @returns a new raw 3D texture (stored in an InternalTexture)
  12842. */
  12843. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12844. /**
  12845. * Update a raw 3D texture
  12846. * @param texture defines the texture to update
  12847. * @param data defines the data to store
  12848. * @param format defines the data format
  12849. * @param invertY defines if data must be stored with Y axis inverted
  12850. */
  12851. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12852. /**
  12853. * Update a raw 3D texture
  12854. * @param texture defines the texture to update
  12855. * @param data defines the data to store
  12856. * @param format defines the data format
  12857. * @param invertY defines if data must be stored with Y axis inverted
  12858. * @param compression defines the used compression (can be null)
  12859. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12860. */
  12861. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12862. /**
  12863. * Creates a new raw 2D array texture
  12864. * @param data defines the data used to create the texture
  12865. * @param width defines the width of the texture
  12866. * @param height defines the height of the texture
  12867. * @param depth defines the number of layers of the texture
  12868. * @param format defines the format of the texture
  12869. * @param generateMipMaps defines if the engine must generate mip levels
  12870. * @param invertY defines if data must be stored with Y axis inverted
  12871. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12872. * @param compression defines the compressed used (can be null)
  12873. * @param textureType defines the compressed used (can be null)
  12874. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12875. */
  12876. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12877. /**
  12878. * Update a raw 2D array texture
  12879. * @param texture defines the texture to update
  12880. * @param data defines the data to store
  12881. * @param format defines the data format
  12882. * @param invertY defines if data must be stored with Y axis inverted
  12883. */
  12884. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12885. /**
  12886. * Update a raw 2D array texture
  12887. * @param texture defines the texture to update
  12888. * @param data defines the data to store
  12889. * @param format defines the data format
  12890. * @param invertY defines if data must be stored with Y axis inverted
  12891. * @param compression defines the used compression (can be null)
  12892. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12893. */
  12894. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12895. }
  12896. }
  12897. }
  12898. declare module "babylonjs/Materials/Textures/rawTexture" {
  12899. import { Scene } from "babylonjs/scene";
  12900. import { Texture } from "babylonjs/Materials/Textures/texture";
  12901. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12902. /**
  12903. * Raw texture can help creating a texture directly from an array of data.
  12904. * This can be super useful if you either get the data from an uncompressed source or
  12905. * if you wish to create your texture pixel by pixel.
  12906. */
  12907. export class RawTexture extends Texture {
  12908. /**
  12909. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12910. */
  12911. format: number;
  12912. private _engine;
  12913. /**
  12914. * Instantiates a new RawTexture.
  12915. * Raw texture can help creating a texture directly from an array of data.
  12916. * This can be super useful if you either get the data from an uncompressed source or
  12917. * if you wish to create your texture pixel by pixel.
  12918. * @param data define the array of data to use to create the texture
  12919. * @param width define the width of the texture
  12920. * @param height define the height of the texture
  12921. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12922. * @param scene define the scene the texture belongs to
  12923. * @param generateMipMaps define whether mip maps should be generated or not
  12924. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12925. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12926. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12927. */
  12928. constructor(data: ArrayBufferView, width: number, height: number,
  12929. /**
  12930. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12931. */
  12932. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12933. /**
  12934. * Updates the texture underlying data.
  12935. * @param data Define the new data of the texture
  12936. */
  12937. update(data: ArrayBufferView): void;
  12938. /**
  12939. * Creates a luminance texture from some data.
  12940. * @param data Define the texture data
  12941. * @param width Define the width of the texture
  12942. * @param height Define the height of the texture
  12943. * @param scene Define the scene the texture belongs to
  12944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12947. * @returns the luminance texture
  12948. */
  12949. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12950. /**
  12951. * Creates a luminance alpha texture from some data.
  12952. * @param data Define the texture data
  12953. * @param width Define the width of the texture
  12954. * @param height Define the height of the texture
  12955. * @param scene Define the scene the texture belongs to
  12956. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12957. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12958. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12959. * @returns the luminance alpha texture
  12960. */
  12961. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12962. /**
  12963. * Creates an alpha texture from some data.
  12964. * @param data Define the texture data
  12965. * @param width Define the width of the texture
  12966. * @param height Define the height of the texture
  12967. * @param scene Define the scene the texture belongs to
  12968. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12969. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12970. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12971. * @returns the alpha texture
  12972. */
  12973. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12974. /**
  12975. * Creates a RGB texture from some data.
  12976. * @param data Define the texture data
  12977. * @param width Define the width of the texture
  12978. * @param height Define the height of the texture
  12979. * @param scene Define the scene the texture belongs to
  12980. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12981. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12982. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12983. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12984. * @returns the RGB alpha texture
  12985. */
  12986. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12987. /**
  12988. * Creates a RGBA texture from some data.
  12989. * @param data Define the texture data
  12990. * @param width Define the width of the texture
  12991. * @param height Define the height of the texture
  12992. * @param scene Define the scene the texture belongs to
  12993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12997. * @returns the RGBA texture
  12998. */
  12999. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13000. /**
  13001. * Creates a R texture from some data.
  13002. * @param data Define the texture data
  13003. * @param width Define the width of the texture
  13004. * @param height Define the height of the texture
  13005. * @param scene Define the scene the texture belongs to
  13006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13009. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13010. * @returns the R texture
  13011. */
  13012. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13013. }
  13014. }
  13015. declare module "babylonjs/Maths/math.size" {
  13016. /**
  13017. * Interface for the size containing width and height
  13018. */
  13019. export interface ISize {
  13020. /**
  13021. * Width
  13022. */
  13023. width: number;
  13024. /**
  13025. * Heighht
  13026. */
  13027. height: number;
  13028. }
  13029. /**
  13030. * Size containing widht and height
  13031. */
  13032. export class Size implements ISize {
  13033. /**
  13034. * Width
  13035. */
  13036. width: number;
  13037. /**
  13038. * Height
  13039. */
  13040. height: number;
  13041. /**
  13042. * Creates a Size object from the given width and height (floats).
  13043. * @param width width of the new size
  13044. * @param height height of the new size
  13045. */
  13046. constructor(width: number, height: number);
  13047. /**
  13048. * Returns a string with the Size width and height
  13049. * @returns a string with the Size width and height
  13050. */
  13051. toString(): string;
  13052. /**
  13053. * "Size"
  13054. * @returns the string "Size"
  13055. */
  13056. getClassName(): string;
  13057. /**
  13058. * Returns the Size hash code.
  13059. * @returns a hash code for a unique width and height
  13060. */
  13061. getHashCode(): number;
  13062. /**
  13063. * Updates the current size from the given one.
  13064. * @param src the given size
  13065. */
  13066. copyFrom(src: Size): void;
  13067. /**
  13068. * Updates in place the current Size from the given floats.
  13069. * @param width width of the new size
  13070. * @param height height of the new size
  13071. * @returns the updated Size.
  13072. */
  13073. copyFromFloats(width: number, height: number): Size;
  13074. /**
  13075. * Updates in place the current Size from the given floats.
  13076. * @param width width to set
  13077. * @param height height to set
  13078. * @returns the updated Size.
  13079. */
  13080. set(width: number, height: number): Size;
  13081. /**
  13082. * Multiplies the width and height by numbers
  13083. * @param w factor to multiple the width by
  13084. * @param h factor to multiple the height by
  13085. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13086. */
  13087. multiplyByFloats(w: number, h: number): Size;
  13088. /**
  13089. * Clones the size
  13090. * @returns a new Size copied from the given one.
  13091. */
  13092. clone(): Size;
  13093. /**
  13094. * True if the current Size and the given one width and height are strictly equal.
  13095. * @param other the other size to compare against
  13096. * @returns True if the current Size and the given one width and height are strictly equal.
  13097. */
  13098. equals(other: Size): boolean;
  13099. /**
  13100. * The surface of the Size : width * height (float).
  13101. */
  13102. readonly surface: number;
  13103. /**
  13104. * Create a new size of zero
  13105. * @returns a new Size set to (0.0, 0.0)
  13106. */
  13107. static Zero(): Size;
  13108. /**
  13109. * Sums the width and height of two sizes
  13110. * @param otherSize size to add to this size
  13111. * @returns a new Size set as the addition result of the current Size and the given one.
  13112. */
  13113. add(otherSize: Size): Size;
  13114. /**
  13115. * Subtracts the width and height of two
  13116. * @param otherSize size to subtract to this size
  13117. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13118. */
  13119. subtract(otherSize: Size): Size;
  13120. /**
  13121. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13122. * @param start starting size to lerp between
  13123. * @param end end size to lerp between
  13124. * @param amount amount to lerp between the start and end values
  13125. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13126. */
  13127. static Lerp(start: Size, end: Size, amount: number): Size;
  13128. }
  13129. }
  13130. declare module "babylonjs/Animations/runtimeAnimation" {
  13131. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13132. import { Animatable } from "babylonjs/Animations/animatable";
  13133. import { Scene } from "babylonjs/scene";
  13134. /**
  13135. * Defines a runtime animation
  13136. */
  13137. export class RuntimeAnimation {
  13138. private _events;
  13139. /**
  13140. * The current frame of the runtime animation
  13141. */
  13142. private _currentFrame;
  13143. /**
  13144. * The animation used by the runtime animation
  13145. */
  13146. private _animation;
  13147. /**
  13148. * The target of the runtime animation
  13149. */
  13150. private _target;
  13151. /**
  13152. * The initiating animatable
  13153. */
  13154. private _host;
  13155. /**
  13156. * The original value of the runtime animation
  13157. */
  13158. private _originalValue;
  13159. /**
  13160. * The original blend value of the runtime animation
  13161. */
  13162. private _originalBlendValue;
  13163. /**
  13164. * The offsets cache of the runtime animation
  13165. */
  13166. private _offsetsCache;
  13167. /**
  13168. * The high limits cache of the runtime animation
  13169. */
  13170. private _highLimitsCache;
  13171. /**
  13172. * Specifies if the runtime animation has been stopped
  13173. */
  13174. private _stopped;
  13175. /**
  13176. * The blending factor of the runtime animation
  13177. */
  13178. private _blendingFactor;
  13179. /**
  13180. * The BabylonJS scene
  13181. */
  13182. private _scene;
  13183. /**
  13184. * The current value of the runtime animation
  13185. */
  13186. private _currentValue;
  13187. /** @hidden */
  13188. _animationState: _IAnimationState;
  13189. /**
  13190. * The active target of the runtime animation
  13191. */
  13192. private _activeTargets;
  13193. private _currentActiveTarget;
  13194. private _directTarget;
  13195. /**
  13196. * The target path of the runtime animation
  13197. */
  13198. private _targetPath;
  13199. /**
  13200. * The weight of the runtime animation
  13201. */
  13202. private _weight;
  13203. /**
  13204. * The ratio offset of the runtime animation
  13205. */
  13206. private _ratioOffset;
  13207. /**
  13208. * The previous delay of the runtime animation
  13209. */
  13210. private _previousDelay;
  13211. /**
  13212. * The previous ratio of the runtime animation
  13213. */
  13214. private _previousRatio;
  13215. private _enableBlending;
  13216. private _keys;
  13217. private _minFrame;
  13218. private _maxFrame;
  13219. private _minValue;
  13220. private _maxValue;
  13221. private _targetIsArray;
  13222. /**
  13223. * Gets the current frame of the runtime animation
  13224. */
  13225. readonly currentFrame: number;
  13226. /**
  13227. * Gets the weight of the runtime animation
  13228. */
  13229. readonly weight: number;
  13230. /**
  13231. * Gets the current value of the runtime animation
  13232. */
  13233. readonly currentValue: any;
  13234. /**
  13235. * Gets the target path of the runtime animation
  13236. */
  13237. readonly targetPath: string;
  13238. /**
  13239. * Gets the actual target of the runtime animation
  13240. */
  13241. readonly target: any;
  13242. /** @hidden */
  13243. _onLoop: () => void;
  13244. /**
  13245. * Create a new RuntimeAnimation object
  13246. * @param target defines the target of the animation
  13247. * @param animation defines the source animation object
  13248. * @param scene defines the hosting scene
  13249. * @param host defines the initiating Animatable
  13250. */
  13251. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13252. private _preparePath;
  13253. /**
  13254. * Gets the animation from the runtime animation
  13255. */
  13256. readonly animation: Animation;
  13257. /**
  13258. * Resets the runtime animation to the beginning
  13259. * @param restoreOriginal defines whether to restore the target property to the original value
  13260. */
  13261. reset(restoreOriginal?: boolean): void;
  13262. /**
  13263. * Specifies if the runtime animation is stopped
  13264. * @returns Boolean specifying if the runtime animation is stopped
  13265. */
  13266. isStopped(): boolean;
  13267. /**
  13268. * Disposes of the runtime animation
  13269. */
  13270. dispose(): void;
  13271. /**
  13272. * Apply the interpolated value to the target
  13273. * @param currentValue defines the value computed by the animation
  13274. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13275. */
  13276. setValue(currentValue: any, weight: number): void;
  13277. private _getOriginalValues;
  13278. private _setValue;
  13279. /**
  13280. * Gets the loop pmode of the runtime animation
  13281. * @returns Loop Mode
  13282. */
  13283. private _getCorrectLoopMode;
  13284. /**
  13285. * Move the current animation to a given frame
  13286. * @param frame defines the frame to move to
  13287. */
  13288. goToFrame(frame: number): void;
  13289. /**
  13290. * @hidden Internal use only
  13291. */
  13292. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13293. /**
  13294. * Execute the current animation
  13295. * @param delay defines the delay to add to the current frame
  13296. * @param from defines the lower bound of the animation range
  13297. * @param to defines the upper bound of the animation range
  13298. * @param loop defines if the current animation must loop
  13299. * @param speedRatio defines the current speed ratio
  13300. * @param weight defines the weight of the animation (default is -1 so no weight)
  13301. * @param onLoop optional callback called when animation loops
  13302. * @returns a boolean indicating if the animation is running
  13303. */
  13304. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13305. }
  13306. }
  13307. declare module "babylonjs/Animations/animatable" {
  13308. import { Animation } from "babylonjs/Animations/animation";
  13309. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13310. import { Nullable } from "babylonjs/types";
  13311. import { Observable } from "babylonjs/Misc/observable";
  13312. import { Scene } from "babylonjs/scene";
  13313. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13314. import { Node } from "babylonjs/node";
  13315. /**
  13316. * Class used to store an actual running animation
  13317. */
  13318. export class Animatable {
  13319. /** defines the target object */
  13320. target: any;
  13321. /** defines the starting frame number (default is 0) */
  13322. fromFrame: number;
  13323. /** defines the ending frame number (default is 100) */
  13324. toFrame: number;
  13325. /** defines if the animation must loop (default is false) */
  13326. loopAnimation: boolean;
  13327. /** defines a callback to call when animation ends if it is not looping */
  13328. onAnimationEnd?: (() => void) | null | undefined;
  13329. /** defines a callback to call when animation loops */
  13330. onAnimationLoop?: (() => void) | null | undefined;
  13331. private _localDelayOffset;
  13332. private _pausedDelay;
  13333. private _runtimeAnimations;
  13334. private _paused;
  13335. private _scene;
  13336. private _speedRatio;
  13337. private _weight;
  13338. private _syncRoot;
  13339. /**
  13340. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13341. * This will only apply for non looping animation (default is true)
  13342. */
  13343. disposeOnEnd: boolean;
  13344. /**
  13345. * Gets a boolean indicating if the animation has started
  13346. */
  13347. animationStarted: boolean;
  13348. /**
  13349. * Observer raised when the animation ends
  13350. */
  13351. onAnimationEndObservable: Observable<Animatable>;
  13352. /**
  13353. * Observer raised when the animation loops
  13354. */
  13355. onAnimationLoopObservable: Observable<Animatable>;
  13356. /**
  13357. * Gets the root Animatable used to synchronize and normalize animations
  13358. */
  13359. readonly syncRoot: Nullable<Animatable>;
  13360. /**
  13361. * Gets the current frame of the first RuntimeAnimation
  13362. * Used to synchronize Animatables
  13363. */
  13364. readonly masterFrame: number;
  13365. /**
  13366. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13367. */
  13368. weight: number;
  13369. /**
  13370. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13371. */
  13372. speedRatio: number;
  13373. /**
  13374. * Creates a new Animatable
  13375. * @param scene defines the hosting scene
  13376. * @param target defines the target object
  13377. * @param fromFrame defines the starting frame number (default is 0)
  13378. * @param toFrame defines the ending frame number (default is 100)
  13379. * @param loopAnimation defines if the animation must loop (default is false)
  13380. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13381. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13382. * @param animations defines a group of animation to add to the new Animatable
  13383. * @param onAnimationLoop defines a callback to call when animation loops
  13384. */
  13385. constructor(scene: Scene,
  13386. /** defines the target object */
  13387. target: any,
  13388. /** defines the starting frame number (default is 0) */
  13389. fromFrame?: number,
  13390. /** defines the ending frame number (default is 100) */
  13391. toFrame?: number,
  13392. /** defines if the animation must loop (default is false) */
  13393. loopAnimation?: boolean, speedRatio?: number,
  13394. /** defines a callback to call when animation ends if it is not looping */
  13395. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13396. /** defines a callback to call when animation loops */
  13397. onAnimationLoop?: (() => void) | null | undefined);
  13398. /**
  13399. * Synchronize and normalize current Animatable with a source Animatable
  13400. * This is useful when using animation weights and when animations are not of the same length
  13401. * @param root defines the root Animatable to synchronize with
  13402. * @returns the current Animatable
  13403. */
  13404. syncWith(root: Animatable): Animatable;
  13405. /**
  13406. * Gets the list of runtime animations
  13407. * @returns an array of RuntimeAnimation
  13408. */
  13409. getAnimations(): RuntimeAnimation[];
  13410. /**
  13411. * Adds more animations to the current animatable
  13412. * @param target defines the target of the animations
  13413. * @param animations defines the new animations to add
  13414. */
  13415. appendAnimations(target: any, animations: Animation[]): void;
  13416. /**
  13417. * Gets the source animation for a specific property
  13418. * @param property defines the propertyu to look for
  13419. * @returns null or the source animation for the given property
  13420. */
  13421. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13422. /**
  13423. * Gets the runtime animation for a specific property
  13424. * @param property defines the propertyu to look for
  13425. * @returns null or the runtime animation for the given property
  13426. */
  13427. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13428. /**
  13429. * Resets the animatable to its original state
  13430. */
  13431. reset(): void;
  13432. /**
  13433. * Allows the animatable to blend with current running animations
  13434. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13435. * @param blendingSpeed defines the blending speed to use
  13436. */
  13437. enableBlending(blendingSpeed: number): void;
  13438. /**
  13439. * Disable animation blending
  13440. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13441. */
  13442. disableBlending(): void;
  13443. /**
  13444. * Jump directly to a given frame
  13445. * @param frame defines the frame to jump to
  13446. */
  13447. goToFrame(frame: number): void;
  13448. /**
  13449. * Pause the animation
  13450. */
  13451. pause(): void;
  13452. /**
  13453. * Restart the animation
  13454. */
  13455. restart(): void;
  13456. private _raiseOnAnimationEnd;
  13457. /**
  13458. * Stop and delete the current animation
  13459. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13460. * @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)
  13461. */
  13462. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13463. /**
  13464. * Wait asynchronously for the animation to end
  13465. * @returns a promise which will be fullfilled when the animation ends
  13466. */
  13467. waitAsync(): Promise<Animatable>;
  13468. /** @hidden */
  13469. _animate(delay: number): boolean;
  13470. }
  13471. module "babylonjs/scene" {
  13472. interface Scene {
  13473. /** @hidden */
  13474. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13475. /** @hidden */
  13476. _processLateAnimationBindingsForMatrices(holder: {
  13477. totalWeight: number;
  13478. animations: RuntimeAnimation[];
  13479. originalValue: Matrix;
  13480. }): any;
  13481. /** @hidden */
  13482. _processLateAnimationBindingsForQuaternions(holder: {
  13483. totalWeight: number;
  13484. animations: RuntimeAnimation[];
  13485. originalValue: Quaternion;
  13486. }, refQuaternion: Quaternion): Quaternion;
  13487. /** @hidden */
  13488. _processLateAnimationBindings(): void;
  13489. /**
  13490. * Will start the animation sequence of a given target
  13491. * @param target defines the target
  13492. * @param from defines from which frame should animation start
  13493. * @param to defines until which frame should animation run.
  13494. * @param weight defines the weight to apply to the animation (1.0 by default)
  13495. * @param loop defines if the animation loops
  13496. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13497. * @param onAnimationEnd defines the function to be executed when the animation ends
  13498. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13499. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13500. * @param onAnimationLoop defines the callback to call when an animation loops
  13501. * @returns the animatable object created for this animation
  13502. */
  13503. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13504. /**
  13505. * Will start the animation sequence of a given target
  13506. * @param target defines the target
  13507. * @param from defines from which frame should animation start
  13508. * @param to defines until which frame should animation run.
  13509. * @param loop defines if the animation loops
  13510. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13511. * @param onAnimationEnd defines the function to be executed when the animation ends
  13512. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13513. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13514. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13515. * @param onAnimationLoop defines the callback to call when an animation loops
  13516. * @returns the animatable object created for this animation
  13517. */
  13518. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13519. /**
  13520. * Will start the animation sequence of a given target and its hierarchy
  13521. * @param target defines the target
  13522. * @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.
  13523. * @param from defines from which frame should animation start
  13524. * @param to defines until which frame should animation run.
  13525. * @param loop defines if the animation loops
  13526. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13527. * @param onAnimationEnd defines the function to be executed when the animation ends
  13528. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13529. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13530. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13531. * @param onAnimationLoop defines the callback to call when an animation loops
  13532. * @returns the list of created animatables
  13533. */
  13534. 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[];
  13535. /**
  13536. * Begin a new animation on a given node
  13537. * @param target defines the target where the animation will take place
  13538. * @param animations defines the list of animations to start
  13539. * @param from defines the initial value
  13540. * @param to defines the final value
  13541. * @param loop defines if you want animation to loop (off by default)
  13542. * @param speedRatio defines the speed ratio to apply to all animations
  13543. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13544. * @param onAnimationLoop defines the callback to call when an animation loops
  13545. * @returns the list of created animatables
  13546. */
  13547. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13548. /**
  13549. * Begin a new animation on a given node and its hierarchy
  13550. * @param target defines the root node where the animation will take place
  13551. * @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.
  13552. * @param animations defines the list of animations to start
  13553. * @param from defines the initial value
  13554. * @param to defines the final value
  13555. * @param loop defines if you want animation to loop (off by default)
  13556. * @param speedRatio defines the speed ratio to apply to all animations
  13557. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13558. * @param onAnimationLoop defines the callback to call when an animation loops
  13559. * @returns the list of animatables created for all nodes
  13560. */
  13561. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13562. /**
  13563. * Gets the animatable associated with a specific target
  13564. * @param target defines the target of the animatable
  13565. * @returns the required animatable if found
  13566. */
  13567. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13568. /**
  13569. * Gets all animatables associated with a given target
  13570. * @param target defines the target to look animatables for
  13571. * @returns an array of Animatables
  13572. */
  13573. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13574. /**
  13575. * Stops and removes all animations that have been applied to the scene
  13576. */
  13577. stopAllAnimations(): void;
  13578. /**
  13579. * Gets the current delta time used by animation engine
  13580. */
  13581. deltaTime: number;
  13582. }
  13583. }
  13584. module "babylonjs/Bones/bone" {
  13585. interface Bone {
  13586. /**
  13587. * Copy an animation range from another bone
  13588. * @param source defines the source bone
  13589. * @param rangeName defines the range name to copy
  13590. * @param frameOffset defines the frame offset
  13591. * @param rescaleAsRequired defines if rescaling must be applied if required
  13592. * @param skelDimensionsRatio defines the scaling ratio
  13593. * @returns true if operation was successful
  13594. */
  13595. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13596. }
  13597. }
  13598. }
  13599. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13600. /**
  13601. * Class used to override all child animations of a given target
  13602. */
  13603. export class AnimationPropertiesOverride {
  13604. /**
  13605. * Gets or sets a value indicating if animation blending must be used
  13606. */
  13607. enableBlending: boolean;
  13608. /**
  13609. * Gets or sets the blending speed to use when enableBlending is true
  13610. */
  13611. blendingSpeed: number;
  13612. /**
  13613. * Gets or sets the default loop mode to use
  13614. */
  13615. loopMode: number;
  13616. }
  13617. }
  13618. declare module "babylonjs/Bones/skeleton" {
  13619. import { Bone } from "babylonjs/Bones/bone";
  13620. import { Observable } from "babylonjs/Misc/observable";
  13621. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13622. import { Scene } from "babylonjs/scene";
  13623. import { Nullable } from "babylonjs/types";
  13624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13625. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13626. import { Animatable } from "babylonjs/Animations/animatable";
  13627. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13628. import { Animation } from "babylonjs/Animations/animation";
  13629. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13630. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13631. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13632. /**
  13633. * Class used to handle skinning animations
  13634. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13635. */
  13636. export class Skeleton implements IAnimatable {
  13637. /** defines the skeleton name */
  13638. name: string;
  13639. /** defines the skeleton Id */
  13640. id: string;
  13641. /**
  13642. * Defines the list of child bones
  13643. */
  13644. bones: Bone[];
  13645. /**
  13646. * Defines an estimate of the dimension of the skeleton at rest
  13647. */
  13648. dimensionsAtRest: Vector3;
  13649. /**
  13650. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13651. */
  13652. needInitialSkinMatrix: boolean;
  13653. /**
  13654. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13655. */
  13656. overrideMesh: Nullable<AbstractMesh>;
  13657. /**
  13658. * Gets the list of animations attached to this skeleton
  13659. */
  13660. animations: Array<Animation>;
  13661. private _scene;
  13662. private _isDirty;
  13663. private _transformMatrices;
  13664. private _transformMatrixTexture;
  13665. private _meshesWithPoseMatrix;
  13666. private _animatables;
  13667. private _identity;
  13668. private _synchronizedWithMesh;
  13669. private _ranges;
  13670. private _lastAbsoluteTransformsUpdateId;
  13671. private _canUseTextureForBones;
  13672. private _uniqueId;
  13673. /** @hidden */
  13674. _numBonesWithLinkedTransformNode: number;
  13675. /** @hidden */
  13676. _hasWaitingData: Nullable<boolean>;
  13677. /**
  13678. * Specifies if the skeleton should be serialized
  13679. */
  13680. doNotSerialize: boolean;
  13681. private _useTextureToStoreBoneMatrices;
  13682. /**
  13683. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13684. * Please note that this option is not available if the hardware does not support it
  13685. */
  13686. useTextureToStoreBoneMatrices: boolean;
  13687. private _animationPropertiesOverride;
  13688. /**
  13689. * Gets or sets the animation properties override
  13690. */
  13691. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13692. /**
  13693. * List of inspectable custom properties (used by the Inspector)
  13694. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13695. */
  13696. inspectableCustomProperties: IInspectable[];
  13697. /**
  13698. * An observable triggered before computing the skeleton's matrices
  13699. */
  13700. onBeforeComputeObservable: Observable<Skeleton>;
  13701. /**
  13702. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13703. */
  13704. readonly isUsingTextureForMatrices: boolean;
  13705. /**
  13706. * Gets the unique ID of this skeleton
  13707. */
  13708. readonly uniqueId: number;
  13709. /**
  13710. * Creates a new skeleton
  13711. * @param name defines the skeleton name
  13712. * @param id defines the skeleton Id
  13713. * @param scene defines the hosting scene
  13714. */
  13715. constructor(
  13716. /** defines the skeleton name */
  13717. name: string,
  13718. /** defines the skeleton Id */
  13719. id: string, scene: Scene);
  13720. /**
  13721. * Gets the current object class name.
  13722. * @return the class name
  13723. */
  13724. getClassName(): string;
  13725. /**
  13726. * Returns an array containing the root bones
  13727. * @returns an array containing the root bones
  13728. */
  13729. getChildren(): Array<Bone>;
  13730. /**
  13731. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13732. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13733. * @returns a Float32Array containing matrices data
  13734. */
  13735. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13736. /**
  13737. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13738. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13739. * @returns a raw texture containing the data
  13740. */
  13741. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13742. /**
  13743. * Gets the current hosting scene
  13744. * @returns a scene object
  13745. */
  13746. getScene(): Scene;
  13747. /**
  13748. * Gets a string representing the current skeleton data
  13749. * @param fullDetails defines a boolean indicating if we want a verbose version
  13750. * @returns a string representing the current skeleton data
  13751. */
  13752. toString(fullDetails?: boolean): string;
  13753. /**
  13754. * Get bone's index searching by name
  13755. * @param name defines bone's name to search for
  13756. * @return the indice of the bone. Returns -1 if not found
  13757. */
  13758. getBoneIndexByName(name: string): number;
  13759. /**
  13760. * Creater a new animation range
  13761. * @param name defines the name of the range
  13762. * @param from defines the start key
  13763. * @param to defines the end key
  13764. */
  13765. createAnimationRange(name: string, from: number, to: number): void;
  13766. /**
  13767. * Delete a specific animation range
  13768. * @param name defines the name of the range
  13769. * @param deleteFrames defines if frames must be removed as well
  13770. */
  13771. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13772. /**
  13773. * Gets a specific animation range
  13774. * @param name defines the name of the range to look for
  13775. * @returns the requested animation range or null if not found
  13776. */
  13777. getAnimationRange(name: string): Nullable<AnimationRange>;
  13778. /**
  13779. * Gets the list of all animation ranges defined on this skeleton
  13780. * @returns an array
  13781. */
  13782. getAnimationRanges(): Nullable<AnimationRange>[];
  13783. /**
  13784. * Copy animation range from a source skeleton.
  13785. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13786. * @param source defines the source skeleton
  13787. * @param name defines the name of the range to copy
  13788. * @param rescaleAsRequired defines if rescaling must be applied if required
  13789. * @returns true if operation was successful
  13790. */
  13791. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13792. /**
  13793. * Forces the skeleton to go to rest pose
  13794. */
  13795. returnToRest(): void;
  13796. private _getHighestAnimationFrame;
  13797. /**
  13798. * Begin a specific animation range
  13799. * @param name defines the name of the range to start
  13800. * @param loop defines if looping must be turned on (false by default)
  13801. * @param speedRatio defines the speed ratio to apply (1 by default)
  13802. * @param onAnimationEnd defines a callback which will be called when animation will end
  13803. * @returns a new animatable
  13804. */
  13805. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13806. /** @hidden */
  13807. _markAsDirty(): void;
  13808. /** @hidden */
  13809. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13810. /** @hidden */
  13811. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13812. private _computeTransformMatrices;
  13813. /**
  13814. * Build all resources required to render a skeleton
  13815. */
  13816. prepare(): void;
  13817. /**
  13818. * Gets the list of animatables currently running for this skeleton
  13819. * @returns an array of animatables
  13820. */
  13821. getAnimatables(): IAnimatable[];
  13822. /**
  13823. * Clone the current skeleton
  13824. * @param name defines the name of the new skeleton
  13825. * @param id defines the id of the new skeleton
  13826. * @returns the new skeleton
  13827. */
  13828. clone(name: string, id?: string): Skeleton;
  13829. /**
  13830. * Enable animation blending for this skeleton
  13831. * @param blendingSpeed defines the blending speed to apply
  13832. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13833. */
  13834. enableBlending(blendingSpeed?: number): void;
  13835. /**
  13836. * Releases all resources associated with the current skeleton
  13837. */
  13838. dispose(): void;
  13839. /**
  13840. * Serialize the skeleton in a JSON object
  13841. * @returns a JSON object
  13842. */
  13843. serialize(): any;
  13844. /**
  13845. * Creates a new skeleton from serialized data
  13846. * @param parsedSkeleton defines the serialized data
  13847. * @param scene defines the hosting scene
  13848. * @returns a new skeleton
  13849. */
  13850. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13851. /**
  13852. * Compute all node absolute transforms
  13853. * @param forceUpdate defines if computation must be done even if cache is up to date
  13854. */
  13855. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13856. /**
  13857. * Gets the root pose matrix
  13858. * @returns a matrix
  13859. */
  13860. getPoseMatrix(): Nullable<Matrix>;
  13861. /**
  13862. * Sorts bones per internal index
  13863. */
  13864. sortBones(): void;
  13865. private _sortBones;
  13866. }
  13867. }
  13868. declare module "babylonjs/Bones/bone" {
  13869. import { Skeleton } from "babylonjs/Bones/skeleton";
  13870. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13871. import { Nullable } from "babylonjs/types";
  13872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13873. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13874. import { Node } from "babylonjs/node";
  13875. import { Space } from "babylonjs/Maths/math.axis";
  13876. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13877. /**
  13878. * Class used to store bone information
  13879. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13880. */
  13881. export class Bone extends Node {
  13882. /**
  13883. * defines the bone name
  13884. */
  13885. name: string;
  13886. private static _tmpVecs;
  13887. private static _tmpQuat;
  13888. private static _tmpMats;
  13889. /**
  13890. * Gets the list of child bones
  13891. */
  13892. children: Bone[];
  13893. /** Gets the animations associated with this bone */
  13894. animations: import("babylonjs/Animations/animation").Animation[];
  13895. /**
  13896. * Gets or sets bone length
  13897. */
  13898. length: number;
  13899. /**
  13900. * @hidden Internal only
  13901. * Set this value to map this bone to a different index in the transform matrices
  13902. * Set this value to -1 to exclude the bone from the transform matrices
  13903. */
  13904. _index: Nullable<number>;
  13905. private _skeleton;
  13906. private _localMatrix;
  13907. private _restPose;
  13908. private _baseMatrix;
  13909. private _absoluteTransform;
  13910. private _invertedAbsoluteTransform;
  13911. private _parent;
  13912. private _scalingDeterminant;
  13913. private _worldTransform;
  13914. private _localScaling;
  13915. private _localRotation;
  13916. private _localPosition;
  13917. private _needToDecompose;
  13918. private _needToCompose;
  13919. /** @hidden */
  13920. _linkedTransformNode: Nullable<TransformNode>;
  13921. /** @hidden */
  13922. _waitingTransformNodeId: Nullable<string>;
  13923. /** @hidden */
  13924. /** @hidden */
  13925. _matrix: Matrix;
  13926. /**
  13927. * Create a new bone
  13928. * @param name defines the bone name
  13929. * @param skeleton defines the parent skeleton
  13930. * @param parentBone defines the parent (can be null if the bone is the root)
  13931. * @param localMatrix defines the local matrix
  13932. * @param restPose defines the rest pose matrix
  13933. * @param baseMatrix defines the base matrix
  13934. * @param index defines index of the bone in the hiearchy
  13935. */
  13936. constructor(
  13937. /**
  13938. * defines the bone name
  13939. */
  13940. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13941. /**
  13942. * Gets the current object class name.
  13943. * @return the class name
  13944. */
  13945. getClassName(): string;
  13946. /**
  13947. * Gets the parent skeleton
  13948. * @returns a skeleton
  13949. */
  13950. getSkeleton(): Skeleton;
  13951. /**
  13952. * Gets parent bone
  13953. * @returns a bone or null if the bone is the root of the bone hierarchy
  13954. */
  13955. getParent(): Nullable<Bone>;
  13956. /**
  13957. * Returns an array containing the root bones
  13958. * @returns an array containing the root bones
  13959. */
  13960. getChildren(): Array<Bone>;
  13961. /**
  13962. * Gets the node index in matrix array generated for rendering
  13963. * @returns the node index
  13964. */
  13965. getIndex(): number;
  13966. /**
  13967. * Sets the parent bone
  13968. * @param parent defines the parent (can be null if the bone is the root)
  13969. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13970. */
  13971. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13972. /**
  13973. * Gets the local matrix
  13974. * @returns a matrix
  13975. */
  13976. getLocalMatrix(): Matrix;
  13977. /**
  13978. * Gets the base matrix (initial matrix which remains unchanged)
  13979. * @returns a matrix
  13980. */
  13981. getBaseMatrix(): Matrix;
  13982. /**
  13983. * Gets the rest pose matrix
  13984. * @returns a matrix
  13985. */
  13986. getRestPose(): Matrix;
  13987. /**
  13988. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13989. */
  13990. getWorldMatrix(): Matrix;
  13991. /**
  13992. * Sets the local matrix to rest pose matrix
  13993. */
  13994. returnToRest(): void;
  13995. /**
  13996. * Gets the inverse of the absolute transform matrix.
  13997. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13998. * @returns a matrix
  13999. */
  14000. getInvertedAbsoluteTransform(): Matrix;
  14001. /**
  14002. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14003. * @returns a matrix
  14004. */
  14005. getAbsoluteTransform(): Matrix;
  14006. /**
  14007. * Links with the given transform node.
  14008. * The local matrix of this bone is copied from the transform node every frame.
  14009. * @param transformNode defines the transform node to link to
  14010. */
  14011. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14012. /**
  14013. * Gets the node used to drive the bone's transformation
  14014. * @returns a transform node or null
  14015. */
  14016. getTransformNode(): Nullable<TransformNode>;
  14017. /** Gets or sets current position (in local space) */
  14018. position: Vector3;
  14019. /** Gets or sets current rotation (in local space) */
  14020. rotation: Vector3;
  14021. /** Gets or sets current rotation quaternion (in local space) */
  14022. rotationQuaternion: Quaternion;
  14023. /** Gets or sets current scaling (in local space) */
  14024. scaling: Vector3;
  14025. /**
  14026. * Gets the animation properties override
  14027. */
  14028. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14029. private _decompose;
  14030. private _compose;
  14031. /**
  14032. * Update the base and local matrices
  14033. * @param matrix defines the new base or local matrix
  14034. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14035. * @param updateLocalMatrix defines if the local matrix should be updated
  14036. */
  14037. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14038. /** @hidden */
  14039. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14040. /**
  14041. * Flag the bone as dirty (Forcing it to update everything)
  14042. */
  14043. markAsDirty(): void;
  14044. /** @hidden */
  14045. _markAsDirtyAndCompose(): void;
  14046. private _markAsDirtyAndDecompose;
  14047. /**
  14048. * Translate the bone in local or world space
  14049. * @param vec The amount to translate the bone
  14050. * @param space The space that the translation is in
  14051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14052. */
  14053. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14054. /**
  14055. * Set the postion of the bone in local or world space
  14056. * @param position The position to set the bone
  14057. * @param space The space that the position is in
  14058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14059. */
  14060. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14061. /**
  14062. * Set the absolute position of the bone (world space)
  14063. * @param position The position to set the bone
  14064. * @param mesh The mesh that this bone is attached to
  14065. */
  14066. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14067. /**
  14068. * Scale the bone on the x, y and z axes (in local space)
  14069. * @param x The amount to scale the bone on the x axis
  14070. * @param y The amount to scale the bone on the y axis
  14071. * @param z The amount to scale the bone on the z axis
  14072. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14073. */
  14074. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14075. /**
  14076. * Set the bone scaling in local space
  14077. * @param scale defines the scaling vector
  14078. */
  14079. setScale(scale: Vector3): void;
  14080. /**
  14081. * Gets the current scaling in local space
  14082. * @returns the current scaling vector
  14083. */
  14084. getScale(): Vector3;
  14085. /**
  14086. * Gets the current scaling in local space and stores it in a target vector
  14087. * @param result defines the target vector
  14088. */
  14089. getScaleToRef(result: Vector3): void;
  14090. /**
  14091. * Set the yaw, pitch, and roll of the bone in local or world space
  14092. * @param yaw The rotation of the bone on the y axis
  14093. * @param pitch The rotation of the bone on the x axis
  14094. * @param roll The rotation of the bone on the z axis
  14095. * @param space The space that the axes of rotation are in
  14096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14097. */
  14098. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14099. /**
  14100. * Add a rotation to the bone on an axis in local or world space
  14101. * @param axis The axis to rotate the bone on
  14102. * @param amount The amount to rotate the bone
  14103. * @param space The space that the axis is in
  14104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14105. */
  14106. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14107. /**
  14108. * Set the rotation of the bone to a particular axis angle in local or world space
  14109. * @param axis The axis to rotate the bone on
  14110. * @param angle The angle that the bone should be rotated to
  14111. * @param space The space that the axis is in
  14112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14113. */
  14114. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14115. /**
  14116. * Set the euler rotation of the bone in local of world space
  14117. * @param rotation The euler rotation that the bone should be set to
  14118. * @param space The space that the rotation is in
  14119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14120. */
  14121. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14122. /**
  14123. * Set the quaternion rotation of the bone in local of world space
  14124. * @param quat The quaternion rotation that the bone should be set to
  14125. * @param space The space that the rotation is in
  14126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14127. */
  14128. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14129. /**
  14130. * Set the rotation matrix of the bone in local of world space
  14131. * @param rotMat The rotation matrix that the bone should be set to
  14132. * @param space The space that the rotation is in
  14133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14134. */
  14135. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14136. private _rotateWithMatrix;
  14137. private _getNegativeRotationToRef;
  14138. /**
  14139. * Get the position of the bone in local or world space
  14140. * @param space The space that the returned position is in
  14141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14142. * @returns The position of the bone
  14143. */
  14144. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14145. /**
  14146. * Copy the position of the bone to a vector3 in local or world space
  14147. * @param space The space that the returned position is in
  14148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14149. * @param result The vector3 to copy the position to
  14150. */
  14151. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14152. /**
  14153. * Get the absolute position of the bone (world space)
  14154. * @param mesh The mesh that this bone is attached to
  14155. * @returns The absolute position of the bone
  14156. */
  14157. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14158. /**
  14159. * Copy the absolute position of the bone (world space) to the result param
  14160. * @param mesh The mesh that this bone is attached to
  14161. * @param result The vector3 to copy the absolute position to
  14162. */
  14163. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14164. /**
  14165. * Compute the absolute transforms of this bone and its children
  14166. */
  14167. computeAbsoluteTransforms(): void;
  14168. /**
  14169. * Get the world direction from an axis that is in the local space of the bone
  14170. * @param localAxis The local direction that is used to compute the world direction
  14171. * @param mesh The mesh that this bone is attached to
  14172. * @returns The world direction
  14173. */
  14174. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14175. /**
  14176. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14177. * @param localAxis The local direction that is used to compute the world direction
  14178. * @param mesh The mesh that this bone is attached to
  14179. * @param result The vector3 that the world direction will be copied to
  14180. */
  14181. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14182. /**
  14183. * Get the euler rotation of the bone in local or world space
  14184. * @param space The space that the rotation should be in
  14185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14186. * @returns The euler rotation
  14187. */
  14188. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14189. /**
  14190. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14191. * @param space The space that the rotation should be in
  14192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14193. * @param result The vector3 that the rotation should be copied to
  14194. */
  14195. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14196. /**
  14197. * Get the quaternion rotation of the bone in either local or world space
  14198. * @param space The space that the rotation should be in
  14199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14200. * @returns The quaternion rotation
  14201. */
  14202. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14203. /**
  14204. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14205. * @param space The space that the rotation should be in
  14206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14207. * @param result The quaternion that the rotation should be copied to
  14208. */
  14209. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14210. /**
  14211. * Get the rotation matrix of the bone in local or world space
  14212. * @param space The space that the rotation should be in
  14213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14214. * @returns The rotation matrix
  14215. */
  14216. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14217. /**
  14218. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14219. * @param space The space that the rotation should be in
  14220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14221. * @param result The quaternion that the rotation should be copied to
  14222. */
  14223. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14224. /**
  14225. * Get the world position of a point that is in the local space of the bone
  14226. * @param position The local position
  14227. * @param mesh The mesh that this bone is attached to
  14228. * @returns The world position
  14229. */
  14230. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14231. /**
  14232. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14233. * @param position The local position
  14234. * @param mesh The mesh that this bone is attached to
  14235. * @param result The vector3 that the world position should be copied to
  14236. */
  14237. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14238. /**
  14239. * Get the local position of a point that is in world space
  14240. * @param position The world position
  14241. * @param mesh The mesh that this bone is attached to
  14242. * @returns The local position
  14243. */
  14244. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14245. /**
  14246. * Get the local position of a point that is in world space and copy it to the result param
  14247. * @param position The world position
  14248. * @param mesh The mesh that this bone is attached to
  14249. * @param result The vector3 that the local position should be copied to
  14250. */
  14251. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14252. }
  14253. }
  14254. declare module "babylonjs/Meshes/transformNode" {
  14255. import { DeepImmutable } from "babylonjs/types";
  14256. import { Observable } from "babylonjs/Misc/observable";
  14257. import { Nullable } from "babylonjs/types";
  14258. import { Camera } from "babylonjs/Cameras/camera";
  14259. import { Scene } from "babylonjs/scene";
  14260. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14261. import { Node } from "babylonjs/node";
  14262. import { Bone } from "babylonjs/Bones/bone";
  14263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14264. import { Space } from "babylonjs/Maths/math.axis";
  14265. /**
  14266. * 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.
  14267. * @see https://doc.babylonjs.com/how_to/transformnode
  14268. */
  14269. export class TransformNode extends Node {
  14270. /**
  14271. * Object will not rotate to face the camera
  14272. */
  14273. static BILLBOARDMODE_NONE: number;
  14274. /**
  14275. * Object will rotate to face the camera but only on the x axis
  14276. */
  14277. static BILLBOARDMODE_X: number;
  14278. /**
  14279. * Object will rotate to face the camera but only on the y axis
  14280. */
  14281. static BILLBOARDMODE_Y: number;
  14282. /**
  14283. * Object will rotate to face the camera but only on the z axis
  14284. */
  14285. static BILLBOARDMODE_Z: number;
  14286. /**
  14287. * Object will rotate to face the camera
  14288. */
  14289. static BILLBOARDMODE_ALL: number;
  14290. /**
  14291. * Object will rotate to face the camera's position instead of orientation
  14292. */
  14293. static BILLBOARDMODE_USE_POSITION: number;
  14294. private _forward;
  14295. private _forwardInverted;
  14296. private _up;
  14297. private _right;
  14298. private _rightInverted;
  14299. private _position;
  14300. private _rotation;
  14301. private _rotationQuaternion;
  14302. protected _scaling: Vector3;
  14303. protected _isDirty: boolean;
  14304. private _transformToBoneReferal;
  14305. private _isAbsoluteSynced;
  14306. private _billboardMode;
  14307. /**
  14308. * Gets or sets the billboard mode. Default is 0.
  14309. *
  14310. * | Value | Type | Description |
  14311. * | --- | --- | --- |
  14312. * | 0 | BILLBOARDMODE_NONE | |
  14313. * | 1 | BILLBOARDMODE_X | |
  14314. * | 2 | BILLBOARDMODE_Y | |
  14315. * | 4 | BILLBOARDMODE_Z | |
  14316. * | 7 | BILLBOARDMODE_ALL | |
  14317. *
  14318. */
  14319. billboardMode: number;
  14320. private _preserveParentRotationForBillboard;
  14321. /**
  14322. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14323. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14324. */
  14325. preserveParentRotationForBillboard: boolean;
  14326. /**
  14327. * 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
  14328. */
  14329. scalingDeterminant: number;
  14330. private _infiniteDistance;
  14331. /**
  14332. * Gets or sets the distance of the object to max, often used by skybox
  14333. */
  14334. infiniteDistance: boolean;
  14335. /**
  14336. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14337. * By default the system will update normals to compensate
  14338. */
  14339. ignoreNonUniformScaling: boolean;
  14340. /**
  14341. * 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
  14342. */
  14343. reIntegrateRotationIntoRotationQuaternion: boolean;
  14344. /** @hidden */
  14345. _poseMatrix: Nullable<Matrix>;
  14346. /** @hidden */
  14347. _localMatrix: Matrix;
  14348. private _usePivotMatrix;
  14349. private _absolutePosition;
  14350. private _absoluteScaling;
  14351. private _absoluteRotationQuaternion;
  14352. private _pivotMatrix;
  14353. private _pivotMatrixInverse;
  14354. protected _postMultiplyPivotMatrix: boolean;
  14355. protected _isWorldMatrixFrozen: boolean;
  14356. /** @hidden */
  14357. _indexInSceneTransformNodesArray: number;
  14358. /**
  14359. * An event triggered after the world matrix is updated
  14360. */
  14361. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14362. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14363. /**
  14364. * Gets a string identifying the name of the class
  14365. * @returns "TransformNode" string
  14366. */
  14367. getClassName(): string;
  14368. /**
  14369. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14370. */
  14371. position: Vector3;
  14372. /**
  14373. * 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)).
  14374. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14375. */
  14376. rotation: Vector3;
  14377. /**
  14378. * 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)).
  14379. */
  14380. scaling: Vector3;
  14381. /**
  14382. * 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).
  14383. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14384. */
  14385. rotationQuaternion: Nullable<Quaternion>;
  14386. /**
  14387. * The forward direction of that transform in world space.
  14388. */
  14389. readonly forward: Vector3;
  14390. /**
  14391. * The up direction of that transform in world space.
  14392. */
  14393. readonly up: Vector3;
  14394. /**
  14395. * The right direction of that transform in world space.
  14396. */
  14397. readonly right: Vector3;
  14398. /**
  14399. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14400. * @param matrix the matrix to copy the pose from
  14401. * @returns this TransformNode.
  14402. */
  14403. updatePoseMatrix(matrix: Matrix): TransformNode;
  14404. /**
  14405. * Returns the mesh Pose matrix.
  14406. * @returns the pose matrix
  14407. */
  14408. getPoseMatrix(): Matrix;
  14409. /** @hidden */
  14410. _isSynchronized(): boolean;
  14411. /** @hidden */
  14412. _initCache(): void;
  14413. /**
  14414. * Flag the transform node as dirty (Forcing it to update everything)
  14415. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14416. * @returns this transform node
  14417. */
  14418. markAsDirty(property: string): TransformNode;
  14419. /**
  14420. * Returns the current mesh absolute position.
  14421. * Returns a Vector3.
  14422. */
  14423. readonly absolutePosition: Vector3;
  14424. /**
  14425. * Returns the current mesh absolute scaling.
  14426. * Returns a Vector3.
  14427. */
  14428. readonly absoluteScaling: Vector3;
  14429. /**
  14430. * Returns the current mesh absolute rotation.
  14431. * Returns a Quaternion.
  14432. */
  14433. readonly absoluteRotationQuaternion: Quaternion;
  14434. /**
  14435. * Sets a new matrix to apply before all other transformation
  14436. * @param matrix defines the transform matrix
  14437. * @returns the current TransformNode
  14438. */
  14439. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14440. /**
  14441. * Sets a new pivot matrix to the current node
  14442. * @param matrix defines the new pivot matrix to use
  14443. * @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
  14444. * @returns the current TransformNode
  14445. */
  14446. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14447. /**
  14448. * Returns the mesh pivot matrix.
  14449. * Default : Identity.
  14450. * @returns the matrix
  14451. */
  14452. getPivotMatrix(): Matrix;
  14453. /**
  14454. * Instantiate (when possible) or clone that node with its hierarchy
  14455. * @param newParent defines the new parent to use for the instance (or clone)
  14456. * @param options defines options to configure how copy is done
  14457. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14458. * @returns an instance (or a clone) of the current node with its hiearchy
  14459. */
  14460. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14461. doNotInstantiate: boolean;
  14462. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14463. /**
  14464. * Prevents the World matrix to be computed any longer
  14465. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14466. * @returns the TransformNode.
  14467. */
  14468. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14469. /**
  14470. * Allows back the World matrix computation.
  14471. * @returns the TransformNode.
  14472. */
  14473. unfreezeWorldMatrix(): this;
  14474. /**
  14475. * True if the World matrix has been frozen.
  14476. */
  14477. readonly isWorldMatrixFrozen: boolean;
  14478. /**
  14479. * Retuns the mesh absolute position in the World.
  14480. * @returns a Vector3.
  14481. */
  14482. getAbsolutePosition(): Vector3;
  14483. /**
  14484. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14485. * @param absolutePosition the absolute position to set
  14486. * @returns the TransformNode.
  14487. */
  14488. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14489. /**
  14490. * Sets the mesh position in its local space.
  14491. * @param vector3 the position to set in localspace
  14492. * @returns the TransformNode.
  14493. */
  14494. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14495. /**
  14496. * Returns the mesh position in the local space from the current World matrix values.
  14497. * @returns a new Vector3.
  14498. */
  14499. getPositionExpressedInLocalSpace(): Vector3;
  14500. /**
  14501. * Translates the mesh along the passed Vector3 in its local space.
  14502. * @param vector3 the distance to translate in localspace
  14503. * @returns the TransformNode.
  14504. */
  14505. locallyTranslate(vector3: Vector3): TransformNode;
  14506. private static _lookAtVectorCache;
  14507. /**
  14508. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14509. * @param targetPoint the position (must be in same space as current mesh) to look at
  14510. * @param yawCor optional yaw (y-axis) correction in radians
  14511. * @param pitchCor optional pitch (x-axis) correction in radians
  14512. * @param rollCor optional roll (z-axis) correction in radians
  14513. * @param space the choosen space of the target
  14514. * @returns the TransformNode.
  14515. */
  14516. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14517. /**
  14518. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14519. * This Vector3 is expressed in the World space.
  14520. * @param localAxis axis to rotate
  14521. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14522. */
  14523. getDirection(localAxis: Vector3): Vector3;
  14524. /**
  14525. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14526. * localAxis is expressed in the mesh local space.
  14527. * result is computed in the Wordl space from the mesh World matrix.
  14528. * @param localAxis axis to rotate
  14529. * @param result the resulting transformnode
  14530. * @returns this TransformNode.
  14531. */
  14532. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14533. /**
  14534. * Sets this transform node rotation to the given local axis.
  14535. * @param localAxis the axis in local space
  14536. * @param yawCor optional yaw (y-axis) correction in radians
  14537. * @param pitchCor optional pitch (x-axis) correction in radians
  14538. * @param rollCor optional roll (z-axis) correction in radians
  14539. * @returns this TransformNode
  14540. */
  14541. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14542. /**
  14543. * Sets a new pivot point to the current node
  14544. * @param point defines the new pivot point to use
  14545. * @param space defines if the point is in world or local space (local by default)
  14546. * @returns the current TransformNode
  14547. */
  14548. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14549. /**
  14550. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14551. * @returns the pivot point
  14552. */
  14553. getPivotPoint(): Vector3;
  14554. /**
  14555. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14556. * @param result the vector3 to store the result
  14557. * @returns this TransformNode.
  14558. */
  14559. getPivotPointToRef(result: Vector3): TransformNode;
  14560. /**
  14561. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14562. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14563. */
  14564. getAbsolutePivotPoint(): Vector3;
  14565. /**
  14566. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14567. * @param result vector3 to store the result
  14568. * @returns this TransformNode.
  14569. */
  14570. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14571. /**
  14572. * Defines the passed node as the parent of the current node.
  14573. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14574. * @see https://doc.babylonjs.com/how_to/parenting
  14575. * @param node the node ot set as the parent
  14576. * @returns this TransformNode.
  14577. */
  14578. setParent(node: Nullable<Node>): TransformNode;
  14579. private _nonUniformScaling;
  14580. /**
  14581. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14582. */
  14583. readonly nonUniformScaling: boolean;
  14584. /** @hidden */
  14585. _updateNonUniformScalingState(value: boolean): boolean;
  14586. /**
  14587. * Attach the current TransformNode to another TransformNode associated with a bone
  14588. * @param bone Bone affecting the TransformNode
  14589. * @param affectedTransformNode TransformNode associated with the bone
  14590. * @returns this object
  14591. */
  14592. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14593. /**
  14594. * Detach the transform node if its associated with a bone
  14595. * @returns this object
  14596. */
  14597. detachFromBone(): TransformNode;
  14598. private static _rotationAxisCache;
  14599. /**
  14600. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14601. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14602. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14603. * The passed axis is also normalized.
  14604. * @param axis the axis to rotate around
  14605. * @param amount the amount to rotate in radians
  14606. * @param space Space to rotate in (Default: local)
  14607. * @returns the TransformNode.
  14608. */
  14609. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14610. /**
  14611. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14612. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14613. * The passed axis is also normalized. .
  14614. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14615. * @param point the point to rotate around
  14616. * @param axis the axis to rotate around
  14617. * @param amount the amount to rotate in radians
  14618. * @returns the TransformNode
  14619. */
  14620. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14621. /**
  14622. * Translates the mesh along the axis vector for the passed distance in the given space.
  14623. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14624. * @param axis the axis to translate in
  14625. * @param distance the distance to translate
  14626. * @param space Space to rotate in (Default: local)
  14627. * @returns the TransformNode.
  14628. */
  14629. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14630. /**
  14631. * Adds a rotation step to the mesh current rotation.
  14632. * x, y, z are Euler angles expressed in radians.
  14633. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14634. * This means this rotation is made in the mesh local space only.
  14635. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14636. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14637. * ```javascript
  14638. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14639. * ```
  14640. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14641. * 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.
  14642. * @param x Rotation to add
  14643. * @param y Rotation to add
  14644. * @param z Rotation to add
  14645. * @returns the TransformNode.
  14646. */
  14647. addRotation(x: number, y: number, z: number): TransformNode;
  14648. /**
  14649. * @hidden
  14650. */
  14651. protected _getEffectiveParent(): Nullable<Node>;
  14652. /**
  14653. * Computes the world matrix of the node
  14654. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14655. * @returns the world matrix
  14656. */
  14657. computeWorldMatrix(force?: boolean): Matrix;
  14658. protected _afterComputeWorldMatrix(): void;
  14659. /**
  14660. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14661. * @param func callback function to add
  14662. *
  14663. * @returns the TransformNode.
  14664. */
  14665. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14666. /**
  14667. * Removes a registered callback function.
  14668. * @param func callback function to remove
  14669. * @returns the TransformNode.
  14670. */
  14671. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14672. /**
  14673. * Gets the position of the current mesh in camera space
  14674. * @param camera defines the camera to use
  14675. * @returns a position
  14676. */
  14677. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14678. /**
  14679. * Returns the distance from the mesh to the active camera
  14680. * @param camera defines the camera to use
  14681. * @returns the distance
  14682. */
  14683. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14684. /**
  14685. * Clone the current transform node
  14686. * @param name Name of the new clone
  14687. * @param newParent New parent for the clone
  14688. * @param doNotCloneChildren Do not clone children hierarchy
  14689. * @returns the new transform node
  14690. */
  14691. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14692. /**
  14693. * Serializes the objects information.
  14694. * @param currentSerializationObject defines the object to serialize in
  14695. * @returns the serialized object
  14696. */
  14697. serialize(currentSerializationObject?: any): any;
  14698. /**
  14699. * Returns a new TransformNode object parsed from the source provided.
  14700. * @param parsedTransformNode is the source.
  14701. * @param scene the scne the object belongs to
  14702. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14703. * @returns a new TransformNode object parsed from the source provided.
  14704. */
  14705. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14706. /**
  14707. * Get all child-transformNodes of this node
  14708. * @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
  14709. * @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
  14710. * @returns an array of TransformNode
  14711. */
  14712. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14713. /**
  14714. * Releases resources associated with this transform node.
  14715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14717. */
  14718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14719. /**
  14720. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14721. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14722. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14723. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14724. * @returns the current mesh
  14725. */
  14726. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14727. private _syncAbsoluteScalingAndRotation;
  14728. }
  14729. }
  14730. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14731. import { Observable } from "babylonjs/Misc/observable";
  14732. import { Nullable } from "babylonjs/types";
  14733. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14734. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14736. import { Ray } from "babylonjs/Culling/ray";
  14737. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14738. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14739. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14740. /**
  14741. * Defines the types of pose enabled controllers that are supported
  14742. */
  14743. export enum PoseEnabledControllerType {
  14744. /**
  14745. * HTC Vive
  14746. */
  14747. VIVE = 0,
  14748. /**
  14749. * Oculus Rift
  14750. */
  14751. OCULUS = 1,
  14752. /**
  14753. * Windows mixed reality
  14754. */
  14755. WINDOWS = 2,
  14756. /**
  14757. * Samsung gear VR
  14758. */
  14759. GEAR_VR = 3,
  14760. /**
  14761. * Google Daydream
  14762. */
  14763. DAYDREAM = 4,
  14764. /**
  14765. * Generic
  14766. */
  14767. GENERIC = 5
  14768. }
  14769. /**
  14770. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14771. */
  14772. export interface MutableGamepadButton {
  14773. /**
  14774. * Value of the button/trigger
  14775. */
  14776. value: number;
  14777. /**
  14778. * If the button/trigger is currently touched
  14779. */
  14780. touched: boolean;
  14781. /**
  14782. * If the button/trigger is currently pressed
  14783. */
  14784. pressed: boolean;
  14785. }
  14786. /**
  14787. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14788. * @hidden
  14789. */
  14790. export interface ExtendedGamepadButton extends GamepadButton {
  14791. /**
  14792. * If the button/trigger is currently pressed
  14793. */
  14794. readonly pressed: boolean;
  14795. /**
  14796. * If the button/trigger is currently touched
  14797. */
  14798. readonly touched: boolean;
  14799. /**
  14800. * Value of the button/trigger
  14801. */
  14802. readonly value: number;
  14803. }
  14804. /** @hidden */
  14805. export interface _GamePadFactory {
  14806. /**
  14807. * Returns wether or not the current gamepad can be created for this type of controller.
  14808. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14809. * @returns true if it can be created, otherwise false
  14810. */
  14811. canCreate(gamepadInfo: any): boolean;
  14812. /**
  14813. * Creates a new instance of the Gamepad.
  14814. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14815. * @returns the new gamepad instance
  14816. */
  14817. create(gamepadInfo: any): Gamepad;
  14818. }
  14819. /**
  14820. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14821. */
  14822. export class PoseEnabledControllerHelper {
  14823. /** @hidden */
  14824. static _ControllerFactories: _GamePadFactory[];
  14825. /** @hidden */
  14826. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14827. /**
  14828. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14829. * @param vrGamepad the gamepad to initialized
  14830. * @returns a vr controller of the type the gamepad identified as
  14831. */
  14832. static InitiateController(vrGamepad: any): Gamepad;
  14833. }
  14834. /**
  14835. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14836. */
  14837. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14838. /**
  14839. * If the controller is used in a webXR session
  14840. */
  14841. isXR: boolean;
  14842. private _deviceRoomPosition;
  14843. private _deviceRoomRotationQuaternion;
  14844. /**
  14845. * The device position in babylon space
  14846. */
  14847. devicePosition: Vector3;
  14848. /**
  14849. * The device rotation in babylon space
  14850. */
  14851. deviceRotationQuaternion: Quaternion;
  14852. /**
  14853. * The scale factor of the device in babylon space
  14854. */
  14855. deviceScaleFactor: number;
  14856. /**
  14857. * (Likely devicePosition should be used instead) The device position in its room space
  14858. */
  14859. position: Vector3;
  14860. /**
  14861. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14862. */
  14863. rotationQuaternion: Quaternion;
  14864. /**
  14865. * The type of controller (Eg. Windows mixed reality)
  14866. */
  14867. controllerType: PoseEnabledControllerType;
  14868. protected _calculatedPosition: Vector3;
  14869. private _calculatedRotation;
  14870. /**
  14871. * The raw pose from the device
  14872. */
  14873. rawPose: DevicePose;
  14874. private _trackPosition;
  14875. private _maxRotationDistFromHeadset;
  14876. private _draggedRoomRotation;
  14877. /**
  14878. * @hidden
  14879. */
  14880. _disableTrackPosition(fixedPosition: Vector3): void;
  14881. /**
  14882. * Internal, the mesh attached to the controller
  14883. * @hidden
  14884. */
  14885. _mesh: Nullable<AbstractMesh>;
  14886. private _poseControlledCamera;
  14887. private _leftHandSystemQuaternion;
  14888. /**
  14889. * Internal, matrix used to convert room space to babylon space
  14890. * @hidden
  14891. */
  14892. _deviceToWorld: Matrix;
  14893. /**
  14894. * Node to be used when casting a ray from the controller
  14895. * @hidden
  14896. */
  14897. _pointingPoseNode: Nullable<TransformNode>;
  14898. /**
  14899. * Name of the child mesh that can be used to cast a ray from the controller
  14900. */
  14901. static readonly POINTING_POSE: string;
  14902. /**
  14903. * Creates a new PoseEnabledController from a gamepad
  14904. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14905. */
  14906. constructor(browserGamepad: any);
  14907. private _workingMatrix;
  14908. /**
  14909. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14910. */
  14911. update(): void;
  14912. /**
  14913. * Updates only the pose device and mesh without doing any button event checking
  14914. */
  14915. protected _updatePoseAndMesh(): void;
  14916. /**
  14917. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14918. * @param poseData raw pose fromthe device
  14919. */
  14920. updateFromDevice(poseData: DevicePose): void;
  14921. /**
  14922. * @hidden
  14923. */
  14924. _meshAttachedObservable: Observable<AbstractMesh>;
  14925. /**
  14926. * Attaches a mesh to the controller
  14927. * @param mesh the mesh to be attached
  14928. */
  14929. attachToMesh(mesh: AbstractMesh): void;
  14930. /**
  14931. * Attaches the controllers mesh to a camera
  14932. * @param camera the camera the mesh should be attached to
  14933. */
  14934. attachToPoseControlledCamera(camera: TargetCamera): void;
  14935. /**
  14936. * Disposes of the controller
  14937. */
  14938. dispose(): void;
  14939. /**
  14940. * The mesh that is attached to the controller
  14941. */
  14942. readonly mesh: Nullable<AbstractMesh>;
  14943. /**
  14944. * Gets the ray of the controller in the direction the controller is pointing
  14945. * @param length the length the resulting ray should be
  14946. * @returns a ray in the direction the controller is pointing
  14947. */
  14948. getForwardRay(length?: number): Ray;
  14949. }
  14950. }
  14951. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14952. import { Observable } from "babylonjs/Misc/observable";
  14953. import { Scene } from "babylonjs/scene";
  14954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14955. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14956. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14957. import { Nullable } from "babylonjs/types";
  14958. /**
  14959. * Defines the WebVRController object that represents controllers tracked in 3D space
  14960. */
  14961. export abstract class WebVRController extends PoseEnabledController {
  14962. /**
  14963. * Internal, the default controller model for the controller
  14964. */
  14965. protected _defaultModel: Nullable<AbstractMesh>;
  14966. /**
  14967. * Fired when the trigger state has changed
  14968. */
  14969. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14970. /**
  14971. * Fired when the main button state has changed
  14972. */
  14973. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14974. /**
  14975. * Fired when the secondary button state has changed
  14976. */
  14977. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14978. /**
  14979. * Fired when the pad state has changed
  14980. */
  14981. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14982. /**
  14983. * Fired when controllers stick values have changed
  14984. */
  14985. onPadValuesChangedObservable: Observable<StickValues>;
  14986. /**
  14987. * Array of button availible on the controller
  14988. */
  14989. protected _buttons: Array<MutableGamepadButton>;
  14990. private _onButtonStateChange;
  14991. /**
  14992. * Fired when a controller button's state has changed
  14993. * @param callback the callback containing the button that was modified
  14994. */
  14995. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14996. /**
  14997. * X and Y axis corresponding to the controllers joystick
  14998. */
  14999. pad: StickValues;
  15000. /**
  15001. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15002. */
  15003. hand: string;
  15004. /**
  15005. * The default controller model for the controller
  15006. */
  15007. readonly defaultModel: Nullable<AbstractMesh>;
  15008. /**
  15009. * Creates a new WebVRController from a gamepad
  15010. * @param vrGamepad the gamepad that the WebVRController should be created from
  15011. */
  15012. constructor(vrGamepad: any);
  15013. /**
  15014. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15015. */
  15016. update(): void;
  15017. /**
  15018. * Function to be called when a button is modified
  15019. */
  15020. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15021. /**
  15022. * Loads a mesh and attaches it to the controller
  15023. * @param scene the scene the mesh should be added to
  15024. * @param meshLoaded callback for when the mesh has been loaded
  15025. */
  15026. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15027. private _setButtonValue;
  15028. private _changes;
  15029. private _checkChanges;
  15030. /**
  15031. * Disposes of th webVRCOntroller
  15032. */
  15033. dispose(): void;
  15034. }
  15035. }
  15036. declare module "babylonjs/Lights/hemisphericLight" {
  15037. import { Nullable } from "babylonjs/types";
  15038. import { Scene } from "babylonjs/scene";
  15039. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15040. import { Color3 } from "babylonjs/Maths/math.color";
  15041. import { Effect } from "babylonjs/Materials/effect";
  15042. import { Light } from "babylonjs/Lights/light";
  15043. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15044. /**
  15045. * The HemisphericLight simulates the ambient environment light,
  15046. * so the passed direction is the light reflection direction, not the incoming direction.
  15047. */
  15048. export class HemisphericLight extends Light {
  15049. /**
  15050. * The groundColor is the light in the opposite direction to the one specified during creation.
  15051. * 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.
  15052. */
  15053. groundColor: Color3;
  15054. /**
  15055. * The light reflection direction, not the incoming direction.
  15056. */
  15057. direction: Vector3;
  15058. /**
  15059. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15060. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15061. * The HemisphericLight can't cast shadows.
  15062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15063. * @param name The friendly name of the light
  15064. * @param direction The direction of the light reflection
  15065. * @param scene The scene the light belongs to
  15066. */
  15067. constructor(name: string, direction: Vector3, scene: Scene);
  15068. protected _buildUniformLayout(): void;
  15069. /**
  15070. * Returns the string "HemisphericLight".
  15071. * @return The class name
  15072. */
  15073. getClassName(): string;
  15074. /**
  15075. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15076. * Returns the updated direction.
  15077. * @param target The target the direction should point to
  15078. * @return The computed direction
  15079. */
  15080. setDirectionToTarget(target: Vector3): Vector3;
  15081. /**
  15082. * Returns the shadow generator associated to the light.
  15083. * @returns Always null for hemispheric lights because it does not support shadows.
  15084. */
  15085. getShadowGenerator(): Nullable<IShadowGenerator>;
  15086. /**
  15087. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15088. * @param effect The effect to update
  15089. * @param lightIndex The index of the light in the effect to update
  15090. * @returns The hemispheric light
  15091. */
  15092. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15093. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15094. /**
  15095. * Computes the world matrix of the node
  15096. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15097. * @param useWasUpdatedFlag defines a reserved property
  15098. * @returns the world matrix
  15099. */
  15100. computeWorldMatrix(): Matrix;
  15101. /**
  15102. * Returns the integer 3.
  15103. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15104. */
  15105. getTypeID(): number;
  15106. /**
  15107. * Prepares the list of defines specific to the light type.
  15108. * @param defines the list of defines
  15109. * @param lightIndex defines the index of the light for the effect
  15110. */
  15111. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15112. }
  15113. }
  15114. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15115. /** @hidden */
  15116. export var vrMultiviewToSingleviewPixelShader: {
  15117. name: string;
  15118. shader: string;
  15119. };
  15120. }
  15121. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15123. import { Scene } from "babylonjs/scene";
  15124. /**
  15125. * Renders to multiple views with a single draw call
  15126. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15127. */
  15128. export class MultiviewRenderTarget extends RenderTargetTexture {
  15129. /**
  15130. * Creates a multiview render target
  15131. * @param scene scene used with the render target
  15132. * @param size the size of the render target (used for each view)
  15133. */
  15134. constructor(scene: Scene, size?: number | {
  15135. width: number;
  15136. height: number;
  15137. } | {
  15138. ratio: number;
  15139. });
  15140. /**
  15141. * @hidden
  15142. * @param faceIndex the face index, if its a cube texture
  15143. */
  15144. _bindFrameBuffer(faceIndex?: number): void;
  15145. /**
  15146. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15147. * @returns the view count
  15148. */
  15149. getViewCount(): number;
  15150. }
  15151. }
  15152. declare module "babylonjs/Maths/math.frustum" {
  15153. import { Matrix } from "babylonjs/Maths/math.vector";
  15154. import { DeepImmutable } from "babylonjs/types";
  15155. import { Plane } from "babylonjs/Maths/math.plane";
  15156. /**
  15157. * Represents a camera frustum
  15158. */
  15159. export class Frustum {
  15160. /**
  15161. * Gets the planes representing the frustum
  15162. * @param transform matrix to be applied to the returned planes
  15163. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15164. */
  15165. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15166. /**
  15167. * Gets the near frustum plane transformed by the transform matrix
  15168. * @param transform transformation matrix to be applied to the resulting frustum plane
  15169. * @param frustumPlane the resuling frustum plane
  15170. */
  15171. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15172. /**
  15173. * Gets the far frustum plane transformed by the transform matrix
  15174. * @param transform transformation matrix to be applied to the resulting frustum plane
  15175. * @param frustumPlane the resuling frustum plane
  15176. */
  15177. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15178. /**
  15179. * Gets the left frustum plane transformed by the transform matrix
  15180. * @param transform transformation matrix to be applied to the resulting frustum plane
  15181. * @param frustumPlane the resuling frustum plane
  15182. */
  15183. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15184. /**
  15185. * Gets the right frustum plane transformed by the transform matrix
  15186. * @param transform transformation matrix to be applied to the resulting frustum plane
  15187. * @param frustumPlane the resuling frustum plane
  15188. */
  15189. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15190. /**
  15191. * Gets the top frustum plane transformed by the transform matrix
  15192. * @param transform transformation matrix to be applied to the resulting frustum plane
  15193. * @param frustumPlane the resuling frustum plane
  15194. */
  15195. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15196. /**
  15197. * Gets the bottom frustum plane transformed by the transform matrix
  15198. * @param transform transformation matrix to be applied to the resulting frustum plane
  15199. * @param frustumPlane the resuling frustum plane
  15200. */
  15201. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15202. /**
  15203. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15204. * @param transform transformation matrix to be applied to the resulting frustum planes
  15205. * @param frustumPlanes the resuling frustum planes
  15206. */
  15207. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15208. }
  15209. }
  15210. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15211. import { Camera } from "babylonjs/Cameras/camera";
  15212. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15213. import { Nullable } from "babylonjs/types";
  15214. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15215. import { Matrix } from "babylonjs/Maths/math.vector";
  15216. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15217. module "babylonjs/Engines/engine" {
  15218. interface Engine {
  15219. /**
  15220. * Creates a new multiview render target
  15221. * @param width defines the width of the texture
  15222. * @param height defines the height of the texture
  15223. * @returns the created multiview texture
  15224. */
  15225. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15226. /**
  15227. * Binds a multiview framebuffer to be drawn to
  15228. * @param multiviewTexture texture to bind
  15229. */
  15230. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15231. }
  15232. }
  15233. module "babylonjs/Cameras/camera" {
  15234. interface Camera {
  15235. /**
  15236. * @hidden
  15237. * 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)
  15238. */
  15239. _useMultiviewToSingleView: boolean;
  15240. /**
  15241. * @hidden
  15242. * 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)
  15243. */
  15244. _multiviewTexture: Nullable<RenderTargetTexture>;
  15245. /**
  15246. * @hidden
  15247. * ensures the multiview texture of the camera exists and has the specified width/height
  15248. * @param width height to set on the multiview texture
  15249. * @param height width to set on the multiview texture
  15250. */
  15251. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15252. }
  15253. }
  15254. module "babylonjs/scene" {
  15255. interface Scene {
  15256. /** @hidden */
  15257. _transformMatrixR: Matrix;
  15258. /** @hidden */
  15259. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15260. /** @hidden */
  15261. _createMultiviewUbo(): void;
  15262. /** @hidden */
  15263. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15264. /** @hidden */
  15265. _renderMultiviewToSingleView(camera: Camera): void;
  15266. }
  15267. }
  15268. }
  15269. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15270. import { Camera } from "babylonjs/Cameras/camera";
  15271. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15272. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15273. import "babylonjs/Engines/Extensions/engine.multiview";
  15274. /**
  15275. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15276. * This will not be used for webXR as it supports displaying texture arrays directly
  15277. */
  15278. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15279. /**
  15280. * Initializes a VRMultiviewToSingleview
  15281. * @param name name of the post process
  15282. * @param camera camera to be applied to
  15283. * @param scaleFactor scaling factor to the size of the output texture
  15284. */
  15285. constructor(name: string, camera: Camera, scaleFactor: number);
  15286. }
  15287. }
  15288. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15289. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15290. import { Nullable } from "babylonjs/types";
  15291. import { Size } from "babylonjs/Maths/math.size";
  15292. import { Observable } from "babylonjs/Misc/observable";
  15293. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15294. /**
  15295. * Interface used to define additional presentation attributes
  15296. */
  15297. export interface IVRPresentationAttributes {
  15298. /**
  15299. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15300. */
  15301. highRefreshRate: boolean;
  15302. /**
  15303. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15304. */
  15305. foveationLevel: number;
  15306. }
  15307. module "babylonjs/Engines/engine" {
  15308. interface Engine {
  15309. /** @hidden */
  15310. _vrDisplay: any;
  15311. /** @hidden */
  15312. _vrSupported: boolean;
  15313. /** @hidden */
  15314. _oldSize: Size;
  15315. /** @hidden */
  15316. _oldHardwareScaleFactor: number;
  15317. /** @hidden */
  15318. _vrExclusivePointerMode: boolean;
  15319. /** @hidden */
  15320. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15321. /** @hidden */
  15322. _onVRDisplayPointerRestricted: () => void;
  15323. /** @hidden */
  15324. _onVRDisplayPointerUnrestricted: () => void;
  15325. /** @hidden */
  15326. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15327. /** @hidden */
  15328. _onVrDisplayDisconnect: Nullable<() => void>;
  15329. /** @hidden */
  15330. _onVrDisplayPresentChange: Nullable<() => void>;
  15331. /**
  15332. * Observable signaled when VR display mode changes
  15333. */
  15334. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15335. /**
  15336. * Observable signaled when VR request present is complete
  15337. */
  15338. onVRRequestPresentComplete: Observable<boolean>;
  15339. /**
  15340. * Observable signaled when VR request present starts
  15341. */
  15342. onVRRequestPresentStart: Observable<Engine>;
  15343. /**
  15344. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15345. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15346. */
  15347. isInVRExclusivePointerMode: boolean;
  15348. /**
  15349. * Gets a boolean indicating if a webVR device was detected
  15350. * @returns true if a webVR device was detected
  15351. */
  15352. isVRDevicePresent(): boolean;
  15353. /**
  15354. * Gets the current webVR device
  15355. * @returns the current webVR device (or null)
  15356. */
  15357. getVRDevice(): any;
  15358. /**
  15359. * Initializes a webVR display and starts listening to display change events
  15360. * The onVRDisplayChangedObservable will be notified upon these changes
  15361. * @returns A promise containing a VRDisplay and if vr is supported
  15362. */
  15363. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15364. /** @hidden */
  15365. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15366. /**
  15367. * Gets or sets the presentation attributes used to configure VR rendering
  15368. */
  15369. vrPresentationAttributes?: IVRPresentationAttributes;
  15370. /**
  15371. * Call this function to switch to webVR mode
  15372. * Will do nothing if webVR is not supported or if there is no webVR device
  15373. * @param options the webvr options provided to the camera. mainly used for multiview
  15374. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15375. */
  15376. enableVR(options: WebVROptions): void;
  15377. /** @hidden */
  15378. _onVRFullScreenTriggered(): void;
  15379. }
  15380. }
  15381. }
  15382. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15383. import { Nullable } from "babylonjs/types";
  15384. import { Observable } from "babylonjs/Misc/observable";
  15385. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15386. import { Scene } from "babylonjs/scene";
  15387. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15388. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15389. import { Node } from "babylonjs/node";
  15390. import { Ray } from "babylonjs/Culling/ray";
  15391. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15392. import "babylonjs/Engines/Extensions/engine.webVR";
  15393. /**
  15394. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15395. * IMPORTANT!! The data is right-hand data.
  15396. * @export
  15397. * @interface DevicePose
  15398. */
  15399. export interface DevicePose {
  15400. /**
  15401. * The position of the device, values in array are [x,y,z].
  15402. */
  15403. readonly position: Nullable<Float32Array>;
  15404. /**
  15405. * The linearVelocity of the device, values in array are [x,y,z].
  15406. */
  15407. readonly linearVelocity: Nullable<Float32Array>;
  15408. /**
  15409. * The linearAcceleration of the device, values in array are [x,y,z].
  15410. */
  15411. readonly linearAcceleration: Nullable<Float32Array>;
  15412. /**
  15413. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15414. */
  15415. readonly orientation: Nullable<Float32Array>;
  15416. /**
  15417. * The angularVelocity of the device, values in array are [x,y,z].
  15418. */
  15419. readonly angularVelocity: Nullable<Float32Array>;
  15420. /**
  15421. * The angularAcceleration of the device, values in array are [x,y,z].
  15422. */
  15423. readonly angularAcceleration: Nullable<Float32Array>;
  15424. }
  15425. /**
  15426. * Interface representing a pose controlled object in Babylon.
  15427. * A pose controlled object has both regular pose values as well as pose values
  15428. * from an external device such as a VR head mounted display
  15429. */
  15430. export interface PoseControlled {
  15431. /**
  15432. * The position of the object in babylon space.
  15433. */
  15434. position: Vector3;
  15435. /**
  15436. * The rotation quaternion of the object in babylon space.
  15437. */
  15438. rotationQuaternion: Quaternion;
  15439. /**
  15440. * The position of the device in babylon space.
  15441. */
  15442. devicePosition?: Vector3;
  15443. /**
  15444. * The rotation quaternion of the device in babylon space.
  15445. */
  15446. deviceRotationQuaternion: Quaternion;
  15447. /**
  15448. * The raw pose coming from the device.
  15449. */
  15450. rawPose: Nullable<DevicePose>;
  15451. /**
  15452. * The scale of the device to be used when translating from device space to babylon space.
  15453. */
  15454. deviceScaleFactor: number;
  15455. /**
  15456. * Updates the poseControlled values based on the input device pose.
  15457. * @param poseData the pose data to update the object with
  15458. */
  15459. updateFromDevice(poseData: DevicePose): void;
  15460. }
  15461. /**
  15462. * Set of options to customize the webVRCamera
  15463. */
  15464. export interface WebVROptions {
  15465. /**
  15466. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15467. */
  15468. trackPosition?: boolean;
  15469. /**
  15470. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15471. */
  15472. positionScale?: number;
  15473. /**
  15474. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15475. */
  15476. displayName?: string;
  15477. /**
  15478. * Should the native controller meshes be initialized. (default: true)
  15479. */
  15480. controllerMeshes?: boolean;
  15481. /**
  15482. * Creating a default HemiLight only on controllers. (default: true)
  15483. */
  15484. defaultLightingOnControllers?: boolean;
  15485. /**
  15486. * If you don't want to use the default VR button of the helper. (default: false)
  15487. */
  15488. useCustomVRButton?: boolean;
  15489. /**
  15490. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15491. */
  15492. customVRButton?: HTMLButtonElement;
  15493. /**
  15494. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15495. */
  15496. rayLength?: number;
  15497. /**
  15498. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15499. */
  15500. defaultHeight?: number;
  15501. /**
  15502. * If multiview should be used if availible (default: false)
  15503. */
  15504. useMultiview?: boolean;
  15505. }
  15506. /**
  15507. * This represents a WebVR camera.
  15508. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15509. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15510. */
  15511. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15512. private webVROptions;
  15513. /**
  15514. * @hidden
  15515. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15516. */
  15517. _vrDevice: any;
  15518. /**
  15519. * The rawPose of the vrDevice.
  15520. */
  15521. rawPose: Nullable<DevicePose>;
  15522. private _onVREnabled;
  15523. private _specsVersion;
  15524. private _attached;
  15525. private _frameData;
  15526. protected _descendants: Array<Node>;
  15527. private _deviceRoomPosition;
  15528. /** @hidden */
  15529. _deviceRoomRotationQuaternion: Quaternion;
  15530. private _standingMatrix;
  15531. /**
  15532. * Represents device position in babylon space.
  15533. */
  15534. devicePosition: Vector3;
  15535. /**
  15536. * Represents device rotation in babylon space.
  15537. */
  15538. deviceRotationQuaternion: Quaternion;
  15539. /**
  15540. * The scale of the device to be used when translating from device space to babylon space.
  15541. */
  15542. deviceScaleFactor: number;
  15543. private _deviceToWorld;
  15544. private _worldToDevice;
  15545. /**
  15546. * References to the webVR controllers for the vrDevice.
  15547. */
  15548. controllers: Array<WebVRController>;
  15549. /**
  15550. * Emits an event when a controller is attached.
  15551. */
  15552. onControllersAttachedObservable: Observable<WebVRController[]>;
  15553. /**
  15554. * Emits an event when a controller's mesh has been loaded;
  15555. */
  15556. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15557. /**
  15558. * Emits an event when the HMD's pose has been updated.
  15559. */
  15560. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15561. private _poseSet;
  15562. /**
  15563. * If the rig cameras be used as parent instead of this camera.
  15564. */
  15565. rigParenting: boolean;
  15566. private _lightOnControllers;
  15567. private _defaultHeight?;
  15568. /**
  15569. * Instantiates a WebVRFreeCamera.
  15570. * @param name The name of the WebVRFreeCamera
  15571. * @param position The starting anchor position for the camera
  15572. * @param scene The scene the camera belongs to
  15573. * @param webVROptions a set of customizable options for the webVRCamera
  15574. */
  15575. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15576. /**
  15577. * Gets the device distance from the ground in meters.
  15578. * @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.
  15579. */
  15580. deviceDistanceToRoomGround(): number;
  15581. /**
  15582. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15583. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15584. */
  15585. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15586. /**
  15587. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15588. * @returns A promise with a boolean set to if the standing matrix is supported.
  15589. */
  15590. useStandingMatrixAsync(): Promise<boolean>;
  15591. /**
  15592. * Disposes the camera
  15593. */
  15594. dispose(): void;
  15595. /**
  15596. * Gets a vrController by name.
  15597. * @param name The name of the controller to retreive
  15598. * @returns the controller matching the name specified or null if not found
  15599. */
  15600. getControllerByName(name: string): Nullable<WebVRController>;
  15601. private _leftController;
  15602. /**
  15603. * The controller corresponding to the users left hand.
  15604. */
  15605. readonly leftController: Nullable<WebVRController>;
  15606. private _rightController;
  15607. /**
  15608. * The controller corresponding to the users right hand.
  15609. */
  15610. readonly rightController: Nullable<WebVRController>;
  15611. /**
  15612. * Casts a ray forward from the vrCamera's gaze.
  15613. * @param length Length of the ray (default: 100)
  15614. * @returns the ray corresponding to the gaze
  15615. */
  15616. getForwardRay(length?: number): Ray;
  15617. /**
  15618. * @hidden
  15619. * Updates the camera based on device's frame data
  15620. */
  15621. _checkInputs(): void;
  15622. /**
  15623. * Updates the poseControlled values based on the input device pose.
  15624. * @param poseData Pose coming from the device
  15625. */
  15626. updateFromDevice(poseData: DevicePose): void;
  15627. private _htmlElementAttached;
  15628. private _detachIfAttached;
  15629. /**
  15630. * WebVR's attach control will start broadcasting frames to the device.
  15631. * Note that in certain browsers (chrome for example) this function must be called
  15632. * within a user-interaction callback. Example:
  15633. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15634. *
  15635. * @param element html element to attach the vrDevice to
  15636. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15637. */
  15638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15639. /**
  15640. * Detaches the camera from the html element and disables VR
  15641. *
  15642. * @param element html element to detach from
  15643. */
  15644. detachControl(element: HTMLElement): void;
  15645. /**
  15646. * @returns the name of this class
  15647. */
  15648. getClassName(): string;
  15649. /**
  15650. * Calls resetPose on the vrDisplay
  15651. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15652. */
  15653. resetToCurrentRotation(): void;
  15654. /**
  15655. * @hidden
  15656. * Updates the rig cameras (left and right eye)
  15657. */
  15658. _updateRigCameras(): void;
  15659. private _workingVector;
  15660. private _oneVector;
  15661. private _workingMatrix;
  15662. private updateCacheCalled;
  15663. private _correctPositionIfNotTrackPosition;
  15664. /**
  15665. * @hidden
  15666. * Updates the cached values of the camera
  15667. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15668. */
  15669. _updateCache(ignoreParentClass?: boolean): void;
  15670. /**
  15671. * @hidden
  15672. * Get current device position in babylon world
  15673. */
  15674. _computeDevicePosition(): void;
  15675. /**
  15676. * Updates the current device position and rotation in the babylon world
  15677. */
  15678. update(): void;
  15679. /**
  15680. * @hidden
  15681. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15682. * @returns an identity matrix
  15683. */
  15684. _getViewMatrix(): Matrix;
  15685. private _tmpMatrix;
  15686. /**
  15687. * This function is called by the two RIG cameras.
  15688. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15689. * @hidden
  15690. */
  15691. _getWebVRViewMatrix(): Matrix;
  15692. /** @hidden */
  15693. _getWebVRProjectionMatrix(): Matrix;
  15694. private _onGamepadConnectedObserver;
  15695. private _onGamepadDisconnectedObserver;
  15696. private _updateCacheWhenTrackingDisabledObserver;
  15697. /**
  15698. * Initializes the controllers and their meshes
  15699. */
  15700. initControllers(): void;
  15701. }
  15702. }
  15703. declare module "babylonjs/PostProcesses/postProcess" {
  15704. import { Nullable } from "babylonjs/types";
  15705. import { SmartArray } from "babylonjs/Misc/smartArray";
  15706. import { Observable } from "babylonjs/Misc/observable";
  15707. import { Vector2 } from "babylonjs/Maths/math.vector";
  15708. import { Camera } from "babylonjs/Cameras/camera";
  15709. import { Effect } from "babylonjs/Materials/effect";
  15710. import "babylonjs/Shaders/postprocess.vertex";
  15711. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15712. import { Engine } from "babylonjs/Engines/engine";
  15713. import { Color4 } from "babylonjs/Maths/math.color";
  15714. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15716. /**
  15717. * Size options for a post process
  15718. */
  15719. export type PostProcessOptions = {
  15720. width: number;
  15721. height: number;
  15722. };
  15723. /**
  15724. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15725. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15726. */
  15727. export class PostProcess {
  15728. /** Name of the PostProcess. */
  15729. name: string;
  15730. /**
  15731. * Gets or sets the unique id of the post process
  15732. */
  15733. uniqueId: number;
  15734. /**
  15735. * Width of the texture to apply the post process on
  15736. */
  15737. width: number;
  15738. /**
  15739. * Height of the texture to apply the post process on
  15740. */
  15741. height: number;
  15742. /**
  15743. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15744. * @hidden
  15745. */
  15746. _outputTexture: Nullable<InternalTexture>;
  15747. /**
  15748. * Sampling mode used by the shader
  15749. * See https://doc.babylonjs.com/classes/3.1/texture
  15750. */
  15751. renderTargetSamplingMode: number;
  15752. /**
  15753. * Clear color to use when screen clearing
  15754. */
  15755. clearColor: Color4;
  15756. /**
  15757. * If the buffer needs to be cleared before applying the post process. (default: true)
  15758. * Should be set to false if shader will overwrite all previous pixels.
  15759. */
  15760. autoClear: boolean;
  15761. /**
  15762. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15763. */
  15764. alphaMode: number;
  15765. /**
  15766. * Sets the setAlphaBlendConstants of the babylon engine
  15767. */
  15768. alphaConstants: Color4;
  15769. /**
  15770. * Animations to be used for the post processing
  15771. */
  15772. animations: import("babylonjs/Animations/animation").Animation[];
  15773. /**
  15774. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15775. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15776. */
  15777. enablePixelPerfectMode: boolean;
  15778. /**
  15779. * Force the postprocess to be applied without taking in account viewport
  15780. */
  15781. forceFullscreenViewport: boolean;
  15782. /**
  15783. * List of inspectable custom properties (used by the Inspector)
  15784. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15785. */
  15786. inspectableCustomProperties: IInspectable[];
  15787. /**
  15788. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15789. *
  15790. * | Value | Type | Description |
  15791. * | ----- | ----------------------------------- | ----------- |
  15792. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15793. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15794. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15795. *
  15796. */
  15797. scaleMode: number;
  15798. /**
  15799. * Force textures to be a power of two (default: false)
  15800. */
  15801. alwaysForcePOT: boolean;
  15802. private _samples;
  15803. /**
  15804. * Number of sample textures (default: 1)
  15805. */
  15806. samples: number;
  15807. /**
  15808. * Modify the scale of the post process to be the same as the viewport (default: false)
  15809. */
  15810. adaptScaleToCurrentViewport: boolean;
  15811. private _camera;
  15812. private _scene;
  15813. private _engine;
  15814. private _options;
  15815. private _reusable;
  15816. private _textureType;
  15817. /**
  15818. * Smart array of input and output textures for the post process.
  15819. * @hidden
  15820. */
  15821. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15822. /**
  15823. * The index in _textures that corresponds to the output texture.
  15824. * @hidden
  15825. */
  15826. _currentRenderTextureInd: number;
  15827. private _effect;
  15828. private _samplers;
  15829. private _fragmentUrl;
  15830. private _vertexUrl;
  15831. private _parameters;
  15832. private _scaleRatio;
  15833. protected _indexParameters: any;
  15834. private _shareOutputWithPostProcess;
  15835. private _texelSize;
  15836. private _forcedOutputTexture;
  15837. /**
  15838. * Returns the fragment url or shader name used in the post process.
  15839. * @returns the fragment url or name in the shader store.
  15840. */
  15841. getEffectName(): string;
  15842. /**
  15843. * An event triggered when the postprocess is activated.
  15844. */
  15845. onActivateObservable: Observable<Camera>;
  15846. private _onActivateObserver;
  15847. /**
  15848. * A function that is added to the onActivateObservable
  15849. */
  15850. onActivate: Nullable<(camera: Camera) => void>;
  15851. /**
  15852. * An event triggered when the postprocess changes its size.
  15853. */
  15854. onSizeChangedObservable: Observable<PostProcess>;
  15855. private _onSizeChangedObserver;
  15856. /**
  15857. * A function that is added to the onSizeChangedObservable
  15858. */
  15859. onSizeChanged: (postProcess: PostProcess) => void;
  15860. /**
  15861. * An event triggered when the postprocess applies its effect.
  15862. */
  15863. onApplyObservable: Observable<Effect>;
  15864. private _onApplyObserver;
  15865. /**
  15866. * A function that is added to the onApplyObservable
  15867. */
  15868. onApply: (effect: Effect) => void;
  15869. /**
  15870. * An event triggered before rendering the postprocess
  15871. */
  15872. onBeforeRenderObservable: Observable<Effect>;
  15873. private _onBeforeRenderObserver;
  15874. /**
  15875. * A function that is added to the onBeforeRenderObservable
  15876. */
  15877. onBeforeRender: (effect: Effect) => void;
  15878. /**
  15879. * An event triggered after rendering the postprocess
  15880. */
  15881. onAfterRenderObservable: Observable<Effect>;
  15882. private _onAfterRenderObserver;
  15883. /**
  15884. * A function that is added to the onAfterRenderObservable
  15885. */
  15886. onAfterRender: (efect: Effect) => void;
  15887. /**
  15888. * 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
  15889. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15890. */
  15891. inputTexture: InternalTexture;
  15892. /**
  15893. * Gets the camera which post process is applied to.
  15894. * @returns The camera the post process is applied to.
  15895. */
  15896. getCamera(): Camera;
  15897. /**
  15898. * Gets the texel size of the postprocess.
  15899. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15900. */
  15901. readonly texelSize: Vector2;
  15902. /**
  15903. * Creates a new instance PostProcess
  15904. * @param name The name of the PostProcess.
  15905. * @param fragmentUrl The url of the fragment shader to be used.
  15906. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15907. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15908. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15909. * @param camera The camera to apply the render pass to.
  15910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15911. * @param engine The engine which the post process will be applied. (default: current engine)
  15912. * @param reusable If the post process can be reused on the same frame. (default: false)
  15913. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15914. * @param textureType Type of textures used when performing the post process. (default: 0)
  15915. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15916. * @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
  15917. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15918. */
  15919. constructor(
  15920. /** Name of the PostProcess. */
  15921. 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);
  15922. /**
  15923. * Gets a string idenfifying the name of the class
  15924. * @returns "PostProcess" string
  15925. */
  15926. getClassName(): string;
  15927. /**
  15928. * Gets the engine which this post process belongs to.
  15929. * @returns The engine the post process was enabled with.
  15930. */
  15931. getEngine(): Engine;
  15932. /**
  15933. * The effect that is created when initializing the post process.
  15934. * @returns The created effect corresponding the the postprocess.
  15935. */
  15936. getEffect(): Effect;
  15937. /**
  15938. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15939. * @param postProcess The post process to share the output with.
  15940. * @returns This post process.
  15941. */
  15942. shareOutputWith(postProcess: PostProcess): PostProcess;
  15943. /**
  15944. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15945. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15946. */
  15947. useOwnOutput(): void;
  15948. /**
  15949. * Updates the effect with the current post process compile time values and recompiles the shader.
  15950. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15951. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15952. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15953. * @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
  15954. * @param onCompiled Called when the shader has been compiled.
  15955. * @param onError Called if there is an error when compiling a shader.
  15956. */
  15957. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15958. /**
  15959. * The post process is reusable if it can be used multiple times within one frame.
  15960. * @returns If the post process is reusable
  15961. */
  15962. isReusable(): boolean;
  15963. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15964. markTextureDirty(): void;
  15965. /**
  15966. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15967. * 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.
  15968. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15969. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15970. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15971. * @returns The target texture that was bound to be written to.
  15972. */
  15973. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15974. /**
  15975. * If the post process is supported.
  15976. */
  15977. readonly isSupported: boolean;
  15978. /**
  15979. * The aspect ratio of the output texture.
  15980. */
  15981. readonly aspectRatio: number;
  15982. /**
  15983. * Get a value indicating if the post-process is ready to be used
  15984. * @returns true if the post-process is ready (shader is compiled)
  15985. */
  15986. isReady(): boolean;
  15987. /**
  15988. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15989. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15990. */
  15991. apply(): Nullable<Effect>;
  15992. private _disposeTextures;
  15993. /**
  15994. * Disposes the post process.
  15995. * @param camera The camera to dispose the post process on.
  15996. */
  15997. dispose(camera?: Camera): void;
  15998. }
  15999. }
  16000. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16001. /** @hidden */
  16002. export var kernelBlurVaryingDeclaration: {
  16003. name: string;
  16004. shader: string;
  16005. };
  16006. }
  16007. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16008. /** @hidden */
  16009. export var kernelBlurFragment: {
  16010. name: string;
  16011. shader: string;
  16012. };
  16013. }
  16014. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16015. /** @hidden */
  16016. export var kernelBlurFragment2: {
  16017. name: string;
  16018. shader: string;
  16019. };
  16020. }
  16021. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16022. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16023. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16024. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16025. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16026. /** @hidden */
  16027. export var kernelBlurPixelShader: {
  16028. name: string;
  16029. shader: string;
  16030. };
  16031. }
  16032. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16033. /** @hidden */
  16034. export var kernelBlurVertex: {
  16035. name: string;
  16036. shader: string;
  16037. };
  16038. }
  16039. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16040. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16041. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16042. /** @hidden */
  16043. export var kernelBlurVertexShader: {
  16044. name: string;
  16045. shader: string;
  16046. };
  16047. }
  16048. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16049. import { Vector2 } from "babylonjs/Maths/math.vector";
  16050. import { Nullable } from "babylonjs/types";
  16051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16052. import { Camera } from "babylonjs/Cameras/camera";
  16053. import { Effect } from "babylonjs/Materials/effect";
  16054. import { Engine } from "babylonjs/Engines/engine";
  16055. import "babylonjs/Shaders/kernelBlur.fragment";
  16056. import "babylonjs/Shaders/kernelBlur.vertex";
  16057. /**
  16058. * The Blur Post Process which blurs an image based on a kernel and direction.
  16059. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16060. */
  16061. export class BlurPostProcess extends PostProcess {
  16062. /** The direction in which to blur the image. */
  16063. direction: Vector2;
  16064. private blockCompilation;
  16065. protected _kernel: number;
  16066. protected _idealKernel: number;
  16067. protected _packedFloat: boolean;
  16068. private _staticDefines;
  16069. /**
  16070. * Sets the length in pixels of the blur sample region
  16071. */
  16072. /**
  16073. * Gets the length in pixels of the blur sample region
  16074. */
  16075. kernel: number;
  16076. /**
  16077. * Sets wether or not the blur needs to unpack/repack floats
  16078. */
  16079. /**
  16080. * Gets wether or not the blur is unpacking/repacking floats
  16081. */
  16082. packedFloat: boolean;
  16083. /**
  16084. * Creates a new instance BlurPostProcess
  16085. * @param name The name of the effect.
  16086. * @param direction The direction in which to blur the image.
  16087. * @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.
  16088. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16089. * @param camera The camera to apply the render pass to.
  16090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16091. * @param engine The engine which the post process will be applied. (default: current engine)
  16092. * @param reusable If the post process can be reused on the same frame. (default: false)
  16093. * @param textureType Type of textures used when performing the post process. (default: 0)
  16094. * @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)
  16095. */
  16096. constructor(name: string,
  16097. /** The direction in which to blur the image. */
  16098. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16099. /**
  16100. * Updates the effect with the current post process compile time values and recompiles the shader.
  16101. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16102. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16103. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16104. * @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
  16105. * @param onCompiled Called when the shader has been compiled.
  16106. * @param onError Called if there is an error when compiling a shader.
  16107. */
  16108. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16109. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16110. /**
  16111. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16112. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16113. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16114. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16115. * The gaps between physical kernels are compensated for in the weighting of the samples
  16116. * @param idealKernel Ideal blur kernel.
  16117. * @return Nearest best kernel.
  16118. */
  16119. protected _nearestBestKernel(idealKernel: number): number;
  16120. /**
  16121. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16122. * @param x The point on the Gaussian distribution to sample.
  16123. * @return the value of the Gaussian function at x.
  16124. */
  16125. protected _gaussianWeight(x: number): number;
  16126. /**
  16127. * Generates a string that can be used as a floating point number in GLSL.
  16128. * @param x Value to print.
  16129. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16130. * @return GLSL float string.
  16131. */
  16132. protected _glslFloat(x: number, decimalFigures?: number): string;
  16133. }
  16134. }
  16135. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16136. import { Scene } from "babylonjs/scene";
  16137. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16138. import { Plane } from "babylonjs/Maths/math.plane";
  16139. /**
  16140. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16141. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16142. * You can then easily use it as a reflectionTexture on a flat surface.
  16143. * In case the surface is not a plane, please consider relying on reflection probes.
  16144. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16145. */
  16146. export class MirrorTexture extends RenderTargetTexture {
  16147. private scene;
  16148. /**
  16149. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16150. * 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.
  16151. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16152. */
  16153. mirrorPlane: Plane;
  16154. /**
  16155. * Define the blur ratio used to blur the reflection if needed.
  16156. */
  16157. blurRatio: number;
  16158. /**
  16159. * Define the adaptive blur kernel used to blur the reflection if needed.
  16160. * This will autocompute the closest best match for the `blurKernel`
  16161. */
  16162. adaptiveBlurKernel: number;
  16163. /**
  16164. * Define the blur kernel used to blur the reflection if needed.
  16165. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16166. */
  16167. blurKernel: number;
  16168. /**
  16169. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16171. */
  16172. blurKernelX: number;
  16173. /**
  16174. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16175. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16176. */
  16177. blurKernelY: number;
  16178. private _autoComputeBlurKernel;
  16179. protected _onRatioRescale(): void;
  16180. private _updateGammaSpace;
  16181. private _imageProcessingConfigChangeObserver;
  16182. private _transformMatrix;
  16183. private _mirrorMatrix;
  16184. private _savedViewMatrix;
  16185. private _blurX;
  16186. private _blurY;
  16187. private _adaptiveBlurKernel;
  16188. private _blurKernelX;
  16189. private _blurKernelY;
  16190. private _blurRatio;
  16191. /**
  16192. * Instantiates a Mirror Texture.
  16193. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16194. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16195. * You can then easily use it as a reflectionTexture on a flat surface.
  16196. * In case the surface is not a plane, please consider relying on reflection probes.
  16197. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16198. * @param name
  16199. * @param size
  16200. * @param scene
  16201. * @param generateMipMaps
  16202. * @param type
  16203. * @param samplingMode
  16204. * @param generateDepthBuffer
  16205. */
  16206. constructor(name: string, size: number | {
  16207. width: number;
  16208. height: number;
  16209. } | {
  16210. ratio: number;
  16211. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16212. private _preparePostProcesses;
  16213. /**
  16214. * Clone the mirror texture.
  16215. * @returns the cloned texture
  16216. */
  16217. clone(): MirrorTexture;
  16218. /**
  16219. * Serialize the texture to a JSON representation you could use in Parse later on
  16220. * @returns the serialized JSON representation
  16221. */
  16222. serialize(): any;
  16223. /**
  16224. * Dispose the texture and release its associated resources.
  16225. */
  16226. dispose(): void;
  16227. }
  16228. }
  16229. declare module "babylonjs/Materials/Textures/texture" {
  16230. import { Observable } from "babylonjs/Misc/observable";
  16231. import { Nullable } from "babylonjs/types";
  16232. import { Matrix } from "babylonjs/Maths/math.vector";
  16233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16235. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16236. import { Scene } from "babylonjs/scene";
  16237. /**
  16238. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16239. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16240. */
  16241. export class Texture extends BaseTexture {
  16242. /**
  16243. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16244. */
  16245. static SerializeBuffers: boolean;
  16246. /** @hidden */
  16247. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16248. /** @hidden */
  16249. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16250. /** @hidden */
  16251. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16252. /** nearest is mag = nearest and min = nearest and mip = linear */
  16253. static readonly NEAREST_SAMPLINGMODE: number;
  16254. /** nearest is mag = nearest and min = nearest and mip = linear */
  16255. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16256. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16257. static readonly BILINEAR_SAMPLINGMODE: number;
  16258. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16259. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16260. /** Trilinear is mag = linear and min = linear and mip = linear */
  16261. static readonly TRILINEAR_SAMPLINGMODE: number;
  16262. /** Trilinear is mag = linear and min = linear and mip = linear */
  16263. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16264. /** mag = nearest and min = nearest and mip = nearest */
  16265. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16266. /** mag = nearest and min = linear and mip = nearest */
  16267. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16268. /** mag = nearest and min = linear and mip = linear */
  16269. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16270. /** mag = nearest and min = linear and mip = none */
  16271. static readonly NEAREST_LINEAR: number;
  16272. /** mag = nearest and min = nearest and mip = none */
  16273. static readonly NEAREST_NEAREST: number;
  16274. /** mag = linear and min = nearest and mip = nearest */
  16275. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16276. /** mag = linear and min = nearest and mip = linear */
  16277. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16278. /** mag = linear and min = linear and mip = none */
  16279. static readonly LINEAR_LINEAR: number;
  16280. /** mag = linear and min = nearest and mip = none */
  16281. static readonly LINEAR_NEAREST: number;
  16282. /** Explicit coordinates mode */
  16283. static readonly EXPLICIT_MODE: number;
  16284. /** Spherical coordinates mode */
  16285. static readonly SPHERICAL_MODE: number;
  16286. /** Planar coordinates mode */
  16287. static readonly PLANAR_MODE: number;
  16288. /** Cubic coordinates mode */
  16289. static readonly CUBIC_MODE: number;
  16290. /** Projection coordinates mode */
  16291. static readonly PROJECTION_MODE: number;
  16292. /** Inverse Cubic coordinates mode */
  16293. static readonly SKYBOX_MODE: number;
  16294. /** Inverse Cubic coordinates mode */
  16295. static readonly INVCUBIC_MODE: number;
  16296. /** Equirectangular coordinates mode */
  16297. static readonly EQUIRECTANGULAR_MODE: number;
  16298. /** Equirectangular Fixed coordinates mode */
  16299. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16300. /** Equirectangular Fixed Mirrored coordinates mode */
  16301. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16302. /** Texture is not repeating outside of 0..1 UVs */
  16303. static readonly CLAMP_ADDRESSMODE: number;
  16304. /** Texture is repeating outside of 0..1 UVs */
  16305. static readonly WRAP_ADDRESSMODE: number;
  16306. /** Texture is repeating and mirrored */
  16307. static readonly MIRROR_ADDRESSMODE: number;
  16308. /**
  16309. * 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
  16310. */
  16311. static UseSerializedUrlIfAny: boolean;
  16312. /**
  16313. * Define the url of the texture.
  16314. */
  16315. url: Nullable<string>;
  16316. /**
  16317. * Define an offset on the texture to offset the u coordinates of the UVs
  16318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16319. */
  16320. uOffset: number;
  16321. /**
  16322. * Define an offset on the texture to offset the v coordinates of the UVs
  16323. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16324. */
  16325. vOffset: number;
  16326. /**
  16327. * Define an offset on the texture to scale the u coordinates of the UVs
  16328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16329. */
  16330. uScale: number;
  16331. /**
  16332. * Define an offset on the texture to scale the v coordinates of the UVs
  16333. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16334. */
  16335. vScale: number;
  16336. /**
  16337. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16338. * @see http://doc.babylonjs.com/how_to/more_materials
  16339. */
  16340. uAng: number;
  16341. /**
  16342. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16343. * @see http://doc.babylonjs.com/how_to/more_materials
  16344. */
  16345. vAng: number;
  16346. /**
  16347. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16348. * @see http://doc.babylonjs.com/how_to/more_materials
  16349. */
  16350. wAng: number;
  16351. /**
  16352. * Defines the center of rotation (U)
  16353. */
  16354. uRotationCenter: number;
  16355. /**
  16356. * Defines the center of rotation (V)
  16357. */
  16358. vRotationCenter: number;
  16359. /**
  16360. * Defines the center of rotation (W)
  16361. */
  16362. wRotationCenter: number;
  16363. /**
  16364. * Are mip maps generated for this texture or not.
  16365. */
  16366. readonly noMipmap: boolean;
  16367. /**
  16368. * List of inspectable custom properties (used by the Inspector)
  16369. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16370. */
  16371. inspectableCustomProperties: Nullable<IInspectable[]>;
  16372. private _noMipmap;
  16373. /** @hidden */
  16374. _invertY: boolean;
  16375. private _rowGenerationMatrix;
  16376. private _cachedTextureMatrix;
  16377. private _projectionModeMatrix;
  16378. private _t0;
  16379. private _t1;
  16380. private _t2;
  16381. private _cachedUOffset;
  16382. private _cachedVOffset;
  16383. private _cachedUScale;
  16384. private _cachedVScale;
  16385. private _cachedUAng;
  16386. private _cachedVAng;
  16387. private _cachedWAng;
  16388. private _cachedProjectionMatrixId;
  16389. private _cachedCoordinatesMode;
  16390. /** @hidden */
  16391. protected _initialSamplingMode: number;
  16392. /** @hidden */
  16393. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16394. private _deleteBuffer;
  16395. protected _format: Nullable<number>;
  16396. private _delayedOnLoad;
  16397. private _delayedOnError;
  16398. private _mimeType?;
  16399. /**
  16400. * Observable triggered once the texture has been loaded.
  16401. */
  16402. onLoadObservable: Observable<Texture>;
  16403. protected _isBlocking: boolean;
  16404. /**
  16405. * Is the texture preventing material to render while loading.
  16406. * If false, a default texture will be used instead of the loading one during the preparation step.
  16407. */
  16408. isBlocking: boolean;
  16409. /**
  16410. * Get the current sampling mode associated with the texture.
  16411. */
  16412. readonly samplingMode: number;
  16413. /**
  16414. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16415. */
  16416. readonly invertY: boolean;
  16417. /**
  16418. * Instantiates a new texture.
  16419. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16420. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16421. * @param url defines the url of the picture to load as a texture
  16422. * @param scene defines the scene or engine the texture will belong to
  16423. * @param noMipmap defines if the texture will require mip maps or not
  16424. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16425. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16426. * @param onLoad defines a callback triggered when the texture has been loaded
  16427. * @param onError defines a callback triggered when an error occurred during the loading session
  16428. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16429. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16430. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16431. * @param mimeType defines an optional mime type information
  16432. */
  16433. 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);
  16434. /**
  16435. * Update the url (and optional buffer) of this texture if url was null during construction.
  16436. * @param url the url of the texture
  16437. * @param buffer the buffer of the texture (defaults to null)
  16438. * @param onLoad callback called when the texture is loaded (defaults to null)
  16439. */
  16440. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16441. /**
  16442. * Finish the loading sequence of a texture flagged as delayed load.
  16443. * @hidden
  16444. */
  16445. delayLoad(): void;
  16446. private _prepareRowForTextureGeneration;
  16447. /**
  16448. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16449. * @returns the transform matrix of the texture.
  16450. */
  16451. getTextureMatrix(uBase?: number): Matrix;
  16452. /**
  16453. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16454. * @returns The reflection texture transform
  16455. */
  16456. getReflectionTextureMatrix(): Matrix;
  16457. /**
  16458. * Clones the texture.
  16459. * @returns the cloned texture
  16460. */
  16461. clone(): Texture;
  16462. /**
  16463. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16464. * @returns The JSON representation of the texture
  16465. */
  16466. serialize(): any;
  16467. /**
  16468. * Get the current class name of the texture useful for serialization or dynamic coding.
  16469. * @returns "Texture"
  16470. */
  16471. getClassName(): string;
  16472. /**
  16473. * Dispose the texture and release its associated resources.
  16474. */
  16475. dispose(): void;
  16476. /**
  16477. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16478. * @param parsedTexture Define the JSON representation of the texture
  16479. * @param scene Define the scene the parsed texture should be instantiated in
  16480. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16481. * @returns The parsed texture if successful
  16482. */
  16483. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16484. /**
  16485. * Creates a texture from its base 64 representation.
  16486. * @param data Define the base64 payload without the data: prefix
  16487. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16488. * @param scene Define the scene the texture should belong to
  16489. * @param noMipmap Forces the texture to not create mip map information if true
  16490. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16491. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16492. * @param onLoad define a callback triggered when the texture has been loaded
  16493. * @param onError define a callback triggered when an error occurred during the loading session
  16494. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16495. * @returns the created texture
  16496. */
  16497. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16498. /**
  16499. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16500. * @param data Define the base64 payload without the data: prefix
  16501. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16502. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16503. * @param scene Define the scene the texture should belong to
  16504. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16505. * @param noMipmap Forces the texture to not create mip map information if true
  16506. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16507. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16508. * @param onLoad define a callback triggered when the texture has been loaded
  16509. * @param onError define a callback triggered when an error occurred during the loading session
  16510. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16511. * @returns the created texture
  16512. */
  16513. 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;
  16514. }
  16515. }
  16516. declare module "babylonjs/PostProcesses/postProcessManager" {
  16517. import { Nullable } from "babylonjs/types";
  16518. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16520. import { Scene } from "babylonjs/scene";
  16521. /**
  16522. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16523. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16524. */
  16525. export class PostProcessManager {
  16526. private _scene;
  16527. private _indexBuffer;
  16528. private _vertexBuffers;
  16529. /**
  16530. * Creates a new instance PostProcess
  16531. * @param scene The scene that the post process is associated with.
  16532. */
  16533. constructor(scene: Scene);
  16534. private _prepareBuffers;
  16535. private _buildIndexBuffer;
  16536. /**
  16537. * Rebuilds the vertex buffers of the manager.
  16538. * @hidden
  16539. */
  16540. _rebuild(): void;
  16541. /**
  16542. * Prepares a frame to be run through a post process.
  16543. * @param sourceTexture The input texture to the post procesess. (default: null)
  16544. * @param postProcesses An array of post processes to be run. (default: null)
  16545. * @returns True if the post processes were able to be run.
  16546. * @hidden
  16547. */
  16548. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16549. /**
  16550. * Manually render a set of post processes to a texture.
  16551. * @param postProcesses An array of post processes to be run.
  16552. * @param targetTexture The target texture to render to.
  16553. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16554. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16555. * @param lodLevel defines which lod of the texture to render to
  16556. */
  16557. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16558. /**
  16559. * Finalize the result of the output of the postprocesses.
  16560. * @param doNotPresent If true the result will not be displayed to the screen.
  16561. * @param targetTexture The target texture to render to.
  16562. * @param faceIndex The index of the face to bind the target texture to.
  16563. * @param postProcesses The array of post processes to render.
  16564. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16565. * @hidden
  16566. */
  16567. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16568. /**
  16569. * Disposes of the post process manager.
  16570. */
  16571. dispose(): void;
  16572. }
  16573. }
  16574. declare module "babylonjs/Misc/gradients" {
  16575. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16576. /** Interface used by value gradients (color, factor, ...) */
  16577. export interface IValueGradient {
  16578. /**
  16579. * Gets or sets the gradient value (between 0 and 1)
  16580. */
  16581. gradient: number;
  16582. }
  16583. /** Class used to store color4 gradient */
  16584. export class ColorGradient implements IValueGradient {
  16585. /**
  16586. * Gets or sets the gradient value (between 0 and 1)
  16587. */
  16588. gradient: number;
  16589. /**
  16590. * Gets or sets first associated color
  16591. */
  16592. color1: Color4;
  16593. /**
  16594. * Gets or sets second associated color
  16595. */
  16596. color2?: Color4;
  16597. /**
  16598. * Will get a color picked randomly between color1 and color2.
  16599. * If color2 is undefined then color1 will be used
  16600. * @param result defines the target Color4 to store the result in
  16601. */
  16602. getColorToRef(result: Color4): void;
  16603. }
  16604. /** Class used to store color 3 gradient */
  16605. export class Color3Gradient implements IValueGradient {
  16606. /**
  16607. * Gets or sets the gradient value (between 0 and 1)
  16608. */
  16609. gradient: number;
  16610. /**
  16611. * Gets or sets the associated color
  16612. */
  16613. color: Color3;
  16614. }
  16615. /** Class used to store factor gradient */
  16616. export class FactorGradient implements IValueGradient {
  16617. /**
  16618. * Gets or sets the gradient value (between 0 and 1)
  16619. */
  16620. gradient: number;
  16621. /**
  16622. * Gets or sets first associated factor
  16623. */
  16624. factor1: number;
  16625. /**
  16626. * Gets or sets second associated factor
  16627. */
  16628. factor2?: number;
  16629. /**
  16630. * Will get a number picked randomly between factor1 and factor2.
  16631. * If factor2 is undefined then factor1 will be used
  16632. * @returns the picked number
  16633. */
  16634. getFactor(): number;
  16635. }
  16636. /**
  16637. * Helper used to simplify some generic gradient tasks
  16638. */
  16639. export class GradientHelper {
  16640. /**
  16641. * Gets the current gradient from an array of IValueGradient
  16642. * @param ratio defines the current ratio to get
  16643. * @param gradients defines the array of IValueGradient
  16644. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16645. */
  16646. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16647. }
  16648. }
  16649. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16651. import { Nullable } from "babylonjs/types";
  16652. module "babylonjs/Engines/thinEngine" {
  16653. interface ThinEngine {
  16654. /**
  16655. * Creates a dynamic texture
  16656. * @param width defines the width of the texture
  16657. * @param height defines the height of the texture
  16658. * @param generateMipMaps defines if the engine should generate the mip levels
  16659. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16660. * @returns the dynamic texture inside an InternalTexture
  16661. */
  16662. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16663. /**
  16664. * Update the content of a dynamic texture
  16665. * @param texture defines the texture to update
  16666. * @param canvas defines the canvas containing the source
  16667. * @param invertY defines if data must be stored with Y axis inverted
  16668. * @param premulAlpha defines if alpha is stored as premultiplied
  16669. * @param format defines the format of the data
  16670. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16671. */
  16672. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16673. }
  16674. }
  16675. }
  16676. declare module "babylonjs/Misc/canvasGenerator" {
  16677. /**
  16678. * Helper class used to generate a canvas to manipulate images
  16679. */
  16680. export class CanvasGenerator {
  16681. /**
  16682. * Create a new canvas (or offscreen canvas depending on the context)
  16683. * @param width defines the expected width
  16684. * @param height defines the expected height
  16685. * @return a new canvas or offscreen canvas
  16686. */
  16687. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16688. }
  16689. }
  16690. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16691. import { Scene } from "babylonjs/scene";
  16692. import { Texture } from "babylonjs/Materials/Textures/texture";
  16693. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16694. /**
  16695. * A class extending Texture allowing drawing on a texture
  16696. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16697. */
  16698. export class DynamicTexture extends Texture {
  16699. private _generateMipMaps;
  16700. private _canvas;
  16701. private _context;
  16702. private _engine;
  16703. /**
  16704. * Creates a DynamicTexture
  16705. * @param name defines the name of the texture
  16706. * @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
  16707. * @param scene defines the scene where you want the texture
  16708. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16709. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16710. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16711. */
  16712. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16713. /**
  16714. * Get the current class name of the texture useful for serialization or dynamic coding.
  16715. * @returns "DynamicTexture"
  16716. */
  16717. getClassName(): string;
  16718. /**
  16719. * Gets the current state of canRescale
  16720. */
  16721. readonly canRescale: boolean;
  16722. private _recreate;
  16723. /**
  16724. * Scales the texture
  16725. * @param ratio the scale factor to apply to both width and height
  16726. */
  16727. scale(ratio: number): void;
  16728. /**
  16729. * Resizes the texture
  16730. * @param width the new width
  16731. * @param height the new height
  16732. */
  16733. scaleTo(width: number, height: number): void;
  16734. /**
  16735. * Gets the context of the canvas used by the texture
  16736. * @returns the canvas context of the dynamic texture
  16737. */
  16738. getContext(): CanvasRenderingContext2D;
  16739. /**
  16740. * Clears the texture
  16741. */
  16742. clear(): void;
  16743. /**
  16744. * Updates the texture
  16745. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16746. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16747. */
  16748. update(invertY?: boolean, premulAlpha?: boolean): void;
  16749. /**
  16750. * Draws text onto the texture
  16751. * @param text defines the text to be drawn
  16752. * @param x defines the placement of the text from the left
  16753. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16754. * @param font defines the font to be used with font-style, font-size, font-name
  16755. * @param color defines the color used for the text
  16756. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16757. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16758. * @param update defines whether texture is immediately update (default is true)
  16759. */
  16760. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16761. /**
  16762. * Clones the texture
  16763. * @returns the clone of the texture.
  16764. */
  16765. clone(): DynamicTexture;
  16766. /**
  16767. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16768. * @returns a serialized dynamic texture object
  16769. */
  16770. serialize(): any;
  16771. /** @hidden */
  16772. _rebuild(): void;
  16773. }
  16774. }
  16775. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16776. import { Scene } from "babylonjs/scene";
  16777. import { ISceneComponent } from "babylonjs/sceneComponent";
  16778. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16779. module "babylonjs/abstractScene" {
  16780. interface AbstractScene {
  16781. /**
  16782. * The list of procedural textures added to the scene
  16783. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16784. */
  16785. proceduralTextures: Array<ProceduralTexture>;
  16786. }
  16787. }
  16788. /**
  16789. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16790. * in a given scene.
  16791. */
  16792. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16793. /**
  16794. * The component name helpfull to identify the component in the list of scene components.
  16795. */
  16796. readonly name: string;
  16797. /**
  16798. * The scene the component belongs to.
  16799. */
  16800. scene: Scene;
  16801. /**
  16802. * Creates a new instance of the component for the given scene
  16803. * @param scene Defines the scene to register the component in
  16804. */
  16805. constructor(scene: Scene);
  16806. /**
  16807. * Registers the component in a given scene
  16808. */
  16809. register(): void;
  16810. /**
  16811. * Rebuilds the elements related to this component in case of
  16812. * context lost for instance.
  16813. */
  16814. rebuild(): void;
  16815. /**
  16816. * Disposes the component and the associated ressources.
  16817. */
  16818. dispose(): void;
  16819. private _beforeClear;
  16820. }
  16821. }
  16822. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16824. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16825. module "babylonjs/Engines/thinEngine" {
  16826. interface ThinEngine {
  16827. /**
  16828. * Creates a new render target cube texture
  16829. * @param size defines the size of the texture
  16830. * @param options defines the options used to create the texture
  16831. * @returns a new render target cube texture stored in an InternalTexture
  16832. */
  16833. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16834. }
  16835. }
  16836. }
  16837. declare module "babylonjs/Shaders/procedural.vertex" {
  16838. /** @hidden */
  16839. export var proceduralVertexShader: {
  16840. name: string;
  16841. shader: string;
  16842. };
  16843. }
  16844. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16845. import { Observable } from "babylonjs/Misc/observable";
  16846. import { Nullable } from "babylonjs/types";
  16847. import { Scene } from "babylonjs/scene";
  16848. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16849. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16850. import { Effect } from "babylonjs/Materials/effect";
  16851. import { Texture } from "babylonjs/Materials/Textures/texture";
  16852. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16853. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16854. import "babylonjs/Shaders/procedural.vertex";
  16855. /**
  16856. * 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.
  16857. * This is the base class of any Procedural texture and contains most of the shareable code.
  16858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16859. */
  16860. export class ProceduralTexture extends Texture {
  16861. isCube: boolean;
  16862. /**
  16863. * Define if the texture is enabled or not (disabled texture will not render)
  16864. */
  16865. isEnabled: boolean;
  16866. /**
  16867. * Define if the texture must be cleared before rendering (default is true)
  16868. */
  16869. autoClear: boolean;
  16870. /**
  16871. * Callback called when the texture is generated
  16872. */
  16873. onGenerated: () => void;
  16874. /**
  16875. * Event raised when the texture is generated
  16876. */
  16877. onGeneratedObservable: Observable<ProceduralTexture>;
  16878. /** @hidden */
  16879. _generateMipMaps: boolean;
  16880. /** @hidden **/
  16881. _effect: Effect;
  16882. /** @hidden */
  16883. _textures: {
  16884. [key: string]: Texture;
  16885. };
  16886. private _size;
  16887. private _currentRefreshId;
  16888. private _refreshRate;
  16889. private _vertexBuffers;
  16890. private _indexBuffer;
  16891. private _uniforms;
  16892. private _samplers;
  16893. private _fragment;
  16894. private _floats;
  16895. private _ints;
  16896. private _floatsArrays;
  16897. private _colors3;
  16898. private _colors4;
  16899. private _vectors2;
  16900. private _vectors3;
  16901. private _matrices;
  16902. private _fallbackTexture;
  16903. private _fallbackTextureUsed;
  16904. private _engine;
  16905. private _cachedDefines;
  16906. private _contentUpdateId;
  16907. private _contentData;
  16908. /**
  16909. * Instantiates a new procedural texture.
  16910. * 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.
  16911. * This is the base class of any Procedural texture and contains most of the shareable code.
  16912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16913. * @param name Define the name of the texture
  16914. * @param size Define the size of the texture to create
  16915. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16916. * @param scene Define the scene the texture belongs to
  16917. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16918. * @param generateMipMaps Define if the texture should creates mip maps or not
  16919. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16920. */
  16921. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16922. /**
  16923. * The effect that is created when initializing the post process.
  16924. * @returns The created effect corresponding the the postprocess.
  16925. */
  16926. getEffect(): Effect;
  16927. /**
  16928. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16929. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16930. */
  16931. getContent(): Nullable<ArrayBufferView>;
  16932. private _createIndexBuffer;
  16933. /** @hidden */
  16934. _rebuild(): void;
  16935. /**
  16936. * Resets the texture in order to recreate its associated resources.
  16937. * This can be called in case of context loss
  16938. */
  16939. reset(): void;
  16940. protected _getDefines(): string;
  16941. /**
  16942. * Is the texture ready to be used ? (rendered at least once)
  16943. * @returns true if ready, otherwise, false.
  16944. */
  16945. isReady(): boolean;
  16946. /**
  16947. * Resets the refresh counter of the texture and start bak from scratch.
  16948. * Could be useful to regenerate the texture if it is setup to render only once.
  16949. */
  16950. resetRefreshCounter(): void;
  16951. /**
  16952. * Set the fragment shader to use in order to render the texture.
  16953. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16954. */
  16955. setFragment(fragment: any): void;
  16956. /**
  16957. * Define the refresh rate of the texture or the rendering frequency.
  16958. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16959. */
  16960. refreshRate: number;
  16961. /** @hidden */
  16962. _shouldRender(): boolean;
  16963. /**
  16964. * Get the size the texture is rendering at.
  16965. * @returns the size (texture is always squared)
  16966. */
  16967. getRenderSize(): number;
  16968. /**
  16969. * Resize the texture to new value.
  16970. * @param size Define the new size the texture should have
  16971. * @param generateMipMaps Define whether the new texture should create mip maps
  16972. */
  16973. resize(size: number, generateMipMaps: boolean): void;
  16974. private _checkUniform;
  16975. /**
  16976. * Set a texture in the shader program used to render.
  16977. * @param name Define the name of the uniform samplers as defined in the shader
  16978. * @param texture Define the texture to bind to this sampler
  16979. * @return the texture itself allowing "fluent" like uniform updates
  16980. */
  16981. setTexture(name: string, texture: Texture): ProceduralTexture;
  16982. /**
  16983. * Set a float in the shader.
  16984. * @param name Define the name of the uniform as defined in the shader
  16985. * @param value Define the value to give to the uniform
  16986. * @return the texture itself allowing "fluent" like uniform updates
  16987. */
  16988. setFloat(name: string, value: number): ProceduralTexture;
  16989. /**
  16990. * Set a int in the shader.
  16991. * @param name Define the name of the uniform as defined in the shader
  16992. * @param value Define the value to give to the uniform
  16993. * @return the texture itself allowing "fluent" like uniform updates
  16994. */
  16995. setInt(name: string, value: number): ProceduralTexture;
  16996. /**
  16997. * Set an array of floats in the shader.
  16998. * @param name Define the name of the uniform as defined in the shader
  16999. * @param value Define the value to give to the uniform
  17000. * @return the texture itself allowing "fluent" like uniform updates
  17001. */
  17002. setFloats(name: string, value: number[]): ProceduralTexture;
  17003. /**
  17004. * Set a vec3 in the shader from a Color3.
  17005. * @param name Define the name of the uniform as defined in the shader
  17006. * @param value Define the value to give to the uniform
  17007. * @return the texture itself allowing "fluent" like uniform updates
  17008. */
  17009. setColor3(name: string, value: Color3): ProceduralTexture;
  17010. /**
  17011. * Set a vec4 in the shader from a Color4.
  17012. * @param name Define the name of the uniform as defined in the shader
  17013. * @param value Define the value to give to the uniform
  17014. * @return the texture itself allowing "fluent" like uniform updates
  17015. */
  17016. setColor4(name: string, value: Color4): ProceduralTexture;
  17017. /**
  17018. * Set a vec2 in the shader from a Vector2.
  17019. * @param name Define the name of the uniform as defined in the shader
  17020. * @param value Define the value to give to the uniform
  17021. * @return the texture itself allowing "fluent" like uniform updates
  17022. */
  17023. setVector2(name: string, value: Vector2): ProceduralTexture;
  17024. /**
  17025. * Set a vec3 in the shader from a Vector3.
  17026. * @param name Define the name of the uniform as defined in the shader
  17027. * @param value Define the value to give to the uniform
  17028. * @return the texture itself allowing "fluent" like uniform updates
  17029. */
  17030. setVector3(name: string, value: Vector3): ProceduralTexture;
  17031. /**
  17032. * Set a mat4 in the shader from a MAtrix.
  17033. * @param name Define the name of the uniform as defined in the shader
  17034. * @param value Define the value to give to the uniform
  17035. * @return the texture itself allowing "fluent" like uniform updates
  17036. */
  17037. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17038. /**
  17039. * Render the texture to its associated render target.
  17040. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17041. */
  17042. render(useCameraPostProcess?: boolean): void;
  17043. /**
  17044. * Clone the texture.
  17045. * @returns the cloned texture
  17046. */
  17047. clone(): ProceduralTexture;
  17048. /**
  17049. * Dispose the texture and release its asoociated resources.
  17050. */
  17051. dispose(): void;
  17052. }
  17053. }
  17054. declare module "babylonjs/Particles/baseParticleSystem" {
  17055. import { Nullable } from "babylonjs/types";
  17056. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17058. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17059. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17060. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17061. import { Scene } from "babylonjs/scene";
  17062. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17063. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17064. import { Texture } from "babylonjs/Materials/Textures/texture";
  17065. import { Color4 } from "babylonjs/Maths/math.color";
  17066. import { Animation } from "babylonjs/Animations/animation";
  17067. /**
  17068. * This represents the base class for particle system in Babylon.
  17069. * 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.
  17070. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17071. * @example https://doc.babylonjs.com/babylon101/particles
  17072. */
  17073. export class BaseParticleSystem {
  17074. /**
  17075. * Source color is added to the destination color without alpha affecting the result
  17076. */
  17077. static BLENDMODE_ONEONE: number;
  17078. /**
  17079. * Blend current color and particle color using particle’s alpha
  17080. */
  17081. static BLENDMODE_STANDARD: number;
  17082. /**
  17083. * Add current color and particle color multiplied by particle’s alpha
  17084. */
  17085. static BLENDMODE_ADD: number;
  17086. /**
  17087. * Multiply current color with particle color
  17088. */
  17089. static BLENDMODE_MULTIPLY: number;
  17090. /**
  17091. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17092. */
  17093. static BLENDMODE_MULTIPLYADD: number;
  17094. /**
  17095. * List of animations used by the particle system.
  17096. */
  17097. animations: Animation[];
  17098. /**
  17099. * The id of the Particle system.
  17100. */
  17101. id: string;
  17102. /**
  17103. * The friendly name of the Particle system.
  17104. */
  17105. name: string;
  17106. /**
  17107. * The rendering group used by the Particle system to chose when to render.
  17108. */
  17109. renderingGroupId: number;
  17110. /**
  17111. * The emitter represents the Mesh or position we are attaching the particle system to.
  17112. */
  17113. emitter: Nullable<AbstractMesh | Vector3>;
  17114. /**
  17115. * The maximum number of particles to emit per frame
  17116. */
  17117. emitRate: number;
  17118. /**
  17119. * If you want to launch only a few particles at once, that can be done, as well.
  17120. */
  17121. manualEmitCount: number;
  17122. /**
  17123. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17124. */
  17125. updateSpeed: number;
  17126. /**
  17127. * The amount of time the particle system is running (depends of the overall update speed).
  17128. */
  17129. targetStopDuration: number;
  17130. /**
  17131. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17132. */
  17133. disposeOnStop: boolean;
  17134. /**
  17135. * Minimum power of emitting particles.
  17136. */
  17137. minEmitPower: number;
  17138. /**
  17139. * Maximum power of emitting particles.
  17140. */
  17141. maxEmitPower: number;
  17142. /**
  17143. * Minimum life time of emitting particles.
  17144. */
  17145. minLifeTime: number;
  17146. /**
  17147. * Maximum life time of emitting particles.
  17148. */
  17149. maxLifeTime: number;
  17150. /**
  17151. * Minimum Size of emitting particles.
  17152. */
  17153. minSize: number;
  17154. /**
  17155. * Maximum Size of emitting particles.
  17156. */
  17157. maxSize: number;
  17158. /**
  17159. * Minimum scale of emitting particles on X axis.
  17160. */
  17161. minScaleX: number;
  17162. /**
  17163. * Maximum scale of emitting particles on X axis.
  17164. */
  17165. maxScaleX: number;
  17166. /**
  17167. * Minimum scale of emitting particles on Y axis.
  17168. */
  17169. minScaleY: number;
  17170. /**
  17171. * Maximum scale of emitting particles on Y axis.
  17172. */
  17173. maxScaleY: number;
  17174. /**
  17175. * Gets or sets the minimal initial rotation in radians.
  17176. */
  17177. minInitialRotation: number;
  17178. /**
  17179. * Gets or sets the maximal initial rotation in radians.
  17180. */
  17181. maxInitialRotation: number;
  17182. /**
  17183. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17184. */
  17185. minAngularSpeed: number;
  17186. /**
  17187. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17188. */
  17189. maxAngularSpeed: number;
  17190. /**
  17191. * The texture used to render each particle. (this can be a spritesheet)
  17192. */
  17193. particleTexture: Nullable<Texture>;
  17194. /**
  17195. * The layer mask we are rendering the particles through.
  17196. */
  17197. layerMask: number;
  17198. /**
  17199. * This can help using your own shader to render the particle system.
  17200. * The according effect will be created
  17201. */
  17202. customShader: any;
  17203. /**
  17204. * By default particle system starts as soon as they are created. This prevents the
  17205. * automatic start to happen and let you decide when to start emitting particles.
  17206. */
  17207. preventAutoStart: boolean;
  17208. private _noiseTexture;
  17209. /**
  17210. * Gets or sets a texture used to add random noise to particle positions
  17211. */
  17212. noiseTexture: Nullable<ProceduralTexture>;
  17213. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17214. noiseStrength: Vector3;
  17215. /**
  17216. * Callback triggered when the particle animation is ending.
  17217. */
  17218. onAnimationEnd: Nullable<() => void>;
  17219. /**
  17220. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17221. */
  17222. blendMode: number;
  17223. /**
  17224. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17225. * to override the particles.
  17226. */
  17227. forceDepthWrite: boolean;
  17228. /** 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 */
  17229. preWarmCycles: number;
  17230. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17231. preWarmStepOffset: number;
  17232. /**
  17233. * 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)
  17234. */
  17235. spriteCellChangeSpeed: number;
  17236. /**
  17237. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17238. */
  17239. startSpriteCellID: number;
  17240. /**
  17241. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17242. */
  17243. endSpriteCellID: number;
  17244. /**
  17245. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17246. */
  17247. spriteCellWidth: number;
  17248. /**
  17249. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17250. */
  17251. spriteCellHeight: number;
  17252. /**
  17253. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17254. */
  17255. spriteRandomStartCell: boolean;
  17256. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17257. translationPivot: Vector2;
  17258. /** @hidden */
  17259. protected _isAnimationSheetEnabled: boolean;
  17260. /**
  17261. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17262. */
  17263. beginAnimationOnStart: boolean;
  17264. /**
  17265. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17266. */
  17267. beginAnimationFrom: number;
  17268. /**
  17269. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17270. */
  17271. beginAnimationTo: number;
  17272. /**
  17273. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17274. */
  17275. beginAnimationLoop: boolean;
  17276. /**
  17277. * Gets or sets a world offset applied to all particles
  17278. */
  17279. worldOffset: Vector3;
  17280. /**
  17281. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17282. */
  17283. isAnimationSheetEnabled: boolean;
  17284. /**
  17285. * Get hosting scene
  17286. * @returns the scene
  17287. */
  17288. getScene(): Scene;
  17289. /**
  17290. * You can use gravity if you want to give an orientation to your particles.
  17291. */
  17292. gravity: Vector3;
  17293. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17294. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17295. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17296. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17297. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17298. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17299. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17300. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17301. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17302. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17303. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17304. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17305. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17306. /**
  17307. * Defines the delay in milliseconds before starting the system (0 by default)
  17308. */
  17309. startDelay: number;
  17310. /**
  17311. * Gets the current list of drag gradients.
  17312. * You must use addDragGradient and removeDragGradient to udpate this list
  17313. * @returns the list of drag gradients
  17314. */
  17315. getDragGradients(): Nullable<Array<FactorGradient>>;
  17316. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17317. limitVelocityDamping: number;
  17318. /**
  17319. * Gets the current list of limit velocity gradients.
  17320. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17321. * @returns the list of limit velocity gradients
  17322. */
  17323. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17324. /**
  17325. * Gets the current list of color gradients.
  17326. * You must use addColorGradient and removeColorGradient to udpate this list
  17327. * @returns the list of color gradients
  17328. */
  17329. getColorGradients(): Nullable<Array<ColorGradient>>;
  17330. /**
  17331. * Gets the current list of size gradients.
  17332. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17333. * @returns the list of size gradients
  17334. */
  17335. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17336. /**
  17337. * Gets the current list of color remap gradients.
  17338. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17339. * @returns the list of color remap gradients
  17340. */
  17341. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17342. /**
  17343. * Gets the current list of alpha remap gradients.
  17344. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17345. * @returns the list of alpha remap gradients
  17346. */
  17347. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17348. /**
  17349. * Gets the current list of life time gradients.
  17350. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17351. * @returns the list of life time gradients
  17352. */
  17353. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17354. /**
  17355. * Gets the current list of angular speed gradients.
  17356. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17357. * @returns the list of angular speed gradients
  17358. */
  17359. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17360. /**
  17361. * Gets the current list of velocity gradients.
  17362. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17363. * @returns the list of velocity gradients
  17364. */
  17365. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17366. /**
  17367. * Gets the current list of start size gradients.
  17368. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17369. * @returns the list of start size gradients
  17370. */
  17371. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17372. /**
  17373. * Gets the current list of emit rate gradients.
  17374. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17375. * @returns the list of emit rate gradients
  17376. */
  17377. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17378. /**
  17379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17380. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17381. */
  17382. direction1: Vector3;
  17383. /**
  17384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17385. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17386. */
  17387. direction2: Vector3;
  17388. /**
  17389. * 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.
  17390. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17391. */
  17392. minEmitBox: Vector3;
  17393. /**
  17394. * 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.
  17395. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17396. */
  17397. maxEmitBox: Vector3;
  17398. /**
  17399. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17400. */
  17401. color1: Color4;
  17402. /**
  17403. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17404. */
  17405. color2: Color4;
  17406. /**
  17407. * Color the particle will have at the end of its lifetime
  17408. */
  17409. colorDead: Color4;
  17410. /**
  17411. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17412. */
  17413. textureMask: Color4;
  17414. /**
  17415. * The particle emitter type defines the emitter used by the particle system.
  17416. * It can be for example box, sphere, or cone...
  17417. */
  17418. particleEmitterType: IParticleEmitterType;
  17419. /** @hidden */
  17420. _isSubEmitter: boolean;
  17421. /**
  17422. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17423. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17424. */
  17425. billboardMode: number;
  17426. protected _isBillboardBased: boolean;
  17427. /**
  17428. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17429. */
  17430. isBillboardBased: boolean;
  17431. /**
  17432. * The scene the particle system belongs to.
  17433. */
  17434. protected _scene: Scene;
  17435. /**
  17436. * Local cache of defines for image processing.
  17437. */
  17438. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17439. /**
  17440. * Default configuration related to image processing available in the standard Material.
  17441. */
  17442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17443. /**
  17444. * Gets the image processing configuration used either in this material.
  17445. */
  17446. /**
  17447. * Sets the Default image processing configuration used either in the this material.
  17448. *
  17449. * If sets to null, the scene one is in use.
  17450. */
  17451. imageProcessingConfiguration: ImageProcessingConfiguration;
  17452. /**
  17453. * Attaches a new image processing configuration to the Standard Material.
  17454. * @param configuration
  17455. */
  17456. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17457. /** @hidden */
  17458. protected _reset(): void;
  17459. /** @hidden */
  17460. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17461. /**
  17462. * Instantiates a particle system.
  17463. * 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.
  17464. * @param name The name of the particle system
  17465. */
  17466. constructor(name: string);
  17467. /**
  17468. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17471. * @returns the emitter
  17472. */
  17473. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17474. /**
  17475. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17476. * @param radius The radius of the hemisphere to emit from
  17477. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17478. * @returns the emitter
  17479. */
  17480. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17481. /**
  17482. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17483. * @param radius The radius of the sphere to emit from
  17484. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17485. * @returns the emitter
  17486. */
  17487. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17488. /**
  17489. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17490. * @param radius The radius of the sphere to emit from
  17491. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17492. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17493. * @returns the emitter
  17494. */
  17495. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17496. /**
  17497. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17498. * @param radius The radius of the emission cylinder
  17499. * @param height The height of the emission cylinder
  17500. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17501. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17502. * @returns the emitter
  17503. */
  17504. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17505. /**
  17506. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17507. * @param radius The radius of the cylinder to emit from
  17508. * @param height The height of the emission cylinder
  17509. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17510. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17511. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17512. * @returns the emitter
  17513. */
  17514. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17515. /**
  17516. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17517. * @param radius The radius of the cone to emit from
  17518. * @param angle The base angle of the cone
  17519. * @returns the emitter
  17520. */
  17521. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17522. /**
  17523. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17524. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17525. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17526. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17527. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17528. * @returns the emitter
  17529. */
  17530. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17531. }
  17532. }
  17533. declare module "babylonjs/Particles/subEmitter" {
  17534. import { Scene } from "babylonjs/scene";
  17535. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17536. /**
  17537. * Type of sub emitter
  17538. */
  17539. export enum SubEmitterType {
  17540. /**
  17541. * Attached to the particle over it's lifetime
  17542. */
  17543. ATTACHED = 0,
  17544. /**
  17545. * Created when the particle dies
  17546. */
  17547. END = 1
  17548. }
  17549. /**
  17550. * Sub emitter class used to emit particles from an existing particle
  17551. */
  17552. export class SubEmitter {
  17553. /**
  17554. * the particle system to be used by the sub emitter
  17555. */
  17556. particleSystem: ParticleSystem;
  17557. /**
  17558. * Type of the submitter (Default: END)
  17559. */
  17560. type: SubEmitterType;
  17561. /**
  17562. * 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)
  17563. * Note: This only is supported when using an emitter of type Mesh
  17564. */
  17565. inheritDirection: boolean;
  17566. /**
  17567. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17568. */
  17569. inheritedVelocityAmount: number;
  17570. /**
  17571. * Creates a sub emitter
  17572. * @param particleSystem the particle system to be used by the sub emitter
  17573. */
  17574. constructor(
  17575. /**
  17576. * the particle system to be used by the sub emitter
  17577. */
  17578. particleSystem: ParticleSystem);
  17579. /**
  17580. * Clones the sub emitter
  17581. * @returns the cloned sub emitter
  17582. */
  17583. clone(): SubEmitter;
  17584. /**
  17585. * Serialize current object to a JSON object
  17586. * @returns the serialized object
  17587. */
  17588. serialize(): any;
  17589. /** @hidden */
  17590. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17591. /**
  17592. * Creates a new SubEmitter from a serialized JSON version
  17593. * @param serializationObject defines the JSON object to read from
  17594. * @param scene defines the hosting scene
  17595. * @param rootUrl defines the rootUrl for data loading
  17596. * @returns a new SubEmitter
  17597. */
  17598. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17599. /** Release associated resources */
  17600. dispose(): void;
  17601. }
  17602. }
  17603. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17604. /** @hidden */
  17605. export var clipPlaneFragmentDeclaration: {
  17606. name: string;
  17607. shader: string;
  17608. };
  17609. }
  17610. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17611. /** @hidden */
  17612. export var imageProcessingDeclaration: {
  17613. name: string;
  17614. shader: string;
  17615. };
  17616. }
  17617. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17618. /** @hidden */
  17619. export var imageProcessingFunctions: {
  17620. name: string;
  17621. shader: string;
  17622. };
  17623. }
  17624. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17625. /** @hidden */
  17626. export var clipPlaneFragment: {
  17627. name: string;
  17628. shader: string;
  17629. };
  17630. }
  17631. declare module "babylonjs/Shaders/particles.fragment" {
  17632. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17633. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17634. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17635. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17637. /** @hidden */
  17638. export var particlesPixelShader: {
  17639. name: string;
  17640. shader: string;
  17641. };
  17642. }
  17643. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17644. /** @hidden */
  17645. export var clipPlaneVertexDeclaration: {
  17646. name: string;
  17647. shader: string;
  17648. };
  17649. }
  17650. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17651. /** @hidden */
  17652. export var clipPlaneVertex: {
  17653. name: string;
  17654. shader: string;
  17655. };
  17656. }
  17657. declare module "babylonjs/Shaders/particles.vertex" {
  17658. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17659. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17660. /** @hidden */
  17661. export var particlesVertexShader: {
  17662. name: string;
  17663. shader: string;
  17664. };
  17665. }
  17666. declare module "babylonjs/Particles/particleSystem" {
  17667. import { Nullable } from "babylonjs/types";
  17668. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17669. import { Observable } from "babylonjs/Misc/observable";
  17670. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17671. import { Effect } from "babylonjs/Materials/effect";
  17672. import { Scene, IDisposable } from "babylonjs/scene";
  17673. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17674. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17675. import { Particle } from "babylonjs/Particles/particle";
  17676. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17677. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17678. import "babylonjs/Shaders/particles.fragment";
  17679. import "babylonjs/Shaders/particles.vertex";
  17680. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17681. /**
  17682. * This represents a particle system in Babylon.
  17683. * 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.
  17684. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17685. * @example https://doc.babylonjs.com/babylon101/particles
  17686. */
  17687. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17688. /**
  17689. * Billboard mode will only apply to Y axis
  17690. */
  17691. static readonly BILLBOARDMODE_Y: number;
  17692. /**
  17693. * Billboard mode will apply to all axes
  17694. */
  17695. static readonly BILLBOARDMODE_ALL: number;
  17696. /**
  17697. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17698. */
  17699. static readonly BILLBOARDMODE_STRETCHED: number;
  17700. /**
  17701. * This function can be defined to provide custom update for active particles.
  17702. * This function will be called instead of regular update (age, position, color, etc.).
  17703. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17704. */
  17705. updateFunction: (particles: Particle[]) => void;
  17706. private _emitterWorldMatrix;
  17707. /**
  17708. * This function can be defined to specify initial direction for every new particle.
  17709. * It by default use the emitterType defined function
  17710. */
  17711. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17712. /**
  17713. * This function can be defined to specify initial position for every new particle.
  17714. * It by default use the emitterType defined function
  17715. */
  17716. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17717. /**
  17718. * @hidden
  17719. */
  17720. _inheritedVelocityOffset: Vector3;
  17721. /**
  17722. * An event triggered when the system is disposed
  17723. */
  17724. onDisposeObservable: Observable<ParticleSystem>;
  17725. private _onDisposeObserver;
  17726. /**
  17727. * Sets a callback that will be triggered when the system is disposed
  17728. */
  17729. onDispose: () => void;
  17730. private _particles;
  17731. private _epsilon;
  17732. private _capacity;
  17733. private _stockParticles;
  17734. private _newPartsExcess;
  17735. private _vertexData;
  17736. private _vertexBuffer;
  17737. private _vertexBuffers;
  17738. private _spriteBuffer;
  17739. private _indexBuffer;
  17740. private _effect;
  17741. private _customEffect;
  17742. private _cachedDefines;
  17743. private _scaledColorStep;
  17744. private _colorDiff;
  17745. private _scaledDirection;
  17746. private _scaledGravity;
  17747. private _currentRenderId;
  17748. private _alive;
  17749. private _useInstancing;
  17750. private _started;
  17751. private _stopped;
  17752. private _actualFrame;
  17753. private _scaledUpdateSpeed;
  17754. private _vertexBufferSize;
  17755. /** @hidden */
  17756. _currentEmitRateGradient: Nullable<FactorGradient>;
  17757. /** @hidden */
  17758. _currentEmitRate1: number;
  17759. /** @hidden */
  17760. _currentEmitRate2: number;
  17761. /** @hidden */
  17762. _currentStartSizeGradient: Nullable<FactorGradient>;
  17763. /** @hidden */
  17764. _currentStartSize1: number;
  17765. /** @hidden */
  17766. _currentStartSize2: number;
  17767. private readonly _rawTextureWidth;
  17768. private _rampGradientsTexture;
  17769. private _useRampGradients;
  17770. /** Gets or sets a boolean indicating that ramp gradients must be used
  17771. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17772. */
  17773. useRampGradients: boolean;
  17774. /**
  17775. * 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.
  17776. * 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: [])
  17777. */
  17778. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17779. private _subEmitters;
  17780. /**
  17781. * @hidden
  17782. * If the particle systems emitter should be disposed when the particle system is disposed
  17783. */
  17784. _disposeEmitterOnDispose: boolean;
  17785. /**
  17786. * The current active Sub-systems, this property is used by the root particle system only.
  17787. */
  17788. activeSubSystems: Array<ParticleSystem>;
  17789. private _rootParticleSystem;
  17790. /**
  17791. * Gets the current list of active particles
  17792. */
  17793. readonly particles: Particle[];
  17794. /**
  17795. * Returns the string "ParticleSystem"
  17796. * @returns a string containing the class name
  17797. */
  17798. getClassName(): string;
  17799. /**
  17800. * Instantiates a particle system.
  17801. * 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.
  17802. * @param name The name of the particle system
  17803. * @param capacity The max number of particles alive at the same time
  17804. * @param scene The scene the particle system belongs to
  17805. * @param customEffect a custom effect used to change the way particles are rendered by default
  17806. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17807. * @param epsilon Offset used to render the particles
  17808. */
  17809. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17810. private _addFactorGradient;
  17811. private _removeFactorGradient;
  17812. /**
  17813. * Adds a new life time gradient
  17814. * @param gradient defines the gradient to use (between 0 and 1)
  17815. * @param factor defines the life time factor to affect to the specified gradient
  17816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17817. * @returns the current particle system
  17818. */
  17819. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17820. /**
  17821. * Remove a specific life time gradient
  17822. * @param gradient defines the gradient to remove
  17823. * @returns the current particle system
  17824. */
  17825. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17826. /**
  17827. * Adds a new size gradient
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param factor defines the size factor to affect to the specified gradient
  17830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17831. * @returns the current particle system
  17832. */
  17833. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17834. /**
  17835. * Remove a specific size gradient
  17836. * @param gradient defines the gradient to remove
  17837. * @returns the current particle system
  17838. */
  17839. removeSizeGradient(gradient: number): IParticleSystem;
  17840. /**
  17841. * Adds a new color remap gradient
  17842. * @param gradient defines the gradient to use (between 0 and 1)
  17843. * @param min defines the color remap minimal range
  17844. * @param max defines the color remap maximal range
  17845. * @returns the current particle system
  17846. */
  17847. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17848. /**
  17849. * Remove a specific color remap gradient
  17850. * @param gradient defines the gradient to remove
  17851. * @returns the current particle system
  17852. */
  17853. removeColorRemapGradient(gradient: number): IParticleSystem;
  17854. /**
  17855. * Adds a new alpha remap gradient
  17856. * @param gradient defines the gradient to use (between 0 and 1)
  17857. * @param min defines the alpha remap minimal range
  17858. * @param max defines the alpha remap maximal range
  17859. * @returns the current particle system
  17860. */
  17861. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17862. /**
  17863. * Remove a specific alpha remap gradient
  17864. * @param gradient defines the gradient to remove
  17865. * @returns the current particle system
  17866. */
  17867. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17868. /**
  17869. * Adds a new angular speed gradient
  17870. * @param gradient defines the gradient to use (between 0 and 1)
  17871. * @param factor defines the angular speed to affect to the specified gradient
  17872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17873. * @returns the current particle system
  17874. */
  17875. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17876. /**
  17877. * Remove a specific angular speed gradient
  17878. * @param gradient defines the gradient to remove
  17879. * @returns the current particle system
  17880. */
  17881. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17882. /**
  17883. * Adds a new velocity gradient
  17884. * @param gradient defines the gradient to use (between 0 and 1)
  17885. * @param factor defines the velocity to affect to the specified gradient
  17886. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17887. * @returns the current particle system
  17888. */
  17889. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17890. /**
  17891. * Remove a specific velocity gradient
  17892. * @param gradient defines the gradient to remove
  17893. * @returns the current particle system
  17894. */
  17895. removeVelocityGradient(gradient: number): IParticleSystem;
  17896. /**
  17897. * Adds a new limit velocity gradient
  17898. * @param gradient defines the gradient to use (between 0 and 1)
  17899. * @param factor defines the limit velocity value to affect to the specified gradient
  17900. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17901. * @returns the current particle system
  17902. */
  17903. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17904. /**
  17905. * Remove a specific limit velocity gradient
  17906. * @param gradient defines the gradient to remove
  17907. * @returns the current particle system
  17908. */
  17909. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17910. /**
  17911. * Adds a new drag gradient
  17912. * @param gradient defines the gradient to use (between 0 and 1)
  17913. * @param factor defines the drag value to affect to the specified gradient
  17914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17915. * @returns the current particle system
  17916. */
  17917. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17918. /**
  17919. * Remove a specific drag gradient
  17920. * @param gradient defines the gradient to remove
  17921. * @returns the current particle system
  17922. */
  17923. removeDragGradient(gradient: number): IParticleSystem;
  17924. /**
  17925. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17926. * @param gradient defines the gradient to use (between 0 and 1)
  17927. * @param factor defines the emit rate value to affect to the specified gradient
  17928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17929. * @returns the current particle system
  17930. */
  17931. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17932. /**
  17933. * Remove a specific emit rate gradient
  17934. * @param gradient defines the gradient to remove
  17935. * @returns the current particle system
  17936. */
  17937. removeEmitRateGradient(gradient: number): IParticleSystem;
  17938. /**
  17939. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17940. * @param gradient defines the gradient to use (between 0 and 1)
  17941. * @param factor defines the start size value to affect to the specified gradient
  17942. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17943. * @returns the current particle system
  17944. */
  17945. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17946. /**
  17947. * Remove a specific start size gradient
  17948. * @param gradient defines the gradient to remove
  17949. * @returns the current particle system
  17950. */
  17951. removeStartSizeGradient(gradient: number): IParticleSystem;
  17952. private _createRampGradientTexture;
  17953. /**
  17954. * Gets the current list of ramp gradients.
  17955. * You must use addRampGradient and removeRampGradient to udpate this list
  17956. * @returns the list of ramp gradients
  17957. */
  17958. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17959. /**
  17960. * Adds a new ramp gradient used to remap particle colors
  17961. * @param gradient defines the gradient to use (between 0 and 1)
  17962. * @param color defines the color to affect to the specified gradient
  17963. * @returns the current particle system
  17964. */
  17965. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17966. /**
  17967. * Remove a specific ramp gradient
  17968. * @param gradient defines the gradient to remove
  17969. * @returns the current particle system
  17970. */
  17971. removeRampGradient(gradient: number): ParticleSystem;
  17972. /**
  17973. * Adds a new color gradient
  17974. * @param gradient defines the gradient to use (between 0 and 1)
  17975. * @param color1 defines the color to affect to the specified gradient
  17976. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17977. * @returns this particle system
  17978. */
  17979. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17980. /**
  17981. * Remove a specific color gradient
  17982. * @param gradient defines the gradient to remove
  17983. * @returns this particle system
  17984. */
  17985. removeColorGradient(gradient: number): IParticleSystem;
  17986. private _fetchR;
  17987. protected _reset(): void;
  17988. private _resetEffect;
  17989. private _createVertexBuffers;
  17990. private _createIndexBuffer;
  17991. /**
  17992. * Gets the maximum number of particles active at the same time.
  17993. * @returns The max number of active particles.
  17994. */
  17995. getCapacity(): number;
  17996. /**
  17997. * Gets whether there are still active particles in the system.
  17998. * @returns True if it is alive, otherwise false.
  17999. */
  18000. isAlive(): boolean;
  18001. /**
  18002. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18003. * @returns True if it has been started, otherwise false.
  18004. */
  18005. isStarted(): boolean;
  18006. private _prepareSubEmitterInternalArray;
  18007. /**
  18008. * Starts the particle system and begins to emit
  18009. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18010. */
  18011. start(delay?: number): void;
  18012. /**
  18013. * Stops the particle system.
  18014. * @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.
  18015. */
  18016. stop(stopSubEmitters?: boolean): void;
  18017. /**
  18018. * Remove all active particles
  18019. */
  18020. reset(): void;
  18021. /**
  18022. * @hidden (for internal use only)
  18023. */
  18024. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18025. /**
  18026. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18027. * Its lifetime will start back at 0.
  18028. */
  18029. recycleParticle: (particle: Particle) => void;
  18030. private _stopSubEmitters;
  18031. private _createParticle;
  18032. private _removeFromRoot;
  18033. private _emitFromParticle;
  18034. private _update;
  18035. /** @hidden */
  18036. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18037. /** @hidden */
  18038. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18039. /** @hidden */
  18040. private _getEffect;
  18041. /**
  18042. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18043. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18044. */
  18045. animate(preWarmOnly?: boolean): void;
  18046. private _appendParticleVertices;
  18047. /**
  18048. * Rebuilds the particle system.
  18049. */
  18050. rebuild(): void;
  18051. /**
  18052. * Is this system ready to be used/rendered
  18053. * @return true if the system is ready
  18054. */
  18055. isReady(): boolean;
  18056. private _render;
  18057. /**
  18058. * Renders the particle system in its current state.
  18059. * @returns the current number of particles
  18060. */
  18061. render(): number;
  18062. /**
  18063. * Disposes the particle system and free the associated resources
  18064. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18065. */
  18066. dispose(disposeTexture?: boolean): void;
  18067. /**
  18068. * Clones the particle system.
  18069. * @param name The name of the cloned object
  18070. * @param newEmitter The new emitter to use
  18071. * @returns the cloned particle system
  18072. */
  18073. clone(name: string, newEmitter: any): ParticleSystem;
  18074. /**
  18075. * Serializes the particle system to a JSON object.
  18076. * @returns the JSON object
  18077. */
  18078. serialize(): any;
  18079. /** @hidden */
  18080. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18081. /** @hidden */
  18082. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18083. /**
  18084. * Parses a JSON object to create a particle system.
  18085. * @param parsedParticleSystem The JSON object to parse
  18086. * @param scene The scene to create the particle system in
  18087. * @param rootUrl The root url to use to load external dependencies like texture
  18088. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18089. * @returns the Parsed particle system
  18090. */
  18091. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18092. }
  18093. }
  18094. declare module "babylonjs/Particles/particle" {
  18095. import { Nullable } from "babylonjs/types";
  18096. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18097. import { Color4 } from "babylonjs/Maths/math.color";
  18098. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18099. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18100. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18101. /**
  18102. * A particle represents one of the element emitted by a particle system.
  18103. * This is mainly define by its coordinates, direction, velocity and age.
  18104. */
  18105. export class Particle {
  18106. /**
  18107. * The particle system the particle belongs to.
  18108. */
  18109. particleSystem: ParticleSystem;
  18110. private static _Count;
  18111. /**
  18112. * Unique ID of the particle
  18113. */
  18114. id: number;
  18115. /**
  18116. * The world position of the particle in the scene.
  18117. */
  18118. position: Vector3;
  18119. /**
  18120. * The world direction of the particle in the scene.
  18121. */
  18122. direction: Vector3;
  18123. /**
  18124. * The color of the particle.
  18125. */
  18126. color: Color4;
  18127. /**
  18128. * The color change of the particle per step.
  18129. */
  18130. colorStep: Color4;
  18131. /**
  18132. * Defines how long will the life of the particle be.
  18133. */
  18134. lifeTime: number;
  18135. /**
  18136. * The current age of the particle.
  18137. */
  18138. age: number;
  18139. /**
  18140. * The current size of the particle.
  18141. */
  18142. size: number;
  18143. /**
  18144. * The current scale of the particle.
  18145. */
  18146. scale: Vector2;
  18147. /**
  18148. * The current angle of the particle.
  18149. */
  18150. angle: number;
  18151. /**
  18152. * Defines how fast is the angle changing.
  18153. */
  18154. angularSpeed: number;
  18155. /**
  18156. * Defines the cell index used by the particle to be rendered from a sprite.
  18157. */
  18158. cellIndex: number;
  18159. /**
  18160. * The information required to support color remapping
  18161. */
  18162. remapData: Vector4;
  18163. /** @hidden */
  18164. _randomCellOffset?: number;
  18165. /** @hidden */
  18166. _initialDirection: Nullable<Vector3>;
  18167. /** @hidden */
  18168. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18169. /** @hidden */
  18170. _initialStartSpriteCellID: number;
  18171. /** @hidden */
  18172. _initialEndSpriteCellID: number;
  18173. /** @hidden */
  18174. _currentColorGradient: Nullable<ColorGradient>;
  18175. /** @hidden */
  18176. _currentColor1: Color4;
  18177. /** @hidden */
  18178. _currentColor2: Color4;
  18179. /** @hidden */
  18180. _currentSizeGradient: Nullable<FactorGradient>;
  18181. /** @hidden */
  18182. _currentSize1: number;
  18183. /** @hidden */
  18184. _currentSize2: number;
  18185. /** @hidden */
  18186. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18187. /** @hidden */
  18188. _currentAngularSpeed1: number;
  18189. /** @hidden */
  18190. _currentAngularSpeed2: number;
  18191. /** @hidden */
  18192. _currentVelocityGradient: Nullable<FactorGradient>;
  18193. /** @hidden */
  18194. _currentVelocity1: number;
  18195. /** @hidden */
  18196. _currentVelocity2: number;
  18197. /** @hidden */
  18198. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18199. /** @hidden */
  18200. _currentLimitVelocity1: number;
  18201. /** @hidden */
  18202. _currentLimitVelocity2: number;
  18203. /** @hidden */
  18204. _currentDragGradient: Nullable<FactorGradient>;
  18205. /** @hidden */
  18206. _currentDrag1: number;
  18207. /** @hidden */
  18208. _currentDrag2: number;
  18209. /** @hidden */
  18210. _randomNoiseCoordinates1: Vector3;
  18211. /** @hidden */
  18212. _randomNoiseCoordinates2: Vector3;
  18213. /**
  18214. * Creates a new instance Particle
  18215. * @param particleSystem the particle system the particle belongs to
  18216. */
  18217. constructor(
  18218. /**
  18219. * The particle system the particle belongs to.
  18220. */
  18221. particleSystem: ParticleSystem);
  18222. private updateCellInfoFromSystem;
  18223. /**
  18224. * Defines how the sprite cell index is updated for the particle
  18225. */
  18226. updateCellIndex(): void;
  18227. /** @hidden */
  18228. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18229. /** @hidden */
  18230. _inheritParticleInfoToSubEmitters(): void;
  18231. /** @hidden */
  18232. _reset(): void;
  18233. /**
  18234. * Copy the properties of particle to another one.
  18235. * @param other the particle to copy the information to.
  18236. */
  18237. copyTo(other: Particle): void;
  18238. }
  18239. }
  18240. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18241. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18242. import { Effect } from "babylonjs/Materials/effect";
  18243. import { Particle } from "babylonjs/Particles/particle";
  18244. /**
  18245. * Particle emitter represents a volume emitting particles.
  18246. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18247. */
  18248. export interface IParticleEmitterType {
  18249. /**
  18250. * Called by the particle System when the direction is computed for the created particle.
  18251. * @param worldMatrix is the world matrix of the particle system
  18252. * @param directionToUpdate is the direction vector to update with the result
  18253. * @param particle is the particle we are computed the direction for
  18254. */
  18255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18256. /**
  18257. * Called by the particle System when the position is computed for the created particle.
  18258. * @param worldMatrix is the world matrix of the particle system
  18259. * @param positionToUpdate is the position vector to update with the result
  18260. * @param particle is the particle we are computed the position for
  18261. */
  18262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18263. /**
  18264. * Clones the current emitter and returns a copy of it
  18265. * @returns the new emitter
  18266. */
  18267. clone(): IParticleEmitterType;
  18268. /**
  18269. * Called by the GPUParticleSystem to setup the update shader
  18270. * @param effect defines the update shader
  18271. */
  18272. applyToShader(effect: Effect): void;
  18273. /**
  18274. * Returns a string to use to update the GPU particles update shader
  18275. * @returns the effect defines string
  18276. */
  18277. getEffectDefines(): string;
  18278. /**
  18279. * Returns a string representing the class name
  18280. * @returns a string containing the class name
  18281. */
  18282. getClassName(): string;
  18283. /**
  18284. * Serializes the particle system to a JSON object.
  18285. * @returns the JSON object
  18286. */
  18287. serialize(): any;
  18288. /**
  18289. * Parse properties from a JSON object
  18290. * @param serializationObject defines the JSON object
  18291. */
  18292. parse(serializationObject: any): void;
  18293. }
  18294. }
  18295. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18296. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18297. import { Effect } from "babylonjs/Materials/effect";
  18298. import { Particle } from "babylonjs/Particles/particle";
  18299. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18300. /**
  18301. * Particle emitter emitting particles from the inside of a box.
  18302. * It emits the particles randomly between 2 given directions.
  18303. */
  18304. export class BoxParticleEmitter implements IParticleEmitterType {
  18305. /**
  18306. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18307. */
  18308. direction1: Vector3;
  18309. /**
  18310. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18311. */
  18312. direction2: Vector3;
  18313. /**
  18314. * 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.
  18315. */
  18316. minEmitBox: Vector3;
  18317. /**
  18318. * 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.
  18319. */
  18320. maxEmitBox: Vector3;
  18321. /**
  18322. * Creates a new instance BoxParticleEmitter
  18323. */
  18324. constructor();
  18325. /**
  18326. * Called by the particle System when the direction is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param directionToUpdate is the direction vector to update with the result
  18329. * @param particle is the particle we are computed the direction for
  18330. */
  18331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Called by the particle System when the position is computed for the created particle.
  18334. * @param worldMatrix is the world matrix of the particle system
  18335. * @param positionToUpdate is the position vector to update with the result
  18336. * @param particle is the particle we are computed the position for
  18337. */
  18338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18339. /**
  18340. * Clones the current emitter and returns a copy of it
  18341. * @returns the new emitter
  18342. */
  18343. clone(): BoxParticleEmitter;
  18344. /**
  18345. * Called by the GPUParticleSystem to setup the update shader
  18346. * @param effect defines the update shader
  18347. */
  18348. applyToShader(effect: Effect): void;
  18349. /**
  18350. * Returns a string to use to update the GPU particles update shader
  18351. * @returns a string containng the defines string
  18352. */
  18353. getEffectDefines(): string;
  18354. /**
  18355. * Returns the string "BoxParticleEmitter"
  18356. * @returns a string containing the class name
  18357. */
  18358. getClassName(): string;
  18359. /**
  18360. * Serializes the particle system to a JSON object.
  18361. * @returns the JSON object
  18362. */
  18363. serialize(): any;
  18364. /**
  18365. * Parse properties from a JSON object
  18366. * @param serializationObject defines the JSON object
  18367. */
  18368. parse(serializationObject: any): void;
  18369. }
  18370. }
  18371. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18372. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18373. import { Effect } from "babylonjs/Materials/effect";
  18374. import { Particle } from "babylonjs/Particles/particle";
  18375. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18376. /**
  18377. * Particle emitter emitting particles from the inside of a cone.
  18378. * It emits the particles alongside the cone volume from the base to the particle.
  18379. * The emission direction might be randomized.
  18380. */
  18381. export class ConeParticleEmitter implements IParticleEmitterType {
  18382. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18383. directionRandomizer: number;
  18384. private _radius;
  18385. private _angle;
  18386. private _height;
  18387. /**
  18388. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18389. */
  18390. radiusRange: number;
  18391. /**
  18392. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18393. */
  18394. heightRange: number;
  18395. /**
  18396. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18397. */
  18398. emitFromSpawnPointOnly: boolean;
  18399. /**
  18400. * Gets or sets the radius of the emission cone
  18401. */
  18402. radius: number;
  18403. /**
  18404. * Gets or sets the angle of the emission cone
  18405. */
  18406. angle: number;
  18407. private _buildHeight;
  18408. /**
  18409. * Creates a new instance ConeParticleEmitter
  18410. * @param radius the radius of the emission cone (1 by default)
  18411. * @param angle the cone base angle (PI by default)
  18412. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18413. */
  18414. constructor(radius?: number, angle?: number,
  18415. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18416. directionRandomizer?: number);
  18417. /**
  18418. * Called by the particle System when the direction is computed for the created particle.
  18419. * @param worldMatrix is the world matrix of the particle system
  18420. * @param directionToUpdate is the direction vector to update with the result
  18421. * @param particle is the particle we are computed the direction for
  18422. */
  18423. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18424. /**
  18425. * Called by the particle System when the position is computed for the created particle.
  18426. * @param worldMatrix is the world matrix of the particle system
  18427. * @param positionToUpdate is the position vector to update with the result
  18428. * @param particle is the particle we are computed the position for
  18429. */
  18430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18431. /**
  18432. * Clones the current emitter and returns a copy of it
  18433. * @returns the new emitter
  18434. */
  18435. clone(): ConeParticleEmitter;
  18436. /**
  18437. * Called by the GPUParticleSystem to setup the update shader
  18438. * @param effect defines the update shader
  18439. */
  18440. applyToShader(effect: Effect): void;
  18441. /**
  18442. * Returns a string to use to update the GPU particles update shader
  18443. * @returns a string containng the defines string
  18444. */
  18445. getEffectDefines(): string;
  18446. /**
  18447. * Returns the string "ConeParticleEmitter"
  18448. * @returns a string containing the class name
  18449. */
  18450. getClassName(): string;
  18451. /**
  18452. * Serializes the particle system to a JSON object.
  18453. * @returns the JSON object
  18454. */
  18455. serialize(): any;
  18456. /**
  18457. * Parse properties from a JSON object
  18458. * @param serializationObject defines the JSON object
  18459. */
  18460. parse(serializationObject: any): void;
  18461. }
  18462. }
  18463. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18464. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18465. import { Effect } from "babylonjs/Materials/effect";
  18466. import { Particle } from "babylonjs/Particles/particle";
  18467. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18468. /**
  18469. * Particle emitter emitting particles from the inside of a cylinder.
  18470. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18471. */
  18472. export class CylinderParticleEmitter implements IParticleEmitterType {
  18473. /**
  18474. * The radius of the emission cylinder.
  18475. */
  18476. radius: number;
  18477. /**
  18478. * The height of the emission cylinder.
  18479. */
  18480. height: number;
  18481. /**
  18482. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18483. */
  18484. radiusRange: number;
  18485. /**
  18486. * How much to randomize the particle direction [0-1].
  18487. */
  18488. directionRandomizer: number;
  18489. /**
  18490. * Creates a new instance CylinderParticleEmitter
  18491. * @param radius the radius of the emission cylinder (1 by default)
  18492. * @param height the height of the emission cylinder (1 by default)
  18493. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18495. */
  18496. constructor(
  18497. /**
  18498. * The radius of the emission cylinder.
  18499. */
  18500. radius?: number,
  18501. /**
  18502. * The height of the emission cylinder.
  18503. */
  18504. height?: number,
  18505. /**
  18506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18507. */
  18508. radiusRange?: number,
  18509. /**
  18510. * How much to randomize the particle direction [0-1].
  18511. */
  18512. directionRandomizer?: number);
  18513. /**
  18514. * Called by the particle System when the direction is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param directionToUpdate is the direction vector to update with the result
  18517. * @param particle is the particle we are computed the direction for
  18518. */
  18519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Called by the particle System when the position is computed for the created particle.
  18522. * @param worldMatrix is the world matrix of the particle system
  18523. * @param positionToUpdate is the position vector to update with the result
  18524. * @param particle is the particle we are computed the position for
  18525. */
  18526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18527. /**
  18528. * Clones the current emitter and returns a copy of it
  18529. * @returns the new emitter
  18530. */
  18531. clone(): CylinderParticleEmitter;
  18532. /**
  18533. * Called by the GPUParticleSystem to setup the update shader
  18534. * @param effect defines the update shader
  18535. */
  18536. applyToShader(effect: Effect): void;
  18537. /**
  18538. * Returns a string to use to update the GPU particles update shader
  18539. * @returns a string containng the defines string
  18540. */
  18541. getEffectDefines(): string;
  18542. /**
  18543. * Returns the string "CylinderParticleEmitter"
  18544. * @returns a string containing the class name
  18545. */
  18546. getClassName(): string;
  18547. /**
  18548. * Serializes the particle system to a JSON object.
  18549. * @returns the JSON object
  18550. */
  18551. serialize(): any;
  18552. /**
  18553. * Parse properties from a JSON object
  18554. * @param serializationObject defines the JSON object
  18555. */
  18556. parse(serializationObject: any): void;
  18557. }
  18558. /**
  18559. * Particle emitter emitting particles from the inside of a cylinder.
  18560. * It emits the particles randomly between two vectors.
  18561. */
  18562. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18563. /**
  18564. * The min limit of the emission direction.
  18565. */
  18566. direction1: Vector3;
  18567. /**
  18568. * The max limit of the emission direction.
  18569. */
  18570. direction2: Vector3;
  18571. /**
  18572. * Creates a new instance CylinderDirectedParticleEmitter
  18573. * @param radius the radius of the emission cylinder (1 by default)
  18574. * @param height the height of the emission cylinder (1 by default)
  18575. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18576. * @param direction1 the min limit of the emission direction (up vector by default)
  18577. * @param direction2 the max limit of the emission direction (up vector by default)
  18578. */
  18579. constructor(radius?: number, height?: number, radiusRange?: number,
  18580. /**
  18581. * The min limit of the emission direction.
  18582. */
  18583. direction1?: Vector3,
  18584. /**
  18585. * The max limit of the emission direction.
  18586. */
  18587. direction2?: Vector3);
  18588. /**
  18589. * Called by the particle System when the direction is computed for the created particle.
  18590. * @param worldMatrix is the world matrix of the particle system
  18591. * @param directionToUpdate is the direction vector to update with the result
  18592. * @param particle is the particle we are computed the direction for
  18593. */
  18594. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18595. /**
  18596. * Clones the current emitter and returns a copy of it
  18597. * @returns the new emitter
  18598. */
  18599. clone(): CylinderDirectedParticleEmitter;
  18600. /**
  18601. * Called by the GPUParticleSystem to setup the update shader
  18602. * @param effect defines the update shader
  18603. */
  18604. applyToShader(effect: Effect): void;
  18605. /**
  18606. * Returns a string to use to update the GPU particles update shader
  18607. * @returns a string containng the defines string
  18608. */
  18609. getEffectDefines(): string;
  18610. /**
  18611. * Returns the string "CylinderDirectedParticleEmitter"
  18612. * @returns a string containing the class name
  18613. */
  18614. getClassName(): string;
  18615. /**
  18616. * Serializes the particle system to a JSON object.
  18617. * @returns the JSON object
  18618. */
  18619. serialize(): any;
  18620. /**
  18621. * Parse properties from a JSON object
  18622. * @param serializationObject defines the JSON object
  18623. */
  18624. parse(serializationObject: any): void;
  18625. }
  18626. }
  18627. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18629. import { Effect } from "babylonjs/Materials/effect";
  18630. import { Particle } from "babylonjs/Particles/particle";
  18631. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18632. /**
  18633. * Particle emitter emitting particles from the inside of a hemisphere.
  18634. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18635. */
  18636. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18637. /**
  18638. * The radius of the emission hemisphere.
  18639. */
  18640. radius: number;
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange: number;
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer: number;
  18649. /**
  18650. * Creates a new instance HemisphericParticleEmitter
  18651. * @param radius the radius of the emission hemisphere (1 by default)
  18652. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18654. */
  18655. constructor(
  18656. /**
  18657. * The radius of the emission hemisphere.
  18658. */
  18659. radius?: number,
  18660. /**
  18661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18662. */
  18663. radiusRange?: number,
  18664. /**
  18665. * How much to randomize the particle direction [0-1].
  18666. */
  18667. directionRandomizer?: number);
  18668. /**
  18669. * Called by the particle System when the direction is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param directionToUpdate is the direction vector to update with the result
  18672. * @param particle is the particle we are computed the direction for
  18673. */
  18674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Called by the particle System when the position is computed for the created particle.
  18677. * @param worldMatrix is the world matrix of the particle system
  18678. * @param positionToUpdate is the position vector to update with the result
  18679. * @param particle is the particle we are computed the position for
  18680. */
  18681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18682. /**
  18683. * Clones the current emitter and returns a copy of it
  18684. * @returns the new emitter
  18685. */
  18686. clone(): HemisphericParticleEmitter;
  18687. /**
  18688. * Called by the GPUParticleSystem to setup the update shader
  18689. * @param effect defines the update shader
  18690. */
  18691. applyToShader(effect: Effect): void;
  18692. /**
  18693. * Returns a string to use to update the GPU particles update shader
  18694. * @returns a string containng the defines string
  18695. */
  18696. getEffectDefines(): string;
  18697. /**
  18698. * Returns the string "HemisphericParticleEmitter"
  18699. * @returns a string containing the class name
  18700. */
  18701. getClassName(): string;
  18702. /**
  18703. * Serializes the particle system to a JSON object.
  18704. * @returns the JSON object
  18705. */
  18706. serialize(): any;
  18707. /**
  18708. * Parse properties from a JSON object
  18709. * @param serializationObject defines the JSON object
  18710. */
  18711. parse(serializationObject: any): void;
  18712. }
  18713. }
  18714. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18715. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18716. import { Effect } from "babylonjs/Materials/effect";
  18717. import { Particle } from "babylonjs/Particles/particle";
  18718. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18719. /**
  18720. * Particle emitter emitting particles from a point.
  18721. * It emits the particles randomly between 2 given directions.
  18722. */
  18723. export class PointParticleEmitter implements IParticleEmitterType {
  18724. /**
  18725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18726. */
  18727. direction1: Vector3;
  18728. /**
  18729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18730. */
  18731. direction2: Vector3;
  18732. /**
  18733. * Creates a new instance PointParticleEmitter
  18734. */
  18735. constructor();
  18736. /**
  18737. * Called by the particle System when the direction is computed for the created particle.
  18738. * @param worldMatrix is the world matrix of the particle system
  18739. * @param directionToUpdate is the direction vector to update with the result
  18740. * @param particle is the particle we are computed the direction for
  18741. */
  18742. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18743. /**
  18744. * Called by the particle System when the position is computed for the created particle.
  18745. * @param worldMatrix is the world matrix of the particle system
  18746. * @param positionToUpdate is the position vector to update with the result
  18747. * @param particle is the particle we are computed the position for
  18748. */
  18749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18750. /**
  18751. * Clones the current emitter and returns a copy of it
  18752. * @returns the new emitter
  18753. */
  18754. clone(): PointParticleEmitter;
  18755. /**
  18756. * Called by the GPUParticleSystem to setup the update shader
  18757. * @param effect defines the update shader
  18758. */
  18759. applyToShader(effect: Effect): void;
  18760. /**
  18761. * Returns a string to use to update the GPU particles update shader
  18762. * @returns a string containng the defines string
  18763. */
  18764. getEffectDefines(): string;
  18765. /**
  18766. * Returns the string "PointParticleEmitter"
  18767. * @returns a string containing the class name
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Serializes the particle system to a JSON object.
  18772. * @returns the JSON object
  18773. */
  18774. serialize(): any;
  18775. /**
  18776. * Parse properties from a JSON object
  18777. * @param serializationObject defines the JSON object
  18778. */
  18779. parse(serializationObject: any): void;
  18780. }
  18781. }
  18782. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18783. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18784. import { Effect } from "babylonjs/Materials/effect";
  18785. import { Particle } from "babylonjs/Particles/particle";
  18786. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18787. /**
  18788. * Particle emitter emitting particles from the inside of a sphere.
  18789. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18790. */
  18791. export class SphereParticleEmitter implements IParticleEmitterType {
  18792. /**
  18793. * The radius of the emission sphere.
  18794. */
  18795. radius: number;
  18796. /**
  18797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18798. */
  18799. radiusRange: number;
  18800. /**
  18801. * How much to randomize the particle direction [0-1].
  18802. */
  18803. directionRandomizer: number;
  18804. /**
  18805. * Creates a new instance SphereParticleEmitter
  18806. * @param radius the radius of the emission sphere (1 by default)
  18807. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18808. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18809. */
  18810. constructor(
  18811. /**
  18812. * The radius of the emission sphere.
  18813. */
  18814. radius?: number,
  18815. /**
  18816. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18817. */
  18818. radiusRange?: number,
  18819. /**
  18820. * How much to randomize the particle direction [0-1].
  18821. */
  18822. directionRandomizer?: number);
  18823. /**
  18824. * Called by the particle System when the direction is computed for the created particle.
  18825. * @param worldMatrix is the world matrix of the particle system
  18826. * @param directionToUpdate is the direction vector to update with the result
  18827. * @param particle is the particle we are computed the direction for
  18828. */
  18829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18830. /**
  18831. * Called by the particle System when the position is computed for the created particle.
  18832. * @param worldMatrix is the world matrix of the particle system
  18833. * @param positionToUpdate is the position vector to update with the result
  18834. * @param particle is the particle we are computed the position for
  18835. */
  18836. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18837. /**
  18838. * Clones the current emitter and returns a copy of it
  18839. * @returns the new emitter
  18840. */
  18841. clone(): SphereParticleEmitter;
  18842. /**
  18843. * Called by the GPUParticleSystem to setup the update shader
  18844. * @param effect defines the update shader
  18845. */
  18846. applyToShader(effect: Effect): void;
  18847. /**
  18848. * Returns a string to use to update the GPU particles update shader
  18849. * @returns a string containng the defines string
  18850. */
  18851. getEffectDefines(): string;
  18852. /**
  18853. * Returns the string "SphereParticleEmitter"
  18854. * @returns a string containing the class name
  18855. */
  18856. getClassName(): string;
  18857. /**
  18858. * Serializes the particle system to a JSON object.
  18859. * @returns the JSON object
  18860. */
  18861. serialize(): any;
  18862. /**
  18863. * Parse properties from a JSON object
  18864. * @param serializationObject defines the JSON object
  18865. */
  18866. parse(serializationObject: any): void;
  18867. }
  18868. /**
  18869. * Particle emitter emitting particles from the inside of a sphere.
  18870. * It emits the particles randomly between two vectors.
  18871. */
  18872. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18873. /**
  18874. * The min limit of the emission direction.
  18875. */
  18876. direction1: Vector3;
  18877. /**
  18878. * The max limit of the emission direction.
  18879. */
  18880. direction2: Vector3;
  18881. /**
  18882. * Creates a new instance SphereDirectedParticleEmitter
  18883. * @param radius the radius of the emission sphere (1 by default)
  18884. * @param direction1 the min limit of the emission direction (up vector by default)
  18885. * @param direction2 the max limit of the emission direction (up vector by default)
  18886. */
  18887. constructor(radius?: number,
  18888. /**
  18889. * The min limit of the emission direction.
  18890. */
  18891. direction1?: Vector3,
  18892. /**
  18893. * The max limit of the emission direction.
  18894. */
  18895. direction2?: Vector3);
  18896. /**
  18897. * Called by the particle System when the direction is computed for the created particle.
  18898. * @param worldMatrix is the world matrix of the particle system
  18899. * @param directionToUpdate is the direction vector to update with the result
  18900. * @param particle is the particle we are computed the direction for
  18901. */
  18902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18903. /**
  18904. * Clones the current emitter and returns a copy of it
  18905. * @returns the new emitter
  18906. */
  18907. clone(): SphereDirectedParticleEmitter;
  18908. /**
  18909. * Called by the GPUParticleSystem to setup the update shader
  18910. * @param effect defines the update shader
  18911. */
  18912. applyToShader(effect: Effect): void;
  18913. /**
  18914. * Returns a string to use to update the GPU particles update shader
  18915. * @returns a string containng the defines string
  18916. */
  18917. getEffectDefines(): string;
  18918. /**
  18919. * Returns the string "SphereDirectedParticleEmitter"
  18920. * @returns a string containing the class name
  18921. */
  18922. getClassName(): string;
  18923. /**
  18924. * Serializes the particle system to a JSON object.
  18925. * @returns the JSON object
  18926. */
  18927. serialize(): any;
  18928. /**
  18929. * Parse properties from a JSON object
  18930. * @param serializationObject defines the JSON object
  18931. */
  18932. parse(serializationObject: any): void;
  18933. }
  18934. }
  18935. declare module "babylonjs/Particles/EmitterTypes/index" {
  18936. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18937. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18938. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18939. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18940. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18941. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18942. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18943. }
  18944. declare module "babylonjs/Particles/IParticleSystem" {
  18945. import { Nullable } from "babylonjs/types";
  18946. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18947. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18950. import { Texture } from "babylonjs/Materials/Textures/texture";
  18951. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18952. import { Scene } from "babylonjs/scene";
  18953. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18954. import { Animation } from "babylonjs/Animations/animation";
  18955. /**
  18956. * Interface representing a particle system in Babylon.js.
  18957. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18958. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18959. */
  18960. export interface IParticleSystem {
  18961. /**
  18962. * List of animations used by the particle system.
  18963. */
  18964. animations: Animation[];
  18965. /**
  18966. * The id of the Particle system.
  18967. */
  18968. id: string;
  18969. /**
  18970. * The name of the Particle system.
  18971. */
  18972. name: string;
  18973. /**
  18974. * The emitter represents the Mesh or position we are attaching the particle system to.
  18975. */
  18976. emitter: Nullable<AbstractMesh | Vector3>;
  18977. /**
  18978. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18979. */
  18980. isBillboardBased: boolean;
  18981. /**
  18982. * The rendering group used by the Particle system to chose when to render.
  18983. */
  18984. renderingGroupId: number;
  18985. /**
  18986. * The layer mask we are rendering the particles through.
  18987. */
  18988. layerMask: number;
  18989. /**
  18990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18991. */
  18992. updateSpeed: number;
  18993. /**
  18994. * The amount of time the particle system is running (depends of the overall update speed).
  18995. */
  18996. targetStopDuration: number;
  18997. /**
  18998. * The texture used to render each particle. (this can be a spritesheet)
  18999. */
  19000. particleTexture: Nullable<Texture>;
  19001. /**
  19002. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19003. */
  19004. blendMode: number;
  19005. /**
  19006. * Minimum life time of emitting particles.
  19007. */
  19008. minLifeTime: number;
  19009. /**
  19010. * Maximum life time of emitting particles.
  19011. */
  19012. maxLifeTime: number;
  19013. /**
  19014. * Minimum Size of emitting particles.
  19015. */
  19016. minSize: number;
  19017. /**
  19018. * Maximum Size of emitting particles.
  19019. */
  19020. maxSize: number;
  19021. /**
  19022. * Minimum scale of emitting particles on X axis.
  19023. */
  19024. minScaleX: number;
  19025. /**
  19026. * Maximum scale of emitting particles on X axis.
  19027. */
  19028. maxScaleX: number;
  19029. /**
  19030. * Minimum scale of emitting particles on Y axis.
  19031. */
  19032. minScaleY: number;
  19033. /**
  19034. * Maximum scale of emitting particles on Y axis.
  19035. */
  19036. maxScaleY: number;
  19037. /**
  19038. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19039. */
  19040. color1: Color4;
  19041. /**
  19042. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19043. */
  19044. color2: Color4;
  19045. /**
  19046. * Color the particle will have at the end of its lifetime.
  19047. */
  19048. colorDead: Color4;
  19049. /**
  19050. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19051. */
  19052. emitRate: number;
  19053. /**
  19054. * You can use gravity if you want to give an orientation to your particles.
  19055. */
  19056. gravity: Vector3;
  19057. /**
  19058. * Minimum power of emitting particles.
  19059. */
  19060. minEmitPower: number;
  19061. /**
  19062. * Maximum power of emitting particles.
  19063. */
  19064. maxEmitPower: number;
  19065. /**
  19066. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19067. */
  19068. minAngularSpeed: number;
  19069. /**
  19070. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19071. */
  19072. maxAngularSpeed: number;
  19073. /**
  19074. * Gets or sets the minimal initial rotation in radians.
  19075. */
  19076. minInitialRotation: number;
  19077. /**
  19078. * Gets or sets the maximal initial rotation in radians.
  19079. */
  19080. maxInitialRotation: number;
  19081. /**
  19082. * The particle emitter type defines the emitter used by the particle system.
  19083. * It can be for example box, sphere, or cone...
  19084. */
  19085. particleEmitterType: Nullable<IParticleEmitterType>;
  19086. /**
  19087. * Defines the delay in milliseconds before starting the system (0 by default)
  19088. */
  19089. startDelay: number;
  19090. /**
  19091. * 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
  19092. */
  19093. preWarmCycles: number;
  19094. /**
  19095. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19096. */
  19097. preWarmStepOffset: number;
  19098. /**
  19099. * 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)
  19100. */
  19101. spriteCellChangeSpeed: number;
  19102. /**
  19103. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19104. */
  19105. startSpriteCellID: number;
  19106. /**
  19107. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19108. */
  19109. endSpriteCellID: number;
  19110. /**
  19111. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19112. */
  19113. spriteCellWidth: number;
  19114. /**
  19115. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19116. */
  19117. spriteCellHeight: number;
  19118. /**
  19119. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19120. */
  19121. spriteRandomStartCell: boolean;
  19122. /**
  19123. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19124. */
  19125. isAnimationSheetEnabled: boolean;
  19126. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19127. translationPivot: Vector2;
  19128. /**
  19129. * Gets or sets a texture used to add random noise to particle positions
  19130. */
  19131. noiseTexture: Nullable<BaseTexture>;
  19132. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19133. noiseStrength: Vector3;
  19134. /**
  19135. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19136. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19137. */
  19138. billboardMode: number;
  19139. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19140. limitVelocityDamping: number;
  19141. /**
  19142. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19143. */
  19144. beginAnimationOnStart: boolean;
  19145. /**
  19146. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19147. */
  19148. beginAnimationFrom: number;
  19149. /**
  19150. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19151. */
  19152. beginAnimationTo: number;
  19153. /**
  19154. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19155. */
  19156. beginAnimationLoop: boolean;
  19157. /**
  19158. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19159. */
  19160. disposeOnStop: boolean;
  19161. /**
  19162. * Gets the maximum number of particles active at the same time.
  19163. * @returns The max number of active particles.
  19164. */
  19165. getCapacity(): number;
  19166. /**
  19167. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19168. * @returns True if it has been started, otherwise false.
  19169. */
  19170. isStarted(): boolean;
  19171. /**
  19172. * Animates the particle system for this frame.
  19173. */
  19174. animate(): void;
  19175. /**
  19176. * Renders the particle system in its current state.
  19177. * @returns the current number of particles
  19178. */
  19179. render(): number;
  19180. /**
  19181. * Dispose the particle system and frees its associated resources.
  19182. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19183. */
  19184. dispose(disposeTexture?: boolean): void;
  19185. /**
  19186. * Clones the particle system.
  19187. * @param name The name of the cloned object
  19188. * @param newEmitter The new emitter to use
  19189. * @returns the cloned particle system
  19190. */
  19191. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19192. /**
  19193. * Serializes the particle system to a JSON object.
  19194. * @returns the JSON object
  19195. */
  19196. serialize(): any;
  19197. /**
  19198. * Rebuild the particle system
  19199. */
  19200. rebuild(): void;
  19201. /**
  19202. * Starts the particle system and begins to emit
  19203. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19204. */
  19205. start(delay?: number): void;
  19206. /**
  19207. * Stops the particle system.
  19208. */
  19209. stop(): void;
  19210. /**
  19211. * Remove all active particles
  19212. */
  19213. reset(): void;
  19214. /**
  19215. * Is this system ready to be used/rendered
  19216. * @return true if the system is ready
  19217. */
  19218. isReady(): boolean;
  19219. /**
  19220. * Adds a new color gradient
  19221. * @param gradient defines the gradient to use (between 0 and 1)
  19222. * @param color1 defines the color to affect to the specified gradient
  19223. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19224. * @returns the current particle system
  19225. */
  19226. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19227. /**
  19228. * Remove a specific color gradient
  19229. * @param gradient defines the gradient to remove
  19230. * @returns the current particle system
  19231. */
  19232. removeColorGradient(gradient: number): IParticleSystem;
  19233. /**
  19234. * Adds a new size gradient
  19235. * @param gradient defines the gradient to use (between 0 and 1)
  19236. * @param factor defines the size factor to affect to the specified gradient
  19237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19238. * @returns the current particle system
  19239. */
  19240. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19241. /**
  19242. * Remove a specific size gradient
  19243. * @param gradient defines the gradient to remove
  19244. * @returns the current particle system
  19245. */
  19246. removeSizeGradient(gradient: number): IParticleSystem;
  19247. /**
  19248. * Gets the current list of color gradients.
  19249. * You must use addColorGradient and removeColorGradient to udpate this list
  19250. * @returns the list of color gradients
  19251. */
  19252. getColorGradients(): Nullable<Array<ColorGradient>>;
  19253. /**
  19254. * Gets the current list of size gradients.
  19255. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19256. * @returns the list of size gradients
  19257. */
  19258. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19259. /**
  19260. * Gets the current list of angular speed gradients.
  19261. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19262. * @returns the list of angular speed gradients
  19263. */
  19264. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19265. /**
  19266. * Adds a new angular speed gradient
  19267. * @param gradient defines the gradient to use (between 0 and 1)
  19268. * @param factor defines the angular speed to affect to the specified gradient
  19269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19270. * @returns the current particle system
  19271. */
  19272. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19273. /**
  19274. * Remove a specific angular speed gradient
  19275. * @param gradient defines the gradient to remove
  19276. * @returns the current particle system
  19277. */
  19278. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19279. /**
  19280. * Gets the current list of velocity gradients.
  19281. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19282. * @returns the list of velocity gradients
  19283. */
  19284. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19285. /**
  19286. * Adds a new velocity gradient
  19287. * @param gradient defines the gradient to use (between 0 and 1)
  19288. * @param factor defines the velocity to affect to the specified gradient
  19289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19290. * @returns the current particle system
  19291. */
  19292. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19293. /**
  19294. * Remove a specific velocity gradient
  19295. * @param gradient defines the gradient to remove
  19296. * @returns the current particle system
  19297. */
  19298. removeVelocityGradient(gradient: number): IParticleSystem;
  19299. /**
  19300. * Gets the current list of limit velocity gradients.
  19301. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19302. * @returns the list of limit velocity gradients
  19303. */
  19304. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19305. /**
  19306. * Adds a new limit velocity gradient
  19307. * @param gradient defines the gradient to use (between 0 and 1)
  19308. * @param factor defines the limit velocity to affect to the specified gradient
  19309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19310. * @returns the current particle system
  19311. */
  19312. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19313. /**
  19314. * Remove a specific limit velocity gradient
  19315. * @param gradient defines the gradient to remove
  19316. * @returns the current particle system
  19317. */
  19318. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19319. /**
  19320. * Adds a new drag gradient
  19321. * @param gradient defines the gradient to use (between 0 and 1)
  19322. * @param factor defines the drag to affect to the specified gradient
  19323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19324. * @returns the current particle system
  19325. */
  19326. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19327. /**
  19328. * Remove a specific drag gradient
  19329. * @param gradient defines the gradient to remove
  19330. * @returns the current particle system
  19331. */
  19332. removeDragGradient(gradient: number): IParticleSystem;
  19333. /**
  19334. * Gets the current list of drag gradients.
  19335. * You must use addDragGradient and removeDragGradient to udpate this list
  19336. * @returns the list of drag gradients
  19337. */
  19338. getDragGradients(): Nullable<Array<FactorGradient>>;
  19339. /**
  19340. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19341. * @param gradient defines the gradient to use (between 0 and 1)
  19342. * @param factor defines the emit rate to affect to the specified gradient
  19343. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19344. * @returns the current particle system
  19345. */
  19346. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19347. /**
  19348. * Remove a specific emit rate gradient
  19349. * @param gradient defines the gradient to remove
  19350. * @returns the current particle system
  19351. */
  19352. removeEmitRateGradient(gradient: number): IParticleSystem;
  19353. /**
  19354. * Gets the current list of emit rate gradients.
  19355. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19356. * @returns the list of emit rate gradients
  19357. */
  19358. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19359. /**
  19360. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19361. * @param gradient defines the gradient to use (between 0 and 1)
  19362. * @param factor defines the start size to affect to the specified gradient
  19363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19364. * @returns the current particle system
  19365. */
  19366. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19367. /**
  19368. * Remove a specific start size gradient
  19369. * @param gradient defines the gradient to remove
  19370. * @returns the current particle system
  19371. */
  19372. removeStartSizeGradient(gradient: number): IParticleSystem;
  19373. /**
  19374. * Gets the current list of start size gradients.
  19375. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19376. * @returns the list of start size gradients
  19377. */
  19378. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19379. /**
  19380. * Adds a new life time gradient
  19381. * @param gradient defines the gradient to use (between 0 and 1)
  19382. * @param factor defines the life time factor to affect to the specified gradient
  19383. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19384. * @returns the current particle system
  19385. */
  19386. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19387. /**
  19388. * Remove a specific life time gradient
  19389. * @param gradient defines the gradient to remove
  19390. * @returns the current particle system
  19391. */
  19392. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19393. /**
  19394. * Gets the current list of life time gradients.
  19395. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19396. * @returns the list of life time gradients
  19397. */
  19398. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19399. /**
  19400. * Gets the current list of color gradients.
  19401. * You must use addColorGradient and removeColorGradient to udpate this list
  19402. * @returns the list of color gradients
  19403. */
  19404. getColorGradients(): Nullable<Array<ColorGradient>>;
  19405. /**
  19406. * Adds a new ramp gradient used to remap particle colors
  19407. * @param gradient defines the gradient to use (between 0 and 1)
  19408. * @param color defines the color to affect to the specified gradient
  19409. * @returns the current particle system
  19410. */
  19411. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19412. /**
  19413. * Gets the current list of ramp gradients.
  19414. * You must use addRampGradient and removeRampGradient to udpate this list
  19415. * @returns the list of ramp gradients
  19416. */
  19417. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19418. /** Gets or sets a boolean indicating that ramp gradients must be used
  19419. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19420. */
  19421. useRampGradients: boolean;
  19422. /**
  19423. * Adds a new color remap gradient
  19424. * @param gradient defines the gradient to use (between 0 and 1)
  19425. * @param min defines the color remap minimal range
  19426. * @param max defines the color remap maximal range
  19427. * @returns the current particle system
  19428. */
  19429. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19430. /**
  19431. * Gets the current list of color remap gradients.
  19432. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19433. * @returns the list of color remap gradients
  19434. */
  19435. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19436. /**
  19437. * Adds a new alpha remap gradient
  19438. * @param gradient defines the gradient to use (between 0 and 1)
  19439. * @param min defines the alpha remap minimal range
  19440. * @param max defines the alpha remap maximal range
  19441. * @returns the current particle system
  19442. */
  19443. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19444. /**
  19445. * Gets the current list of alpha remap gradients.
  19446. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19447. * @returns the list of alpha remap gradients
  19448. */
  19449. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19450. /**
  19451. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19454. * @returns the emitter
  19455. */
  19456. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19457. /**
  19458. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19459. * @param radius The radius of the hemisphere to emit from
  19460. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19461. * @returns the emitter
  19462. */
  19463. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19464. /**
  19465. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19466. * @param radius The radius of the sphere to emit from
  19467. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19468. * @returns the emitter
  19469. */
  19470. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19471. /**
  19472. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19473. * @param radius The radius of the sphere to emit from
  19474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19476. * @returns the emitter
  19477. */
  19478. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19479. /**
  19480. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19481. * @param radius The radius of the emission cylinder
  19482. * @param height The height of the emission cylinder
  19483. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19484. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19485. * @returns the emitter
  19486. */
  19487. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19488. /**
  19489. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19490. * @param radius The radius of the cylinder to emit from
  19491. * @param height The height of the emission cylinder
  19492. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19493. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19494. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19495. * @returns the emitter
  19496. */
  19497. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19498. /**
  19499. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19500. * @param radius The radius of the cone to emit from
  19501. * @param angle The base angle of the cone
  19502. * @returns the emitter
  19503. */
  19504. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19505. /**
  19506. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19509. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19510. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19511. * @returns the emitter
  19512. */
  19513. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19514. /**
  19515. * Get hosting scene
  19516. * @returns the scene
  19517. */
  19518. getScene(): Scene;
  19519. }
  19520. }
  19521. declare module "babylonjs/Meshes/instancedMesh" {
  19522. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19523. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19524. import { Camera } from "babylonjs/Cameras/camera";
  19525. import { Node } from "babylonjs/node";
  19526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19527. import { Mesh } from "babylonjs/Meshes/mesh";
  19528. import { Material } from "babylonjs/Materials/material";
  19529. import { Skeleton } from "babylonjs/Bones/skeleton";
  19530. import { Light } from "babylonjs/Lights/light";
  19531. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19532. /**
  19533. * Creates an instance based on a source mesh.
  19534. */
  19535. export class InstancedMesh extends AbstractMesh {
  19536. private _sourceMesh;
  19537. private _currentLOD;
  19538. /** @hidden */
  19539. _indexInSourceMeshInstanceArray: number;
  19540. constructor(name: string, source: Mesh);
  19541. /**
  19542. * Returns the string "InstancedMesh".
  19543. */
  19544. getClassName(): string;
  19545. /** Gets the list of lights affecting that mesh */
  19546. readonly lightSources: Light[];
  19547. _resyncLightSources(): void;
  19548. _resyncLightSource(light: Light): void;
  19549. _removeLightSource(light: Light, dispose: boolean): void;
  19550. /**
  19551. * If the source mesh receives shadows
  19552. */
  19553. readonly receiveShadows: boolean;
  19554. /**
  19555. * The material of the source mesh
  19556. */
  19557. readonly material: Nullable<Material>;
  19558. /**
  19559. * Visibility of the source mesh
  19560. */
  19561. readonly visibility: number;
  19562. /**
  19563. * Skeleton of the source mesh
  19564. */
  19565. readonly skeleton: Nullable<Skeleton>;
  19566. /**
  19567. * Rendering ground id of the source mesh
  19568. */
  19569. renderingGroupId: number;
  19570. /**
  19571. * Returns the total number of vertices (integer).
  19572. */
  19573. getTotalVertices(): number;
  19574. /**
  19575. * Returns a positive integer : the total number of indices in this mesh geometry.
  19576. * @returns the numner of indices or zero if the mesh has no geometry.
  19577. */
  19578. getTotalIndices(): number;
  19579. /**
  19580. * The source mesh of the instance
  19581. */
  19582. readonly sourceMesh: Mesh;
  19583. /**
  19584. * Is this node ready to be used/rendered
  19585. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19586. * @return {boolean} is it ready
  19587. */
  19588. isReady(completeCheck?: boolean): boolean;
  19589. /**
  19590. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19591. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19592. * @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.
  19593. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19594. */
  19595. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19596. /**
  19597. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19598. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19599. * The `data` are either a numeric array either a Float32Array.
  19600. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19601. * 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).
  19602. * Note that a new underlying VertexBuffer object is created each call.
  19603. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19604. *
  19605. * Possible `kind` values :
  19606. * - VertexBuffer.PositionKind
  19607. * - VertexBuffer.UVKind
  19608. * - VertexBuffer.UV2Kind
  19609. * - VertexBuffer.UV3Kind
  19610. * - VertexBuffer.UV4Kind
  19611. * - VertexBuffer.UV5Kind
  19612. * - VertexBuffer.UV6Kind
  19613. * - VertexBuffer.ColorKind
  19614. * - VertexBuffer.MatricesIndicesKind
  19615. * - VertexBuffer.MatricesIndicesExtraKind
  19616. * - VertexBuffer.MatricesWeightsKind
  19617. * - VertexBuffer.MatricesWeightsExtraKind
  19618. *
  19619. * Returns the Mesh.
  19620. */
  19621. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19622. /**
  19623. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19624. * If the mesh has no geometry, it is simply returned as it is.
  19625. * The `data` are either a numeric array either a Float32Array.
  19626. * No new underlying VertexBuffer object is created.
  19627. * 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.
  19628. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19629. *
  19630. * Possible `kind` values :
  19631. * - VertexBuffer.PositionKind
  19632. * - VertexBuffer.UVKind
  19633. * - VertexBuffer.UV2Kind
  19634. * - VertexBuffer.UV3Kind
  19635. * - VertexBuffer.UV4Kind
  19636. * - VertexBuffer.UV5Kind
  19637. * - VertexBuffer.UV6Kind
  19638. * - VertexBuffer.ColorKind
  19639. * - VertexBuffer.MatricesIndicesKind
  19640. * - VertexBuffer.MatricesIndicesExtraKind
  19641. * - VertexBuffer.MatricesWeightsKind
  19642. * - VertexBuffer.MatricesWeightsExtraKind
  19643. *
  19644. * Returns the Mesh.
  19645. */
  19646. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19647. /**
  19648. * Sets the mesh indices.
  19649. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19650. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19651. * This method creates a new index buffer each call.
  19652. * Returns the Mesh.
  19653. */
  19654. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19655. /**
  19656. * Boolean : True if the mesh owns the requested kind of data.
  19657. */
  19658. isVerticesDataPresent(kind: string): boolean;
  19659. /**
  19660. * Returns an array of indices (IndicesArray).
  19661. */
  19662. getIndices(): Nullable<IndicesArray>;
  19663. readonly _positions: Nullable<Vector3[]>;
  19664. /**
  19665. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19666. * This means the mesh underlying bounding box and sphere are recomputed.
  19667. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19668. * @returns the current mesh
  19669. */
  19670. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19671. /** @hidden */
  19672. _preActivate(): InstancedMesh;
  19673. /** @hidden */
  19674. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19675. /** @hidden */
  19676. _postActivate(): void;
  19677. getWorldMatrix(): Matrix;
  19678. readonly isAnInstance: boolean;
  19679. /**
  19680. * Returns the current associated LOD AbstractMesh.
  19681. */
  19682. getLOD(camera: Camera): AbstractMesh;
  19683. /** @hidden */
  19684. _syncSubMeshes(): InstancedMesh;
  19685. /** @hidden */
  19686. _generatePointsArray(): boolean;
  19687. /**
  19688. * Creates a new InstancedMesh from the current mesh.
  19689. * - name (string) : the cloned mesh name
  19690. * - newParent (optional Node) : the optional Node to parent the clone to.
  19691. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19692. *
  19693. * Returns the clone.
  19694. */
  19695. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19696. /**
  19697. * Disposes the InstancedMesh.
  19698. * Returns nothing.
  19699. */
  19700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19701. }
  19702. module "babylonjs/Meshes/mesh" {
  19703. interface Mesh {
  19704. /**
  19705. * Register a custom buffer that will be instanced
  19706. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19707. * @param kind defines the buffer kind
  19708. * @param stride defines the stride in floats
  19709. */
  19710. registerInstancedBuffer(kind: string, stride: number): void;
  19711. /** @hidden */
  19712. _userInstancedBuffersStorage: {
  19713. data: {
  19714. [key: string]: Float32Array;
  19715. };
  19716. sizes: {
  19717. [key: string]: number;
  19718. };
  19719. vertexBuffers: {
  19720. [key: string]: Nullable<VertexBuffer>;
  19721. };
  19722. strides: {
  19723. [key: string]: number;
  19724. };
  19725. };
  19726. }
  19727. }
  19728. module "babylonjs/Meshes/abstractMesh" {
  19729. interface AbstractMesh {
  19730. /**
  19731. * Object used to store instanced buffers defined by user
  19732. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19733. */
  19734. instancedBuffers: {
  19735. [key: string]: any;
  19736. };
  19737. }
  19738. }
  19739. }
  19740. declare module "babylonjs/Materials/shaderMaterial" {
  19741. import { Scene } from "babylonjs/scene";
  19742. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19744. import { Mesh } from "babylonjs/Meshes/mesh";
  19745. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19747. import { Texture } from "babylonjs/Materials/Textures/texture";
  19748. import { Material } from "babylonjs/Materials/material";
  19749. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19750. /**
  19751. * Defines the options associated with the creation of a shader material.
  19752. */
  19753. export interface IShaderMaterialOptions {
  19754. /**
  19755. * Does the material work in alpha blend mode
  19756. */
  19757. needAlphaBlending: boolean;
  19758. /**
  19759. * Does the material work in alpha test mode
  19760. */
  19761. needAlphaTesting: boolean;
  19762. /**
  19763. * The list of attribute names used in the shader
  19764. */
  19765. attributes: string[];
  19766. /**
  19767. * The list of unifrom names used in the shader
  19768. */
  19769. uniforms: string[];
  19770. /**
  19771. * The list of UBO names used in the shader
  19772. */
  19773. uniformBuffers: string[];
  19774. /**
  19775. * The list of sampler names used in the shader
  19776. */
  19777. samplers: string[];
  19778. /**
  19779. * The list of defines used in the shader
  19780. */
  19781. defines: string[];
  19782. }
  19783. /**
  19784. * 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.
  19785. *
  19786. * This returned material effects how the mesh will look based on the code in the shaders.
  19787. *
  19788. * @see http://doc.babylonjs.com/how_to/shader_material
  19789. */
  19790. export class ShaderMaterial extends Material {
  19791. private _shaderPath;
  19792. private _options;
  19793. private _textures;
  19794. private _textureArrays;
  19795. private _floats;
  19796. private _ints;
  19797. private _floatsArrays;
  19798. private _colors3;
  19799. private _colors3Arrays;
  19800. private _colors4;
  19801. private _colors4Arrays;
  19802. private _vectors2;
  19803. private _vectors3;
  19804. private _vectors4;
  19805. private _matrices;
  19806. private _matrixArrays;
  19807. private _matrices3x3;
  19808. private _matrices2x2;
  19809. private _vectors2Arrays;
  19810. private _vectors3Arrays;
  19811. private _vectors4Arrays;
  19812. private _cachedWorldViewMatrix;
  19813. private _cachedWorldViewProjectionMatrix;
  19814. private _renderId;
  19815. private _multiview;
  19816. /**
  19817. * Instantiate a new shader material.
  19818. * 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.
  19819. * This returned material effects how the mesh will look based on the code in the shaders.
  19820. * @see http://doc.babylonjs.com/how_to/shader_material
  19821. * @param name Define the name of the material in the scene
  19822. * @param scene Define the scene the material belongs to
  19823. * @param shaderPath Defines the route to the shader code in one of three ways:
  19824. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19825. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19826. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19827. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19828. * @param options Define the options used to create the shader
  19829. */
  19830. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19831. /**
  19832. * Gets the shader path used to define the shader code
  19833. * It can be modified to trigger a new compilation
  19834. */
  19835. /**
  19836. * Sets the shader path used to define the shader code
  19837. * It can be modified to trigger a new compilation
  19838. */
  19839. shaderPath: any;
  19840. /**
  19841. * Gets the options used to compile the shader.
  19842. * They can be modified to trigger a new compilation
  19843. */
  19844. readonly options: IShaderMaterialOptions;
  19845. /**
  19846. * Gets the current class name of the material e.g. "ShaderMaterial"
  19847. * Mainly use in serialization.
  19848. * @returns the class name
  19849. */
  19850. getClassName(): string;
  19851. /**
  19852. * Specifies if the material will require alpha blending
  19853. * @returns a boolean specifying if alpha blending is needed
  19854. */
  19855. needAlphaBlending(): boolean;
  19856. /**
  19857. * Specifies if this material should be rendered in alpha test mode
  19858. * @returns a boolean specifying if an alpha test is needed.
  19859. */
  19860. needAlphaTesting(): boolean;
  19861. private _checkUniform;
  19862. /**
  19863. * Set a texture in the shader.
  19864. * @param name Define the name of the uniform samplers as defined in the shader
  19865. * @param texture Define the texture to bind to this sampler
  19866. * @return the material itself allowing "fluent" like uniform updates
  19867. */
  19868. setTexture(name: string, texture: Texture): ShaderMaterial;
  19869. /**
  19870. * Set a texture array in the shader.
  19871. * @param name Define the name of the uniform sampler array as defined in the shader
  19872. * @param textures Define the list of textures to bind to this sampler
  19873. * @return the material itself allowing "fluent" like uniform updates
  19874. */
  19875. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19876. /**
  19877. * Set a float in the shader.
  19878. * @param name Define the name of the uniform as defined in the shader
  19879. * @param value Define the value to give to the uniform
  19880. * @return the material itself allowing "fluent" like uniform updates
  19881. */
  19882. setFloat(name: string, value: number): ShaderMaterial;
  19883. /**
  19884. * Set a int in the shader.
  19885. * @param name Define the name of the uniform as defined in the shader
  19886. * @param value Define the value to give to the uniform
  19887. * @return the material itself allowing "fluent" like uniform updates
  19888. */
  19889. setInt(name: string, value: number): ShaderMaterial;
  19890. /**
  19891. * Set an array of floats in the shader.
  19892. * @param name Define the name of the uniform as defined in the shader
  19893. * @param value Define the value to give to the uniform
  19894. * @return the material itself allowing "fluent" like uniform updates
  19895. */
  19896. setFloats(name: string, value: number[]): ShaderMaterial;
  19897. /**
  19898. * Set a vec3 in the shader from a Color3.
  19899. * @param name Define the name of the uniform as defined in the shader
  19900. * @param value Define the value to give to the uniform
  19901. * @return the material itself allowing "fluent" like uniform updates
  19902. */
  19903. setColor3(name: string, value: Color3): ShaderMaterial;
  19904. /**
  19905. * Set a vec3 array in the shader from a Color3 array.
  19906. * @param name Define the name of the uniform as defined in the shader
  19907. * @param value Define the value to give to the uniform
  19908. * @return the material itself allowing "fluent" like uniform updates
  19909. */
  19910. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19911. /**
  19912. * Set a vec4 in the shader from a Color4.
  19913. * @param name Define the name of the uniform as defined in the shader
  19914. * @param value Define the value to give to the uniform
  19915. * @return the material itself allowing "fluent" like uniform updates
  19916. */
  19917. setColor4(name: string, value: Color4): ShaderMaterial;
  19918. /**
  19919. * Set a vec4 array in the shader from a Color4 array.
  19920. * @param name Define the name of the uniform as defined in the shader
  19921. * @param value Define the value to give to the uniform
  19922. * @return the material itself allowing "fluent" like uniform updates
  19923. */
  19924. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19925. /**
  19926. * Set a vec2 in the shader from a Vector2.
  19927. * @param name Define the name of the uniform as defined in the shader
  19928. * @param value Define the value to give to the uniform
  19929. * @return the material itself allowing "fluent" like uniform updates
  19930. */
  19931. setVector2(name: string, value: Vector2): ShaderMaterial;
  19932. /**
  19933. * Set a vec3 in the shader from a Vector3.
  19934. * @param name Define the name of the uniform as defined in the shader
  19935. * @param value Define the value to give to the uniform
  19936. * @return the material itself allowing "fluent" like uniform updates
  19937. */
  19938. setVector3(name: string, value: Vector3): ShaderMaterial;
  19939. /**
  19940. * Set a vec4 in the shader from a Vector4.
  19941. * @param name Define the name of the uniform as defined in the shader
  19942. * @param value Define the value to give to the uniform
  19943. * @return the material itself allowing "fluent" like uniform updates
  19944. */
  19945. setVector4(name: string, value: Vector4): ShaderMaterial;
  19946. /**
  19947. * Set a mat4 in the shader from a Matrix.
  19948. * @param name Define the name of the uniform as defined in the shader
  19949. * @param value Define the value to give to the uniform
  19950. * @return the material itself allowing "fluent" like uniform updates
  19951. */
  19952. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19953. /**
  19954. * Set a float32Array in the shader from a matrix array.
  19955. * @param name Define the name of the uniform as defined in the shader
  19956. * @param value Define the value to give to the uniform
  19957. * @return the material itself allowing "fluent" like uniform updates
  19958. */
  19959. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19960. /**
  19961. * Set a mat3 in the shader from a Float32Array.
  19962. * @param name Define the name of the uniform as defined in the shader
  19963. * @param value Define the value to give to the uniform
  19964. * @return the material itself allowing "fluent" like uniform updates
  19965. */
  19966. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19967. /**
  19968. * Set a mat2 in the shader from a Float32Array.
  19969. * @param name Define the name of the uniform as defined in the shader
  19970. * @param value Define the value to give to the uniform
  19971. * @return the material itself allowing "fluent" like uniform updates
  19972. */
  19973. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19974. /**
  19975. * Set a vec2 array in the shader from a number array.
  19976. * @param name Define the name of the uniform as defined in the shader
  19977. * @param value Define the value to give to the uniform
  19978. * @return the material itself allowing "fluent" like uniform updates
  19979. */
  19980. setArray2(name: string, value: number[]): ShaderMaterial;
  19981. /**
  19982. * Set a vec3 array in the shader from a number array.
  19983. * @param name Define the name of the uniform as defined in the shader
  19984. * @param value Define the value to give to the uniform
  19985. * @return the material itself allowing "fluent" like uniform updates
  19986. */
  19987. setArray3(name: string, value: number[]): ShaderMaterial;
  19988. /**
  19989. * Set a vec4 array in the shader from a number array.
  19990. * @param name Define the name of the uniform as defined in the shader
  19991. * @param value Define the value to give to the uniform
  19992. * @return the material itself allowing "fluent" like uniform updates
  19993. */
  19994. setArray4(name: string, value: number[]): ShaderMaterial;
  19995. private _checkCache;
  19996. /**
  19997. * Specifies that the submesh is ready to be used
  19998. * @param mesh defines the mesh to check
  19999. * @param subMesh defines which submesh to check
  20000. * @param useInstances specifies that instances should be used
  20001. * @returns a boolean indicating that the submesh is ready or not
  20002. */
  20003. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20004. /**
  20005. * Checks if the material is ready to render the requested mesh
  20006. * @param mesh Define the mesh to render
  20007. * @param useInstances Define whether or not the material is used with instances
  20008. * @returns true if ready, otherwise false
  20009. */
  20010. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20011. /**
  20012. * Binds the world matrix to the material
  20013. * @param world defines the world transformation matrix
  20014. */
  20015. bindOnlyWorldMatrix(world: Matrix): void;
  20016. /**
  20017. * Binds the material to the mesh
  20018. * @param world defines the world transformation matrix
  20019. * @param mesh defines the mesh to bind the material to
  20020. */
  20021. bind(world: Matrix, mesh?: Mesh): void;
  20022. /**
  20023. * Gets the active textures from the material
  20024. * @returns an array of textures
  20025. */
  20026. getActiveTextures(): BaseTexture[];
  20027. /**
  20028. * Specifies if the material uses a texture
  20029. * @param texture defines the texture to check against the material
  20030. * @returns a boolean specifying if the material uses the texture
  20031. */
  20032. hasTexture(texture: BaseTexture): boolean;
  20033. /**
  20034. * Makes a duplicate of the material, and gives it a new name
  20035. * @param name defines the new name for the duplicated material
  20036. * @returns the cloned material
  20037. */
  20038. clone(name: string): ShaderMaterial;
  20039. /**
  20040. * Disposes the material
  20041. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20042. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20043. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20044. */
  20045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20046. /**
  20047. * Serializes this material in a JSON representation
  20048. * @returns the serialized material object
  20049. */
  20050. serialize(): any;
  20051. /**
  20052. * Creates a shader material from parsed shader material data
  20053. * @param source defines the JSON represnetation of the material
  20054. * @param scene defines the hosting scene
  20055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20056. * @returns a new material
  20057. */
  20058. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20059. }
  20060. }
  20061. declare module "babylonjs/Shaders/color.fragment" {
  20062. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20064. /** @hidden */
  20065. export var colorPixelShader: {
  20066. name: string;
  20067. shader: string;
  20068. };
  20069. }
  20070. declare module "babylonjs/Shaders/color.vertex" {
  20071. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20072. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20073. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20074. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20075. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20076. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20077. /** @hidden */
  20078. export var colorVertexShader: {
  20079. name: string;
  20080. shader: string;
  20081. };
  20082. }
  20083. declare module "babylonjs/Meshes/linesMesh" {
  20084. import { Nullable } from "babylonjs/types";
  20085. import { Scene } from "babylonjs/scene";
  20086. import { Color3 } from "babylonjs/Maths/math.color";
  20087. import { Node } from "babylonjs/node";
  20088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20089. import { Mesh } from "babylonjs/Meshes/mesh";
  20090. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20091. import { Effect } from "babylonjs/Materials/effect";
  20092. import { Material } from "babylonjs/Materials/material";
  20093. import "babylonjs/Shaders/color.fragment";
  20094. import "babylonjs/Shaders/color.vertex";
  20095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20096. /**
  20097. * Line mesh
  20098. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20099. */
  20100. export class LinesMesh extends Mesh {
  20101. /**
  20102. * If vertex color should be applied to the mesh
  20103. */
  20104. readonly useVertexColor?: boolean | undefined;
  20105. /**
  20106. * If vertex alpha should be applied to the mesh
  20107. */
  20108. readonly useVertexAlpha?: boolean | undefined;
  20109. /**
  20110. * Color of the line (Default: White)
  20111. */
  20112. color: Color3;
  20113. /**
  20114. * Alpha of the line (Default: 1)
  20115. */
  20116. alpha: number;
  20117. /**
  20118. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20119. * This margin is expressed in world space coordinates, so its value may vary.
  20120. * Default value is 0.1
  20121. */
  20122. intersectionThreshold: number;
  20123. private _colorShader;
  20124. private color4;
  20125. /**
  20126. * Creates a new LinesMesh
  20127. * @param name defines the name
  20128. * @param scene defines the hosting scene
  20129. * @param parent defines the parent mesh if any
  20130. * @param source defines the optional source LinesMesh used to clone data from
  20131. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20132. * When false, achieved by calling a clone(), also passing False.
  20133. * This will make creation of children, recursive.
  20134. * @param useVertexColor defines if this LinesMesh supports vertex color
  20135. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20136. */
  20137. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20138. /**
  20139. * If vertex color should be applied to the mesh
  20140. */
  20141. useVertexColor?: boolean | undefined,
  20142. /**
  20143. * If vertex alpha should be applied to the mesh
  20144. */
  20145. useVertexAlpha?: boolean | undefined);
  20146. private _addClipPlaneDefine;
  20147. private _removeClipPlaneDefine;
  20148. isReady(): boolean;
  20149. /**
  20150. * Returns the string "LineMesh"
  20151. */
  20152. getClassName(): string;
  20153. /**
  20154. * @hidden
  20155. */
  20156. /**
  20157. * @hidden
  20158. */
  20159. material: Material;
  20160. /**
  20161. * @hidden
  20162. */
  20163. readonly checkCollisions: boolean;
  20164. /** @hidden */
  20165. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20166. /** @hidden */
  20167. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20168. /**
  20169. * Disposes of the line mesh
  20170. * @param doNotRecurse If children should be disposed
  20171. */
  20172. dispose(doNotRecurse?: boolean): void;
  20173. /**
  20174. * Returns a new LineMesh object cloned from the current one.
  20175. */
  20176. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20177. /**
  20178. * Creates a new InstancedLinesMesh object from the mesh model.
  20179. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20180. * @param name defines the name of the new instance
  20181. * @returns a new InstancedLinesMesh
  20182. */
  20183. createInstance(name: string): InstancedLinesMesh;
  20184. }
  20185. /**
  20186. * Creates an instance based on a source LinesMesh
  20187. */
  20188. export class InstancedLinesMesh extends InstancedMesh {
  20189. /**
  20190. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20191. * This margin is expressed in world space coordinates, so its value may vary.
  20192. * Initilized with the intersectionThreshold value of the source LinesMesh
  20193. */
  20194. intersectionThreshold: number;
  20195. constructor(name: string, source: LinesMesh);
  20196. /**
  20197. * Returns the string "InstancedLinesMesh".
  20198. */
  20199. getClassName(): string;
  20200. }
  20201. }
  20202. declare module "babylonjs/Shaders/line.fragment" {
  20203. /** @hidden */
  20204. export var linePixelShader: {
  20205. name: string;
  20206. shader: string;
  20207. };
  20208. }
  20209. declare module "babylonjs/Shaders/line.vertex" {
  20210. /** @hidden */
  20211. export var lineVertexShader: {
  20212. name: string;
  20213. shader: string;
  20214. };
  20215. }
  20216. declare module "babylonjs/Rendering/edgesRenderer" {
  20217. import { Nullable } from "babylonjs/types";
  20218. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20220. import { Vector3 } from "babylonjs/Maths/math.vector";
  20221. import { IDisposable } from "babylonjs/scene";
  20222. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20223. import "babylonjs/Shaders/line.fragment";
  20224. import "babylonjs/Shaders/line.vertex";
  20225. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20226. module "babylonjs/Meshes/abstractMesh" {
  20227. interface AbstractMesh {
  20228. /**
  20229. * Gets the edgesRenderer associated with the mesh
  20230. */
  20231. edgesRenderer: Nullable<EdgesRenderer>;
  20232. }
  20233. }
  20234. module "babylonjs/Meshes/linesMesh" {
  20235. interface LinesMesh {
  20236. /**
  20237. * Enables the edge rendering mode on the mesh.
  20238. * This mode makes the mesh edges visible
  20239. * @param epsilon defines the maximal distance between two angles to detect a face
  20240. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20241. * @returns the currentAbstractMesh
  20242. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20243. */
  20244. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20245. }
  20246. }
  20247. module "babylonjs/Meshes/linesMesh" {
  20248. interface InstancedLinesMesh {
  20249. /**
  20250. * Enables the edge rendering mode on the mesh.
  20251. * This mode makes the mesh edges visible
  20252. * @param epsilon defines the maximal distance between two angles to detect a face
  20253. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20254. * @returns the current InstancedLinesMesh
  20255. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20256. */
  20257. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20258. }
  20259. }
  20260. /**
  20261. * Defines the minimum contract an Edges renderer should follow.
  20262. */
  20263. export interface IEdgesRenderer extends IDisposable {
  20264. /**
  20265. * Gets or sets a boolean indicating if the edgesRenderer is active
  20266. */
  20267. isEnabled: boolean;
  20268. /**
  20269. * Renders the edges of the attached mesh,
  20270. */
  20271. render(): void;
  20272. /**
  20273. * Checks wether or not the edges renderer is ready to render.
  20274. * @return true if ready, otherwise false.
  20275. */
  20276. isReady(): boolean;
  20277. }
  20278. /**
  20279. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20280. */
  20281. export class EdgesRenderer implements IEdgesRenderer {
  20282. /**
  20283. * Define the size of the edges with an orthographic camera
  20284. */
  20285. edgesWidthScalerForOrthographic: number;
  20286. /**
  20287. * Define the size of the edges with a perspective camera
  20288. */
  20289. edgesWidthScalerForPerspective: number;
  20290. protected _source: AbstractMesh;
  20291. protected _linesPositions: number[];
  20292. protected _linesNormals: number[];
  20293. protected _linesIndices: number[];
  20294. protected _epsilon: number;
  20295. protected _indicesCount: number;
  20296. protected _lineShader: ShaderMaterial;
  20297. protected _ib: DataBuffer;
  20298. protected _buffers: {
  20299. [key: string]: Nullable<VertexBuffer>;
  20300. };
  20301. protected _checkVerticesInsteadOfIndices: boolean;
  20302. private _meshRebuildObserver;
  20303. private _meshDisposeObserver;
  20304. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20305. isEnabled: boolean;
  20306. /**
  20307. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20308. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20309. * @param source Mesh used to create edges
  20310. * @param epsilon sum of angles in adjacency to check for edge
  20311. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20312. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20313. */
  20314. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20315. protected _prepareRessources(): void;
  20316. /** @hidden */
  20317. _rebuild(): void;
  20318. /**
  20319. * Releases the required resources for the edges renderer
  20320. */
  20321. dispose(): void;
  20322. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20323. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20324. /**
  20325. * Checks if the pair of p0 and p1 is en edge
  20326. * @param faceIndex
  20327. * @param edge
  20328. * @param faceNormals
  20329. * @param p0
  20330. * @param p1
  20331. * @private
  20332. */
  20333. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20334. /**
  20335. * push line into the position, normal and index buffer
  20336. * @protected
  20337. */
  20338. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20339. /**
  20340. * Generates lines edges from adjacencjes
  20341. * @private
  20342. */
  20343. _generateEdgesLines(): void;
  20344. /**
  20345. * Checks wether or not the edges renderer is ready to render.
  20346. * @return true if ready, otherwise false.
  20347. */
  20348. isReady(): boolean;
  20349. /**
  20350. * Renders the edges of the attached mesh,
  20351. */
  20352. render(): void;
  20353. }
  20354. /**
  20355. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20356. */
  20357. export class LineEdgesRenderer extends EdgesRenderer {
  20358. /**
  20359. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20360. * @param source LineMesh used to generate edges
  20361. * @param epsilon not important (specified angle for edge detection)
  20362. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20363. */
  20364. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20365. /**
  20366. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20367. */
  20368. _generateEdgesLines(): void;
  20369. }
  20370. }
  20371. declare module "babylonjs/Rendering/renderingGroup" {
  20372. import { SmartArray } from "babylonjs/Misc/smartArray";
  20373. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20375. import { Nullable } from "babylonjs/types";
  20376. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20377. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20379. import { Material } from "babylonjs/Materials/material";
  20380. import { Scene } from "babylonjs/scene";
  20381. /**
  20382. * This represents the object necessary to create a rendering group.
  20383. * This is exclusively used and created by the rendering manager.
  20384. * To modify the behavior, you use the available helpers in your scene or meshes.
  20385. * @hidden
  20386. */
  20387. export class RenderingGroup {
  20388. index: number;
  20389. private static _zeroVector;
  20390. private _scene;
  20391. private _opaqueSubMeshes;
  20392. private _transparentSubMeshes;
  20393. private _alphaTestSubMeshes;
  20394. private _depthOnlySubMeshes;
  20395. private _particleSystems;
  20396. private _spriteManagers;
  20397. private _opaqueSortCompareFn;
  20398. private _alphaTestSortCompareFn;
  20399. private _transparentSortCompareFn;
  20400. private _renderOpaque;
  20401. private _renderAlphaTest;
  20402. private _renderTransparent;
  20403. /** @hidden */
  20404. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20405. onBeforeTransparentRendering: () => void;
  20406. /**
  20407. * Set the opaque sort comparison function.
  20408. * If null the sub meshes will be render in the order they were created
  20409. */
  20410. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20411. /**
  20412. * Set the alpha test sort comparison function.
  20413. * If null the sub meshes will be render in the order they were created
  20414. */
  20415. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20416. /**
  20417. * Set the transparent sort comparison function.
  20418. * If null the sub meshes will be render in the order they were created
  20419. */
  20420. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20421. /**
  20422. * Creates a new rendering group.
  20423. * @param index The rendering group index
  20424. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20425. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20426. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20427. */
  20428. 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>);
  20429. /**
  20430. * Render all the sub meshes contained in the group.
  20431. * @param customRenderFunction Used to override the default render behaviour of the group.
  20432. * @returns true if rendered some submeshes.
  20433. */
  20434. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20435. /**
  20436. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20437. * @param subMeshes The submeshes to render
  20438. */
  20439. private renderOpaqueSorted;
  20440. /**
  20441. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20442. * @param subMeshes The submeshes to render
  20443. */
  20444. private renderAlphaTestSorted;
  20445. /**
  20446. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20447. * @param subMeshes The submeshes to render
  20448. */
  20449. private renderTransparentSorted;
  20450. /**
  20451. * Renders the submeshes in a specified order.
  20452. * @param subMeshes The submeshes to sort before render
  20453. * @param sortCompareFn The comparison function use to sort
  20454. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20455. * @param transparent Specifies to activate blending if true
  20456. */
  20457. private static renderSorted;
  20458. /**
  20459. * Renders the submeshes in the order they were dispatched (no sort applied).
  20460. * @param subMeshes The submeshes to render
  20461. */
  20462. private static renderUnsorted;
  20463. /**
  20464. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20465. * are rendered back to front if in the same alpha index.
  20466. *
  20467. * @param a The first submesh
  20468. * @param b The second submesh
  20469. * @returns The result of the comparison
  20470. */
  20471. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20472. /**
  20473. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20474. * are rendered back to front.
  20475. *
  20476. * @param a The first submesh
  20477. * @param b The second submesh
  20478. * @returns The result of the comparison
  20479. */
  20480. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20481. /**
  20482. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20483. * are rendered front to back (prevent overdraw).
  20484. *
  20485. * @param a The first submesh
  20486. * @param b The second submesh
  20487. * @returns The result of the comparison
  20488. */
  20489. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20490. /**
  20491. * Resets the different lists of submeshes to prepare a new frame.
  20492. */
  20493. prepare(): void;
  20494. dispose(): void;
  20495. /**
  20496. * Inserts the submesh in its correct queue depending on its material.
  20497. * @param subMesh The submesh to dispatch
  20498. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20499. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20500. */
  20501. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20502. dispatchSprites(spriteManager: ISpriteManager): void;
  20503. dispatchParticles(particleSystem: IParticleSystem): void;
  20504. private _renderParticles;
  20505. private _renderSprites;
  20506. }
  20507. }
  20508. declare module "babylonjs/Rendering/renderingManager" {
  20509. import { Nullable } from "babylonjs/types";
  20510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20511. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20512. import { SmartArray } from "babylonjs/Misc/smartArray";
  20513. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20514. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20515. import { Material } from "babylonjs/Materials/material";
  20516. import { Scene } from "babylonjs/scene";
  20517. import { Camera } from "babylonjs/Cameras/camera";
  20518. /**
  20519. * Interface describing the different options available in the rendering manager
  20520. * regarding Auto Clear between groups.
  20521. */
  20522. export interface IRenderingManagerAutoClearSetup {
  20523. /**
  20524. * Defines whether or not autoclear is enable.
  20525. */
  20526. autoClear: boolean;
  20527. /**
  20528. * Defines whether or not to autoclear the depth buffer.
  20529. */
  20530. depth: boolean;
  20531. /**
  20532. * Defines whether or not to autoclear the stencil buffer.
  20533. */
  20534. stencil: boolean;
  20535. }
  20536. /**
  20537. * This class is used by the onRenderingGroupObservable
  20538. */
  20539. export class RenderingGroupInfo {
  20540. /**
  20541. * The Scene that being rendered
  20542. */
  20543. scene: Scene;
  20544. /**
  20545. * The camera currently used for the rendering pass
  20546. */
  20547. camera: Nullable<Camera>;
  20548. /**
  20549. * The ID of the renderingGroup being processed
  20550. */
  20551. renderingGroupId: number;
  20552. }
  20553. /**
  20554. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20555. * It is enable to manage the different groups as well as the different necessary sort functions.
  20556. * This should not be used directly aside of the few static configurations
  20557. */
  20558. export class RenderingManager {
  20559. /**
  20560. * The max id used for rendering groups (not included)
  20561. */
  20562. static MAX_RENDERINGGROUPS: number;
  20563. /**
  20564. * The min id used for rendering groups (included)
  20565. */
  20566. static MIN_RENDERINGGROUPS: number;
  20567. /**
  20568. * Used to globally prevent autoclearing scenes.
  20569. */
  20570. static AUTOCLEAR: boolean;
  20571. /**
  20572. * @hidden
  20573. */
  20574. _useSceneAutoClearSetup: boolean;
  20575. private _scene;
  20576. private _renderingGroups;
  20577. private _depthStencilBufferAlreadyCleaned;
  20578. private _autoClearDepthStencil;
  20579. private _customOpaqueSortCompareFn;
  20580. private _customAlphaTestSortCompareFn;
  20581. private _customTransparentSortCompareFn;
  20582. private _renderingGroupInfo;
  20583. /**
  20584. * Instantiates a new rendering group for a particular scene
  20585. * @param scene Defines the scene the groups belongs to
  20586. */
  20587. constructor(scene: Scene);
  20588. private _clearDepthStencilBuffer;
  20589. /**
  20590. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20591. * @hidden
  20592. */
  20593. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20594. /**
  20595. * Resets the different information of the group to prepare a new frame
  20596. * @hidden
  20597. */
  20598. reset(): void;
  20599. /**
  20600. * Dispose and release the group and its associated resources.
  20601. * @hidden
  20602. */
  20603. dispose(): void;
  20604. /**
  20605. * Clear the info related to rendering groups preventing retention points during dispose.
  20606. */
  20607. freeRenderingGroups(): void;
  20608. private _prepareRenderingGroup;
  20609. /**
  20610. * Add a sprite manager to the rendering manager in order to render it this frame.
  20611. * @param spriteManager Define the sprite manager to render
  20612. */
  20613. dispatchSprites(spriteManager: ISpriteManager): void;
  20614. /**
  20615. * Add a particle system to the rendering manager in order to render it this frame.
  20616. * @param particleSystem Define the particle system to render
  20617. */
  20618. dispatchParticles(particleSystem: IParticleSystem): void;
  20619. /**
  20620. * Add a submesh to the manager in order to render it this frame
  20621. * @param subMesh The submesh to dispatch
  20622. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20623. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20624. */
  20625. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20626. /**
  20627. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20628. * This allowed control for front to back rendering or reversly depending of the special needs.
  20629. *
  20630. * @param renderingGroupId The rendering group id corresponding to its index
  20631. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20632. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20633. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20634. */
  20635. 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;
  20636. /**
  20637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20638. *
  20639. * @param renderingGroupId The rendering group id corresponding to its index
  20640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20641. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20642. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20643. */
  20644. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20645. /**
  20646. * Gets the current auto clear configuration for one rendering group of the rendering
  20647. * manager.
  20648. * @param index the rendering group index to get the information for
  20649. * @returns The auto clear setup for the requested rendering group
  20650. */
  20651. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20652. }
  20653. }
  20654. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20655. import { Observable } from "babylonjs/Misc/observable";
  20656. import { SmartArray } from "babylonjs/Misc/smartArray";
  20657. import { Nullable } from "babylonjs/types";
  20658. import { Camera } from "babylonjs/Cameras/camera";
  20659. import { Scene } from "babylonjs/scene";
  20660. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20661. import { Color4 } from "babylonjs/Maths/math.color";
  20662. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20664. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20665. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20666. import { Texture } from "babylonjs/Materials/Textures/texture";
  20667. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20668. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20669. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20670. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20671. import { Engine } from "babylonjs/Engines/engine";
  20672. /**
  20673. * This Helps creating a texture that will be created from a camera in your scene.
  20674. * It is basically a dynamic texture that could be used to create special effects for instance.
  20675. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20676. */
  20677. export class RenderTargetTexture extends Texture {
  20678. isCube: boolean;
  20679. /**
  20680. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20681. */
  20682. static readonly REFRESHRATE_RENDER_ONCE: number;
  20683. /**
  20684. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20685. */
  20686. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20687. /**
  20688. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20689. * the central point of your effect and can save a lot of performances.
  20690. */
  20691. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20692. /**
  20693. * Use this predicate to dynamically define the list of mesh you want to render.
  20694. * If set, the renderList property will be overwritten.
  20695. */
  20696. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20697. private _renderList;
  20698. /**
  20699. * Use this list to define the list of mesh you want to render.
  20700. */
  20701. renderList: Nullable<Array<AbstractMesh>>;
  20702. private _hookArray;
  20703. /**
  20704. * Define if particles should be rendered in your texture.
  20705. */
  20706. renderParticles: boolean;
  20707. /**
  20708. * Define if sprites should be rendered in your texture.
  20709. */
  20710. renderSprites: boolean;
  20711. /**
  20712. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20713. */
  20714. coordinatesMode: number;
  20715. /**
  20716. * Define the camera used to render the texture.
  20717. */
  20718. activeCamera: Nullable<Camera>;
  20719. /**
  20720. * Override the render function of the texture with your own one.
  20721. */
  20722. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20723. /**
  20724. * Define if camera post processes should be use while rendering the texture.
  20725. */
  20726. useCameraPostProcesses: boolean;
  20727. /**
  20728. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20729. */
  20730. ignoreCameraViewport: boolean;
  20731. private _postProcessManager;
  20732. private _postProcesses;
  20733. private _resizeObserver;
  20734. /**
  20735. * An event triggered when the texture is unbind.
  20736. */
  20737. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20738. /**
  20739. * An event triggered when the texture is unbind.
  20740. */
  20741. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20742. private _onAfterUnbindObserver;
  20743. /**
  20744. * Set a after unbind callback in the texture.
  20745. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20746. */
  20747. onAfterUnbind: () => void;
  20748. /**
  20749. * An event triggered before rendering the texture
  20750. */
  20751. onBeforeRenderObservable: Observable<number>;
  20752. private _onBeforeRenderObserver;
  20753. /**
  20754. * Set a before render callback in the texture.
  20755. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20756. */
  20757. onBeforeRender: (faceIndex: number) => void;
  20758. /**
  20759. * An event triggered after rendering the texture
  20760. */
  20761. onAfterRenderObservable: Observable<number>;
  20762. private _onAfterRenderObserver;
  20763. /**
  20764. * Set a after render callback in the texture.
  20765. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20766. */
  20767. onAfterRender: (faceIndex: number) => void;
  20768. /**
  20769. * An event triggered after the texture clear
  20770. */
  20771. onClearObservable: Observable<Engine>;
  20772. private _onClearObserver;
  20773. /**
  20774. * Set a clear callback in the texture.
  20775. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20776. */
  20777. onClear: (Engine: Engine) => void;
  20778. /**
  20779. * An event triggered when the texture is resized.
  20780. */
  20781. onResizeObservable: Observable<RenderTargetTexture>;
  20782. /**
  20783. * Define the clear color of the Render Target if it should be different from the scene.
  20784. */
  20785. clearColor: Color4;
  20786. protected _size: number | {
  20787. width: number;
  20788. height: number;
  20789. };
  20790. protected _initialSizeParameter: number | {
  20791. width: number;
  20792. height: number;
  20793. } | {
  20794. ratio: number;
  20795. };
  20796. protected _sizeRatio: Nullable<number>;
  20797. /** @hidden */
  20798. _generateMipMaps: boolean;
  20799. protected _renderingManager: RenderingManager;
  20800. /** @hidden */
  20801. _waitingRenderList: string[];
  20802. protected _doNotChangeAspectRatio: boolean;
  20803. protected _currentRefreshId: number;
  20804. protected _refreshRate: number;
  20805. protected _textureMatrix: Matrix;
  20806. protected _samples: number;
  20807. protected _renderTargetOptions: RenderTargetCreationOptions;
  20808. /**
  20809. * Gets render target creation options that were used.
  20810. */
  20811. readonly renderTargetOptions: RenderTargetCreationOptions;
  20812. protected _engine: Engine;
  20813. protected _onRatioRescale(): void;
  20814. /**
  20815. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20816. * It must define where the camera used to render the texture is set
  20817. */
  20818. boundingBoxPosition: Vector3;
  20819. private _boundingBoxSize;
  20820. /**
  20821. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20822. * When defined, the cubemap will switch to local mode
  20823. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20824. * @example https://www.babylonjs-playground.com/#RNASML
  20825. */
  20826. boundingBoxSize: Vector3;
  20827. /**
  20828. * In case the RTT has been created with a depth texture, get the associated
  20829. * depth texture.
  20830. * Otherwise, return null.
  20831. */
  20832. depthStencilTexture: Nullable<InternalTexture>;
  20833. /**
  20834. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20835. * or used a shadow, depth texture...
  20836. * @param name The friendly name of the texture
  20837. * @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)
  20838. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20839. * @param generateMipMaps True if mip maps need to be generated after render.
  20840. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20841. * @param type The type of the buffer in the RTT (int, half float, float...)
  20842. * @param isCube True if a cube texture needs to be created
  20843. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20844. * @param generateDepthBuffer True to generate a depth buffer
  20845. * @param generateStencilBuffer True to generate a stencil buffer
  20846. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20847. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20848. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20849. */
  20850. constructor(name: string, size: number | {
  20851. width: number;
  20852. height: number;
  20853. } | {
  20854. ratio: number;
  20855. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20856. /**
  20857. * Creates a depth stencil texture.
  20858. * This is only available in WebGL 2 or with the depth texture extension available.
  20859. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20860. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20861. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20862. */
  20863. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20864. private _processSizeParameter;
  20865. /**
  20866. * Define the number of samples to use in case of MSAA.
  20867. * It defaults to one meaning no MSAA has been enabled.
  20868. */
  20869. samples: number;
  20870. /**
  20871. * Resets the refresh counter of the texture and start bak from scratch.
  20872. * Could be useful to regenerate the texture if it is setup to render only once.
  20873. */
  20874. resetRefreshCounter(): void;
  20875. /**
  20876. * Define the refresh rate of the texture or the rendering frequency.
  20877. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20878. */
  20879. refreshRate: number;
  20880. /**
  20881. * Adds a post process to the render target rendering passes.
  20882. * @param postProcess define the post process to add
  20883. */
  20884. addPostProcess(postProcess: PostProcess): void;
  20885. /**
  20886. * Clear all the post processes attached to the render target
  20887. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20888. */
  20889. clearPostProcesses(dispose?: boolean): void;
  20890. /**
  20891. * Remove one of the post process from the list of attached post processes to the texture
  20892. * @param postProcess define the post process to remove from the list
  20893. */
  20894. removePostProcess(postProcess: PostProcess): void;
  20895. /** @hidden */
  20896. _shouldRender(): boolean;
  20897. /**
  20898. * Gets the actual render size of the texture.
  20899. * @returns the width of the render size
  20900. */
  20901. getRenderSize(): number;
  20902. /**
  20903. * Gets the actual render width of the texture.
  20904. * @returns the width of the render size
  20905. */
  20906. getRenderWidth(): number;
  20907. /**
  20908. * Gets the actual render height of the texture.
  20909. * @returns the height of the render size
  20910. */
  20911. getRenderHeight(): number;
  20912. /**
  20913. * Get if the texture can be rescaled or not.
  20914. */
  20915. readonly canRescale: boolean;
  20916. /**
  20917. * Resize the texture using a ratio.
  20918. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20919. */
  20920. scale(ratio: number): void;
  20921. /**
  20922. * Get the texture reflection matrix used to rotate/transform the reflection.
  20923. * @returns the reflection matrix
  20924. */
  20925. getReflectionTextureMatrix(): Matrix;
  20926. /**
  20927. * Resize the texture to a new desired size.
  20928. * Be carrefull as it will recreate all the data in the new texture.
  20929. * @param size Define the new size. It can be:
  20930. * - a number for squared texture,
  20931. * - an object containing { width: number, height: number }
  20932. * - or an object containing a ratio { ratio: number }
  20933. */
  20934. resize(size: number | {
  20935. width: number;
  20936. height: number;
  20937. } | {
  20938. ratio: number;
  20939. }): void;
  20940. /**
  20941. * Renders all the objects from the render list into the texture.
  20942. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20943. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20944. */
  20945. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20946. private _bestReflectionRenderTargetDimension;
  20947. /**
  20948. * @hidden
  20949. * @param faceIndex face index to bind to if this is a cubetexture
  20950. */
  20951. _bindFrameBuffer(faceIndex?: number): void;
  20952. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20953. private renderToTarget;
  20954. /**
  20955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20956. * This allowed control for front to back rendering or reversly depending of the special needs.
  20957. *
  20958. * @param renderingGroupId The rendering group id corresponding to its index
  20959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20962. */
  20963. 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;
  20964. /**
  20965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20966. *
  20967. * @param renderingGroupId The rendering group id corresponding to its index
  20968. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20969. */
  20970. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20971. /**
  20972. * Clones the texture.
  20973. * @returns the cloned texture
  20974. */
  20975. clone(): RenderTargetTexture;
  20976. /**
  20977. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20978. * @returns The JSON representation of the texture
  20979. */
  20980. serialize(): any;
  20981. /**
  20982. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20983. */
  20984. disposeFramebufferObjects(): void;
  20985. /**
  20986. * Dispose the texture and release its associated resources.
  20987. */
  20988. dispose(): void;
  20989. /** @hidden */
  20990. _rebuild(): void;
  20991. /**
  20992. * Clear the info related to rendering groups preventing retention point in material dispose.
  20993. */
  20994. freeRenderingGroups(): void;
  20995. /**
  20996. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20997. * @returns the view count
  20998. */
  20999. getViewCount(): number;
  21000. }
  21001. }
  21002. declare module "babylonjs/Materials/material" {
  21003. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21004. import { SmartArray } from "babylonjs/Misc/smartArray";
  21005. import { Observable } from "babylonjs/Misc/observable";
  21006. import { Nullable } from "babylonjs/types";
  21007. import { Scene } from "babylonjs/scene";
  21008. import { Matrix } from "babylonjs/Maths/math.vector";
  21009. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21011. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21012. import { Effect } from "babylonjs/Materials/effect";
  21013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21015. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21016. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21017. import { Mesh } from "babylonjs/Meshes/mesh";
  21018. import { Animation } from "babylonjs/Animations/animation";
  21019. /**
  21020. * Options for compiling materials.
  21021. */
  21022. export interface IMaterialCompilationOptions {
  21023. /**
  21024. * Defines whether clip planes are enabled.
  21025. */
  21026. clipPlane: boolean;
  21027. /**
  21028. * Defines whether instances are enabled.
  21029. */
  21030. useInstances: boolean;
  21031. }
  21032. /**
  21033. * Base class for the main features of a material in Babylon.js
  21034. */
  21035. export class Material implements IAnimatable {
  21036. /**
  21037. * Returns the triangle fill mode
  21038. */
  21039. static readonly TriangleFillMode: number;
  21040. /**
  21041. * Returns the wireframe mode
  21042. */
  21043. static readonly WireFrameFillMode: number;
  21044. /**
  21045. * Returns the point fill mode
  21046. */
  21047. static readonly PointFillMode: number;
  21048. /**
  21049. * Returns the point list draw mode
  21050. */
  21051. static readonly PointListDrawMode: number;
  21052. /**
  21053. * Returns the line list draw mode
  21054. */
  21055. static readonly LineListDrawMode: number;
  21056. /**
  21057. * Returns the line loop draw mode
  21058. */
  21059. static readonly LineLoopDrawMode: number;
  21060. /**
  21061. * Returns the line strip draw mode
  21062. */
  21063. static readonly LineStripDrawMode: number;
  21064. /**
  21065. * Returns the triangle strip draw mode
  21066. */
  21067. static readonly TriangleStripDrawMode: number;
  21068. /**
  21069. * Returns the triangle fan draw mode
  21070. */
  21071. static readonly TriangleFanDrawMode: number;
  21072. /**
  21073. * Stores the clock-wise side orientation
  21074. */
  21075. static readonly ClockWiseSideOrientation: number;
  21076. /**
  21077. * Stores the counter clock-wise side orientation
  21078. */
  21079. static readonly CounterClockWiseSideOrientation: number;
  21080. /**
  21081. * The dirty texture flag value
  21082. */
  21083. static readonly TextureDirtyFlag: number;
  21084. /**
  21085. * The dirty light flag value
  21086. */
  21087. static readonly LightDirtyFlag: number;
  21088. /**
  21089. * The dirty fresnel flag value
  21090. */
  21091. static readonly FresnelDirtyFlag: number;
  21092. /**
  21093. * The dirty attribute flag value
  21094. */
  21095. static readonly AttributesDirtyFlag: number;
  21096. /**
  21097. * The dirty misc flag value
  21098. */
  21099. static readonly MiscDirtyFlag: number;
  21100. /**
  21101. * The all dirty flag value
  21102. */
  21103. static readonly AllDirtyFlag: number;
  21104. /**
  21105. * The ID of the material
  21106. */
  21107. id: string;
  21108. /**
  21109. * Gets or sets the unique id of the material
  21110. */
  21111. uniqueId: number;
  21112. /**
  21113. * The name of the material
  21114. */
  21115. name: string;
  21116. /**
  21117. * Gets or sets user defined metadata
  21118. */
  21119. metadata: any;
  21120. /**
  21121. * For internal use only. Please do not use.
  21122. */
  21123. reservedDataStore: any;
  21124. /**
  21125. * Specifies if the ready state should be checked on each call
  21126. */
  21127. checkReadyOnEveryCall: boolean;
  21128. /**
  21129. * Specifies if the ready state should be checked once
  21130. */
  21131. checkReadyOnlyOnce: boolean;
  21132. /**
  21133. * The state of the material
  21134. */
  21135. state: string;
  21136. /**
  21137. * The alpha value of the material
  21138. */
  21139. protected _alpha: number;
  21140. /**
  21141. * List of inspectable custom properties (used by the Inspector)
  21142. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21143. */
  21144. inspectableCustomProperties: IInspectable[];
  21145. /**
  21146. * Sets the alpha value of the material
  21147. */
  21148. /**
  21149. * Gets the alpha value of the material
  21150. */
  21151. alpha: number;
  21152. /**
  21153. * Specifies if back face culling is enabled
  21154. */
  21155. protected _backFaceCulling: boolean;
  21156. /**
  21157. * Sets the back-face culling state
  21158. */
  21159. /**
  21160. * Gets the back-face culling state
  21161. */
  21162. backFaceCulling: boolean;
  21163. /**
  21164. * Stores the value for side orientation
  21165. */
  21166. sideOrientation: number;
  21167. /**
  21168. * Callback triggered when the material is compiled
  21169. */
  21170. onCompiled: Nullable<(effect: Effect) => void>;
  21171. /**
  21172. * Callback triggered when an error occurs
  21173. */
  21174. onError: Nullable<(effect: Effect, errors: string) => void>;
  21175. /**
  21176. * Callback triggered to get the render target textures
  21177. */
  21178. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21179. /**
  21180. * Gets a boolean indicating that current material needs to register RTT
  21181. */
  21182. readonly hasRenderTargetTextures: boolean;
  21183. /**
  21184. * Specifies if the material should be serialized
  21185. */
  21186. doNotSerialize: boolean;
  21187. /**
  21188. * @hidden
  21189. */
  21190. _storeEffectOnSubMeshes: boolean;
  21191. /**
  21192. * Stores the animations for the material
  21193. */
  21194. animations: Nullable<Array<Animation>>;
  21195. /**
  21196. * An event triggered when the material is disposed
  21197. */
  21198. onDisposeObservable: Observable<Material>;
  21199. /**
  21200. * An observer which watches for dispose events
  21201. */
  21202. private _onDisposeObserver;
  21203. private _onUnBindObservable;
  21204. /**
  21205. * Called during a dispose event
  21206. */
  21207. onDispose: () => void;
  21208. private _onBindObservable;
  21209. /**
  21210. * An event triggered when the material is bound
  21211. */
  21212. readonly onBindObservable: Observable<AbstractMesh>;
  21213. /**
  21214. * An observer which watches for bind events
  21215. */
  21216. private _onBindObserver;
  21217. /**
  21218. * Called during a bind event
  21219. */
  21220. onBind: (Mesh: AbstractMesh) => void;
  21221. /**
  21222. * An event triggered when the material is unbound
  21223. */
  21224. readonly onUnBindObservable: Observable<Material>;
  21225. /**
  21226. * Stores the value of the alpha mode
  21227. */
  21228. private _alphaMode;
  21229. /**
  21230. * Sets the value of the alpha mode.
  21231. *
  21232. * | Value | Type | Description |
  21233. * | --- | --- | --- |
  21234. * | 0 | ALPHA_DISABLE | |
  21235. * | 1 | ALPHA_ADD | |
  21236. * | 2 | ALPHA_COMBINE | |
  21237. * | 3 | ALPHA_SUBTRACT | |
  21238. * | 4 | ALPHA_MULTIPLY | |
  21239. * | 5 | ALPHA_MAXIMIZED | |
  21240. * | 6 | ALPHA_ONEONE | |
  21241. * | 7 | ALPHA_PREMULTIPLIED | |
  21242. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21243. * | 9 | ALPHA_INTERPOLATE | |
  21244. * | 10 | ALPHA_SCREENMODE | |
  21245. *
  21246. */
  21247. /**
  21248. * Gets the value of the alpha mode
  21249. */
  21250. alphaMode: number;
  21251. /**
  21252. * Stores the state of the need depth pre-pass value
  21253. */
  21254. private _needDepthPrePass;
  21255. /**
  21256. * Sets the need depth pre-pass value
  21257. */
  21258. /**
  21259. * Gets the depth pre-pass value
  21260. */
  21261. needDepthPrePass: boolean;
  21262. /**
  21263. * Specifies if depth writing should be disabled
  21264. */
  21265. disableDepthWrite: boolean;
  21266. /**
  21267. * Specifies if depth writing should be forced
  21268. */
  21269. forceDepthWrite: boolean;
  21270. /**
  21271. * Specifies the depth function that should be used. 0 means the default engine function
  21272. */
  21273. depthFunction: number;
  21274. /**
  21275. * Specifies if there should be a separate pass for culling
  21276. */
  21277. separateCullingPass: boolean;
  21278. /**
  21279. * Stores the state specifing if fog should be enabled
  21280. */
  21281. private _fogEnabled;
  21282. /**
  21283. * Sets the state for enabling fog
  21284. */
  21285. /**
  21286. * Gets the value of the fog enabled state
  21287. */
  21288. fogEnabled: boolean;
  21289. /**
  21290. * Stores the size of points
  21291. */
  21292. pointSize: number;
  21293. /**
  21294. * Stores the z offset value
  21295. */
  21296. zOffset: number;
  21297. /**
  21298. * Gets a value specifying if wireframe mode is enabled
  21299. */
  21300. /**
  21301. * Sets the state of wireframe mode
  21302. */
  21303. wireframe: boolean;
  21304. /**
  21305. * Gets the value specifying if point clouds are enabled
  21306. */
  21307. /**
  21308. * Sets the state of point cloud mode
  21309. */
  21310. pointsCloud: boolean;
  21311. /**
  21312. * Gets the material fill mode
  21313. */
  21314. /**
  21315. * Sets the material fill mode
  21316. */
  21317. fillMode: number;
  21318. /**
  21319. * @hidden
  21320. * Stores the effects for the material
  21321. */
  21322. _effect: Nullable<Effect>;
  21323. /**
  21324. * @hidden
  21325. * Specifies if the material was previously ready
  21326. */
  21327. _wasPreviouslyReady: boolean;
  21328. /**
  21329. * Specifies if uniform buffers should be used
  21330. */
  21331. private _useUBO;
  21332. /**
  21333. * Stores a reference to the scene
  21334. */
  21335. private _scene;
  21336. /**
  21337. * Stores the fill mode state
  21338. */
  21339. private _fillMode;
  21340. /**
  21341. * Specifies if the depth write state should be cached
  21342. */
  21343. private _cachedDepthWriteState;
  21344. /**
  21345. * Specifies if the depth function state should be cached
  21346. */
  21347. private _cachedDepthFunctionState;
  21348. /**
  21349. * Stores the uniform buffer
  21350. */
  21351. protected _uniformBuffer: UniformBuffer;
  21352. /** @hidden */
  21353. _indexInSceneMaterialArray: number;
  21354. /** @hidden */
  21355. meshMap: Nullable<{
  21356. [id: string]: AbstractMesh | undefined;
  21357. }>;
  21358. /**
  21359. * Creates a material instance
  21360. * @param name defines the name of the material
  21361. * @param scene defines the scene to reference
  21362. * @param doNotAdd specifies if the material should be added to the scene
  21363. */
  21364. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21365. /**
  21366. * Returns a string representation of the current material
  21367. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21368. * @returns a string with material information
  21369. */
  21370. toString(fullDetails?: boolean): string;
  21371. /**
  21372. * Gets the class name of the material
  21373. * @returns a string with the class name of the material
  21374. */
  21375. getClassName(): string;
  21376. /**
  21377. * Specifies if updates for the material been locked
  21378. */
  21379. readonly isFrozen: boolean;
  21380. /**
  21381. * Locks updates for the material
  21382. */
  21383. freeze(): void;
  21384. /**
  21385. * Unlocks updates for the material
  21386. */
  21387. unfreeze(): void;
  21388. /**
  21389. * Specifies if the material is ready to be used
  21390. * @param mesh defines the mesh to check
  21391. * @param useInstances specifies if instances should be used
  21392. * @returns a boolean indicating if the material is ready to be used
  21393. */
  21394. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21395. /**
  21396. * Specifies that the submesh is ready to be used
  21397. * @param mesh defines the mesh to check
  21398. * @param subMesh defines which submesh to check
  21399. * @param useInstances specifies that instances should be used
  21400. * @returns a boolean indicating that the submesh is ready or not
  21401. */
  21402. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21403. /**
  21404. * Returns the material effect
  21405. * @returns the effect associated with the material
  21406. */
  21407. getEffect(): Nullable<Effect>;
  21408. /**
  21409. * Returns the current scene
  21410. * @returns a Scene
  21411. */
  21412. getScene(): Scene;
  21413. /**
  21414. * Specifies if the material will require alpha blending
  21415. * @returns a boolean specifying if alpha blending is needed
  21416. */
  21417. needAlphaBlending(): boolean;
  21418. /**
  21419. * Specifies if the mesh will require alpha blending
  21420. * @param mesh defines the mesh to check
  21421. * @returns a boolean specifying if alpha blending is needed for the mesh
  21422. */
  21423. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21424. /**
  21425. * Specifies if this material should be rendered in alpha test mode
  21426. * @returns a boolean specifying if an alpha test is needed.
  21427. */
  21428. needAlphaTesting(): boolean;
  21429. /**
  21430. * Gets the texture used for the alpha test
  21431. * @returns the texture to use for alpha testing
  21432. */
  21433. getAlphaTestTexture(): Nullable<BaseTexture>;
  21434. /**
  21435. * Marks the material to indicate that it needs to be re-calculated
  21436. */
  21437. markDirty(): void;
  21438. /** @hidden */
  21439. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21440. /**
  21441. * Binds the material to the mesh
  21442. * @param world defines the world transformation matrix
  21443. * @param mesh defines the mesh to bind the material to
  21444. */
  21445. bind(world: Matrix, mesh?: Mesh): void;
  21446. /**
  21447. * Binds the submesh to the material
  21448. * @param world defines the world transformation matrix
  21449. * @param mesh defines the mesh containing the submesh
  21450. * @param subMesh defines the submesh to bind the material to
  21451. */
  21452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21453. /**
  21454. * Binds the world matrix to the material
  21455. * @param world defines the world transformation matrix
  21456. */
  21457. bindOnlyWorldMatrix(world: Matrix): void;
  21458. /**
  21459. * Binds the scene's uniform buffer to the effect.
  21460. * @param effect defines the effect to bind to the scene uniform buffer
  21461. * @param sceneUbo defines the uniform buffer storing scene data
  21462. */
  21463. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21464. /**
  21465. * Binds the view matrix to the effect
  21466. * @param effect defines the effect to bind the view matrix to
  21467. */
  21468. bindView(effect: Effect): void;
  21469. /**
  21470. * Binds the view projection matrix to the effect
  21471. * @param effect defines the effect to bind the view projection matrix to
  21472. */
  21473. bindViewProjection(effect: Effect): void;
  21474. /**
  21475. * Specifies if material alpha testing should be turned on for the mesh
  21476. * @param mesh defines the mesh to check
  21477. */
  21478. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21479. /**
  21480. * Processes to execute after binding the material to a mesh
  21481. * @param mesh defines the rendered mesh
  21482. */
  21483. protected _afterBind(mesh?: Mesh): void;
  21484. /**
  21485. * Unbinds the material from the mesh
  21486. */
  21487. unbind(): void;
  21488. /**
  21489. * Gets the active textures from the material
  21490. * @returns an array of textures
  21491. */
  21492. getActiveTextures(): BaseTexture[];
  21493. /**
  21494. * Specifies if the material uses a texture
  21495. * @param texture defines the texture to check against the material
  21496. * @returns a boolean specifying if the material uses the texture
  21497. */
  21498. hasTexture(texture: BaseTexture): boolean;
  21499. /**
  21500. * Makes a duplicate of the material, and gives it a new name
  21501. * @param name defines the new name for the duplicated material
  21502. * @returns the cloned material
  21503. */
  21504. clone(name: string): Nullable<Material>;
  21505. /**
  21506. * Gets the meshes bound to the material
  21507. * @returns an array of meshes bound to the material
  21508. */
  21509. getBindedMeshes(): AbstractMesh[];
  21510. /**
  21511. * Force shader compilation
  21512. * @param mesh defines the mesh associated with this material
  21513. * @param onCompiled defines a function to execute once the material is compiled
  21514. * @param options defines the options to configure the compilation
  21515. * @param onError defines a function to execute if the material fails compiling
  21516. */
  21517. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21518. /**
  21519. * Force shader compilation
  21520. * @param mesh defines the mesh that will use this material
  21521. * @param options defines additional options for compiling the shaders
  21522. * @returns a promise that resolves when the compilation completes
  21523. */
  21524. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21525. private static readonly _AllDirtyCallBack;
  21526. private static readonly _ImageProcessingDirtyCallBack;
  21527. private static readonly _TextureDirtyCallBack;
  21528. private static readonly _FresnelDirtyCallBack;
  21529. private static readonly _MiscDirtyCallBack;
  21530. private static readonly _LightsDirtyCallBack;
  21531. private static readonly _AttributeDirtyCallBack;
  21532. private static _FresnelAndMiscDirtyCallBack;
  21533. private static _TextureAndMiscDirtyCallBack;
  21534. private static readonly _DirtyCallbackArray;
  21535. private static readonly _RunDirtyCallBacks;
  21536. /**
  21537. * Marks a define in the material to indicate that it needs to be re-computed
  21538. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21539. */
  21540. markAsDirty(flag: number): void;
  21541. /**
  21542. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21543. * @param func defines a function which checks material defines against the submeshes
  21544. */
  21545. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21546. /**
  21547. * Indicates that we need to re-calculated for all submeshes
  21548. */
  21549. protected _markAllSubMeshesAsAllDirty(): void;
  21550. /**
  21551. * Indicates that image processing needs to be re-calculated for all submeshes
  21552. */
  21553. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21554. /**
  21555. * Indicates that textures need to be re-calculated for all submeshes
  21556. */
  21557. protected _markAllSubMeshesAsTexturesDirty(): void;
  21558. /**
  21559. * Indicates that fresnel needs to be re-calculated for all submeshes
  21560. */
  21561. protected _markAllSubMeshesAsFresnelDirty(): void;
  21562. /**
  21563. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21564. */
  21565. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21566. /**
  21567. * Indicates that lights need to be re-calculated for all submeshes
  21568. */
  21569. protected _markAllSubMeshesAsLightsDirty(): void;
  21570. /**
  21571. * Indicates that attributes need to be re-calculated for all submeshes
  21572. */
  21573. protected _markAllSubMeshesAsAttributesDirty(): void;
  21574. /**
  21575. * Indicates that misc needs to be re-calculated for all submeshes
  21576. */
  21577. protected _markAllSubMeshesAsMiscDirty(): void;
  21578. /**
  21579. * Indicates that textures and misc need to be re-calculated for all submeshes
  21580. */
  21581. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21582. /**
  21583. * Disposes the material
  21584. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21585. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21586. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21587. */
  21588. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21589. /** @hidden */
  21590. private releaseVertexArrayObject;
  21591. /**
  21592. * Serializes this material
  21593. * @returns the serialized material object
  21594. */
  21595. serialize(): any;
  21596. /**
  21597. * Creates a material from parsed material data
  21598. * @param parsedMaterial defines parsed material data
  21599. * @param scene defines the hosting scene
  21600. * @param rootUrl defines the root URL to use to load textures
  21601. * @returns a new material
  21602. */
  21603. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21604. }
  21605. }
  21606. declare module "babylonjs/Materials/multiMaterial" {
  21607. import { Nullable } from "babylonjs/types";
  21608. import { Scene } from "babylonjs/scene";
  21609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21610. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21611. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21612. import { Material } from "babylonjs/Materials/material";
  21613. /**
  21614. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21615. * separate meshes. This can be use to improve performances.
  21616. * @see http://doc.babylonjs.com/how_to/multi_materials
  21617. */
  21618. export class MultiMaterial extends Material {
  21619. private _subMaterials;
  21620. /**
  21621. * Gets or Sets the list of Materials used within the multi material.
  21622. * They need to be ordered according to the submeshes order in the associated mesh
  21623. */
  21624. subMaterials: Nullable<Material>[];
  21625. /**
  21626. * Function used to align with Node.getChildren()
  21627. * @returns the list of Materials used within the multi material
  21628. */
  21629. getChildren(): Nullable<Material>[];
  21630. /**
  21631. * Instantiates a new Multi Material
  21632. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21633. * separate meshes. This can be use to improve performances.
  21634. * @see http://doc.babylonjs.com/how_to/multi_materials
  21635. * @param name Define the name in the scene
  21636. * @param scene Define the scene the material belongs to
  21637. */
  21638. constructor(name: string, scene: Scene);
  21639. private _hookArray;
  21640. /**
  21641. * Get one of the submaterial by its index in the submaterials array
  21642. * @param index The index to look the sub material at
  21643. * @returns The Material if the index has been defined
  21644. */
  21645. getSubMaterial(index: number): Nullable<Material>;
  21646. /**
  21647. * Get the list of active textures for the whole sub materials list.
  21648. * @returns All the textures that will be used during the rendering
  21649. */
  21650. getActiveTextures(): BaseTexture[];
  21651. /**
  21652. * Gets the current class name of the material e.g. "MultiMaterial"
  21653. * Mainly use in serialization.
  21654. * @returns the class name
  21655. */
  21656. getClassName(): string;
  21657. /**
  21658. * Checks if the material is ready to render the requested sub mesh
  21659. * @param mesh Define the mesh the submesh belongs to
  21660. * @param subMesh Define the sub mesh to look readyness for
  21661. * @param useInstances Define whether or not the material is used with instances
  21662. * @returns true if ready, otherwise false
  21663. */
  21664. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21665. /**
  21666. * Clones the current material and its related sub materials
  21667. * @param name Define the name of the newly cloned material
  21668. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21669. * @returns the cloned material
  21670. */
  21671. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21672. /**
  21673. * Serializes the materials into a JSON representation.
  21674. * @returns the JSON representation
  21675. */
  21676. serialize(): any;
  21677. /**
  21678. * Dispose the material and release its associated resources
  21679. * @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)
  21680. * @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)
  21681. * @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)
  21682. */
  21683. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21684. /**
  21685. * Creates a MultiMaterial from parsed MultiMaterial data.
  21686. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21687. * @param scene defines the hosting scene
  21688. * @returns a new MultiMaterial
  21689. */
  21690. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21691. }
  21692. }
  21693. declare module "babylonjs/Meshes/subMesh" {
  21694. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21695. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21696. import { Engine } from "babylonjs/Engines/engine";
  21697. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21698. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21699. import { Effect } from "babylonjs/Materials/effect";
  21700. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21701. import { Plane } from "babylonjs/Maths/math.plane";
  21702. import { Collider } from "babylonjs/Collisions/collider";
  21703. import { Material } from "babylonjs/Materials/material";
  21704. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21706. import { Mesh } from "babylonjs/Meshes/mesh";
  21707. import { Ray } from "babylonjs/Culling/ray";
  21708. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21709. /**
  21710. * Base class for submeshes
  21711. */
  21712. export class BaseSubMesh {
  21713. /** @hidden */
  21714. _materialDefines: Nullable<MaterialDefines>;
  21715. /** @hidden */
  21716. _materialEffect: Nullable<Effect>;
  21717. /**
  21718. * Gets material defines used by the effect associated to the sub mesh
  21719. */
  21720. /**
  21721. * Sets material defines used by the effect associated to the sub mesh
  21722. */
  21723. materialDefines: Nullable<MaterialDefines>;
  21724. /**
  21725. * Gets associated effect
  21726. */
  21727. readonly effect: Nullable<Effect>;
  21728. /**
  21729. * Sets associated effect (effect used to render this submesh)
  21730. * @param effect defines the effect to associate with
  21731. * @param defines defines the set of defines used to compile this effect
  21732. */
  21733. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21734. }
  21735. /**
  21736. * Defines a subdivision inside a mesh
  21737. */
  21738. export class SubMesh extends BaseSubMesh implements ICullable {
  21739. /** the material index to use */
  21740. materialIndex: number;
  21741. /** vertex index start */
  21742. verticesStart: number;
  21743. /** vertices count */
  21744. verticesCount: number;
  21745. /** index start */
  21746. indexStart: number;
  21747. /** indices count */
  21748. indexCount: number;
  21749. /** @hidden */
  21750. _linesIndexCount: number;
  21751. private _mesh;
  21752. private _renderingMesh;
  21753. private _boundingInfo;
  21754. private _linesIndexBuffer;
  21755. /** @hidden */
  21756. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21757. /** @hidden */
  21758. _trianglePlanes: Plane[];
  21759. /** @hidden */
  21760. _lastColliderTransformMatrix: Nullable<Matrix>;
  21761. /** @hidden */
  21762. _renderId: number;
  21763. /** @hidden */
  21764. _alphaIndex: number;
  21765. /** @hidden */
  21766. _distanceToCamera: number;
  21767. /** @hidden */
  21768. _id: number;
  21769. private _currentMaterial;
  21770. /**
  21771. * Add a new submesh to a mesh
  21772. * @param materialIndex defines the material index to use
  21773. * @param verticesStart defines vertex index start
  21774. * @param verticesCount defines vertices count
  21775. * @param indexStart defines index start
  21776. * @param indexCount defines indices count
  21777. * @param mesh defines the parent mesh
  21778. * @param renderingMesh defines an optional rendering mesh
  21779. * @param createBoundingBox defines if bounding box should be created for this submesh
  21780. * @returns the new submesh
  21781. */
  21782. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21783. /**
  21784. * Creates a new submesh
  21785. * @param materialIndex defines the material index to use
  21786. * @param verticesStart defines vertex index start
  21787. * @param verticesCount defines vertices count
  21788. * @param indexStart defines index start
  21789. * @param indexCount defines indices count
  21790. * @param mesh defines the parent mesh
  21791. * @param renderingMesh defines an optional rendering mesh
  21792. * @param createBoundingBox defines if bounding box should be created for this submesh
  21793. */
  21794. constructor(
  21795. /** the material index to use */
  21796. materialIndex: number,
  21797. /** vertex index start */
  21798. verticesStart: number,
  21799. /** vertices count */
  21800. verticesCount: number,
  21801. /** index start */
  21802. indexStart: number,
  21803. /** indices count */
  21804. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21805. /**
  21806. * Returns true if this submesh covers the entire parent mesh
  21807. * @ignorenaming
  21808. */
  21809. readonly IsGlobal: boolean;
  21810. /**
  21811. * Returns the submesh BoudingInfo object
  21812. * @returns current bounding info (or mesh's one if the submesh is global)
  21813. */
  21814. getBoundingInfo(): BoundingInfo;
  21815. /**
  21816. * Sets the submesh BoundingInfo
  21817. * @param boundingInfo defines the new bounding info to use
  21818. * @returns the SubMesh
  21819. */
  21820. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21821. /**
  21822. * Returns the mesh of the current submesh
  21823. * @return the parent mesh
  21824. */
  21825. getMesh(): AbstractMesh;
  21826. /**
  21827. * Returns the rendering mesh of the submesh
  21828. * @returns the rendering mesh (could be different from parent mesh)
  21829. */
  21830. getRenderingMesh(): Mesh;
  21831. /**
  21832. * Returns the submesh material
  21833. * @returns null or the current material
  21834. */
  21835. getMaterial(): Nullable<Material>;
  21836. /**
  21837. * Sets a new updated BoundingInfo object to the submesh
  21838. * @param data defines an optional position array to use to determine the bounding info
  21839. * @returns the SubMesh
  21840. */
  21841. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21842. /** @hidden */
  21843. _checkCollision(collider: Collider): boolean;
  21844. /**
  21845. * Updates the submesh BoundingInfo
  21846. * @param world defines the world matrix to use to update the bounding info
  21847. * @returns the submesh
  21848. */
  21849. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21850. /**
  21851. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21852. * @param frustumPlanes defines the frustum planes
  21853. * @returns true if the submesh is intersecting with the frustum
  21854. */
  21855. isInFrustum(frustumPlanes: Plane[]): boolean;
  21856. /**
  21857. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21858. * @param frustumPlanes defines the frustum planes
  21859. * @returns true if the submesh is inside the frustum
  21860. */
  21861. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21862. /**
  21863. * Renders the submesh
  21864. * @param enableAlphaMode defines if alpha needs to be used
  21865. * @returns the submesh
  21866. */
  21867. render(enableAlphaMode: boolean): SubMesh;
  21868. /**
  21869. * @hidden
  21870. */
  21871. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21872. /**
  21873. * Checks if the submesh intersects with a ray
  21874. * @param ray defines the ray to test
  21875. * @returns true is the passed ray intersects the submesh bounding box
  21876. */
  21877. canIntersects(ray: Ray): boolean;
  21878. /**
  21879. * Intersects current submesh with a ray
  21880. * @param ray defines the ray to test
  21881. * @param positions defines mesh's positions array
  21882. * @param indices defines mesh's indices array
  21883. * @param fastCheck defines if only bounding info should be used
  21884. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21885. * @returns intersection info or null if no intersection
  21886. */
  21887. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21888. /** @hidden */
  21889. private _intersectLines;
  21890. /** @hidden */
  21891. private _intersectUnIndexedLines;
  21892. /** @hidden */
  21893. private _intersectTriangles;
  21894. /** @hidden */
  21895. private _intersectUnIndexedTriangles;
  21896. /** @hidden */
  21897. _rebuild(): void;
  21898. /**
  21899. * Creates a new submesh from the passed mesh
  21900. * @param newMesh defines the new hosting mesh
  21901. * @param newRenderingMesh defines an optional rendering mesh
  21902. * @returns the new submesh
  21903. */
  21904. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21905. /**
  21906. * Release associated resources
  21907. */
  21908. dispose(): void;
  21909. /**
  21910. * Gets the class name
  21911. * @returns the string "SubMesh".
  21912. */
  21913. getClassName(): string;
  21914. /**
  21915. * Creates a new submesh from indices data
  21916. * @param materialIndex the index of the main mesh material
  21917. * @param startIndex the index where to start the copy in the mesh indices array
  21918. * @param indexCount the number of indices to copy then from the startIndex
  21919. * @param mesh the main mesh to create the submesh from
  21920. * @param renderingMesh the optional rendering mesh
  21921. * @returns a new submesh
  21922. */
  21923. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21924. }
  21925. }
  21926. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21927. /**
  21928. * Class used to represent data loading progression
  21929. */
  21930. export class SceneLoaderFlags {
  21931. private static _ForceFullSceneLoadingForIncremental;
  21932. private static _ShowLoadingScreen;
  21933. private static _CleanBoneMatrixWeights;
  21934. private static _loggingLevel;
  21935. /**
  21936. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21937. */
  21938. static ForceFullSceneLoadingForIncremental: boolean;
  21939. /**
  21940. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21941. */
  21942. static ShowLoadingScreen: boolean;
  21943. /**
  21944. * Defines the current logging level (while loading the scene)
  21945. * @ignorenaming
  21946. */
  21947. static loggingLevel: number;
  21948. /**
  21949. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21950. */
  21951. static CleanBoneMatrixWeights: boolean;
  21952. }
  21953. }
  21954. declare module "babylonjs/Meshes/geometry" {
  21955. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21956. import { Scene } from "babylonjs/scene";
  21957. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21958. import { Engine } from "babylonjs/Engines/engine";
  21959. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21960. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21961. import { Effect } from "babylonjs/Materials/effect";
  21962. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21963. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21964. import { Mesh } from "babylonjs/Meshes/mesh";
  21965. /**
  21966. * Class used to store geometry data (vertex buffers + index buffer)
  21967. */
  21968. export class Geometry implements IGetSetVerticesData {
  21969. /**
  21970. * Gets or sets the ID of the geometry
  21971. */
  21972. id: string;
  21973. /**
  21974. * Gets or sets the unique ID of the geometry
  21975. */
  21976. uniqueId: number;
  21977. /**
  21978. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21979. */
  21980. delayLoadState: number;
  21981. /**
  21982. * Gets the file containing the data to load when running in delay load state
  21983. */
  21984. delayLoadingFile: Nullable<string>;
  21985. /**
  21986. * Callback called when the geometry is updated
  21987. */
  21988. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21989. private _scene;
  21990. private _engine;
  21991. private _meshes;
  21992. private _totalVertices;
  21993. /** @hidden */
  21994. _indices: IndicesArray;
  21995. /** @hidden */
  21996. _vertexBuffers: {
  21997. [key: string]: VertexBuffer;
  21998. };
  21999. private _isDisposed;
  22000. private _extend;
  22001. private _boundingBias;
  22002. /** @hidden */
  22003. _delayInfo: Array<string>;
  22004. private _indexBuffer;
  22005. private _indexBufferIsUpdatable;
  22006. /** @hidden */
  22007. _boundingInfo: Nullable<BoundingInfo>;
  22008. /** @hidden */
  22009. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22010. /** @hidden */
  22011. _softwareSkinningFrameId: number;
  22012. private _vertexArrayObjects;
  22013. private _updatable;
  22014. /** @hidden */
  22015. _positions: Nullable<Vector3[]>;
  22016. /**
  22017. * 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
  22018. */
  22019. /**
  22020. * 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
  22021. */
  22022. boundingBias: Vector2;
  22023. /**
  22024. * Static function used to attach a new empty geometry to a mesh
  22025. * @param mesh defines the mesh to attach the geometry to
  22026. * @returns the new Geometry
  22027. */
  22028. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22029. /**
  22030. * Creates a new geometry
  22031. * @param id defines the unique ID
  22032. * @param scene defines the hosting scene
  22033. * @param vertexData defines the VertexData used to get geometry data
  22034. * @param updatable defines if geometry must be updatable (false by default)
  22035. * @param mesh defines the mesh that will be associated with the geometry
  22036. */
  22037. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22038. /**
  22039. * Gets the current extend of the geometry
  22040. */
  22041. readonly extend: {
  22042. minimum: Vector3;
  22043. maximum: Vector3;
  22044. };
  22045. /**
  22046. * Gets the hosting scene
  22047. * @returns the hosting Scene
  22048. */
  22049. getScene(): Scene;
  22050. /**
  22051. * Gets the hosting engine
  22052. * @returns the hosting Engine
  22053. */
  22054. getEngine(): Engine;
  22055. /**
  22056. * Defines if the geometry is ready to use
  22057. * @returns true if the geometry is ready to be used
  22058. */
  22059. isReady(): boolean;
  22060. /**
  22061. * Gets a value indicating that the geometry should not be serialized
  22062. */
  22063. readonly doNotSerialize: boolean;
  22064. /** @hidden */
  22065. _rebuild(): void;
  22066. /**
  22067. * Affects all geometry data in one call
  22068. * @param vertexData defines the geometry data
  22069. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22070. */
  22071. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22072. /**
  22073. * Set specific vertex data
  22074. * @param kind defines the data kind (Position, normal, etc...)
  22075. * @param data defines the vertex data to use
  22076. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22077. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22078. */
  22079. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22080. /**
  22081. * Removes a specific vertex data
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. */
  22084. removeVerticesData(kind: string): void;
  22085. /**
  22086. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22087. * @param buffer defines the vertex buffer to use
  22088. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22089. */
  22090. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22091. /**
  22092. * Update a specific vertex buffer
  22093. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22094. * It will do nothing if the buffer is not updatable
  22095. * @param kind defines the data kind (Position, normal, etc...)
  22096. * @param data defines the data to use
  22097. * @param offset defines the offset in the target buffer where to store the data
  22098. * @param useBytes set to true if the offset is in bytes
  22099. */
  22100. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22101. /**
  22102. * Update a specific vertex buffer
  22103. * This function will create a new buffer if the current one is not updatable
  22104. * @param kind defines the data kind (Position, normal, etc...)
  22105. * @param data defines the data to use
  22106. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22107. */
  22108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22109. private _updateBoundingInfo;
  22110. /** @hidden */
  22111. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22112. /**
  22113. * Gets total number of vertices
  22114. * @returns the total number of vertices
  22115. */
  22116. getTotalVertices(): number;
  22117. /**
  22118. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22119. * @param kind defines the data kind (Position, normal, etc...)
  22120. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22122. * @returns a float array containing vertex data
  22123. */
  22124. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22125. /**
  22126. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22127. * @param kind defines the data kind (Position, normal, etc...)
  22128. * @returns true if the vertex buffer with the specified kind is updatable
  22129. */
  22130. isVertexBufferUpdatable(kind: string): boolean;
  22131. /**
  22132. * Gets a specific vertex buffer
  22133. * @param kind defines the data kind (Position, normal, etc...)
  22134. * @returns a VertexBuffer
  22135. */
  22136. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22137. /**
  22138. * Returns all vertex buffers
  22139. * @return an object holding all vertex buffers indexed by kind
  22140. */
  22141. getVertexBuffers(): Nullable<{
  22142. [key: string]: VertexBuffer;
  22143. }>;
  22144. /**
  22145. * Gets a boolean indicating if specific vertex buffer is present
  22146. * @param kind defines the data kind (Position, normal, etc...)
  22147. * @returns true if data is present
  22148. */
  22149. isVerticesDataPresent(kind: string): boolean;
  22150. /**
  22151. * Gets a list of all attached data kinds (Position, normal, etc...)
  22152. * @returns a list of string containing all kinds
  22153. */
  22154. getVerticesDataKinds(): string[];
  22155. /**
  22156. * Update index buffer
  22157. * @param indices defines the indices to store in the index buffer
  22158. * @param offset defines the offset in the target buffer where to store the data
  22159. * @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)
  22160. */
  22161. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22162. /**
  22163. * Creates a new index buffer
  22164. * @param indices defines the indices to store in the index buffer
  22165. * @param totalVertices defines the total number of vertices (could be null)
  22166. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22167. */
  22168. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22169. /**
  22170. * Return the total number of indices
  22171. * @returns the total number of indices
  22172. */
  22173. getTotalIndices(): number;
  22174. /**
  22175. * Gets the index buffer array
  22176. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22177. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22178. * @returns the index buffer array
  22179. */
  22180. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22181. /**
  22182. * Gets the index buffer
  22183. * @return the index buffer
  22184. */
  22185. getIndexBuffer(): Nullable<DataBuffer>;
  22186. /** @hidden */
  22187. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22188. /**
  22189. * Release the associated resources for a specific mesh
  22190. * @param mesh defines the source mesh
  22191. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22192. */
  22193. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22194. /**
  22195. * Apply current geometry to a given mesh
  22196. * @param mesh defines the mesh to apply geometry to
  22197. */
  22198. applyToMesh(mesh: Mesh): void;
  22199. private _updateExtend;
  22200. private _applyToMesh;
  22201. private notifyUpdate;
  22202. /**
  22203. * Load the geometry if it was flagged as delay loaded
  22204. * @param scene defines the hosting scene
  22205. * @param onLoaded defines a callback called when the geometry is loaded
  22206. */
  22207. load(scene: Scene, onLoaded?: () => void): void;
  22208. private _queueLoad;
  22209. /**
  22210. * Invert the geometry to move from a right handed system to a left handed one.
  22211. */
  22212. toLeftHanded(): void;
  22213. /** @hidden */
  22214. _resetPointsArrayCache(): void;
  22215. /** @hidden */
  22216. _generatePointsArray(): boolean;
  22217. /**
  22218. * Gets a value indicating if the geometry is disposed
  22219. * @returns true if the geometry was disposed
  22220. */
  22221. isDisposed(): boolean;
  22222. private _disposeVertexArrayObjects;
  22223. /**
  22224. * Free all associated resources
  22225. */
  22226. dispose(): void;
  22227. /**
  22228. * Clone the current geometry into a new geometry
  22229. * @param id defines the unique ID of the new geometry
  22230. * @returns a new geometry object
  22231. */
  22232. copy(id: string): Geometry;
  22233. /**
  22234. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22235. * @return a JSON representation of the current geometry data (without the vertices data)
  22236. */
  22237. serialize(): any;
  22238. private toNumberArray;
  22239. /**
  22240. * Serialize all vertices data into a JSON oject
  22241. * @returns a JSON representation of the current geometry data
  22242. */
  22243. serializeVerticeData(): any;
  22244. /**
  22245. * Extracts a clone of a mesh geometry
  22246. * @param mesh defines the source mesh
  22247. * @param id defines the unique ID of the new geometry object
  22248. * @returns the new geometry object
  22249. */
  22250. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22251. /**
  22252. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22253. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22254. * Be aware Math.random() could cause collisions, but:
  22255. * "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"
  22256. * @returns a string containing a new GUID
  22257. */
  22258. static RandomId(): string;
  22259. /** @hidden */
  22260. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22261. private static _CleanMatricesWeights;
  22262. /**
  22263. * Create a new geometry from persisted data (Using .babylon file format)
  22264. * @param parsedVertexData defines the persisted data
  22265. * @param scene defines the hosting scene
  22266. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22267. * @returns the new geometry object
  22268. */
  22269. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22270. }
  22271. }
  22272. declare module "babylonjs/Meshes/mesh.vertexData" {
  22273. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22274. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22275. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22276. import { Geometry } from "babylonjs/Meshes/geometry";
  22277. import { Mesh } from "babylonjs/Meshes/mesh";
  22278. /**
  22279. * Define an interface for all classes that will get and set the data on vertices
  22280. */
  22281. export interface IGetSetVerticesData {
  22282. /**
  22283. * Gets a boolean indicating if specific vertex data is present
  22284. * @param kind defines the vertex data kind to use
  22285. * @returns true is data kind is present
  22286. */
  22287. isVerticesDataPresent(kind: string): boolean;
  22288. /**
  22289. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22290. * @param kind defines the data kind (Position, normal, etc...)
  22291. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22292. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22293. * @returns a float array containing vertex data
  22294. */
  22295. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22296. /**
  22297. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22298. * @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.
  22299. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22300. * @returns the indices array or an empty array if the mesh has no geometry
  22301. */
  22302. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22303. /**
  22304. * Set specific vertex data
  22305. * @param kind defines the data kind (Position, normal, etc...)
  22306. * @param data defines the vertex data to use
  22307. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22308. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22309. */
  22310. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22311. /**
  22312. * Update a specific associated vertex buffer
  22313. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22314. * - VertexBuffer.PositionKind
  22315. * - VertexBuffer.UVKind
  22316. * - VertexBuffer.UV2Kind
  22317. * - VertexBuffer.UV3Kind
  22318. * - VertexBuffer.UV4Kind
  22319. * - VertexBuffer.UV5Kind
  22320. * - VertexBuffer.UV6Kind
  22321. * - VertexBuffer.ColorKind
  22322. * - VertexBuffer.MatricesIndicesKind
  22323. * - VertexBuffer.MatricesIndicesExtraKind
  22324. * - VertexBuffer.MatricesWeightsKind
  22325. * - VertexBuffer.MatricesWeightsExtraKind
  22326. * @param data defines the data source
  22327. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22328. * @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)
  22329. */
  22330. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22331. /**
  22332. * Creates a new index buffer
  22333. * @param indices defines the indices to store in the index buffer
  22334. * @param totalVertices defines the total number of vertices (could be null)
  22335. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22336. */
  22337. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22338. }
  22339. /**
  22340. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22341. */
  22342. export class VertexData {
  22343. /**
  22344. * Mesh side orientation : usually the external or front surface
  22345. */
  22346. static readonly FRONTSIDE: number;
  22347. /**
  22348. * Mesh side orientation : usually the internal or back surface
  22349. */
  22350. static readonly BACKSIDE: number;
  22351. /**
  22352. * Mesh side orientation : both internal and external or front and back surfaces
  22353. */
  22354. static readonly DOUBLESIDE: number;
  22355. /**
  22356. * Mesh side orientation : by default, `FRONTSIDE`
  22357. */
  22358. static readonly DEFAULTSIDE: number;
  22359. /**
  22360. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22361. */
  22362. positions: Nullable<FloatArray>;
  22363. /**
  22364. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22365. */
  22366. normals: Nullable<FloatArray>;
  22367. /**
  22368. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22369. */
  22370. tangents: Nullable<FloatArray>;
  22371. /**
  22372. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22373. */
  22374. uvs: Nullable<FloatArray>;
  22375. /**
  22376. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22377. */
  22378. uvs2: Nullable<FloatArray>;
  22379. /**
  22380. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22381. */
  22382. uvs3: Nullable<FloatArray>;
  22383. /**
  22384. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22385. */
  22386. uvs4: Nullable<FloatArray>;
  22387. /**
  22388. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22389. */
  22390. uvs5: Nullable<FloatArray>;
  22391. /**
  22392. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22393. */
  22394. uvs6: Nullable<FloatArray>;
  22395. /**
  22396. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22397. */
  22398. colors: Nullable<FloatArray>;
  22399. /**
  22400. * 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).
  22401. */
  22402. matricesIndices: Nullable<FloatArray>;
  22403. /**
  22404. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22405. */
  22406. matricesWeights: Nullable<FloatArray>;
  22407. /**
  22408. * An array extending the number of possible indices
  22409. */
  22410. matricesIndicesExtra: Nullable<FloatArray>;
  22411. /**
  22412. * An array extending the number of possible weights when the number of indices is extended
  22413. */
  22414. matricesWeightsExtra: Nullable<FloatArray>;
  22415. /**
  22416. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22417. */
  22418. indices: Nullable<IndicesArray>;
  22419. /**
  22420. * Uses the passed data array to set the set the values for the specified kind of data
  22421. * @param data a linear array of floating numbers
  22422. * @param kind the type of data that is being set, eg positions, colors etc
  22423. */
  22424. set(data: FloatArray, kind: string): void;
  22425. /**
  22426. * Associates the vertexData to the passed Mesh.
  22427. * Sets it as updatable or not (default `false`)
  22428. * @param mesh the mesh the vertexData is applied to
  22429. * @param updatable when used and having the value true allows new data to update the vertexData
  22430. * @returns the VertexData
  22431. */
  22432. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22433. /**
  22434. * Associates the vertexData to the passed Geometry.
  22435. * Sets it as updatable or not (default `false`)
  22436. * @param geometry the geometry the vertexData is applied to
  22437. * @param updatable when used and having the value true allows new data to update the vertexData
  22438. * @returns VertexData
  22439. */
  22440. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22441. /**
  22442. * Updates the associated mesh
  22443. * @param mesh the mesh to be updated
  22444. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22445. * @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
  22446. * @returns VertexData
  22447. */
  22448. updateMesh(mesh: Mesh): VertexData;
  22449. /**
  22450. * Updates the associated geometry
  22451. * @param geometry the geometry to be updated
  22452. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22453. * @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
  22454. * @returns VertexData.
  22455. */
  22456. updateGeometry(geometry: Geometry): VertexData;
  22457. private _applyTo;
  22458. private _update;
  22459. /**
  22460. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22461. * @param matrix the transforming matrix
  22462. * @returns the VertexData
  22463. */
  22464. transform(matrix: Matrix): VertexData;
  22465. /**
  22466. * Merges the passed VertexData into the current one
  22467. * @param other the VertexData to be merged into the current one
  22468. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22469. * @returns the modified VertexData
  22470. */
  22471. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22472. private _mergeElement;
  22473. private _validate;
  22474. /**
  22475. * Serializes the VertexData
  22476. * @returns a serialized object
  22477. */
  22478. serialize(): any;
  22479. /**
  22480. * Extracts the vertexData from a mesh
  22481. * @param mesh the mesh from which to extract the VertexData
  22482. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22483. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22484. * @returns the object VertexData associated to the passed mesh
  22485. */
  22486. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22487. /**
  22488. * Extracts the vertexData from the geometry
  22489. * @param geometry the geometry from which to extract the VertexData
  22490. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22491. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22492. * @returns the object VertexData associated to the passed mesh
  22493. */
  22494. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22495. private static _ExtractFrom;
  22496. /**
  22497. * Creates the VertexData for a Ribbon
  22498. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22499. * * pathArray array of paths, each of which an array of successive Vector3
  22500. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22501. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22502. * * 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
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * * 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)
  22505. * * 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)
  22506. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22507. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22508. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22509. * @returns the VertexData of the ribbon
  22510. */
  22511. static CreateRibbon(options: {
  22512. pathArray: Vector3[][];
  22513. closeArray?: boolean;
  22514. closePath?: boolean;
  22515. offset?: number;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. invertUV?: boolean;
  22520. uvs?: Vector2[];
  22521. colors?: Color4[];
  22522. }): VertexData;
  22523. /**
  22524. * Creates the VertexData for a box
  22525. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22526. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22527. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22528. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22529. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22530. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22531. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22533. * * 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)
  22534. * * 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)
  22535. * @returns the VertexData of the box
  22536. */
  22537. static CreateBox(options: {
  22538. size?: number;
  22539. width?: number;
  22540. height?: number;
  22541. depth?: number;
  22542. faceUV?: Vector4[];
  22543. faceColors?: Color4[];
  22544. sideOrientation?: number;
  22545. frontUVs?: Vector4;
  22546. backUVs?: Vector4;
  22547. }): VertexData;
  22548. /**
  22549. * Creates the VertexData for a tiled box
  22550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22551. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22552. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22553. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22554. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22555. * @returns the VertexData of the box
  22556. */
  22557. static CreateTiledBox(options: {
  22558. pattern?: number;
  22559. width?: number;
  22560. height?: number;
  22561. depth?: number;
  22562. tileSize?: number;
  22563. tileWidth?: number;
  22564. tileHeight?: number;
  22565. alignHorizontal?: number;
  22566. alignVertical?: number;
  22567. faceUV?: Vector4[];
  22568. faceColors?: Color4[];
  22569. sideOrientation?: number;
  22570. }): VertexData;
  22571. /**
  22572. * Creates the VertexData for a tiled plane
  22573. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22574. * * pattern a limited pattern arrangement depending on the number
  22575. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22576. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22577. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * 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)
  22580. * * 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)
  22581. * @returns the VertexData of the tiled plane
  22582. */
  22583. static CreateTiledPlane(options: {
  22584. pattern?: number;
  22585. tileSize?: number;
  22586. tileWidth?: number;
  22587. tileHeight?: number;
  22588. size?: number;
  22589. width?: number;
  22590. height?: number;
  22591. alignHorizontal?: number;
  22592. alignVertical?: number;
  22593. sideOrientation?: number;
  22594. frontUVs?: Vector4;
  22595. backUVs?: Vector4;
  22596. }): VertexData;
  22597. /**
  22598. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22599. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22600. * * segments sets the number of horizontal strips optional, default 32
  22601. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22602. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22603. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22604. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22605. * * 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
  22606. * * 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
  22607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22608. * * 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)
  22609. * * 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)
  22610. * @returns the VertexData of the ellipsoid
  22611. */
  22612. static CreateSphere(options: {
  22613. segments?: number;
  22614. diameter?: number;
  22615. diameterX?: number;
  22616. diameterY?: number;
  22617. diameterZ?: number;
  22618. arc?: number;
  22619. slice?: number;
  22620. sideOrientation?: number;
  22621. frontUVs?: Vector4;
  22622. backUVs?: Vector4;
  22623. }): VertexData;
  22624. /**
  22625. * Creates the VertexData for a cylinder, cone or prism
  22626. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22627. * * height sets the height (y direction) of the cylinder, optional, default 2
  22628. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22629. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22630. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22631. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22632. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22633. * * 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
  22634. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22635. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22636. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22637. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22639. * * 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)
  22640. * * 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)
  22641. * @returns the VertexData of the cylinder, cone or prism
  22642. */
  22643. static CreateCylinder(options: {
  22644. height?: number;
  22645. diameterTop?: number;
  22646. diameterBottom?: number;
  22647. diameter?: number;
  22648. tessellation?: number;
  22649. subdivisions?: number;
  22650. arc?: number;
  22651. faceColors?: Color4[];
  22652. faceUV?: Vector4[];
  22653. hasRings?: boolean;
  22654. enclose?: boolean;
  22655. sideOrientation?: number;
  22656. frontUVs?: Vector4;
  22657. backUVs?: Vector4;
  22658. }): VertexData;
  22659. /**
  22660. * Creates the VertexData for a torus
  22661. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22662. * * diameter the diameter of the torus, optional default 1
  22663. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22664. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22666. * * 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)
  22667. * * 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)
  22668. * @returns the VertexData of the torus
  22669. */
  22670. static CreateTorus(options: {
  22671. diameter?: number;
  22672. thickness?: number;
  22673. tessellation?: number;
  22674. sideOrientation?: number;
  22675. frontUVs?: Vector4;
  22676. backUVs?: Vector4;
  22677. }): VertexData;
  22678. /**
  22679. * Creates the VertexData of the LineSystem
  22680. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22681. * - lines an array of lines, each line being an array of successive Vector3
  22682. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22683. * @returns the VertexData of the LineSystem
  22684. */
  22685. static CreateLineSystem(options: {
  22686. lines: Vector3[][];
  22687. colors?: Nullable<Color4[][]>;
  22688. }): VertexData;
  22689. /**
  22690. * Create the VertexData for a DashedLines
  22691. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22692. * - points an array successive Vector3
  22693. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22694. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22695. * - dashNb the intended total number of dashes, optional, default 200
  22696. * @returns the VertexData for the DashedLines
  22697. */
  22698. static CreateDashedLines(options: {
  22699. points: Vector3[];
  22700. dashSize?: number;
  22701. gapSize?: number;
  22702. dashNb?: number;
  22703. }): VertexData;
  22704. /**
  22705. * Creates the VertexData for a Ground
  22706. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22707. * - width the width (x direction) of the ground, optional, default 1
  22708. * - height the height (z direction) of the ground, optional, default 1
  22709. * - subdivisions the number of subdivisions per side, optional, default 1
  22710. * @returns the VertexData of the Ground
  22711. */
  22712. static CreateGround(options: {
  22713. width?: number;
  22714. height?: number;
  22715. subdivisions?: number;
  22716. subdivisionsX?: number;
  22717. subdivisionsY?: number;
  22718. }): VertexData;
  22719. /**
  22720. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22721. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22722. * * xmin the ground minimum X coordinate, optional, default -1
  22723. * * zmin the ground minimum Z coordinate, optional, default -1
  22724. * * xmax the ground maximum X coordinate, optional, default 1
  22725. * * zmax the ground maximum Z coordinate, optional, default 1
  22726. * * 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}
  22727. * * 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}
  22728. * @returns the VertexData of the TiledGround
  22729. */
  22730. static CreateTiledGround(options: {
  22731. xmin: number;
  22732. zmin: number;
  22733. xmax: number;
  22734. zmax: number;
  22735. subdivisions?: {
  22736. w: number;
  22737. h: number;
  22738. };
  22739. precision?: {
  22740. w: number;
  22741. h: number;
  22742. };
  22743. }): VertexData;
  22744. /**
  22745. * Creates the VertexData of the Ground designed from a heightmap
  22746. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22747. * * width the width (x direction) of the ground
  22748. * * height the height (z direction) of the ground
  22749. * * subdivisions the number of subdivisions per side
  22750. * * minHeight the minimum altitude on the ground, optional, default 0
  22751. * * maxHeight the maximum altitude on the ground, optional default 1
  22752. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22753. * * buffer the array holding the image color data
  22754. * * bufferWidth the width of image
  22755. * * bufferHeight the height of image
  22756. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22757. * @returns the VertexData of the Ground designed from a heightmap
  22758. */
  22759. static CreateGroundFromHeightMap(options: {
  22760. width: number;
  22761. height: number;
  22762. subdivisions: number;
  22763. minHeight: number;
  22764. maxHeight: number;
  22765. colorFilter: Color3;
  22766. buffer: Uint8Array;
  22767. bufferWidth: number;
  22768. bufferHeight: number;
  22769. alphaFilter: number;
  22770. }): VertexData;
  22771. /**
  22772. * Creates the VertexData for a Plane
  22773. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22774. * * size sets the width and height of the plane to the value of size, optional default 1
  22775. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22776. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22777. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22778. * * 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)
  22779. * * 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)
  22780. * @returns the VertexData of the box
  22781. */
  22782. static CreatePlane(options: {
  22783. size?: number;
  22784. width?: number;
  22785. height?: number;
  22786. sideOrientation?: number;
  22787. frontUVs?: Vector4;
  22788. backUVs?: Vector4;
  22789. }): VertexData;
  22790. /**
  22791. * Creates the VertexData of the Disc or regular Polygon
  22792. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22793. * * radius the radius of the disc, optional default 0.5
  22794. * * tessellation the number of polygon sides, optional, default 64
  22795. * * 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
  22796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22797. * * 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)
  22798. * * 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)
  22799. * @returns the VertexData of the box
  22800. */
  22801. static CreateDisc(options: {
  22802. radius?: number;
  22803. tessellation?: number;
  22804. arc?: number;
  22805. sideOrientation?: number;
  22806. frontUVs?: Vector4;
  22807. backUVs?: Vector4;
  22808. }): VertexData;
  22809. /**
  22810. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22811. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22812. * @param polygon a mesh built from polygonTriangulation.build()
  22813. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22814. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22815. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22816. * @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)
  22817. * @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)
  22818. * @returns the VertexData of the Polygon
  22819. */
  22820. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22821. /**
  22822. * Creates the VertexData of the IcoSphere
  22823. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22824. * * radius the radius of the IcoSphere, optional default 1
  22825. * * radiusX allows stretching in the x direction, optional, default radius
  22826. * * radiusY allows stretching in the y direction, optional, default radius
  22827. * * radiusZ allows stretching in the z direction, optional, default radius
  22828. * * flat when true creates a flat shaded mesh, optional, default true
  22829. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22830. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22831. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22832. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22833. * @returns the VertexData of the IcoSphere
  22834. */
  22835. static CreateIcoSphere(options: {
  22836. radius?: number;
  22837. radiusX?: number;
  22838. radiusY?: number;
  22839. radiusZ?: number;
  22840. flat?: boolean;
  22841. subdivisions?: number;
  22842. sideOrientation?: number;
  22843. frontUVs?: Vector4;
  22844. backUVs?: Vector4;
  22845. }): VertexData;
  22846. /**
  22847. * Creates the VertexData for a Polyhedron
  22848. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22849. * * type provided types are:
  22850. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22851. * * 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)
  22852. * * size the size of the IcoSphere, optional default 1
  22853. * * sizeX allows stretching in the x direction, optional, default size
  22854. * * sizeY allows stretching in the y direction, optional, default size
  22855. * * sizeZ allows stretching in the z direction, optional, default size
  22856. * * 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
  22857. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22858. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22859. * * flat when true creates a flat shaded mesh, optional, default true
  22860. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22861. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22862. * * 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)
  22863. * * 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)
  22864. * @returns the VertexData of the Polyhedron
  22865. */
  22866. static CreatePolyhedron(options: {
  22867. type?: number;
  22868. size?: number;
  22869. sizeX?: number;
  22870. sizeY?: number;
  22871. sizeZ?: number;
  22872. custom?: any;
  22873. faceUV?: Vector4[];
  22874. faceColors?: Color4[];
  22875. flat?: boolean;
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for a TorusKnot
  22882. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22883. * * radius the radius of the torus knot, optional, default 2
  22884. * * tube the thickness of the tube, optional, default 0.5
  22885. * * radialSegments the number of sides on each tube segments, optional, default 32
  22886. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22887. * * p the number of windings around the z axis, optional, default 2
  22888. * * q the number of windings around the x axis, optional, default 3
  22889. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22890. * * 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)
  22891. * * 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)
  22892. * @returns the VertexData of the Torus Knot
  22893. */
  22894. static CreateTorusKnot(options: {
  22895. radius?: number;
  22896. tube?: number;
  22897. radialSegments?: number;
  22898. tubularSegments?: number;
  22899. p?: number;
  22900. q?: number;
  22901. sideOrientation?: number;
  22902. frontUVs?: Vector4;
  22903. backUVs?: Vector4;
  22904. }): VertexData;
  22905. /**
  22906. * Compute normals for given positions and indices
  22907. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22908. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22909. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22910. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22911. * * facetNormals : optional array of facet normals (vector3)
  22912. * * facetPositions : optional array of facet positions (vector3)
  22913. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22914. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22915. * * bInfo : optional bounding info, required for facetPartitioning computation
  22916. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22917. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22918. * * useRightHandedSystem: optional boolean to for right handed system computation
  22919. * * depthSort : optional boolean to enable the facet depth sort computation
  22920. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22921. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22922. */
  22923. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22924. facetNormals?: any;
  22925. facetPositions?: any;
  22926. facetPartitioning?: any;
  22927. ratio?: number;
  22928. bInfo?: any;
  22929. bbSize?: Vector3;
  22930. subDiv?: any;
  22931. useRightHandedSystem?: boolean;
  22932. depthSort?: boolean;
  22933. distanceTo?: Vector3;
  22934. depthSortedFacets?: any;
  22935. }): void;
  22936. /** @hidden */
  22937. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22938. /**
  22939. * Applies VertexData created from the imported parameters to the geometry
  22940. * @param parsedVertexData the parsed data from an imported file
  22941. * @param geometry the geometry to apply the VertexData to
  22942. */
  22943. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22944. }
  22945. }
  22946. declare module "babylonjs/Morph/morphTarget" {
  22947. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22948. import { Observable } from "babylonjs/Misc/observable";
  22949. import { Nullable, FloatArray } from "babylonjs/types";
  22950. import { Scene } from "babylonjs/scene";
  22951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22952. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22953. /**
  22954. * Defines a target to use with MorphTargetManager
  22955. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22956. */
  22957. export class MorphTarget implements IAnimatable {
  22958. /** defines the name of the target */
  22959. name: string;
  22960. /**
  22961. * Gets or sets the list of animations
  22962. */
  22963. animations: import("babylonjs/Animations/animation").Animation[];
  22964. private _scene;
  22965. private _positions;
  22966. private _normals;
  22967. private _tangents;
  22968. private _uvs;
  22969. private _influence;
  22970. private _uniqueId;
  22971. /**
  22972. * Observable raised when the influence changes
  22973. */
  22974. onInfluenceChanged: Observable<boolean>;
  22975. /** @hidden */
  22976. _onDataLayoutChanged: Observable<void>;
  22977. /**
  22978. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22979. */
  22980. influence: number;
  22981. /**
  22982. * Gets or sets the id of the morph Target
  22983. */
  22984. id: string;
  22985. private _animationPropertiesOverride;
  22986. /**
  22987. * Gets or sets the animation properties override
  22988. */
  22989. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22990. /**
  22991. * Creates a new MorphTarget
  22992. * @param name defines the name of the target
  22993. * @param influence defines the influence to use
  22994. * @param scene defines the scene the morphtarget belongs to
  22995. */
  22996. constructor(
  22997. /** defines the name of the target */
  22998. name: string, influence?: number, scene?: Nullable<Scene>);
  22999. /**
  23000. * Gets the unique ID of this manager
  23001. */
  23002. readonly uniqueId: number;
  23003. /**
  23004. * Gets a boolean defining if the target contains position data
  23005. */
  23006. readonly hasPositions: boolean;
  23007. /**
  23008. * Gets a boolean defining if the target contains normal data
  23009. */
  23010. readonly hasNormals: boolean;
  23011. /**
  23012. * Gets a boolean defining if the target contains tangent data
  23013. */
  23014. readonly hasTangents: boolean;
  23015. /**
  23016. * Gets a boolean defining if the target contains texture coordinates data
  23017. */
  23018. readonly hasUVs: boolean;
  23019. /**
  23020. * Affects position data to this target
  23021. * @param data defines the position data to use
  23022. */
  23023. setPositions(data: Nullable<FloatArray>): void;
  23024. /**
  23025. * Gets the position data stored in this target
  23026. * @returns a FloatArray containing the position data (or null if not present)
  23027. */
  23028. getPositions(): Nullable<FloatArray>;
  23029. /**
  23030. * Affects normal data to this target
  23031. * @param data defines the normal data to use
  23032. */
  23033. setNormals(data: Nullable<FloatArray>): void;
  23034. /**
  23035. * Gets the normal data stored in this target
  23036. * @returns a FloatArray containing the normal data (or null if not present)
  23037. */
  23038. getNormals(): Nullable<FloatArray>;
  23039. /**
  23040. * Affects tangent data to this target
  23041. * @param data defines the tangent data to use
  23042. */
  23043. setTangents(data: Nullable<FloatArray>): void;
  23044. /**
  23045. * Gets the tangent data stored in this target
  23046. * @returns a FloatArray containing the tangent data (or null if not present)
  23047. */
  23048. getTangents(): Nullable<FloatArray>;
  23049. /**
  23050. * Affects texture coordinates data to this target
  23051. * @param data defines the texture coordinates data to use
  23052. */
  23053. setUVs(data: Nullable<FloatArray>): void;
  23054. /**
  23055. * Gets the texture coordinates data stored in this target
  23056. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23057. */
  23058. getUVs(): Nullable<FloatArray>;
  23059. /**
  23060. * Clone the current target
  23061. * @returns a new MorphTarget
  23062. */
  23063. clone(): MorphTarget;
  23064. /**
  23065. * Serializes the current target into a Serialization object
  23066. * @returns the serialized object
  23067. */
  23068. serialize(): any;
  23069. /**
  23070. * Returns the string "MorphTarget"
  23071. * @returns "MorphTarget"
  23072. */
  23073. getClassName(): string;
  23074. /**
  23075. * Creates a new target from serialized data
  23076. * @param serializationObject defines the serialized data to use
  23077. * @returns a new MorphTarget
  23078. */
  23079. static Parse(serializationObject: any): MorphTarget;
  23080. /**
  23081. * Creates a MorphTarget from mesh data
  23082. * @param mesh defines the source mesh
  23083. * @param name defines the name to use for the new target
  23084. * @param influence defines the influence to attach to the target
  23085. * @returns a new MorphTarget
  23086. */
  23087. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23088. }
  23089. }
  23090. declare module "babylonjs/Morph/morphTargetManager" {
  23091. import { Nullable } from "babylonjs/types";
  23092. import { Scene } from "babylonjs/scene";
  23093. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23094. /**
  23095. * This class is used to deform meshes using morphing between different targets
  23096. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23097. */
  23098. export class MorphTargetManager {
  23099. private _targets;
  23100. private _targetInfluenceChangedObservers;
  23101. private _targetDataLayoutChangedObservers;
  23102. private _activeTargets;
  23103. private _scene;
  23104. private _influences;
  23105. private _supportsNormals;
  23106. private _supportsTangents;
  23107. private _supportsUVs;
  23108. private _vertexCount;
  23109. private _uniqueId;
  23110. private _tempInfluences;
  23111. /**
  23112. * Gets or sets a boolean indicating if normals must be morphed
  23113. */
  23114. enableNormalMorphing: boolean;
  23115. /**
  23116. * Gets or sets a boolean indicating if tangents must be morphed
  23117. */
  23118. enableTangentMorphing: boolean;
  23119. /**
  23120. * Gets or sets a boolean indicating if UV must be morphed
  23121. */
  23122. enableUVMorphing: boolean;
  23123. /**
  23124. * Creates a new MorphTargetManager
  23125. * @param scene defines the current scene
  23126. */
  23127. constructor(scene?: Nullable<Scene>);
  23128. /**
  23129. * Gets the unique ID of this manager
  23130. */
  23131. readonly uniqueId: number;
  23132. /**
  23133. * Gets the number of vertices handled by this manager
  23134. */
  23135. readonly vertexCount: number;
  23136. /**
  23137. * Gets a boolean indicating if this manager supports morphing of normals
  23138. */
  23139. readonly supportsNormals: boolean;
  23140. /**
  23141. * Gets a boolean indicating if this manager supports morphing of tangents
  23142. */
  23143. readonly supportsTangents: boolean;
  23144. /**
  23145. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23146. */
  23147. readonly supportsUVs: boolean;
  23148. /**
  23149. * Gets the number of targets stored in this manager
  23150. */
  23151. readonly numTargets: number;
  23152. /**
  23153. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23154. */
  23155. readonly numInfluencers: number;
  23156. /**
  23157. * Gets the list of influences (one per target)
  23158. */
  23159. readonly influences: Float32Array;
  23160. /**
  23161. * Gets the active target at specified index. An active target is a target with an influence > 0
  23162. * @param index defines the index to check
  23163. * @returns the requested target
  23164. */
  23165. getActiveTarget(index: number): MorphTarget;
  23166. /**
  23167. * Gets the target at specified index
  23168. * @param index defines the index to check
  23169. * @returns the requested target
  23170. */
  23171. getTarget(index: number): MorphTarget;
  23172. /**
  23173. * Add a new target to this manager
  23174. * @param target defines the target to add
  23175. */
  23176. addTarget(target: MorphTarget): void;
  23177. /**
  23178. * Removes a target from the manager
  23179. * @param target defines the target to remove
  23180. */
  23181. removeTarget(target: MorphTarget): void;
  23182. /**
  23183. * Clone the current manager
  23184. * @returns a new MorphTargetManager
  23185. */
  23186. clone(): MorphTargetManager;
  23187. /**
  23188. * Serializes the current manager into a Serialization object
  23189. * @returns the serialized object
  23190. */
  23191. serialize(): any;
  23192. private _syncActiveTargets;
  23193. /**
  23194. * Syncrhonize the targets with all the meshes using this morph target manager
  23195. */
  23196. synchronize(): void;
  23197. /**
  23198. * Creates a new MorphTargetManager from serialized data
  23199. * @param serializationObject defines the serialized data
  23200. * @param scene defines the hosting scene
  23201. * @returns the new MorphTargetManager
  23202. */
  23203. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23204. }
  23205. }
  23206. declare module "babylonjs/Meshes/meshLODLevel" {
  23207. import { Mesh } from "babylonjs/Meshes/mesh";
  23208. import { Nullable } from "babylonjs/types";
  23209. /**
  23210. * Class used to represent a specific level of detail of a mesh
  23211. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23212. */
  23213. export class MeshLODLevel {
  23214. /** Defines the distance where this level should start being displayed */
  23215. distance: number;
  23216. /** Defines the mesh to use to render this level */
  23217. mesh: Nullable<Mesh>;
  23218. /**
  23219. * Creates a new LOD level
  23220. * @param distance defines the distance where this level should star being displayed
  23221. * @param mesh defines the mesh to use to render this level
  23222. */
  23223. constructor(
  23224. /** Defines the distance where this level should start being displayed */
  23225. distance: number,
  23226. /** Defines the mesh to use to render this level */
  23227. mesh: Nullable<Mesh>);
  23228. }
  23229. }
  23230. declare module "babylonjs/Meshes/groundMesh" {
  23231. import { Scene } from "babylonjs/scene";
  23232. import { Vector3 } from "babylonjs/Maths/math.vector";
  23233. import { Mesh } from "babylonjs/Meshes/mesh";
  23234. /**
  23235. * Mesh representing the gorund
  23236. */
  23237. export class GroundMesh extends Mesh {
  23238. /** If octree should be generated */
  23239. generateOctree: boolean;
  23240. private _heightQuads;
  23241. /** @hidden */
  23242. _subdivisionsX: number;
  23243. /** @hidden */
  23244. _subdivisionsY: number;
  23245. /** @hidden */
  23246. _width: number;
  23247. /** @hidden */
  23248. _height: number;
  23249. /** @hidden */
  23250. _minX: number;
  23251. /** @hidden */
  23252. _maxX: number;
  23253. /** @hidden */
  23254. _minZ: number;
  23255. /** @hidden */
  23256. _maxZ: number;
  23257. constructor(name: string, scene: Scene);
  23258. /**
  23259. * "GroundMesh"
  23260. * @returns "GroundMesh"
  23261. */
  23262. getClassName(): string;
  23263. /**
  23264. * The minimum of x and y subdivisions
  23265. */
  23266. readonly subdivisions: number;
  23267. /**
  23268. * X subdivisions
  23269. */
  23270. readonly subdivisionsX: number;
  23271. /**
  23272. * Y subdivisions
  23273. */
  23274. readonly subdivisionsY: number;
  23275. /**
  23276. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23277. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23278. * @param chunksCount the number of subdivisions for x and y
  23279. * @param octreeBlocksSize (Default: 32)
  23280. */
  23281. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23282. /**
  23283. * Returns a height (y) value in the Worl system :
  23284. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23285. * @param x x coordinate
  23286. * @param z z coordinate
  23287. * @returns the ground y position if (x, z) are outside the ground surface.
  23288. */
  23289. getHeightAtCoordinates(x: number, z: number): number;
  23290. /**
  23291. * Returns a normalized vector (Vector3) orthogonal to the ground
  23292. * at the ground coordinates (x, z) expressed in the World system.
  23293. * @param x x coordinate
  23294. * @param z z coordinate
  23295. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23296. */
  23297. getNormalAtCoordinates(x: number, z: number): Vector3;
  23298. /**
  23299. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23300. * at the ground coordinates (x, z) expressed in the World system.
  23301. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23302. * @param x x coordinate
  23303. * @param z z coordinate
  23304. * @param ref vector to store the result
  23305. * @returns the GroundMesh.
  23306. */
  23307. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23308. /**
  23309. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23310. * if the ground has been updated.
  23311. * This can be used in the render loop.
  23312. * @returns the GroundMesh.
  23313. */
  23314. updateCoordinateHeights(): GroundMesh;
  23315. private _getFacetAt;
  23316. private _initHeightQuads;
  23317. private _computeHeightQuads;
  23318. /**
  23319. * Serializes this ground mesh
  23320. * @param serializationObject object to write serialization to
  23321. */
  23322. serialize(serializationObject: any): void;
  23323. /**
  23324. * Parses a serialized ground mesh
  23325. * @param parsedMesh the serialized mesh
  23326. * @param scene the scene to create the ground mesh in
  23327. * @returns the created ground mesh
  23328. */
  23329. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23330. }
  23331. }
  23332. declare module "babylonjs/Physics/physicsJoint" {
  23333. import { Vector3 } from "babylonjs/Maths/math.vector";
  23334. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23335. /**
  23336. * Interface for Physics-Joint data
  23337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23338. */
  23339. export interface PhysicsJointData {
  23340. /**
  23341. * The main pivot of the joint
  23342. */
  23343. mainPivot?: Vector3;
  23344. /**
  23345. * The connected pivot of the joint
  23346. */
  23347. connectedPivot?: Vector3;
  23348. /**
  23349. * The main axis of the joint
  23350. */
  23351. mainAxis?: Vector3;
  23352. /**
  23353. * The connected axis of the joint
  23354. */
  23355. connectedAxis?: Vector3;
  23356. /**
  23357. * The collision of the joint
  23358. */
  23359. collision?: boolean;
  23360. /**
  23361. * Native Oimo/Cannon/Energy data
  23362. */
  23363. nativeParams?: any;
  23364. }
  23365. /**
  23366. * This is a holder class for the physics joint created by the physics plugin
  23367. * It holds a set of functions to control the underlying joint
  23368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23369. */
  23370. export class PhysicsJoint {
  23371. /**
  23372. * The type of the physics joint
  23373. */
  23374. type: number;
  23375. /**
  23376. * The data for the physics joint
  23377. */
  23378. jointData: PhysicsJointData;
  23379. private _physicsJoint;
  23380. protected _physicsPlugin: IPhysicsEnginePlugin;
  23381. /**
  23382. * Initializes the physics joint
  23383. * @param type The type of the physics joint
  23384. * @param jointData The data for the physics joint
  23385. */
  23386. constructor(
  23387. /**
  23388. * The type of the physics joint
  23389. */
  23390. type: number,
  23391. /**
  23392. * The data for the physics joint
  23393. */
  23394. jointData: PhysicsJointData);
  23395. /**
  23396. * Gets the physics joint
  23397. */
  23398. /**
  23399. * Sets the physics joint
  23400. */
  23401. physicsJoint: any;
  23402. /**
  23403. * Sets the physics plugin
  23404. */
  23405. physicsPlugin: IPhysicsEnginePlugin;
  23406. /**
  23407. * Execute a function that is physics-plugin specific.
  23408. * @param {Function} func the function that will be executed.
  23409. * It accepts two parameters: the physics world and the physics joint
  23410. */
  23411. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23412. /**
  23413. * Distance-Joint type
  23414. */
  23415. static DistanceJoint: number;
  23416. /**
  23417. * Hinge-Joint type
  23418. */
  23419. static HingeJoint: number;
  23420. /**
  23421. * Ball-and-Socket joint type
  23422. */
  23423. static BallAndSocketJoint: number;
  23424. /**
  23425. * Wheel-Joint type
  23426. */
  23427. static WheelJoint: number;
  23428. /**
  23429. * Slider-Joint type
  23430. */
  23431. static SliderJoint: number;
  23432. /**
  23433. * Prismatic-Joint type
  23434. */
  23435. static PrismaticJoint: number;
  23436. /**
  23437. * Universal-Joint type
  23438. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23439. */
  23440. static UniversalJoint: number;
  23441. /**
  23442. * Hinge-Joint 2 type
  23443. */
  23444. static Hinge2Joint: number;
  23445. /**
  23446. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23447. */
  23448. static PointToPointJoint: number;
  23449. /**
  23450. * Spring-Joint type
  23451. */
  23452. static SpringJoint: number;
  23453. /**
  23454. * Lock-Joint type
  23455. */
  23456. static LockJoint: number;
  23457. }
  23458. /**
  23459. * A class representing a physics distance joint
  23460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23461. */
  23462. export class DistanceJoint extends PhysicsJoint {
  23463. /**
  23464. *
  23465. * @param jointData The data for the Distance-Joint
  23466. */
  23467. constructor(jointData: DistanceJointData);
  23468. /**
  23469. * Update the predefined distance.
  23470. * @param maxDistance The maximum preferred distance
  23471. * @param minDistance The minimum preferred distance
  23472. */
  23473. updateDistance(maxDistance: number, minDistance?: number): void;
  23474. }
  23475. /**
  23476. * Represents a Motor-Enabled Joint
  23477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23478. */
  23479. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23480. /**
  23481. * Initializes the Motor-Enabled Joint
  23482. * @param type The type of the joint
  23483. * @param jointData The physica joint data for the joint
  23484. */
  23485. constructor(type: number, jointData: PhysicsJointData);
  23486. /**
  23487. * Set the motor values.
  23488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23489. * @param force the force to apply
  23490. * @param maxForce max force for this motor.
  23491. */
  23492. setMotor(force?: number, maxForce?: number): void;
  23493. /**
  23494. * Set the motor's limits.
  23495. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23496. * @param upperLimit The upper limit of the motor
  23497. * @param lowerLimit The lower limit of the motor
  23498. */
  23499. setLimit(upperLimit: number, lowerLimit?: number): void;
  23500. }
  23501. /**
  23502. * This class represents a single physics Hinge-Joint
  23503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23504. */
  23505. export class HingeJoint extends MotorEnabledJoint {
  23506. /**
  23507. * Initializes the Hinge-Joint
  23508. * @param jointData The joint data for the Hinge-Joint
  23509. */
  23510. constructor(jointData: PhysicsJointData);
  23511. /**
  23512. * Set the motor values.
  23513. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23514. * @param {number} force the force to apply
  23515. * @param {number} maxForce max force for this motor.
  23516. */
  23517. setMotor(force?: number, maxForce?: number): void;
  23518. /**
  23519. * Set the motor's limits.
  23520. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23521. * @param upperLimit The upper limit of the motor
  23522. * @param lowerLimit The lower limit of the motor
  23523. */
  23524. setLimit(upperLimit: number, lowerLimit?: number): void;
  23525. }
  23526. /**
  23527. * This class represents a dual hinge physics joint (same as wheel joint)
  23528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23529. */
  23530. export class Hinge2Joint extends MotorEnabledJoint {
  23531. /**
  23532. * Initializes the Hinge2-Joint
  23533. * @param jointData The joint data for the Hinge2-Joint
  23534. */
  23535. constructor(jointData: PhysicsJointData);
  23536. /**
  23537. * Set the motor values.
  23538. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23539. * @param {number} targetSpeed the speed the motor is to reach
  23540. * @param {number} maxForce max force for this motor.
  23541. * @param {motorIndex} the motor's index, 0 or 1.
  23542. */
  23543. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23544. /**
  23545. * Set the motor limits.
  23546. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23547. * @param {number} upperLimit the upper limit
  23548. * @param {number} lowerLimit lower limit
  23549. * @param {motorIndex} the motor's index, 0 or 1.
  23550. */
  23551. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23552. }
  23553. /**
  23554. * Interface for a motor enabled joint
  23555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23556. */
  23557. export interface IMotorEnabledJoint {
  23558. /**
  23559. * Physics joint
  23560. */
  23561. physicsJoint: any;
  23562. /**
  23563. * Sets the motor of the motor-enabled joint
  23564. * @param force The force of the motor
  23565. * @param maxForce The maximum force of the motor
  23566. * @param motorIndex The index of the motor
  23567. */
  23568. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23569. /**
  23570. * Sets the limit of the motor
  23571. * @param upperLimit The upper limit of the motor
  23572. * @param lowerLimit The lower limit of the motor
  23573. * @param motorIndex The index of the motor
  23574. */
  23575. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23576. }
  23577. /**
  23578. * Joint data for a Distance-Joint
  23579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23580. */
  23581. export interface DistanceJointData extends PhysicsJointData {
  23582. /**
  23583. * Max distance the 2 joint objects can be apart
  23584. */
  23585. maxDistance: number;
  23586. }
  23587. /**
  23588. * Joint data from a spring joint
  23589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23590. */
  23591. export interface SpringJointData extends PhysicsJointData {
  23592. /**
  23593. * Length of the spring
  23594. */
  23595. length: number;
  23596. /**
  23597. * Stiffness of the spring
  23598. */
  23599. stiffness: number;
  23600. /**
  23601. * Damping of the spring
  23602. */
  23603. damping: number;
  23604. /** this callback will be called when applying the force to the impostors. */
  23605. forceApplicationCallback: () => void;
  23606. }
  23607. }
  23608. declare module "babylonjs/Physics/physicsRaycastResult" {
  23609. import { Vector3 } from "babylonjs/Maths/math.vector";
  23610. /**
  23611. * Holds the data for the raycast result
  23612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23613. */
  23614. export class PhysicsRaycastResult {
  23615. private _hasHit;
  23616. private _hitDistance;
  23617. private _hitNormalWorld;
  23618. private _hitPointWorld;
  23619. private _rayFromWorld;
  23620. private _rayToWorld;
  23621. /**
  23622. * Gets if there was a hit
  23623. */
  23624. readonly hasHit: boolean;
  23625. /**
  23626. * Gets the distance from the hit
  23627. */
  23628. readonly hitDistance: number;
  23629. /**
  23630. * Gets the hit normal/direction in the world
  23631. */
  23632. readonly hitNormalWorld: Vector3;
  23633. /**
  23634. * Gets the hit point in the world
  23635. */
  23636. readonly hitPointWorld: Vector3;
  23637. /**
  23638. * Gets the ray "start point" of the ray in the world
  23639. */
  23640. readonly rayFromWorld: Vector3;
  23641. /**
  23642. * Gets the ray "end point" of the ray in the world
  23643. */
  23644. readonly rayToWorld: Vector3;
  23645. /**
  23646. * Sets the hit data (normal & point in world space)
  23647. * @param hitNormalWorld defines the normal in world space
  23648. * @param hitPointWorld defines the point in world space
  23649. */
  23650. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23651. /**
  23652. * Sets the distance from the start point to the hit point
  23653. * @param distance
  23654. */
  23655. setHitDistance(distance: number): void;
  23656. /**
  23657. * Calculates the distance manually
  23658. */
  23659. calculateHitDistance(): void;
  23660. /**
  23661. * Resets all the values to default
  23662. * @param from The from point on world space
  23663. * @param to The to point on world space
  23664. */
  23665. reset(from?: Vector3, to?: Vector3): void;
  23666. }
  23667. /**
  23668. * Interface for the size containing width and height
  23669. */
  23670. interface IXYZ {
  23671. /**
  23672. * X
  23673. */
  23674. x: number;
  23675. /**
  23676. * Y
  23677. */
  23678. y: number;
  23679. /**
  23680. * Z
  23681. */
  23682. z: number;
  23683. }
  23684. }
  23685. declare module "babylonjs/Physics/IPhysicsEngine" {
  23686. import { Nullable } from "babylonjs/types";
  23687. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23689. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23690. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23691. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23692. /**
  23693. * Interface used to describe a physics joint
  23694. */
  23695. export interface PhysicsImpostorJoint {
  23696. /** Defines the main impostor to which the joint is linked */
  23697. mainImpostor: PhysicsImpostor;
  23698. /** Defines the impostor that is connected to the main impostor using this joint */
  23699. connectedImpostor: PhysicsImpostor;
  23700. /** Defines the joint itself */
  23701. joint: PhysicsJoint;
  23702. }
  23703. /** @hidden */
  23704. export interface IPhysicsEnginePlugin {
  23705. world: any;
  23706. name: string;
  23707. setGravity(gravity: Vector3): void;
  23708. setTimeStep(timeStep: number): void;
  23709. getTimeStep(): number;
  23710. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23712. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23713. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23714. removePhysicsBody(impostor: PhysicsImpostor): void;
  23715. generateJoint(joint: PhysicsImpostorJoint): void;
  23716. removeJoint(joint: PhysicsImpostorJoint): void;
  23717. isSupported(): boolean;
  23718. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23719. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23720. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23721. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23722. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23723. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23724. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23725. getBodyMass(impostor: PhysicsImpostor): number;
  23726. getBodyFriction(impostor: PhysicsImpostor): number;
  23727. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23728. getBodyRestitution(impostor: PhysicsImpostor): number;
  23729. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23730. getBodyPressure?(impostor: PhysicsImpostor): number;
  23731. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23732. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23733. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23734. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23735. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23736. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23737. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23738. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23739. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23740. sleepBody(impostor: PhysicsImpostor): void;
  23741. wakeUpBody(impostor: PhysicsImpostor): void;
  23742. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23744. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23745. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23746. getRadius(impostor: PhysicsImpostor): number;
  23747. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23748. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23749. dispose(): void;
  23750. }
  23751. /**
  23752. * Interface used to define a physics engine
  23753. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23754. */
  23755. export interface IPhysicsEngine {
  23756. /**
  23757. * Gets the gravity vector used by the simulation
  23758. */
  23759. gravity: Vector3;
  23760. /**
  23761. * Sets the gravity vector used by the simulation
  23762. * @param gravity defines the gravity vector to use
  23763. */
  23764. setGravity(gravity: Vector3): void;
  23765. /**
  23766. * Set the time step of the physics engine.
  23767. * Default is 1/60.
  23768. * To slow it down, enter 1/600 for example.
  23769. * To speed it up, 1/30
  23770. * @param newTimeStep the new timestep to apply to this world.
  23771. */
  23772. setTimeStep(newTimeStep: number): void;
  23773. /**
  23774. * Get the time step of the physics engine.
  23775. * @returns the current time step
  23776. */
  23777. getTimeStep(): number;
  23778. /**
  23779. * Set the sub time step of the physics engine.
  23780. * Default is 0 meaning there is no sub steps
  23781. * To increase physics resolution precision, set a small value (like 1 ms)
  23782. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23783. */
  23784. setSubTimeStep(subTimeStep: number): void;
  23785. /**
  23786. * Get the sub time step of the physics engine.
  23787. * @returns the current sub time step
  23788. */
  23789. getSubTimeStep(): number;
  23790. /**
  23791. * Release all resources
  23792. */
  23793. dispose(): void;
  23794. /**
  23795. * Gets the name of the current physics plugin
  23796. * @returns the name of the plugin
  23797. */
  23798. getPhysicsPluginName(): string;
  23799. /**
  23800. * Adding a new impostor for the impostor tracking.
  23801. * This will be done by the impostor itself.
  23802. * @param impostor the impostor to add
  23803. */
  23804. addImpostor(impostor: PhysicsImpostor): void;
  23805. /**
  23806. * Remove an impostor from the engine.
  23807. * This impostor and its mesh will not longer be updated by the physics engine.
  23808. * @param impostor the impostor to remove
  23809. */
  23810. removeImpostor(impostor: PhysicsImpostor): void;
  23811. /**
  23812. * Add a joint to the physics engine
  23813. * @param mainImpostor defines the main impostor to which the joint is added.
  23814. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23815. * @param joint defines the joint that will connect both impostors.
  23816. */
  23817. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23818. /**
  23819. * Removes a joint from the simulation
  23820. * @param mainImpostor defines the impostor used with the joint
  23821. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23822. * @param joint defines the joint to remove
  23823. */
  23824. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23825. /**
  23826. * Gets the current plugin used to run the simulation
  23827. * @returns current plugin
  23828. */
  23829. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23830. /**
  23831. * Gets the list of physic impostors
  23832. * @returns an array of PhysicsImpostor
  23833. */
  23834. getImpostors(): Array<PhysicsImpostor>;
  23835. /**
  23836. * Gets the impostor for a physics enabled object
  23837. * @param object defines the object impersonated by the impostor
  23838. * @returns the PhysicsImpostor or null if not found
  23839. */
  23840. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23841. /**
  23842. * Gets the impostor for a physics body object
  23843. * @param body defines physics body used by the impostor
  23844. * @returns the PhysicsImpostor or null if not found
  23845. */
  23846. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23847. /**
  23848. * Does a raycast in the physics world
  23849. * @param from when should the ray start?
  23850. * @param to when should the ray end?
  23851. * @returns PhysicsRaycastResult
  23852. */
  23853. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23854. /**
  23855. * Called by the scene. No need to call it.
  23856. * @param delta defines the timespam between frames
  23857. */
  23858. _step(delta: number): void;
  23859. }
  23860. }
  23861. declare module "babylonjs/Physics/physicsImpostor" {
  23862. import { Nullable, IndicesArray } from "babylonjs/types";
  23863. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23864. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23866. import { Scene } from "babylonjs/scene";
  23867. import { Bone } from "babylonjs/Bones/bone";
  23868. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23869. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23870. import { Space } from "babylonjs/Maths/math.axis";
  23871. /**
  23872. * The interface for the physics imposter parameters
  23873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23874. */
  23875. export interface PhysicsImpostorParameters {
  23876. /**
  23877. * The mass of the physics imposter
  23878. */
  23879. mass: number;
  23880. /**
  23881. * The friction of the physics imposter
  23882. */
  23883. friction?: number;
  23884. /**
  23885. * The coefficient of restitution of the physics imposter
  23886. */
  23887. restitution?: number;
  23888. /**
  23889. * The native options of the physics imposter
  23890. */
  23891. nativeOptions?: any;
  23892. /**
  23893. * Specifies if the parent should be ignored
  23894. */
  23895. ignoreParent?: boolean;
  23896. /**
  23897. * Specifies if bi-directional transformations should be disabled
  23898. */
  23899. disableBidirectionalTransformation?: boolean;
  23900. /**
  23901. * The pressure inside the physics imposter, soft object only
  23902. */
  23903. pressure?: number;
  23904. /**
  23905. * The stiffness the physics imposter, soft object only
  23906. */
  23907. stiffness?: number;
  23908. /**
  23909. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23910. */
  23911. velocityIterations?: number;
  23912. /**
  23913. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23914. */
  23915. positionIterations?: number;
  23916. /**
  23917. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23918. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23919. * Add to fix multiple points
  23920. */
  23921. fixedPoints?: number;
  23922. /**
  23923. * The collision margin around a soft object
  23924. */
  23925. margin?: number;
  23926. /**
  23927. * The collision margin around a soft object
  23928. */
  23929. damping?: number;
  23930. /**
  23931. * The path for a rope based on an extrusion
  23932. */
  23933. path?: any;
  23934. /**
  23935. * The shape of an extrusion used for a rope based on an extrusion
  23936. */
  23937. shape?: any;
  23938. }
  23939. /**
  23940. * Interface for a physics-enabled object
  23941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23942. */
  23943. export interface IPhysicsEnabledObject {
  23944. /**
  23945. * The position of the physics-enabled object
  23946. */
  23947. position: Vector3;
  23948. /**
  23949. * The rotation of the physics-enabled object
  23950. */
  23951. rotationQuaternion: Nullable<Quaternion>;
  23952. /**
  23953. * The scale of the physics-enabled object
  23954. */
  23955. scaling: Vector3;
  23956. /**
  23957. * The rotation of the physics-enabled object
  23958. */
  23959. rotation?: Vector3;
  23960. /**
  23961. * The parent of the physics-enabled object
  23962. */
  23963. parent?: any;
  23964. /**
  23965. * The bounding info of the physics-enabled object
  23966. * @returns The bounding info of the physics-enabled object
  23967. */
  23968. getBoundingInfo(): BoundingInfo;
  23969. /**
  23970. * Computes the world matrix
  23971. * @param force Specifies if the world matrix should be computed by force
  23972. * @returns A world matrix
  23973. */
  23974. computeWorldMatrix(force: boolean): Matrix;
  23975. /**
  23976. * Gets the world matrix
  23977. * @returns A world matrix
  23978. */
  23979. getWorldMatrix?(): Matrix;
  23980. /**
  23981. * Gets the child meshes
  23982. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23983. * @returns An array of abstract meshes
  23984. */
  23985. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23986. /**
  23987. * Gets the vertex data
  23988. * @param kind The type of vertex data
  23989. * @returns A nullable array of numbers, or a float32 array
  23990. */
  23991. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23992. /**
  23993. * Gets the indices from the mesh
  23994. * @returns A nullable array of index arrays
  23995. */
  23996. getIndices?(): Nullable<IndicesArray>;
  23997. /**
  23998. * Gets the scene from the mesh
  23999. * @returns the indices array or null
  24000. */
  24001. getScene?(): Scene;
  24002. /**
  24003. * Gets the absolute position from the mesh
  24004. * @returns the absolute position
  24005. */
  24006. getAbsolutePosition(): Vector3;
  24007. /**
  24008. * Gets the absolute pivot point from the mesh
  24009. * @returns the absolute pivot point
  24010. */
  24011. getAbsolutePivotPoint(): Vector3;
  24012. /**
  24013. * Rotates the mesh
  24014. * @param axis The axis of rotation
  24015. * @param amount The amount of rotation
  24016. * @param space The space of the rotation
  24017. * @returns The rotation transform node
  24018. */
  24019. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24020. /**
  24021. * Translates the mesh
  24022. * @param axis The axis of translation
  24023. * @param distance The distance of translation
  24024. * @param space The space of the translation
  24025. * @returns The transform node
  24026. */
  24027. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24028. /**
  24029. * Sets the absolute position of the mesh
  24030. * @param absolutePosition The absolute position of the mesh
  24031. * @returns The transform node
  24032. */
  24033. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24034. /**
  24035. * Gets the class name of the mesh
  24036. * @returns The class name
  24037. */
  24038. getClassName(): string;
  24039. }
  24040. /**
  24041. * Represents a physics imposter
  24042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24043. */
  24044. export class PhysicsImpostor {
  24045. /**
  24046. * The physics-enabled object used as the physics imposter
  24047. */
  24048. object: IPhysicsEnabledObject;
  24049. /**
  24050. * The type of the physics imposter
  24051. */
  24052. type: number;
  24053. private _options;
  24054. private _scene?;
  24055. /**
  24056. * The default object size of the imposter
  24057. */
  24058. static DEFAULT_OBJECT_SIZE: Vector3;
  24059. /**
  24060. * The identity quaternion of the imposter
  24061. */
  24062. static IDENTITY_QUATERNION: Quaternion;
  24063. /** @hidden */
  24064. _pluginData: any;
  24065. private _physicsEngine;
  24066. private _physicsBody;
  24067. private _bodyUpdateRequired;
  24068. private _onBeforePhysicsStepCallbacks;
  24069. private _onAfterPhysicsStepCallbacks;
  24070. /** @hidden */
  24071. _onPhysicsCollideCallbacks: Array<{
  24072. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24073. otherImpostors: Array<PhysicsImpostor>;
  24074. }>;
  24075. private _deltaPosition;
  24076. private _deltaRotation;
  24077. private _deltaRotationConjugated;
  24078. /** @hidden */
  24079. _isFromLine: boolean;
  24080. private _parent;
  24081. private _isDisposed;
  24082. private static _tmpVecs;
  24083. private static _tmpQuat;
  24084. /**
  24085. * Specifies if the physics imposter is disposed
  24086. */
  24087. readonly isDisposed: boolean;
  24088. /**
  24089. * Gets the mass of the physics imposter
  24090. */
  24091. mass: number;
  24092. /**
  24093. * Gets the coefficient of friction
  24094. */
  24095. /**
  24096. * Sets the coefficient of friction
  24097. */
  24098. friction: number;
  24099. /**
  24100. * Gets the coefficient of restitution
  24101. */
  24102. /**
  24103. * Sets the coefficient of restitution
  24104. */
  24105. restitution: number;
  24106. /**
  24107. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24108. */
  24109. /**
  24110. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24111. */
  24112. pressure: number;
  24113. /**
  24114. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24115. */
  24116. /**
  24117. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24118. */
  24119. stiffness: number;
  24120. /**
  24121. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24122. */
  24123. /**
  24124. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24125. */
  24126. velocityIterations: number;
  24127. /**
  24128. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24129. */
  24130. /**
  24131. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24132. */
  24133. positionIterations: number;
  24134. /**
  24135. * The unique id of the physics imposter
  24136. * set by the physics engine when adding this impostor to the array
  24137. */
  24138. uniqueId: number;
  24139. /**
  24140. * @hidden
  24141. */
  24142. soft: boolean;
  24143. /**
  24144. * @hidden
  24145. */
  24146. segments: number;
  24147. private _joints;
  24148. /**
  24149. * Initializes the physics imposter
  24150. * @param object The physics-enabled object used as the physics imposter
  24151. * @param type The type of the physics imposter
  24152. * @param _options The options for the physics imposter
  24153. * @param _scene The Babylon scene
  24154. */
  24155. constructor(
  24156. /**
  24157. * The physics-enabled object used as the physics imposter
  24158. */
  24159. object: IPhysicsEnabledObject,
  24160. /**
  24161. * The type of the physics imposter
  24162. */
  24163. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24164. /**
  24165. * This function will completly initialize this impostor.
  24166. * It will create a new body - but only if this mesh has no parent.
  24167. * If it has, this impostor will not be used other than to define the impostor
  24168. * of the child mesh.
  24169. * @hidden
  24170. */
  24171. _init(): void;
  24172. private _getPhysicsParent;
  24173. /**
  24174. * Should a new body be generated.
  24175. * @returns boolean specifying if body initialization is required
  24176. */
  24177. isBodyInitRequired(): boolean;
  24178. /**
  24179. * Sets the updated scaling
  24180. * @param updated Specifies if the scaling is updated
  24181. */
  24182. setScalingUpdated(): void;
  24183. /**
  24184. * Force a regeneration of this or the parent's impostor's body.
  24185. * Use under cautious - This will remove all joints already implemented.
  24186. */
  24187. forceUpdate(): void;
  24188. /**
  24189. * Gets the body that holds this impostor. Either its own, or its parent.
  24190. */
  24191. /**
  24192. * Set the physics body. Used mainly by the physics engine/plugin
  24193. */
  24194. physicsBody: any;
  24195. /**
  24196. * Get the parent of the physics imposter
  24197. * @returns Physics imposter or null
  24198. */
  24199. /**
  24200. * Sets the parent of the physics imposter
  24201. */
  24202. parent: Nullable<PhysicsImpostor>;
  24203. /**
  24204. * Resets the update flags
  24205. */
  24206. resetUpdateFlags(): void;
  24207. /**
  24208. * Gets the object extend size
  24209. * @returns the object extend size
  24210. */
  24211. getObjectExtendSize(): Vector3;
  24212. /**
  24213. * Gets the object center
  24214. * @returns The object center
  24215. */
  24216. getObjectCenter(): Vector3;
  24217. /**
  24218. * Get a specific parametes from the options parameter
  24219. * @param paramName The object parameter name
  24220. * @returns The object parameter
  24221. */
  24222. getParam(paramName: string): any;
  24223. /**
  24224. * Sets a specific parameter in the options given to the physics plugin
  24225. * @param paramName The parameter name
  24226. * @param value The value of the parameter
  24227. */
  24228. setParam(paramName: string, value: number): void;
  24229. /**
  24230. * Specifically change the body's mass option. Won't recreate the physics body object
  24231. * @param mass The mass of the physics imposter
  24232. */
  24233. setMass(mass: number): void;
  24234. /**
  24235. * Gets the linear velocity
  24236. * @returns linear velocity or null
  24237. */
  24238. getLinearVelocity(): Nullable<Vector3>;
  24239. /**
  24240. * Sets the linear velocity
  24241. * @param velocity linear velocity or null
  24242. */
  24243. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24244. /**
  24245. * Gets the angular velocity
  24246. * @returns angular velocity or null
  24247. */
  24248. getAngularVelocity(): Nullable<Vector3>;
  24249. /**
  24250. * Sets the angular velocity
  24251. * @param velocity The velocity or null
  24252. */
  24253. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24254. /**
  24255. * Execute a function with the physics plugin native code
  24256. * Provide a function the will have two variables - the world object and the physics body object
  24257. * @param func The function to execute with the physics plugin native code
  24258. */
  24259. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24260. /**
  24261. * Register a function that will be executed before the physics world is stepping forward
  24262. * @param func The function to execute before the physics world is stepped forward
  24263. */
  24264. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24265. /**
  24266. * Unregister a function that will be executed before the physics world is stepping forward
  24267. * @param func The function to execute before the physics world is stepped forward
  24268. */
  24269. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24270. /**
  24271. * Register a function that will be executed after the physics step
  24272. * @param func The function to execute after physics step
  24273. */
  24274. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24275. /**
  24276. * Unregisters a function that will be executed after the physics step
  24277. * @param func The function to execute after physics step
  24278. */
  24279. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24280. /**
  24281. * register a function that will be executed when this impostor collides against a different body
  24282. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24283. * @param func Callback that is executed on collision
  24284. */
  24285. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24286. /**
  24287. * Unregisters the physics imposter on contact
  24288. * @param collideAgainst The physics object to collide against
  24289. * @param func Callback to execute on collision
  24290. */
  24291. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24292. private _tmpQuat;
  24293. private _tmpQuat2;
  24294. /**
  24295. * Get the parent rotation
  24296. * @returns The parent rotation
  24297. */
  24298. getParentsRotation(): Quaternion;
  24299. /**
  24300. * this function is executed by the physics engine.
  24301. */
  24302. beforeStep: () => void;
  24303. /**
  24304. * this function is executed by the physics engine
  24305. */
  24306. afterStep: () => void;
  24307. /**
  24308. * Legacy collision detection event support
  24309. */
  24310. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24311. /**
  24312. * event and body object due to cannon's event-based architecture.
  24313. */
  24314. onCollide: (e: {
  24315. body: any;
  24316. }) => void;
  24317. /**
  24318. * Apply a force
  24319. * @param force The force to apply
  24320. * @param contactPoint The contact point for the force
  24321. * @returns The physics imposter
  24322. */
  24323. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24324. /**
  24325. * Apply an impulse
  24326. * @param force The impulse force
  24327. * @param contactPoint The contact point for the impulse force
  24328. * @returns The physics imposter
  24329. */
  24330. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24331. /**
  24332. * A help function to create a joint
  24333. * @param otherImpostor A physics imposter used to create a joint
  24334. * @param jointType The type of joint
  24335. * @param jointData The data for the joint
  24336. * @returns The physics imposter
  24337. */
  24338. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24339. /**
  24340. * Add a joint to this impostor with a different impostor
  24341. * @param otherImpostor A physics imposter used to add a joint
  24342. * @param joint The joint to add
  24343. * @returns The physics imposter
  24344. */
  24345. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24346. /**
  24347. * Add an anchor to a cloth impostor
  24348. * @param otherImpostor rigid impostor to anchor to
  24349. * @param width ratio across width from 0 to 1
  24350. * @param height ratio up height from 0 to 1
  24351. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24352. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24353. * @returns impostor the soft imposter
  24354. */
  24355. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24356. /**
  24357. * Add a hook to a rope impostor
  24358. * @param otherImpostor rigid impostor to anchor to
  24359. * @param length ratio across rope from 0 to 1
  24360. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24361. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24362. * @returns impostor the rope imposter
  24363. */
  24364. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24365. /**
  24366. * Will keep this body still, in a sleep mode.
  24367. * @returns the physics imposter
  24368. */
  24369. sleep(): PhysicsImpostor;
  24370. /**
  24371. * Wake the body up.
  24372. * @returns The physics imposter
  24373. */
  24374. wakeUp(): PhysicsImpostor;
  24375. /**
  24376. * Clones the physics imposter
  24377. * @param newObject The physics imposter clones to this physics-enabled object
  24378. * @returns A nullable physics imposter
  24379. */
  24380. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24381. /**
  24382. * Disposes the physics imposter
  24383. */
  24384. dispose(): void;
  24385. /**
  24386. * Sets the delta position
  24387. * @param position The delta position amount
  24388. */
  24389. setDeltaPosition(position: Vector3): void;
  24390. /**
  24391. * Sets the delta rotation
  24392. * @param rotation The delta rotation amount
  24393. */
  24394. setDeltaRotation(rotation: Quaternion): void;
  24395. /**
  24396. * Gets the box size of the physics imposter and stores the result in the input parameter
  24397. * @param result Stores the box size
  24398. * @returns The physics imposter
  24399. */
  24400. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24401. /**
  24402. * Gets the radius of the physics imposter
  24403. * @returns Radius of the physics imposter
  24404. */
  24405. getRadius(): number;
  24406. /**
  24407. * Sync a bone with this impostor
  24408. * @param bone The bone to sync to the impostor.
  24409. * @param boneMesh The mesh that the bone is influencing.
  24410. * @param jointPivot The pivot of the joint / bone in local space.
  24411. * @param distToJoint Optional distance from the impostor to the joint.
  24412. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24413. */
  24414. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24415. /**
  24416. * Sync impostor to a bone
  24417. * @param bone The bone that the impostor will be synced to.
  24418. * @param boneMesh The mesh that the bone is influencing.
  24419. * @param jointPivot The pivot of the joint / bone in local space.
  24420. * @param distToJoint Optional distance from the impostor to the joint.
  24421. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24422. * @param boneAxis Optional vector3 axis the bone is aligned with
  24423. */
  24424. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24425. /**
  24426. * No-Imposter type
  24427. */
  24428. static NoImpostor: number;
  24429. /**
  24430. * Sphere-Imposter type
  24431. */
  24432. static SphereImpostor: number;
  24433. /**
  24434. * Box-Imposter type
  24435. */
  24436. static BoxImpostor: number;
  24437. /**
  24438. * Plane-Imposter type
  24439. */
  24440. static PlaneImpostor: number;
  24441. /**
  24442. * Mesh-imposter type
  24443. */
  24444. static MeshImpostor: number;
  24445. /**
  24446. * Capsule-Impostor type (Ammo.js plugin only)
  24447. */
  24448. static CapsuleImpostor: number;
  24449. /**
  24450. * Cylinder-Imposter type
  24451. */
  24452. static CylinderImpostor: number;
  24453. /**
  24454. * Particle-Imposter type
  24455. */
  24456. static ParticleImpostor: number;
  24457. /**
  24458. * Heightmap-Imposter type
  24459. */
  24460. static HeightmapImpostor: number;
  24461. /**
  24462. * ConvexHull-Impostor type (Ammo.js plugin only)
  24463. */
  24464. static ConvexHullImpostor: number;
  24465. /**
  24466. * Custom-Imposter type (Ammo.js plugin only)
  24467. */
  24468. static CustomImpostor: number;
  24469. /**
  24470. * Rope-Imposter type
  24471. */
  24472. static RopeImpostor: number;
  24473. /**
  24474. * Cloth-Imposter type
  24475. */
  24476. static ClothImpostor: number;
  24477. /**
  24478. * Softbody-Imposter type
  24479. */
  24480. static SoftbodyImpostor: number;
  24481. }
  24482. }
  24483. declare module "babylonjs/Meshes/mesh" {
  24484. import { Observable } from "babylonjs/Misc/observable";
  24485. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24486. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24487. import { Camera } from "babylonjs/Cameras/camera";
  24488. import { Scene } from "babylonjs/scene";
  24489. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24490. import { Color4 } from "babylonjs/Maths/math.color";
  24491. import { Engine } from "babylonjs/Engines/engine";
  24492. import { Node } from "babylonjs/node";
  24493. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24494. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24495. import { Buffer } from "babylonjs/Meshes/buffer";
  24496. import { Geometry } from "babylonjs/Meshes/geometry";
  24497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24499. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24500. import { Effect } from "babylonjs/Materials/effect";
  24501. import { Material } from "babylonjs/Materials/material";
  24502. import { Skeleton } from "babylonjs/Bones/skeleton";
  24503. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24504. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24505. import { Path3D } from "babylonjs/Maths/math.path";
  24506. import { Plane } from "babylonjs/Maths/math.plane";
  24507. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24508. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24509. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24510. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24511. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24513. /**
  24514. * @hidden
  24515. **/
  24516. export class _CreationDataStorage {
  24517. closePath?: boolean;
  24518. closeArray?: boolean;
  24519. idx: number[];
  24520. dashSize: number;
  24521. gapSize: number;
  24522. path3D: Path3D;
  24523. pathArray: Vector3[][];
  24524. arc: number;
  24525. radius: number;
  24526. cap: number;
  24527. tessellation: number;
  24528. }
  24529. /**
  24530. * @hidden
  24531. **/
  24532. class _InstanceDataStorage {
  24533. visibleInstances: any;
  24534. batchCache: _InstancesBatch;
  24535. instancesBufferSize: number;
  24536. instancesBuffer: Nullable<Buffer>;
  24537. instancesData: Float32Array;
  24538. overridenInstanceCount: number;
  24539. isFrozen: boolean;
  24540. previousBatch: Nullable<_InstancesBatch>;
  24541. hardwareInstancedRendering: boolean;
  24542. sideOrientation: number;
  24543. manualUpdate: boolean;
  24544. }
  24545. /**
  24546. * @hidden
  24547. **/
  24548. export class _InstancesBatch {
  24549. mustReturn: boolean;
  24550. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24551. renderSelf: boolean[];
  24552. hardwareInstancedRendering: boolean[];
  24553. }
  24554. /**
  24555. * Class used to represent renderable models
  24556. */
  24557. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24558. /**
  24559. * Mesh side orientation : usually the external or front surface
  24560. */
  24561. static readonly FRONTSIDE: number;
  24562. /**
  24563. * Mesh side orientation : usually the internal or back surface
  24564. */
  24565. static readonly BACKSIDE: number;
  24566. /**
  24567. * Mesh side orientation : both internal and external or front and back surfaces
  24568. */
  24569. static readonly DOUBLESIDE: number;
  24570. /**
  24571. * Mesh side orientation : by default, `FRONTSIDE`
  24572. */
  24573. static readonly DEFAULTSIDE: number;
  24574. /**
  24575. * Mesh cap setting : no cap
  24576. */
  24577. static readonly NO_CAP: number;
  24578. /**
  24579. * Mesh cap setting : one cap at the beginning of the mesh
  24580. */
  24581. static readonly CAP_START: number;
  24582. /**
  24583. * Mesh cap setting : one cap at the end of the mesh
  24584. */
  24585. static readonly CAP_END: number;
  24586. /**
  24587. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24588. */
  24589. static readonly CAP_ALL: number;
  24590. /**
  24591. * Mesh pattern setting : no flip or rotate
  24592. */
  24593. static readonly NO_FLIP: number;
  24594. /**
  24595. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24596. */
  24597. static readonly FLIP_TILE: number;
  24598. /**
  24599. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24600. */
  24601. static readonly ROTATE_TILE: number;
  24602. /**
  24603. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24604. */
  24605. static readonly FLIP_ROW: number;
  24606. /**
  24607. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24608. */
  24609. static readonly ROTATE_ROW: number;
  24610. /**
  24611. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24612. */
  24613. static readonly FLIP_N_ROTATE_TILE: number;
  24614. /**
  24615. * Mesh pattern setting : rotate pattern and rotate
  24616. */
  24617. static readonly FLIP_N_ROTATE_ROW: number;
  24618. /**
  24619. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24620. */
  24621. static readonly CENTER: number;
  24622. /**
  24623. * Mesh tile positioning : part tiles on left
  24624. */
  24625. static readonly LEFT: number;
  24626. /**
  24627. * Mesh tile positioning : part tiles on right
  24628. */
  24629. static readonly RIGHT: number;
  24630. /**
  24631. * Mesh tile positioning : part tiles on top
  24632. */
  24633. static readonly TOP: number;
  24634. /**
  24635. * Mesh tile positioning : part tiles on bottom
  24636. */
  24637. static readonly BOTTOM: number;
  24638. /**
  24639. * Gets the default side orientation.
  24640. * @param orientation the orientation to value to attempt to get
  24641. * @returns the default orientation
  24642. * @hidden
  24643. */
  24644. static _GetDefaultSideOrientation(orientation?: number): number;
  24645. private _internalMeshDataInfo;
  24646. /**
  24647. * An event triggered before rendering the mesh
  24648. */
  24649. readonly onBeforeRenderObservable: Observable<Mesh>;
  24650. /**
  24651. * An event triggered before binding the mesh
  24652. */
  24653. readonly onBeforeBindObservable: Observable<Mesh>;
  24654. /**
  24655. * An event triggered after rendering the mesh
  24656. */
  24657. readonly onAfterRenderObservable: Observable<Mesh>;
  24658. /**
  24659. * An event triggered before drawing the mesh
  24660. */
  24661. readonly onBeforeDrawObservable: Observable<Mesh>;
  24662. private _onBeforeDrawObserver;
  24663. /**
  24664. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24665. */
  24666. onBeforeDraw: () => void;
  24667. readonly hasInstances: boolean;
  24668. /**
  24669. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24670. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24671. */
  24672. delayLoadState: number;
  24673. /**
  24674. * Gets the list of instances created from this mesh
  24675. * it is not supposed to be modified manually.
  24676. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24677. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24678. */
  24679. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24680. /**
  24681. * Gets the file containing delay loading data for this mesh
  24682. */
  24683. delayLoadingFile: string;
  24684. /** @hidden */
  24685. _binaryInfo: any;
  24686. /**
  24687. * User defined function used to change how LOD level selection is done
  24688. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24689. */
  24690. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24691. /**
  24692. * Gets or sets the morph target manager
  24693. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24694. */
  24695. morphTargetManager: Nullable<MorphTargetManager>;
  24696. /** @hidden */
  24697. _creationDataStorage: Nullable<_CreationDataStorage>;
  24698. /** @hidden */
  24699. _geometry: Nullable<Geometry>;
  24700. /** @hidden */
  24701. _delayInfo: Array<string>;
  24702. /** @hidden */
  24703. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24704. /** @hidden */
  24705. _instanceDataStorage: _InstanceDataStorage;
  24706. private _effectiveMaterial;
  24707. /** @hidden */
  24708. _shouldGenerateFlatShading: boolean;
  24709. /** @hidden */
  24710. _originalBuilderSideOrientation: number;
  24711. /**
  24712. * Use this property to change the original side orientation defined at construction time
  24713. */
  24714. overrideMaterialSideOrientation: Nullable<number>;
  24715. /**
  24716. * Gets the source mesh (the one used to clone this one from)
  24717. */
  24718. readonly source: Nullable<Mesh>;
  24719. /**
  24720. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24721. */
  24722. isUnIndexed: boolean;
  24723. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24724. readonly worldMatrixInstancedBuffer: Float32Array;
  24725. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24726. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24727. /**
  24728. * @constructor
  24729. * @param name The value used by scene.getMeshByName() to do a lookup.
  24730. * @param scene The scene to add this mesh to.
  24731. * @param parent The parent of this mesh, if it has one
  24732. * @param source An optional Mesh from which geometry is shared, cloned.
  24733. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24734. * When false, achieved by calling a clone(), also passing False.
  24735. * This will make creation of children, recursive.
  24736. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24737. */
  24738. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24739. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24740. doNotInstantiate: boolean;
  24741. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24742. /**
  24743. * Gets the class name
  24744. * @returns the string "Mesh".
  24745. */
  24746. getClassName(): string;
  24747. /** @hidden */
  24748. readonly _isMesh: boolean;
  24749. /**
  24750. * Returns a description of this mesh
  24751. * @param fullDetails define if full details about this mesh must be used
  24752. * @returns a descriptive string representing this mesh
  24753. */
  24754. toString(fullDetails?: boolean): string;
  24755. /** @hidden */
  24756. _unBindEffect(): void;
  24757. /**
  24758. * Gets a boolean indicating if this mesh has LOD
  24759. */
  24760. readonly hasLODLevels: boolean;
  24761. /**
  24762. * Gets the list of MeshLODLevel associated with the current mesh
  24763. * @returns an array of MeshLODLevel
  24764. */
  24765. getLODLevels(): MeshLODLevel[];
  24766. private _sortLODLevels;
  24767. /**
  24768. * Add a mesh as LOD level triggered at the given distance.
  24769. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24770. * @param distance The distance from the center of the object to show this level
  24771. * @param mesh The mesh to be added as LOD level (can be null)
  24772. * @return This mesh (for chaining)
  24773. */
  24774. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24775. /**
  24776. * Returns the LOD level mesh at the passed distance or null if not found.
  24777. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24778. * @param distance The distance from the center of the object to show this level
  24779. * @returns a Mesh or `null`
  24780. */
  24781. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24782. /**
  24783. * Remove a mesh from the LOD array
  24784. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24785. * @param mesh defines the mesh to be removed
  24786. * @return This mesh (for chaining)
  24787. */
  24788. removeLODLevel(mesh: Mesh): Mesh;
  24789. /**
  24790. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24791. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24792. * @param camera defines the camera to use to compute distance
  24793. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24794. * @return This mesh (for chaining)
  24795. */
  24796. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24797. /**
  24798. * Gets the mesh internal Geometry object
  24799. */
  24800. readonly geometry: Nullable<Geometry>;
  24801. /**
  24802. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24803. * @returns the total number of vertices
  24804. */
  24805. getTotalVertices(): number;
  24806. /**
  24807. * Returns the content of an associated vertex buffer
  24808. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24809. * - VertexBuffer.PositionKind
  24810. * - VertexBuffer.UVKind
  24811. * - VertexBuffer.UV2Kind
  24812. * - VertexBuffer.UV3Kind
  24813. * - VertexBuffer.UV4Kind
  24814. * - VertexBuffer.UV5Kind
  24815. * - VertexBuffer.UV6Kind
  24816. * - VertexBuffer.ColorKind
  24817. * - VertexBuffer.MatricesIndicesKind
  24818. * - VertexBuffer.MatricesIndicesExtraKind
  24819. * - VertexBuffer.MatricesWeightsKind
  24820. * - VertexBuffer.MatricesWeightsExtraKind
  24821. * @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
  24822. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24823. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24824. */
  24825. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24826. /**
  24827. * Returns the mesh VertexBuffer object from the requested `kind`
  24828. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24829. * - VertexBuffer.PositionKind
  24830. * - VertexBuffer.NormalKind
  24831. * - VertexBuffer.UVKind
  24832. * - VertexBuffer.UV2Kind
  24833. * - VertexBuffer.UV3Kind
  24834. * - VertexBuffer.UV4Kind
  24835. * - VertexBuffer.UV5Kind
  24836. * - VertexBuffer.UV6Kind
  24837. * - VertexBuffer.ColorKind
  24838. * - VertexBuffer.MatricesIndicesKind
  24839. * - VertexBuffer.MatricesIndicesExtraKind
  24840. * - VertexBuffer.MatricesWeightsKind
  24841. * - VertexBuffer.MatricesWeightsExtraKind
  24842. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24843. */
  24844. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24845. /**
  24846. * Tests if a specific vertex buffer is associated with this mesh
  24847. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24848. * - VertexBuffer.PositionKind
  24849. * - VertexBuffer.NormalKind
  24850. * - VertexBuffer.UVKind
  24851. * - VertexBuffer.UV2Kind
  24852. * - VertexBuffer.UV3Kind
  24853. * - VertexBuffer.UV4Kind
  24854. * - VertexBuffer.UV5Kind
  24855. * - VertexBuffer.UV6Kind
  24856. * - VertexBuffer.ColorKind
  24857. * - VertexBuffer.MatricesIndicesKind
  24858. * - VertexBuffer.MatricesIndicesExtraKind
  24859. * - VertexBuffer.MatricesWeightsKind
  24860. * - VertexBuffer.MatricesWeightsExtraKind
  24861. * @returns a boolean
  24862. */
  24863. isVerticesDataPresent(kind: string): boolean;
  24864. /**
  24865. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24866. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24867. * - VertexBuffer.PositionKind
  24868. * - VertexBuffer.UVKind
  24869. * - VertexBuffer.UV2Kind
  24870. * - VertexBuffer.UV3Kind
  24871. * - VertexBuffer.UV4Kind
  24872. * - VertexBuffer.UV5Kind
  24873. * - VertexBuffer.UV6Kind
  24874. * - VertexBuffer.ColorKind
  24875. * - VertexBuffer.MatricesIndicesKind
  24876. * - VertexBuffer.MatricesIndicesExtraKind
  24877. * - VertexBuffer.MatricesWeightsKind
  24878. * - VertexBuffer.MatricesWeightsExtraKind
  24879. * @returns a boolean
  24880. */
  24881. isVertexBufferUpdatable(kind: string): boolean;
  24882. /**
  24883. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24884. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24885. * - VertexBuffer.PositionKind
  24886. * - VertexBuffer.NormalKind
  24887. * - VertexBuffer.UVKind
  24888. * - VertexBuffer.UV2Kind
  24889. * - VertexBuffer.UV3Kind
  24890. * - VertexBuffer.UV4Kind
  24891. * - VertexBuffer.UV5Kind
  24892. * - VertexBuffer.UV6Kind
  24893. * - VertexBuffer.ColorKind
  24894. * - VertexBuffer.MatricesIndicesKind
  24895. * - VertexBuffer.MatricesIndicesExtraKind
  24896. * - VertexBuffer.MatricesWeightsKind
  24897. * - VertexBuffer.MatricesWeightsExtraKind
  24898. * @returns an array of strings
  24899. */
  24900. getVerticesDataKinds(): string[];
  24901. /**
  24902. * Returns a positive integer : the total number of indices in this mesh geometry.
  24903. * @returns the numner of indices or zero if the mesh has no geometry.
  24904. */
  24905. getTotalIndices(): number;
  24906. /**
  24907. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24908. * @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.
  24909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24910. * @returns the indices array or an empty array if the mesh has no geometry
  24911. */
  24912. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24913. readonly isBlocked: boolean;
  24914. /**
  24915. * Determine if the current mesh is ready to be rendered
  24916. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24917. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24918. * @returns true if all associated assets are ready (material, textures, shaders)
  24919. */
  24920. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24921. /**
  24922. * 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.
  24923. */
  24924. readonly areNormalsFrozen: boolean;
  24925. /**
  24926. * 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.
  24927. * @returns the current mesh
  24928. */
  24929. freezeNormals(): Mesh;
  24930. /**
  24931. * 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
  24932. * @returns the current mesh
  24933. */
  24934. unfreezeNormals(): Mesh;
  24935. /**
  24936. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24937. */
  24938. overridenInstanceCount: number;
  24939. /** @hidden */
  24940. _preActivate(): Mesh;
  24941. /** @hidden */
  24942. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24943. /** @hidden */
  24944. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24945. /**
  24946. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24947. * This means the mesh underlying bounding box and sphere are recomputed.
  24948. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24949. * @returns the current mesh
  24950. */
  24951. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24952. /** @hidden */
  24953. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24954. /**
  24955. * This function will subdivide the mesh into multiple submeshes
  24956. * @param count defines the expected number of submeshes
  24957. */
  24958. subdivide(count: number): void;
  24959. /**
  24960. * Copy a FloatArray into a specific associated vertex buffer
  24961. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24962. * - VertexBuffer.PositionKind
  24963. * - VertexBuffer.UVKind
  24964. * - VertexBuffer.UV2Kind
  24965. * - VertexBuffer.UV3Kind
  24966. * - VertexBuffer.UV4Kind
  24967. * - VertexBuffer.UV5Kind
  24968. * - VertexBuffer.UV6Kind
  24969. * - VertexBuffer.ColorKind
  24970. * - VertexBuffer.MatricesIndicesKind
  24971. * - VertexBuffer.MatricesIndicesExtraKind
  24972. * - VertexBuffer.MatricesWeightsKind
  24973. * - VertexBuffer.MatricesWeightsExtraKind
  24974. * @param data defines the data source
  24975. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24976. * @param stride defines the data stride size (can be null)
  24977. * @returns the current mesh
  24978. */
  24979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24980. /**
  24981. * Delete a vertex buffer associated with this mesh
  24982. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24983. * - VertexBuffer.PositionKind
  24984. * - VertexBuffer.UVKind
  24985. * - VertexBuffer.UV2Kind
  24986. * - VertexBuffer.UV3Kind
  24987. * - VertexBuffer.UV4Kind
  24988. * - VertexBuffer.UV5Kind
  24989. * - VertexBuffer.UV6Kind
  24990. * - VertexBuffer.ColorKind
  24991. * - VertexBuffer.MatricesIndicesKind
  24992. * - VertexBuffer.MatricesIndicesExtraKind
  24993. * - VertexBuffer.MatricesWeightsKind
  24994. * - VertexBuffer.MatricesWeightsExtraKind
  24995. */
  24996. removeVerticesData(kind: string): void;
  24997. /**
  24998. * Flags an associated vertex buffer as updatable
  24999. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25000. * - VertexBuffer.PositionKind
  25001. * - VertexBuffer.UVKind
  25002. * - VertexBuffer.UV2Kind
  25003. * - VertexBuffer.UV3Kind
  25004. * - VertexBuffer.UV4Kind
  25005. * - VertexBuffer.UV5Kind
  25006. * - VertexBuffer.UV6Kind
  25007. * - VertexBuffer.ColorKind
  25008. * - VertexBuffer.MatricesIndicesKind
  25009. * - VertexBuffer.MatricesIndicesExtraKind
  25010. * - VertexBuffer.MatricesWeightsKind
  25011. * - VertexBuffer.MatricesWeightsExtraKind
  25012. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25013. */
  25014. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25015. /**
  25016. * Sets the mesh global Vertex Buffer
  25017. * @param buffer defines the buffer to use
  25018. * @returns the current mesh
  25019. */
  25020. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25021. /**
  25022. * Update a specific associated vertex buffer
  25023. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25024. * - VertexBuffer.PositionKind
  25025. * - VertexBuffer.UVKind
  25026. * - VertexBuffer.UV2Kind
  25027. * - VertexBuffer.UV3Kind
  25028. * - VertexBuffer.UV4Kind
  25029. * - VertexBuffer.UV5Kind
  25030. * - VertexBuffer.UV6Kind
  25031. * - VertexBuffer.ColorKind
  25032. * - VertexBuffer.MatricesIndicesKind
  25033. * - VertexBuffer.MatricesIndicesExtraKind
  25034. * - VertexBuffer.MatricesWeightsKind
  25035. * - VertexBuffer.MatricesWeightsExtraKind
  25036. * @param data defines the data source
  25037. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25038. * @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)
  25039. * @returns the current mesh
  25040. */
  25041. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25042. /**
  25043. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25044. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25045. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25046. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25047. * @returns the current mesh
  25048. */
  25049. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25050. /**
  25051. * Creates a un-shared specific occurence of the geometry for the mesh.
  25052. * @returns the current mesh
  25053. */
  25054. makeGeometryUnique(): Mesh;
  25055. /**
  25056. * Set the index buffer of this mesh
  25057. * @param indices defines the source data
  25058. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25059. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25060. * @returns the current mesh
  25061. */
  25062. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25063. /**
  25064. * Update the current index buffer
  25065. * @param indices defines the source data
  25066. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25067. * @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)
  25068. * @returns the current mesh
  25069. */
  25070. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25071. /**
  25072. * Invert the geometry to move from a right handed system to a left handed one.
  25073. * @returns the current mesh
  25074. */
  25075. toLeftHanded(): Mesh;
  25076. /** @hidden */
  25077. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25078. /** @hidden */
  25079. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25080. /**
  25081. * Registers for this mesh a javascript function called just before the rendering process
  25082. * @param func defines the function to call before rendering this mesh
  25083. * @returns the current mesh
  25084. */
  25085. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25086. /**
  25087. * Disposes a previously registered javascript function called before the rendering
  25088. * @param func defines the function to remove
  25089. * @returns the current mesh
  25090. */
  25091. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25092. /**
  25093. * Registers for this mesh a javascript function called just after the rendering is complete
  25094. * @param func defines the function to call after rendering this mesh
  25095. * @returns the current mesh
  25096. */
  25097. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25098. /**
  25099. * Disposes a previously registered javascript function called after the rendering.
  25100. * @param func defines the function to remove
  25101. * @returns the current mesh
  25102. */
  25103. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25104. /** @hidden */
  25105. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25106. /** @hidden */
  25107. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25108. /** @hidden */
  25109. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25110. /** @hidden */
  25111. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25112. /** @hidden */
  25113. _rebuild(): void;
  25114. /** @hidden */
  25115. _freeze(): void;
  25116. /** @hidden */
  25117. _unFreeze(): void;
  25118. /**
  25119. * 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
  25120. * @param subMesh defines the subMesh to render
  25121. * @param enableAlphaMode defines if alpha mode can be changed
  25122. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25123. * @returns the current mesh
  25124. */
  25125. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25126. private _onBeforeDraw;
  25127. /**
  25128. * Renormalize the mesh and patch it up if there are no weights
  25129. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25130. * However in the case of zero weights then we set just a single influence to 1.
  25131. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25132. */
  25133. cleanMatrixWeights(): void;
  25134. private normalizeSkinFourWeights;
  25135. private normalizeSkinWeightsAndExtra;
  25136. /**
  25137. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25138. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25139. * the user know there was an issue with importing the mesh
  25140. * @returns a validation object with skinned, valid and report string
  25141. */
  25142. validateSkinning(): {
  25143. skinned: boolean;
  25144. valid: boolean;
  25145. report: string;
  25146. };
  25147. /** @hidden */
  25148. _checkDelayState(): Mesh;
  25149. private _queueLoad;
  25150. /**
  25151. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25152. * A mesh is in the frustum if its bounding box intersects the frustum
  25153. * @param frustumPlanes defines the frustum to test
  25154. * @returns true if the mesh is in the frustum planes
  25155. */
  25156. isInFrustum(frustumPlanes: Plane[]): boolean;
  25157. /**
  25158. * Sets the mesh material by the material or multiMaterial `id` property
  25159. * @param id is a string identifying the material or the multiMaterial
  25160. * @returns the current mesh
  25161. */
  25162. setMaterialByID(id: string): Mesh;
  25163. /**
  25164. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25165. * @returns an array of IAnimatable
  25166. */
  25167. getAnimatables(): IAnimatable[];
  25168. /**
  25169. * Modifies the mesh geometry according to the passed transformation matrix.
  25170. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25171. * The mesh normals are modified using the same transformation.
  25172. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25173. * @param transform defines the transform matrix to use
  25174. * @see http://doc.babylonjs.com/resources/baking_transformations
  25175. * @returns the current mesh
  25176. */
  25177. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25178. /**
  25179. * Modifies the mesh geometry according to its own current World Matrix.
  25180. * The mesh World Matrix is then reset.
  25181. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25182. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25183. * @see http://doc.babylonjs.com/resources/baking_transformations
  25184. * @returns the current mesh
  25185. */
  25186. bakeCurrentTransformIntoVertices(): Mesh;
  25187. /** @hidden */
  25188. readonly _positions: Nullable<Vector3[]>;
  25189. /** @hidden */
  25190. _resetPointsArrayCache(): Mesh;
  25191. /** @hidden */
  25192. _generatePointsArray(): boolean;
  25193. /**
  25194. * Returns a new Mesh object generated from the current mesh properties.
  25195. * This method must not get confused with createInstance()
  25196. * @param name is a string, the name given to the new mesh
  25197. * @param newParent can be any Node object (default `null`)
  25198. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25199. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25200. * @returns a new mesh
  25201. */
  25202. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25203. /**
  25204. * Releases resources associated with this mesh.
  25205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25207. */
  25208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25209. /** @hidden */
  25210. _disposeInstanceSpecificData(): void;
  25211. /**
  25212. * Modifies the mesh geometry according to a displacement map.
  25213. * 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.
  25214. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25215. * @param url is a string, the URL from the image file is to be downloaded.
  25216. * @param minHeight is the lower limit of the displacement.
  25217. * @param maxHeight is the upper limit of the displacement.
  25218. * @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.
  25219. * @param uvOffset is an optional vector2 used to offset UV.
  25220. * @param uvScale is an optional vector2 used to scale UV.
  25221. * @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.
  25222. * @returns the Mesh.
  25223. */
  25224. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25225. /**
  25226. * Modifies the mesh geometry according to a displacementMap buffer.
  25227. * 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.
  25228. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25229. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25230. * @param heightMapWidth is the width of the buffer image.
  25231. * @param heightMapHeight is the height of the buffer image.
  25232. * @param minHeight is the lower limit of the displacement.
  25233. * @param maxHeight is the upper limit of the displacement.
  25234. * @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.
  25235. * @param uvOffset is an optional vector2 used to offset UV.
  25236. * @param uvScale is an optional vector2 used to scale UV.
  25237. * @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.
  25238. * @returns the Mesh.
  25239. */
  25240. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25241. /**
  25242. * Modify the mesh to get a flat shading rendering.
  25243. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25244. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25245. * @returns current mesh
  25246. */
  25247. convertToFlatShadedMesh(): Mesh;
  25248. /**
  25249. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25250. * In other words, more vertices, no more indices and a single bigger VBO.
  25251. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25252. * @returns current mesh
  25253. */
  25254. convertToUnIndexedMesh(): Mesh;
  25255. /**
  25256. * Inverses facet orientations.
  25257. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25258. * @param flipNormals will also inverts the normals
  25259. * @returns current mesh
  25260. */
  25261. flipFaces(flipNormals?: boolean): Mesh;
  25262. /**
  25263. * Increase the number of facets and hence vertices in a mesh
  25264. * Vertex normals are interpolated from existing vertex normals
  25265. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25266. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25267. */
  25268. increaseVertices(numberPerEdge: number): void;
  25269. /**
  25270. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25271. * This will undo any application of covertToFlatShadedMesh
  25272. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25273. */
  25274. forceSharedVertices(): void;
  25275. /** @hidden */
  25276. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25277. /** @hidden */
  25278. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25279. /**
  25280. * Creates a new InstancedMesh object from the mesh model.
  25281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25282. * @param name defines the name of the new instance
  25283. * @returns a new InstancedMesh
  25284. */
  25285. createInstance(name: string): InstancedMesh;
  25286. /**
  25287. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25288. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25289. * @returns the current mesh
  25290. */
  25291. synchronizeInstances(): Mesh;
  25292. /**
  25293. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25294. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25295. * This should be used together with the simplification to avoid disappearing triangles.
  25296. * @param successCallback an optional success callback to be called after the optimization finished.
  25297. * @returns the current mesh
  25298. */
  25299. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25300. /**
  25301. * Serialize current mesh
  25302. * @param serializationObject defines the object which will receive the serialization data
  25303. */
  25304. serialize(serializationObject: any): void;
  25305. /** @hidden */
  25306. _syncGeometryWithMorphTargetManager(): void;
  25307. /** @hidden */
  25308. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25309. /**
  25310. * Returns a new Mesh object parsed from the source provided.
  25311. * @param parsedMesh is the source
  25312. * @param scene defines the hosting scene
  25313. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25314. * @returns a new Mesh
  25315. */
  25316. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25317. /**
  25318. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25319. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25320. * @param name defines the name of the mesh to create
  25321. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25322. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25323. * @param closePath creates a seam between the first and the last points of each path of the path array
  25324. * @param offset is taken in account only if the `pathArray` is containing a single path
  25325. * @param scene defines the hosting scene
  25326. * @param updatable defines if the mesh must be flagged as updatable
  25327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25328. * @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)
  25329. * @returns a new Mesh
  25330. */
  25331. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25332. /**
  25333. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25334. * @param name defines the name of the mesh to create
  25335. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25336. * @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
  25337. * @param scene defines the hosting scene
  25338. * @param updatable defines if the mesh must be flagged as updatable
  25339. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25340. * @returns a new Mesh
  25341. */
  25342. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25343. /**
  25344. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25345. * @param name defines the name of the mesh to create
  25346. * @param size sets the size (float) of each box side (default 1)
  25347. * @param scene defines the hosting scene
  25348. * @param updatable defines if the mesh must be flagged as updatable
  25349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25350. * @returns a new Mesh
  25351. */
  25352. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25353. /**
  25354. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25355. * @param name defines the name of the mesh to create
  25356. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25357. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25358. * @param scene defines the hosting scene
  25359. * @param updatable defines if the mesh must be flagged as updatable
  25360. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25361. * @returns a new Mesh
  25362. */
  25363. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25364. /**
  25365. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25366. * @param name defines the name of the mesh to create
  25367. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25368. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25369. * @param scene defines the hosting scene
  25370. * @returns a new Mesh
  25371. */
  25372. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25373. /**
  25374. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25375. * @param name defines the name of the mesh to create
  25376. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25377. * @param diameterTop set the top cap diameter (floats, default 1)
  25378. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25379. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25380. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25381. * @param scene defines the hosting scene
  25382. * @param updatable defines if the mesh must be flagged as updatable
  25383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25384. * @returns a new Mesh
  25385. */
  25386. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25387. /**
  25388. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25389. * @param name defines the name of the mesh to create
  25390. * @param diameter sets the diameter size (float) of the torus (default 1)
  25391. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25392. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25393. * @param scene defines the hosting scene
  25394. * @param updatable defines if the mesh must be flagged as updatable
  25395. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25396. * @returns a new Mesh
  25397. */
  25398. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25399. /**
  25400. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25401. * @param name defines the name of the mesh to create
  25402. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25403. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25404. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25405. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25406. * @param p the number of windings on X axis (positive integers, default 2)
  25407. * @param q the number of windings on Y axis (positive integers, default 3)
  25408. * @param scene defines the hosting scene
  25409. * @param updatable defines if the mesh must be flagged as updatable
  25410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25411. * @returns a new Mesh
  25412. */
  25413. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25414. /**
  25415. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25416. * @param name defines the name of the mesh to create
  25417. * @param points is an array successive Vector3
  25418. * @param scene defines the hosting scene
  25419. * @param updatable defines if the mesh must be flagged as updatable
  25420. * @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).
  25421. * @returns a new Mesh
  25422. */
  25423. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25424. /**
  25425. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25426. * @param name defines the name of the mesh to create
  25427. * @param points is an array successive Vector3
  25428. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25429. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25430. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25431. * @param scene defines the hosting scene
  25432. * @param updatable defines if the mesh must be flagged as updatable
  25433. * @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)
  25434. * @returns a new Mesh
  25435. */
  25436. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25437. /**
  25438. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25439. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25440. * 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.
  25441. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25442. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25443. * Remember you can only change the shape positions, not their number when updating a polygon.
  25444. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25445. * @param name defines the name of the mesh to create
  25446. * @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
  25447. * @param scene defines the hosting scene
  25448. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25449. * @param updatable defines if the mesh must be flagged as updatable
  25450. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25451. * @param earcutInjection can be used to inject your own earcut reference
  25452. * @returns a new Mesh
  25453. */
  25454. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25455. /**
  25456. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25457. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25458. * @param name defines the name of the mesh to create
  25459. * @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
  25460. * @param depth defines the height of extrusion
  25461. * @param scene defines the hosting scene
  25462. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25463. * @param updatable defines if the mesh must be flagged as updatable
  25464. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25465. * @param earcutInjection can be used to inject your own earcut reference
  25466. * @returns a new Mesh
  25467. */
  25468. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25469. /**
  25470. * Creates an extruded shape mesh.
  25471. * 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
  25472. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25473. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25474. * @param name defines the name of the mesh to create
  25475. * @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
  25476. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25477. * @param scale is the value to scale the shape
  25478. * @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
  25479. * @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
  25480. * @param scene defines the hosting scene
  25481. * @param updatable defines if the mesh must be flagged as updatable
  25482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25483. * @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)
  25484. * @returns a new Mesh
  25485. */
  25486. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25487. /**
  25488. * Creates an custom extruded shape mesh.
  25489. * The custom extrusion is a parametric shape.
  25490. * It has no predefined shape. Its final shape will depend on the input parameters.
  25491. * Please consider using the same method from the MeshBuilder class instead
  25492. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25493. * @param name defines the name of the mesh to create
  25494. * @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
  25495. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25496. * @param scaleFunction is a custom Javascript function called on each path point
  25497. * @param rotationFunction is a custom Javascript function called on each path point
  25498. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25499. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25500. * @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
  25501. * @param scene defines the hosting scene
  25502. * @param updatable defines if the mesh must be flagged as updatable
  25503. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25504. * @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)
  25505. * @returns a new Mesh
  25506. */
  25507. 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;
  25508. /**
  25509. * Creates lathe mesh.
  25510. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25511. * Please consider using the same method from the MeshBuilder class instead
  25512. * @param name defines the name of the mesh to create
  25513. * @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
  25514. * @param radius is the radius value of the lathe
  25515. * @param tessellation is the side number of the lathe.
  25516. * @param scene defines the hosting scene
  25517. * @param updatable defines if the mesh must be flagged as updatable
  25518. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25519. * @returns a new Mesh
  25520. */
  25521. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25522. /**
  25523. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25524. * @param name defines the name of the mesh to create
  25525. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25526. * @param scene defines the hosting scene
  25527. * @param updatable defines if the mesh must be flagged as updatable
  25528. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25529. * @returns a new Mesh
  25530. */
  25531. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25532. /**
  25533. * Creates a ground mesh.
  25534. * Please consider using the same method from the MeshBuilder class instead
  25535. * @param name defines the name of the mesh to create
  25536. * @param width set the width of the ground
  25537. * @param height set the height of the ground
  25538. * @param subdivisions sets the number of subdivisions per side
  25539. * @param scene defines the hosting scene
  25540. * @param updatable defines if the mesh must be flagged as updatable
  25541. * @returns a new Mesh
  25542. */
  25543. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25544. /**
  25545. * Creates a tiled ground mesh.
  25546. * Please consider using the same method from the MeshBuilder class instead
  25547. * @param name defines the name of the mesh to create
  25548. * @param xmin set the ground minimum X coordinate
  25549. * @param zmin set the ground minimum Y coordinate
  25550. * @param xmax set the ground maximum X coordinate
  25551. * @param zmax set the ground maximum Z coordinate
  25552. * @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
  25553. * @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
  25554. * @param scene defines the hosting scene
  25555. * @param updatable defines if the mesh must be flagged as updatable
  25556. * @returns a new Mesh
  25557. */
  25558. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25559. w: number;
  25560. h: number;
  25561. }, precision: {
  25562. w: number;
  25563. h: number;
  25564. }, scene: Scene, updatable?: boolean): Mesh;
  25565. /**
  25566. * Creates a ground mesh from a height map.
  25567. * Please consider using the same method from the MeshBuilder class instead
  25568. * @see http://doc.babylonjs.com/babylon101/height_map
  25569. * @param name defines the name of the mesh to create
  25570. * @param url sets the URL of the height map image resource
  25571. * @param width set the ground width size
  25572. * @param height set the ground height size
  25573. * @param subdivisions sets the number of subdivision per side
  25574. * @param minHeight is the minimum altitude on the ground
  25575. * @param maxHeight is the maximum altitude on the ground
  25576. * @param scene defines the hosting scene
  25577. * @param updatable defines if the mesh must be flagged as updatable
  25578. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25579. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25580. * @returns a new Mesh
  25581. */
  25582. 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;
  25583. /**
  25584. * Creates a tube mesh.
  25585. * The tube is a parametric shape.
  25586. * It has no predefined shape. Its final shape will depend on the input parameters.
  25587. * Please consider using the same method from the MeshBuilder class instead
  25588. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25589. * @param name defines the name of the mesh to create
  25590. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25591. * @param radius sets the tube radius size
  25592. * @param tessellation is the number of sides on the tubular surface
  25593. * @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
  25594. * @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
  25595. * @param scene defines the hosting scene
  25596. * @param updatable defines if the mesh must be flagged as updatable
  25597. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25598. * @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)
  25599. * @returns a new Mesh
  25600. */
  25601. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25602. (i: number, distance: number): number;
  25603. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25604. /**
  25605. * Creates a polyhedron mesh.
  25606. * Please consider using the same method from the MeshBuilder class instead.
  25607. * * 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
  25608. * * The parameter `size` (positive float, default 1) sets the polygon size
  25609. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25610. * * 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`
  25611. * * 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
  25612. * * 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)`)
  25613. * * 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
  25614. * * 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
  25615. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25616. * * If you create a double-sided mesh, you can choose what parts of 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
  25617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25618. * @param name defines the name of the mesh to create
  25619. * @param options defines the options used to create the mesh
  25620. * @param scene defines the hosting scene
  25621. * @returns a new Mesh
  25622. */
  25623. static CreatePolyhedron(name: string, options: {
  25624. type?: number;
  25625. size?: number;
  25626. sizeX?: number;
  25627. sizeY?: number;
  25628. sizeZ?: number;
  25629. custom?: any;
  25630. faceUV?: Vector4[];
  25631. faceColors?: Color4[];
  25632. updatable?: boolean;
  25633. sideOrientation?: number;
  25634. }, scene: Scene): Mesh;
  25635. /**
  25636. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25637. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25638. * * 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`)
  25639. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25640. * * 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
  25641. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25642. * * If you create a double-sided mesh, you can choose what parts of 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
  25643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25644. * @param name defines the name of the mesh
  25645. * @param options defines the options used to create the mesh
  25646. * @param scene defines the hosting scene
  25647. * @returns a new Mesh
  25648. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25649. */
  25650. static CreateIcoSphere(name: string, options: {
  25651. radius?: number;
  25652. flat?: boolean;
  25653. subdivisions?: number;
  25654. sideOrientation?: number;
  25655. updatable?: boolean;
  25656. }, scene: Scene): Mesh;
  25657. /**
  25658. * Creates a decal mesh.
  25659. * Please consider using the same method from the MeshBuilder class instead.
  25660. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25661. * @param name defines the name of the mesh
  25662. * @param sourceMesh defines the mesh receiving the decal
  25663. * @param position sets the position of the decal in world coordinates
  25664. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25665. * @param size sets the decal scaling
  25666. * @param angle sets the angle to rotate the decal
  25667. * @returns a new Mesh
  25668. */
  25669. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25670. /**
  25671. * Prepare internal position array for software CPU skinning
  25672. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25673. */
  25674. setPositionsForCPUSkinning(): Float32Array;
  25675. /**
  25676. * Prepare internal normal array for software CPU skinning
  25677. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25678. */
  25679. setNormalsForCPUSkinning(): Float32Array;
  25680. /**
  25681. * Updates the vertex buffer by applying transformation from the bones
  25682. * @param skeleton defines the skeleton to apply to current mesh
  25683. * @returns the current mesh
  25684. */
  25685. applySkeleton(skeleton: Skeleton): Mesh;
  25686. /**
  25687. * 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
  25688. * @param meshes defines the list of meshes to scan
  25689. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25690. */
  25691. static MinMax(meshes: AbstractMesh[]): {
  25692. min: Vector3;
  25693. max: Vector3;
  25694. };
  25695. /**
  25696. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25697. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25698. * @returns a vector3
  25699. */
  25700. static Center(meshesOrMinMaxVector: {
  25701. min: Vector3;
  25702. max: Vector3;
  25703. } | AbstractMesh[]): Vector3;
  25704. /**
  25705. * Merge the array of meshes into a single mesh for performance reasons.
  25706. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25707. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25708. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25709. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25710. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25711. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25712. * @returns a new mesh
  25713. */
  25714. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25715. /** @hidden */
  25716. addInstance(instance: InstancedMesh): void;
  25717. /** @hidden */
  25718. removeInstance(instance: InstancedMesh): void;
  25719. }
  25720. }
  25721. declare module "babylonjs/Cameras/camera" {
  25722. import { SmartArray } from "babylonjs/Misc/smartArray";
  25723. import { Observable } from "babylonjs/Misc/observable";
  25724. import { Nullable } from "babylonjs/types";
  25725. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25726. import { Scene } from "babylonjs/scene";
  25727. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25728. import { Node } from "babylonjs/node";
  25729. import { Mesh } from "babylonjs/Meshes/mesh";
  25730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25731. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25732. import { Viewport } from "babylonjs/Maths/math.viewport";
  25733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25734. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25735. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25736. import { Ray } from "babylonjs/Culling/ray";
  25737. /**
  25738. * This is the base class of all the camera used in the application.
  25739. * @see http://doc.babylonjs.com/features/cameras
  25740. */
  25741. export class Camera extends Node {
  25742. /** @hidden */
  25743. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25744. /**
  25745. * This is the default projection mode used by the cameras.
  25746. * It helps recreating a feeling of perspective and better appreciate depth.
  25747. * This is the best way to simulate real life cameras.
  25748. */
  25749. static readonly PERSPECTIVE_CAMERA: number;
  25750. /**
  25751. * This helps creating camera with an orthographic mode.
  25752. * 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.
  25753. */
  25754. static readonly ORTHOGRAPHIC_CAMERA: number;
  25755. /**
  25756. * This is the default FOV mode for perspective cameras.
  25757. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25758. */
  25759. static readonly FOVMODE_VERTICAL_FIXED: number;
  25760. /**
  25761. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25762. */
  25763. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25764. /**
  25765. * This specifies ther is no need for a camera rig.
  25766. * Basically only one eye is rendered corresponding to the camera.
  25767. */
  25768. static readonly RIG_MODE_NONE: number;
  25769. /**
  25770. * Simulates a camera Rig with one blue eye and one red eye.
  25771. * This can be use with 3d blue and red glasses.
  25772. */
  25773. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25774. /**
  25775. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25776. */
  25777. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25778. /**
  25779. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25780. */
  25781. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25782. /**
  25783. * Defines that both eyes of the camera will be rendered over under each other.
  25784. */
  25785. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25786. /**
  25787. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25788. */
  25789. static readonly RIG_MODE_VR: number;
  25790. /**
  25791. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25792. */
  25793. static readonly RIG_MODE_WEBVR: number;
  25794. /**
  25795. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25796. */
  25797. static readonly RIG_MODE_CUSTOM: number;
  25798. /**
  25799. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25800. */
  25801. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25802. /**
  25803. * Define the input manager associated with the camera.
  25804. */
  25805. inputs: CameraInputsManager<Camera>;
  25806. /** @hidden */
  25807. _position: Vector3;
  25808. /**
  25809. * Define the current local position of the camera in the scene
  25810. */
  25811. position: Vector3;
  25812. /**
  25813. * The vector the camera should consider as up.
  25814. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25815. */
  25816. upVector: Vector3;
  25817. /**
  25818. * Define the current limit on the left side for an orthographic camera
  25819. * In scene unit
  25820. */
  25821. orthoLeft: Nullable<number>;
  25822. /**
  25823. * Define the current limit on the right side for an orthographic camera
  25824. * In scene unit
  25825. */
  25826. orthoRight: Nullable<number>;
  25827. /**
  25828. * Define the current limit on the bottom side for an orthographic camera
  25829. * In scene unit
  25830. */
  25831. orthoBottom: Nullable<number>;
  25832. /**
  25833. * Define the current limit on the top side for an orthographic camera
  25834. * In scene unit
  25835. */
  25836. orthoTop: Nullable<number>;
  25837. /**
  25838. * Field Of View is set in Radians. (default is 0.8)
  25839. */
  25840. fov: number;
  25841. /**
  25842. * Define the minimum distance the camera can see from.
  25843. * This is important to note that the depth buffer are not infinite and the closer it starts
  25844. * the more your scene might encounter depth fighting issue.
  25845. */
  25846. minZ: number;
  25847. /**
  25848. * Define the maximum distance the camera can see to.
  25849. * This is important to note that the depth buffer are not infinite and the further it end
  25850. * the more your scene might encounter depth fighting issue.
  25851. */
  25852. maxZ: number;
  25853. /**
  25854. * Define the default inertia of the camera.
  25855. * This helps giving a smooth feeling to the camera movement.
  25856. */
  25857. inertia: number;
  25858. /**
  25859. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25860. */
  25861. mode: number;
  25862. /**
  25863. * Define wether the camera is intermediate.
  25864. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25865. */
  25866. isIntermediate: boolean;
  25867. /**
  25868. * Define the viewport of the camera.
  25869. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25870. */
  25871. viewport: Viewport;
  25872. /**
  25873. * Restricts the camera to viewing objects with the same layerMask.
  25874. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25875. */
  25876. layerMask: number;
  25877. /**
  25878. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25879. */
  25880. fovMode: number;
  25881. /**
  25882. * Rig mode of the camera.
  25883. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25884. * This is normally controlled byt the camera themselves as internal use.
  25885. */
  25886. cameraRigMode: number;
  25887. /**
  25888. * Defines the distance between both "eyes" in case of a RIG
  25889. */
  25890. interaxialDistance: number;
  25891. /**
  25892. * Defines if stereoscopic rendering is done side by side or over under.
  25893. */
  25894. isStereoscopicSideBySide: boolean;
  25895. /**
  25896. * 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
  25897. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25898. * else in the scene. (Eg. security camera)
  25899. *
  25900. * 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)
  25901. */
  25902. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25903. /**
  25904. * When set, the camera will render to this render target instead of the default canvas
  25905. *
  25906. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25907. */
  25908. outputRenderTarget: Nullable<RenderTargetTexture>;
  25909. /**
  25910. * Observable triggered when the camera view matrix has changed.
  25911. */
  25912. onViewMatrixChangedObservable: Observable<Camera>;
  25913. /**
  25914. * Observable triggered when the camera Projection matrix has changed.
  25915. */
  25916. onProjectionMatrixChangedObservable: Observable<Camera>;
  25917. /**
  25918. * Observable triggered when the inputs have been processed.
  25919. */
  25920. onAfterCheckInputsObservable: Observable<Camera>;
  25921. /**
  25922. * Observable triggered when reset has been called and applied to the camera.
  25923. */
  25924. onRestoreStateObservable: Observable<Camera>;
  25925. /** @hidden */
  25926. _cameraRigParams: any;
  25927. /** @hidden */
  25928. _rigCameras: Camera[];
  25929. /** @hidden */
  25930. _rigPostProcess: Nullable<PostProcess>;
  25931. protected _webvrViewMatrix: Matrix;
  25932. /** @hidden */
  25933. _skipRendering: boolean;
  25934. /** @hidden */
  25935. _projectionMatrix: Matrix;
  25936. /** @hidden */
  25937. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25938. /** @hidden */
  25939. _activeMeshes: SmartArray<AbstractMesh>;
  25940. protected _globalPosition: Vector3;
  25941. /** @hidden */
  25942. _computedViewMatrix: Matrix;
  25943. private _doNotComputeProjectionMatrix;
  25944. private _transformMatrix;
  25945. private _frustumPlanes;
  25946. private _refreshFrustumPlanes;
  25947. private _storedFov;
  25948. private _stateStored;
  25949. /**
  25950. * Instantiates a new camera object.
  25951. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25952. * @see http://doc.babylonjs.com/features/cameras
  25953. * @param name Defines the name of the camera in the scene
  25954. * @param position Defines the position of the camera
  25955. * @param scene Defines the scene the camera belongs too
  25956. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25957. */
  25958. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25959. /**
  25960. * Store current camera state (fov, position, etc..)
  25961. * @returns the camera
  25962. */
  25963. storeState(): Camera;
  25964. /**
  25965. * Restores the camera state values if it has been stored. You must call storeState() first
  25966. */
  25967. protected _restoreStateValues(): boolean;
  25968. /**
  25969. * Restored camera state. You must call storeState() first.
  25970. * @returns true if restored and false otherwise
  25971. */
  25972. restoreState(): boolean;
  25973. /**
  25974. * Gets the class name of the camera.
  25975. * @returns the class name
  25976. */
  25977. getClassName(): string;
  25978. /** @hidden */
  25979. readonly _isCamera: boolean;
  25980. /**
  25981. * Gets a string representation of the camera useful for debug purpose.
  25982. * @param fullDetails Defines that a more verboe level of logging is required
  25983. * @returns the string representation
  25984. */
  25985. toString(fullDetails?: boolean): string;
  25986. /**
  25987. * Gets the current world space position of the camera.
  25988. */
  25989. readonly globalPosition: Vector3;
  25990. /**
  25991. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25992. * @returns the active meshe list
  25993. */
  25994. getActiveMeshes(): SmartArray<AbstractMesh>;
  25995. /**
  25996. * Check wether a mesh is part of the current active mesh list of the camera
  25997. * @param mesh Defines the mesh to check
  25998. * @returns true if active, false otherwise
  25999. */
  26000. isActiveMesh(mesh: Mesh): boolean;
  26001. /**
  26002. * Is this camera ready to be used/rendered
  26003. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26004. * @return true if the camera is ready
  26005. */
  26006. isReady(completeCheck?: boolean): boolean;
  26007. /** @hidden */
  26008. _initCache(): void;
  26009. /** @hidden */
  26010. _updateCache(ignoreParentClass?: boolean): void;
  26011. /** @hidden */
  26012. _isSynchronized(): boolean;
  26013. /** @hidden */
  26014. _isSynchronizedViewMatrix(): boolean;
  26015. /** @hidden */
  26016. _isSynchronizedProjectionMatrix(): boolean;
  26017. /**
  26018. * Attach the input controls to a specific dom element to get the input from.
  26019. * @param element Defines the element the controls should be listened from
  26020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26021. */
  26022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26023. /**
  26024. * Detach the current controls from the specified dom element.
  26025. * @param element Defines the element to stop listening the inputs from
  26026. */
  26027. detachControl(element: HTMLElement): void;
  26028. /**
  26029. * Update the camera state according to the different inputs gathered during the frame.
  26030. */
  26031. update(): void;
  26032. /** @hidden */
  26033. _checkInputs(): void;
  26034. /** @hidden */
  26035. readonly rigCameras: Camera[];
  26036. /**
  26037. * Gets the post process used by the rig cameras
  26038. */
  26039. readonly rigPostProcess: Nullable<PostProcess>;
  26040. /**
  26041. * Internal, gets the first post proces.
  26042. * @returns the first post process to be run on this camera.
  26043. */
  26044. _getFirstPostProcess(): Nullable<PostProcess>;
  26045. private _cascadePostProcessesToRigCams;
  26046. /**
  26047. * Attach a post process to the camera.
  26048. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26049. * @param postProcess The post process to attach to the camera
  26050. * @param insertAt The position of the post process in case several of them are in use in the scene
  26051. * @returns the position the post process has been inserted at
  26052. */
  26053. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26054. /**
  26055. * Detach a post process to the camera.
  26056. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26057. * @param postProcess The post process to detach from the camera
  26058. */
  26059. detachPostProcess(postProcess: PostProcess): void;
  26060. /**
  26061. * Gets the current world matrix of the camera
  26062. */
  26063. getWorldMatrix(): Matrix;
  26064. /** @hidden */
  26065. _getViewMatrix(): Matrix;
  26066. /**
  26067. * Gets the current view matrix of the camera.
  26068. * @param force forces the camera to recompute the matrix without looking at the cached state
  26069. * @returns the view matrix
  26070. */
  26071. getViewMatrix(force?: boolean): Matrix;
  26072. /**
  26073. * Freeze the projection matrix.
  26074. * It will prevent the cache check of the camera projection compute and can speed up perf
  26075. * if no parameter of the camera are meant to change
  26076. * @param projection Defines manually a projection if necessary
  26077. */
  26078. freezeProjectionMatrix(projection?: Matrix): void;
  26079. /**
  26080. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26081. */
  26082. unfreezeProjectionMatrix(): void;
  26083. /**
  26084. * Gets the current projection matrix of the camera.
  26085. * @param force forces the camera to recompute the matrix without looking at the cached state
  26086. * @returns the projection matrix
  26087. */
  26088. getProjectionMatrix(force?: boolean): Matrix;
  26089. /**
  26090. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26091. * @returns a Matrix
  26092. */
  26093. getTransformationMatrix(): Matrix;
  26094. private _updateFrustumPlanes;
  26095. /**
  26096. * Checks if a cullable object (mesh...) is in the camera frustum
  26097. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26098. * @param target The object to check
  26099. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26100. * @returns true if the object is in frustum otherwise false
  26101. */
  26102. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26103. /**
  26104. * Checks if a cullable object (mesh...) is in the camera frustum
  26105. * Unlike isInFrustum this cheks the full bounding box
  26106. * @param target The object to check
  26107. * @returns true if the object is in frustum otherwise false
  26108. */
  26109. isCompletelyInFrustum(target: ICullable): boolean;
  26110. /**
  26111. * Gets a ray in the forward direction from the camera.
  26112. * @param length Defines the length of the ray to create
  26113. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26114. * @param origin Defines the start point of the ray which defaults to the camera position
  26115. * @returns the forward ray
  26116. */
  26117. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26118. /**
  26119. * Releases resources associated with this node.
  26120. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26121. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26122. */
  26123. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26124. /** @hidden */
  26125. _isLeftCamera: boolean;
  26126. /**
  26127. * Gets the left camera of a rig setup in case of Rigged Camera
  26128. */
  26129. readonly isLeftCamera: boolean;
  26130. /** @hidden */
  26131. _isRightCamera: boolean;
  26132. /**
  26133. * Gets the right camera of a rig setup in case of Rigged Camera
  26134. */
  26135. readonly isRightCamera: boolean;
  26136. /**
  26137. * Gets the left camera of a rig setup in case of Rigged Camera
  26138. */
  26139. readonly leftCamera: Nullable<FreeCamera>;
  26140. /**
  26141. * Gets the right camera of a rig setup in case of Rigged Camera
  26142. */
  26143. readonly rightCamera: Nullable<FreeCamera>;
  26144. /**
  26145. * Gets the left camera target of a rig setup in case of Rigged Camera
  26146. * @returns the target position
  26147. */
  26148. getLeftTarget(): Nullable<Vector3>;
  26149. /**
  26150. * Gets the right camera target of a rig setup in case of Rigged Camera
  26151. * @returns the target position
  26152. */
  26153. getRightTarget(): Nullable<Vector3>;
  26154. /**
  26155. * @hidden
  26156. */
  26157. setCameraRigMode(mode: number, rigParams: any): void;
  26158. /** @hidden */
  26159. static _setStereoscopicRigMode(camera: Camera): void;
  26160. /** @hidden */
  26161. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26162. /** @hidden */
  26163. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26164. /** @hidden */
  26165. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26166. /** @hidden */
  26167. _getVRProjectionMatrix(): Matrix;
  26168. protected _updateCameraRotationMatrix(): void;
  26169. protected _updateWebVRCameraRotationMatrix(): void;
  26170. /**
  26171. * This function MUST be overwritten by the different WebVR cameras available.
  26172. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26173. * @hidden
  26174. */
  26175. _getWebVRProjectionMatrix(): Matrix;
  26176. /**
  26177. * This function MUST be overwritten by the different WebVR cameras available.
  26178. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26179. * @hidden
  26180. */
  26181. _getWebVRViewMatrix(): Matrix;
  26182. /** @hidden */
  26183. setCameraRigParameter(name: string, value: any): void;
  26184. /**
  26185. * needs to be overridden by children so sub has required properties to be copied
  26186. * @hidden
  26187. */
  26188. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26189. /**
  26190. * May need to be overridden by children
  26191. * @hidden
  26192. */
  26193. _updateRigCameras(): void;
  26194. /** @hidden */
  26195. _setupInputs(): void;
  26196. /**
  26197. * Serialiaze the camera setup to a json represention
  26198. * @returns the JSON representation
  26199. */
  26200. serialize(): any;
  26201. /**
  26202. * Clones the current camera.
  26203. * @param name The cloned camera name
  26204. * @returns the cloned camera
  26205. */
  26206. clone(name: string): Camera;
  26207. /**
  26208. * Gets the direction of the camera relative to a given local axis.
  26209. * @param localAxis Defines the reference axis to provide a relative direction.
  26210. * @return the direction
  26211. */
  26212. getDirection(localAxis: Vector3): Vector3;
  26213. /**
  26214. * Returns the current camera absolute rotation
  26215. */
  26216. readonly absoluteRotation: Quaternion;
  26217. /**
  26218. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26219. * @param localAxis Defines the reference axis to provide a relative direction.
  26220. * @param result Defines the vector to store the result in
  26221. */
  26222. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26223. /**
  26224. * Gets a camera constructor for a given camera type
  26225. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26226. * @param name The name of the camera the result will be able to instantiate
  26227. * @param scene The scene the result will construct the camera in
  26228. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26229. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26230. * @returns a factory method to construc the camera
  26231. */
  26232. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26233. /**
  26234. * Compute the world matrix of the camera.
  26235. * @returns the camera world matrix
  26236. */
  26237. computeWorldMatrix(): Matrix;
  26238. /**
  26239. * Parse a JSON and creates the camera from the parsed information
  26240. * @param parsedCamera The JSON to parse
  26241. * @param scene The scene to instantiate the camera in
  26242. * @returns the newly constructed camera
  26243. */
  26244. static Parse(parsedCamera: any, scene: Scene): Camera;
  26245. }
  26246. }
  26247. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26248. import { Nullable } from "babylonjs/types";
  26249. import { Scene } from "babylonjs/scene";
  26250. import { Vector4 } from "babylonjs/Maths/math.vector";
  26251. import { Mesh } from "babylonjs/Meshes/mesh";
  26252. /**
  26253. * Class containing static functions to help procedurally build meshes
  26254. */
  26255. export class DiscBuilder {
  26256. /**
  26257. * Creates a plane polygonal mesh. By default, this is a disc
  26258. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26259. * * 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
  26260. * * 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
  26261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26264. * @param name defines the name of the mesh
  26265. * @param options defines the options used to create the mesh
  26266. * @param scene defines the hosting scene
  26267. * @returns the plane polygonal mesh
  26268. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26269. */
  26270. static CreateDisc(name: string, options: {
  26271. radius?: number;
  26272. tessellation?: number;
  26273. arc?: number;
  26274. updatable?: boolean;
  26275. sideOrientation?: number;
  26276. frontUVs?: Vector4;
  26277. backUVs?: Vector4;
  26278. }, scene?: Nullable<Scene>): Mesh;
  26279. }
  26280. }
  26281. declare module "babylonjs/Materials/fresnelParameters" {
  26282. import { Color3 } from "babylonjs/Maths/math.color";
  26283. /**
  26284. * This represents all the required information to add a fresnel effect on a material:
  26285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26286. */
  26287. export class FresnelParameters {
  26288. private _isEnabled;
  26289. /**
  26290. * Define if the fresnel effect is enable or not.
  26291. */
  26292. isEnabled: boolean;
  26293. /**
  26294. * Define the color used on edges (grazing angle)
  26295. */
  26296. leftColor: Color3;
  26297. /**
  26298. * Define the color used on center
  26299. */
  26300. rightColor: Color3;
  26301. /**
  26302. * Define bias applied to computed fresnel term
  26303. */
  26304. bias: number;
  26305. /**
  26306. * Defined the power exponent applied to fresnel term
  26307. */
  26308. power: number;
  26309. /**
  26310. * Clones the current fresnel and its valuues
  26311. * @returns a clone fresnel configuration
  26312. */
  26313. clone(): FresnelParameters;
  26314. /**
  26315. * Serializes the current fresnel parameters to a JSON representation.
  26316. * @return the JSON serialization
  26317. */
  26318. serialize(): any;
  26319. /**
  26320. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26321. * @param parsedFresnelParameters Define the JSON representation
  26322. * @returns the parsed parameters
  26323. */
  26324. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26325. }
  26326. }
  26327. declare module "babylonjs/Materials/pushMaterial" {
  26328. import { Nullable } from "babylonjs/types";
  26329. import { Scene } from "babylonjs/scene";
  26330. import { Matrix } from "babylonjs/Maths/math.vector";
  26331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26332. import { Mesh } from "babylonjs/Meshes/mesh";
  26333. import { Material } from "babylonjs/Materials/material";
  26334. import { Effect } from "babylonjs/Materials/effect";
  26335. /**
  26336. * Base class of materials working in push mode in babylon JS
  26337. * @hidden
  26338. */
  26339. export class PushMaterial extends Material {
  26340. protected _activeEffect: Effect;
  26341. protected _normalMatrix: Matrix;
  26342. /**
  26343. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26344. * This means that the material can keep using a previous shader while a new one is being compiled.
  26345. * This is mostly used when shader parallel compilation is supported (true by default)
  26346. */
  26347. allowShaderHotSwapping: boolean;
  26348. constructor(name: string, scene: Scene);
  26349. getEffect(): Effect;
  26350. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26351. /**
  26352. * Binds the given world matrix to the active effect
  26353. *
  26354. * @param world the matrix to bind
  26355. */
  26356. bindOnlyWorldMatrix(world: Matrix): void;
  26357. /**
  26358. * Binds the given normal matrix to the active effect
  26359. *
  26360. * @param normalMatrix the matrix to bind
  26361. */
  26362. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26363. bind(world: Matrix, mesh?: Mesh): void;
  26364. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26365. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26366. }
  26367. }
  26368. declare module "babylonjs/Materials/materialFlags" {
  26369. /**
  26370. * This groups all the flags used to control the materials channel.
  26371. */
  26372. export class MaterialFlags {
  26373. private static _DiffuseTextureEnabled;
  26374. /**
  26375. * Are diffuse textures enabled in the application.
  26376. */
  26377. static DiffuseTextureEnabled: boolean;
  26378. private static _AmbientTextureEnabled;
  26379. /**
  26380. * Are ambient textures enabled in the application.
  26381. */
  26382. static AmbientTextureEnabled: boolean;
  26383. private static _OpacityTextureEnabled;
  26384. /**
  26385. * Are opacity textures enabled in the application.
  26386. */
  26387. static OpacityTextureEnabled: boolean;
  26388. private static _ReflectionTextureEnabled;
  26389. /**
  26390. * Are reflection textures enabled in the application.
  26391. */
  26392. static ReflectionTextureEnabled: boolean;
  26393. private static _EmissiveTextureEnabled;
  26394. /**
  26395. * Are emissive textures enabled in the application.
  26396. */
  26397. static EmissiveTextureEnabled: boolean;
  26398. private static _SpecularTextureEnabled;
  26399. /**
  26400. * Are specular textures enabled in the application.
  26401. */
  26402. static SpecularTextureEnabled: boolean;
  26403. private static _BumpTextureEnabled;
  26404. /**
  26405. * Are bump textures enabled in the application.
  26406. */
  26407. static BumpTextureEnabled: boolean;
  26408. private static _LightmapTextureEnabled;
  26409. /**
  26410. * Are lightmap textures enabled in the application.
  26411. */
  26412. static LightmapTextureEnabled: boolean;
  26413. private static _RefractionTextureEnabled;
  26414. /**
  26415. * Are refraction textures enabled in the application.
  26416. */
  26417. static RefractionTextureEnabled: boolean;
  26418. private static _ColorGradingTextureEnabled;
  26419. /**
  26420. * Are color grading textures enabled in the application.
  26421. */
  26422. static ColorGradingTextureEnabled: boolean;
  26423. private static _FresnelEnabled;
  26424. /**
  26425. * Are fresnels enabled in the application.
  26426. */
  26427. static FresnelEnabled: boolean;
  26428. private static _ClearCoatTextureEnabled;
  26429. /**
  26430. * Are clear coat textures enabled in the application.
  26431. */
  26432. static ClearCoatTextureEnabled: boolean;
  26433. private static _ClearCoatBumpTextureEnabled;
  26434. /**
  26435. * Are clear coat bump textures enabled in the application.
  26436. */
  26437. static ClearCoatBumpTextureEnabled: boolean;
  26438. private static _ClearCoatTintTextureEnabled;
  26439. /**
  26440. * Are clear coat tint textures enabled in the application.
  26441. */
  26442. static ClearCoatTintTextureEnabled: boolean;
  26443. private static _SheenTextureEnabled;
  26444. /**
  26445. * Are sheen textures enabled in the application.
  26446. */
  26447. static SheenTextureEnabled: boolean;
  26448. private static _AnisotropicTextureEnabled;
  26449. /**
  26450. * Are anisotropic textures enabled in the application.
  26451. */
  26452. static AnisotropicTextureEnabled: boolean;
  26453. private static _ThicknessTextureEnabled;
  26454. /**
  26455. * Are thickness textures enabled in the application.
  26456. */
  26457. static ThicknessTextureEnabled: boolean;
  26458. }
  26459. }
  26460. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26461. /** @hidden */
  26462. export var defaultFragmentDeclaration: {
  26463. name: string;
  26464. shader: string;
  26465. };
  26466. }
  26467. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26468. /** @hidden */
  26469. export var defaultUboDeclaration: {
  26470. name: string;
  26471. shader: string;
  26472. };
  26473. }
  26474. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26475. /** @hidden */
  26476. export var lightFragmentDeclaration: {
  26477. name: string;
  26478. shader: string;
  26479. };
  26480. }
  26481. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26482. /** @hidden */
  26483. export var lightUboDeclaration: {
  26484. name: string;
  26485. shader: string;
  26486. };
  26487. }
  26488. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26489. /** @hidden */
  26490. export var lightsFragmentFunctions: {
  26491. name: string;
  26492. shader: string;
  26493. };
  26494. }
  26495. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26496. /** @hidden */
  26497. export var shadowsFragmentFunctions: {
  26498. name: string;
  26499. shader: string;
  26500. };
  26501. }
  26502. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26503. /** @hidden */
  26504. export var fresnelFunction: {
  26505. name: string;
  26506. shader: string;
  26507. };
  26508. }
  26509. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26510. /** @hidden */
  26511. export var reflectionFunction: {
  26512. name: string;
  26513. shader: string;
  26514. };
  26515. }
  26516. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26517. /** @hidden */
  26518. export var bumpFragmentFunctions: {
  26519. name: string;
  26520. shader: string;
  26521. };
  26522. }
  26523. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26524. /** @hidden */
  26525. export var logDepthDeclaration: {
  26526. name: string;
  26527. shader: string;
  26528. };
  26529. }
  26530. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26531. /** @hidden */
  26532. export var bumpFragment: {
  26533. name: string;
  26534. shader: string;
  26535. };
  26536. }
  26537. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26538. /** @hidden */
  26539. export var depthPrePass: {
  26540. name: string;
  26541. shader: string;
  26542. };
  26543. }
  26544. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26545. /** @hidden */
  26546. export var lightFragment: {
  26547. name: string;
  26548. shader: string;
  26549. };
  26550. }
  26551. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26552. /** @hidden */
  26553. export var logDepthFragment: {
  26554. name: string;
  26555. shader: string;
  26556. };
  26557. }
  26558. declare module "babylonjs/Shaders/default.fragment" {
  26559. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26560. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26561. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26562. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26563. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26564. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26565. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26566. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26567. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26568. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26569. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26570. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26571. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26572. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26573. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26574. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26575. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26576. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26577. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26578. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26579. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26580. /** @hidden */
  26581. export var defaultPixelShader: {
  26582. name: string;
  26583. shader: string;
  26584. };
  26585. }
  26586. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26587. /** @hidden */
  26588. export var defaultVertexDeclaration: {
  26589. name: string;
  26590. shader: string;
  26591. };
  26592. }
  26593. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26594. /** @hidden */
  26595. export var bumpVertexDeclaration: {
  26596. name: string;
  26597. shader: string;
  26598. };
  26599. }
  26600. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26601. /** @hidden */
  26602. export var bumpVertex: {
  26603. name: string;
  26604. shader: string;
  26605. };
  26606. }
  26607. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26608. /** @hidden */
  26609. export var fogVertex: {
  26610. name: string;
  26611. shader: string;
  26612. };
  26613. }
  26614. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26615. /** @hidden */
  26616. export var shadowsVertex: {
  26617. name: string;
  26618. shader: string;
  26619. };
  26620. }
  26621. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26622. /** @hidden */
  26623. export var pointCloudVertex: {
  26624. name: string;
  26625. shader: string;
  26626. };
  26627. }
  26628. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26629. /** @hidden */
  26630. export var logDepthVertex: {
  26631. name: string;
  26632. shader: string;
  26633. };
  26634. }
  26635. declare module "babylonjs/Shaders/default.vertex" {
  26636. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26637. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26638. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26639. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26641. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26642. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26643. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26644. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26645. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26648. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26649. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26650. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26651. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26652. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26653. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26654. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26655. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26656. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26657. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26658. /** @hidden */
  26659. export var defaultVertexShader: {
  26660. name: string;
  26661. shader: string;
  26662. };
  26663. }
  26664. declare module "babylonjs/Materials/standardMaterial" {
  26665. import { SmartArray } from "babylonjs/Misc/smartArray";
  26666. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26667. import { Nullable } from "babylonjs/types";
  26668. import { Scene } from "babylonjs/scene";
  26669. import { Matrix } from "babylonjs/Maths/math.vector";
  26670. import { Color3 } from "babylonjs/Maths/math.color";
  26671. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26673. import { Mesh } from "babylonjs/Meshes/mesh";
  26674. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26675. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26676. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26677. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26678. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26680. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26681. import "babylonjs/Shaders/default.fragment";
  26682. import "babylonjs/Shaders/default.vertex";
  26683. /** @hidden */
  26684. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26685. MAINUV1: boolean;
  26686. MAINUV2: boolean;
  26687. DIFFUSE: boolean;
  26688. DIFFUSEDIRECTUV: number;
  26689. AMBIENT: boolean;
  26690. AMBIENTDIRECTUV: number;
  26691. OPACITY: boolean;
  26692. OPACITYDIRECTUV: number;
  26693. OPACITYRGB: boolean;
  26694. REFLECTION: boolean;
  26695. EMISSIVE: boolean;
  26696. EMISSIVEDIRECTUV: number;
  26697. SPECULAR: boolean;
  26698. SPECULARDIRECTUV: number;
  26699. BUMP: boolean;
  26700. BUMPDIRECTUV: number;
  26701. PARALLAX: boolean;
  26702. PARALLAXOCCLUSION: boolean;
  26703. SPECULAROVERALPHA: boolean;
  26704. CLIPPLANE: boolean;
  26705. CLIPPLANE2: boolean;
  26706. CLIPPLANE3: boolean;
  26707. CLIPPLANE4: boolean;
  26708. ALPHATEST: boolean;
  26709. DEPTHPREPASS: boolean;
  26710. ALPHAFROMDIFFUSE: boolean;
  26711. POINTSIZE: boolean;
  26712. FOG: boolean;
  26713. SPECULARTERM: boolean;
  26714. DIFFUSEFRESNEL: boolean;
  26715. OPACITYFRESNEL: boolean;
  26716. REFLECTIONFRESNEL: boolean;
  26717. REFRACTIONFRESNEL: boolean;
  26718. EMISSIVEFRESNEL: boolean;
  26719. FRESNEL: boolean;
  26720. NORMAL: boolean;
  26721. UV1: boolean;
  26722. UV2: boolean;
  26723. VERTEXCOLOR: boolean;
  26724. VERTEXALPHA: boolean;
  26725. NUM_BONE_INFLUENCERS: number;
  26726. BonesPerMesh: number;
  26727. BONETEXTURE: boolean;
  26728. INSTANCES: boolean;
  26729. GLOSSINESS: boolean;
  26730. ROUGHNESS: boolean;
  26731. EMISSIVEASILLUMINATION: boolean;
  26732. LINKEMISSIVEWITHDIFFUSE: boolean;
  26733. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26734. LIGHTMAP: boolean;
  26735. LIGHTMAPDIRECTUV: number;
  26736. OBJECTSPACE_NORMALMAP: boolean;
  26737. USELIGHTMAPASSHADOWMAP: boolean;
  26738. REFLECTIONMAP_3D: boolean;
  26739. REFLECTIONMAP_SPHERICAL: boolean;
  26740. REFLECTIONMAP_PLANAR: boolean;
  26741. REFLECTIONMAP_CUBIC: boolean;
  26742. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26743. REFLECTIONMAP_PROJECTION: boolean;
  26744. REFLECTIONMAP_SKYBOX: boolean;
  26745. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26746. REFLECTIONMAP_EXPLICIT: boolean;
  26747. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26748. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26749. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26750. INVERTCUBICMAP: boolean;
  26751. LOGARITHMICDEPTH: boolean;
  26752. REFRACTION: boolean;
  26753. REFRACTIONMAP_3D: boolean;
  26754. REFLECTIONOVERALPHA: boolean;
  26755. TWOSIDEDLIGHTING: boolean;
  26756. SHADOWFLOAT: boolean;
  26757. MORPHTARGETS: boolean;
  26758. MORPHTARGETS_NORMAL: boolean;
  26759. MORPHTARGETS_TANGENT: boolean;
  26760. MORPHTARGETS_UV: boolean;
  26761. NUM_MORPH_INFLUENCERS: number;
  26762. NONUNIFORMSCALING: boolean;
  26763. PREMULTIPLYALPHA: boolean;
  26764. IMAGEPROCESSING: boolean;
  26765. VIGNETTE: boolean;
  26766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26767. VIGNETTEBLENDMODEOPAQUE: boolean;
  26768. TONEMAPPING: boolean;
  26769. TONEMAPPING_ACES: boolean;
  26770. CONTRAST: boolean;
  26771. COLORCURVES: boolean;
  26772. COLORGRADING: boolean;
  26773. COLORGRADING3D: boolean;
  26774. SAMPLER3DGREENDEPTH: boolean;
  26775. SAMPLER3DBGRMAP: boolean;
  26776. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26777. MULTIVIEW: boolean;
  26778. /**
  26779. * If the reflection texture on this material is in linear color space
  26780. * @hidden
  26781. */
  26782. IS_REFLECTION_LINEAR: boolean;
  26783. /**
  26784. * If the refraction texture on this material is in linear color space
  26785. * @hidden
  26786. */
  26787. IS_REFRACTION_LINEAR: boolean;
  26788. EXPOSURE: boolean;
  26789. constructor();
  26790. setReflectionMode(modeToEnable: string): void;
  26791. }
  26792. /**
  26793. * This is the default material used in Babylon. It is the best trade off between quality
  26794. * and performances.
  26795. * @see http://doc.babylonjs.com/babylon101/materials
  26796. */
  26797. export class StandardMaterial extends PushMaterial {
  26798. private _diffuseTexture;
  26799. /**
  26800. * The basic texture of the material as viewed under a light.
  26801. */
  26802. diffuseTexture: Nullable<BaseTexture>;
  26803. private _ambientTexture;
  26804. /**
  26805. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26806. */
  26807. ambientTexture: Nullable<BaseTexture>;
  26808. private _opacityTexture;
  26809. /**
  26810. * Define the transparency of the material from a texture.
  26811. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26812. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26813. */
  26814. opacityTexture: Nullable<BaseTexture>;
  26815. private _reflectionTexture;
  26816. /**
  26817. * Define the texture used to display the reflection.
  26818. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26819. */
  26820. reflectionTexture: Nullable<BaseTexture>;
  26821. private _emissiveTexture;
  26822. /**
  26823. * Define texture of the material as if self lit.
  26824. * This will be mixed in the final result even in the absence of light.
  26825. */
  26826. emissiveTexture: Nullable<BaseTexture>;
  26827. private _specularTexture;
  26828. /**
  26829. * Define how the color and intensity of the highlight given by the light in the material.
  26830. */
  26831. specularTexture: Nullable<BaseTexture>;
  26832. private _bumpTexture;
  26833. /**
  26834. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26835. * 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.
  26836. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26837. */
  26838. bumpTexture: Nullable<BaseTexture>;
  26839. private _lightmapTexture;
  26840. /**
  26841. * Complex lighting can be computationally expensive to compute at runtime.
  26842. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26843. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26844. */
  26845. lightmapTexture: Nullable<BaseTexture>;
  26846. private _refractionTexture;
  26847. /**
  26848. * Define the texture used to display the refraction.
  26849. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26850. */
  26851. refractionTexture: Nullable<BaseTexture>;
  26852. /**
  26853. * The color of the material lit by the environmental background lighting.
  26854. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26855. */
  26856. ambientColor: Color3;
  26857. /**
  26858. * The basic color of the material as viewed under a light.
  26859. */
  26860. diffuseColor: Color3;
  26861. /**
  26862. * Define how the color and intensity of the highlight given by the light in the material.
  26863. */
  26864. specularColor: Color3;
  26865. /**
  26866. * Define the color of the material as if self lit.
  26867. * This will be mixed in the final result even in the absence of light.
  26868. */
  26869. emissiveColor: Color3;
  26870. /**
  26871. * Defines how sharp are the highlights in the material.
  26872. * The bigger the value the sharper giving a more glossy feeling to the result.
  26873. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26874. */
  26875. specularPower: number;
  26876. private _useAlphaFromDiffuseTexture;
  26877. /**
  26878. * Does the transparency come from the diffuse texture alpha channel.
  26879. */
  26880. useAlphaFromDiffuseTexture: boolean;
  26881. private _useEmissiveAsIllumination;
  26882. /**
  26883. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26884. */
  26885. useEmissiveAsIllumination: boolean;
  26886. private _linkEmissiveWithDiffuse;
  26887. /**
  26888. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26889. * the emissive level when the final color is close to one.
  26890. */
  26891. linkEmissiveWithDiffuse: boolean;
  26892. private _useSpecularOverAlpha;
  26893. /**
  26894. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26896. */
  26897. useSpecularOverAlpha: boolean;
  26898. private _useReflectionOverAlpha;
  26899. /**
  26900. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26901. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26902. */
  26903. useReflectionOverAlpha: boolean;
  26904. private _disableLighting;
  26905. /**
  26906. * Does lights from the scene impacts this material.
  26907. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26908. */
  26909. disableLighting: boolean;
  26910. private _useObjectSpaceNormalMap;
  26911. /**
  26912. * Allows using an object space normal map (instead of tangent space).
  26913. */
  26914. useObjectSpaceNormalMap: boolean;
  26915. private _useParallax;
  26916. /**
  26917. * Is parallax enabled or not.
  26918. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26919. */
  26920. useParallax: boolean;
  26921. private _useParallaxOcclusion;
  26922. /**
  26923. * Is parallax occlusion enabled or not.
  26924. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26925. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26926. */
  26927. useParallaxOcclusion: boolean;
  26928. /**
  26929. * 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.
  26930. */
  26931. parallaxScaleBias: number;
  26932. private _roughness;
  26933. /**
  26934. * Helps to define how blurry the reflections should appears in the material.
  26935. */
  26936. roughness: number;
  26937. /**
  26938. * In case of refraction, define the value of the index of refraction.
  26939. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26940. */
  26941. indexOfRefraction: number;
  26942. /**
  26943. * Invert the refraction texture alongside the y axis.
  26944. * It can be useful with procedural textures or probe for instance.
  26945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26946. */
  26947. invertRefractionY: boolean;
  26948. /**
  26949. * Defines the alpha limits in alpha test mode.
  26950. */
  26951. alphaCutOff: number;
  26952. private _useLightmapAsShadowmap;
  26953. /**
  26954. * In case of light mapping, define whether the map contains light or shadow informations.
  26955. */
  26956. useLightmapAsShadowmap: boolean;
  26957. private _diffuseFresnelParameters;
  26958. /**
  26959. * Define the diffuse fresnel parameters of the material.
  26960. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26961. */
  26962. diffuseFresnelParameters: FresnelParameters;
  26963. private _opacityFresnelParameters;
  26964. /**
  26965. * Define the opacity fresnel parameters of the material.
  26966. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26967. */
  26968. opacityFresnelParameters: FresnelParameters;
  26969. private _reflectionFresnelParameters;
  26970. /**
  26971. * Define the reflection fresnel parameters of the material.
  26972. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26973. */
  26974. reflectionFresnelParameters: FresnelParameters;
  26975. private _refractionFresnelParameters;
  26976. /**
  26977. * Define the refraction fresnel parameters of the material.
  26978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26979. */
  26980. refractionFresnelParameters: FresnelParameters;
  26981. private _emissiveFresnelParameters;
  26982. /**
  26983. * Define the emissive fresnel parameters of the material.
  26984. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26985. */
  26986. emissiveFresnelParameters: FresnelParameters;
  26987. private _useReflectionFresnelFromSpecular;
  26988. /**
  26989. * If true automatically deducts the fresnels values from the material specularity.
  26990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26991. */
  26992. useReflectionFresnelFromSpecular: boolean;
  26993. private _useGlossinessFromSpecularMapAlpha;
  26994. /**
  26995. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26996. */
  26997. useGlossinessFromSpecularMapAlpha: boolean;
  26998. private _maxSimultaneousLights;
  26999. /**
  27000. * Defines the maximum number of lights that can be used in the material
  27001. */
  27002. maxSimultaneousLights: number;
  27003. private _invertNormalMapX;
  27004. /**
  27005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27006. */
  27007. invertNormalMapX: boolean;
  27008. private _invertNormalMapY;
  27009. /**
  27010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27011. */
  27012. invertNormalMapY: boolean;
  27013. private _twoSidedLighting;
  27014. /**
  27015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27016. */
  27017. twoSidedLighting: boolean;
  27018. /**
  27019. * Default configuration related to image processing available in the standard Material.
  27020. */
  27021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27022. /**
  27023. * Gets the image processing configuration used either in this material.
  27024. */
  27025. /**
  27026. * Sets the Default image processing configuration used either in the this material.
  27027. *
  27028. * If sets to null, the scene one is in use.
  27029. */
  27030. imageProcessingConfiguration: ImageProcessingConfiguration;
  27031. /**
  27032. * Keep track of the image processing observer to allow dispose and replace.
  27033. */
  27034. private _imageProcessingObserver;
  27035. /**
  27036. * Attaches a new image processing configuration to the Standard Material.
  27037. * @param configuration
  27038. */
  27039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27040. /**
  27041. * Gets wether the color curves effect is enabled.
  27042. */
  27043. /**
  27044. * Sets wether the color curves effect is enabled.
  27045. */
  27046. cameraColorCurvesEnabled: boolean;
  27047. /**
  27048. * Gets wether the color grading effect is enabled.
  27049. */
  27050. /**
  27051. * Gets wether the color grading effect is enabled.
  27052. */
  27053. cameraColorGradingEnabled: boolean;
  27054. /**
  27055. * Gets wether tonemapping is enabled or not.
  27056. */
  27057. /**
  27058. * Sets wether tonemapping is enabled or not
  27059. */
  27060. cameraToneMappingEnabled: boolean;
  27061. /**
  27062. * The camera exposure used on this material.
  27063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27064. * This corresponds to a photographic exposure.
  27065. */
  27066. /**
  27067. * The camera exposure used on this material.
  27068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27069. * This corresponds to a photographic exposure.
  27070. */
  27071. cameraExposure: number;
  27072. /**
  27073. * Gets The camera contrast used on this material.
  27074. */
  27075. /**
  27076. * Sets The camera contrast used on this material.
  27077. */
  27078. cameraContrast: number;
  27079. /**
  27080. * Gets the Color Grading 2D Lookup Texture.
  27081. */
  27082. /**
  27083. * Sets the Color Grading 2D Lookup Texture.
  27084. */
  27085. cameraColorGradingTexture: Nullable<BaseTexture>;
  27086. /**
  27087. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27088. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27089. * 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;
  27090. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27091. */
  27092. /**
  27093. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27094. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27095. * 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;
  27096. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27097. */
  27098. cameraColorCurves: Nullable<ColorCurves>;
  27099. /**
  27100. * Custom callback helping to override the default shader used in the material.
  27101. */
  27102. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27103. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27104. protected _worldViewProjectionMatrix: Matrix;
  27105. protected _globalAmbientColor: Color3;
  27106. protected _useLogarithmicDepth: boolean;
  27107. protected _rebuildInParallel: boolean;
  27108. /**
  27109. * Instantiates a new standard material.
  27110. * This is the default material used in Babylon. It is the best trade off between quality
  27111. * and performances.
  27112. * @see http://doc.babylonjs.com/babylon101/materials
  27113. * @param name Define the name of the material in the scene
  27114. * @param scene Define the scene the material belong to
  27115. */
  27116. constructor(name: string, scene: Scene);
  27117. /**
  27118. * Gets a boolean indicating that current material needs to register RTT
  27119. */
  27120. readonly hasRenderTargetTextures: boolean;
  27121. /**
  27122. * Gets the current class name of the material e.g. "StandardMaterial"
  27123. * Mainly use in serialization.
  27124. * @returns the class name
  27125. */
  27126. getClassName(): string;
  27127. /**
  27128. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27129. * You can try switching to logarithmic depth.
  27130. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27131. */
  27132. useLogarithmicDepth: boolean;
  27133. /**
  27134. * Specifies if the material will require alpha blending
  27135. * @returns a boolean specifying if alpha blending is needed
  27136. */
  27137. needAlphaBlending(): boolean;
  27138. /**
  27139. * Specifies if this material should be rendered in alpha test mode
  27140. * @returns a boolean specifying if an alpha test is needed.
  27141. */
  27142. needAlphaTesting(): boolean;
  27143. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27144. /**
  27145. * Get the texture used for alpha test purpose.
  27146. * @returns the diffuse texture in case of the standard material.
  27147. */
  27148. getAlphaTestTexture(): Nullable<BaseTexture>;
  27149. /**
  27150. * Get if the submesh is ready to be used and all its information available.
  27151. * Child classes can use it to update shaders
  27152. * @param mesh defines the mesh to check
  27153. * @param subMesh defines which submesh to check
  27154. * @param useInstances specifies that instances should be used
  27155. * @returns a boolean indicating that the submesh is ready or not
  27156. */
  27157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27158. /**
  27159. * Builds the material UBO layouts.
  27160. * Used internally during the effect preparation.
  27161. */
  27162. buildUniformLayout(): void;
  27163. /**
  27164. * Unbinds the material from the mesh
  27165. */
  27166. unbind(): void;
  27167. /**
  27168. * Binds the submesh to this material by preparing the effect and shader to draw
  27169. * @param world defines the world transformation matrix
  27170. * @param mesh defines the mesh containing the submesh
  27171. * @param subMesh defines the submesh to bind the material to
  27172. */
  27173. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27174. /**
  27175. * Get the list of animatables in the material.
  27176. * @returns the list of animatables object used in the material
  27177. */
  27178. getAnimatables(): IAnimatable[];
  27179. /**
  27180. * Gets the active textures from the material
  27181. * @returns an array of textures
  27182. */
  27183. getActiveTextures(): BaseTexture[];
  27184. /**
  27185. * Specifies if the material uses a texture
  27186. * @param texture defines the texture to check against the material
  27187. * @returns a boolean specifying if the material uses the texture
  27188. */
  27189. hasTexture(texture: BaseTexture): boolean;
  27190. /**
  27191. * Disposes the material
  27192. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27193. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27194. */
  27195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27196. /**
  27197. * Makes a duplicate of the material, and gives it a new name
  27198. * @param name defines the new name for the duplicated material
  27199. * @returns the cloned material
  27200. */
  27201. clone(name: string): StandardMaterial;
  27202. /**
  27203. * Serializes this material in a JSON representation
  27204. * @returns the serialized material object
  27205. */
  27206. serialize(): any;
  27207. /**
  27208. * Creates a standard material from parsed material data
  27209. * @param source defines the JSON representation of the material
  27210. * @param scene defines the hosting scene
  27211. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27212. * @returns a new standard material
  27213. */
  27214. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27215. /**
  27216. * Are diffuse textures enabled in the application.
  27217. */
  27218. static DiffuseTextureEnabled: boolean;
  27219. /**
  27220. * Are ambient textures enabled in the application.
  27221. */
  27222. static AmbientTextureEnabled: boolean;
  27223. /**
  27224. * Are opacity textures enabled in the application.
  27225. */
  27226. static OpacityTextureEnabled: boolean;
  27227. /**
  27228. * Are reflection textures enabled in the application.
  27229. */
  27230. static ReflectionTextureEnabled: boolean;
  27231. /**
  27232. * Are emissive textures enabled in the application.
  27233. */
  27234. static EmissiveTextureEnabled: boolean;
  27235. /**
  27236. * Are specular textures enabled in the application.
  27237. */
  27238. static SpecularTextureEnabled: boolean;
  27239. /**
  27240. * Are bump textures enabled in the application.
  27241. */
  27242. static BumpTextureEnabled: boolean;
  27243. /**
  27244. * Are lightmap textures enabled in the application.
  27245. */
  27246. static LightmapTextureEnabled: boolean;
  27247. /**
  27248. * Are refraction textures enabled in the application.
  27249. */
  27250. static RefractionTextureEnabled: boolean;
  27251. /**
  27252. * Are color grading textures enabled in the application.
  27253. */
  27254. static ColorGradingTextureEnabled: boolean;
  27255. /**
  27256. * Are fresnels enabled in the application.
  27257. */
  27258. static FresnelEnabled: boolean;
  27259. }
  27260. }
  27261. declare module "babylonjs/Particles/solidParticleSystem" {
  27262. import { Nullable } from "babylonjs/types";
  27263. import { Vector3 } from "babylonjs/Maths/math.vector";
  27264. import { Mesh } from "babylonjs/Meshes/mesh";
  27265. import { Scene, IDisposable } from "babylonjs/scene";
  27266. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27267. import { Material } from "babylonjs/Materials/material";
  27268. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27269. /**
  27270. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27271. *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.
  27272. * The SPS is also a particle system. It provides some methods to manage the particles.
  27273. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27274. *
  27275. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27276. */
  27277. export class SolidParticleSystem implements IDisposable {
  27278. /**
  27279. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27280. * Example : var p = SPS.particles[i];
  27281. */
  27282. particles: SolidParticle[];
  27283. /**
  27284. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27285. */
  27286. nbParticles: number;
  27287. /**
  27288. * If the particles must ever face the camera (default false). Useful for planar particles.
  27289. */
  27290. billboard: boolean;
  27291. /**
  27292. * Recompute normals when adding a shape
  27293. */
  27294. recomputeNormals: boolean;
  27295. /**
  27296. * This a counter ofr your own usage. It's not set by any SPS functions.
  27297. */
  27298. counter: number;
  27299. /**
  27300. * The SPS name. This name is also given to the underlying mesh.
  27301. */
  27302. name: string;
  27303. /**
  27304. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27305. */
  27306. mesh: Mesh;
  27307. /**
  27308. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27309. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27310. */
  27311. vars: any;
  27312. /**
  27313. * This array is populated when the SPS is set as 'pickable'.
  27314. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27315. * Each element of this array is an object `{idx: int, faceId: int}`.
  27316. * `idx` is the picked particle index in the `SPS.particles` array
  27317. * `faceId` is the picked face index counted within this particle.
  27318. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27319. */
  27320. pickedParticles: {
  27321. idx: number;
  27322. faceId: number;
  27323. }[];
  27324. /**
  27325. * This array is populated when `enableDepthSort` is set to true.
  27326. * Each element of this array is an instance of the class DepthSortedParticle.
  27327. */
  27328. depthSortedParticles: DepthSortedParticle[];
  27329. /**
  27330. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27331. * @hidden
  27332. */
  27333. _bSphereOnly: boolean;
  27334. /**
  27335. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27336. * @hidden
  27337. */
  27338. _bSphereRadiusFactor: number;
  27339. private _scene;
  27340. private _positions;
  27341. private _indices;
  27342. private _normals;
  27343. private _colors;
  27344. private _uvs;
  27345. private _indices32;
  27346. private _positions32;
  27347. private _normals32;
  27348. private _fixedNormal32;
  27349. private _colors32;
  27350. private _uvs32;
  27351. private _index;
  27352. private _updatable;
  27353. private _pickable;
  27354. private _isVisibilityBoxLocked;
  27355. private _alwaysVisible;
  27356. private _depthSort;
  27357. private _expandable;
  27358. private _shapeCounter;
  27359. private _copy;
  27360. private _color;
  27361. private _computeParticleColor;
  27362. private _computeParticleTexture;
  27363. private _computeParticleRotation;
  27364. private _computeParticleVertex;
  27365. private _computeBoundingBox;
  27366. private _depthSortParticles;
  27367. private _camera;
  27368. private _mustUnrotateFixedNormals;
  27369. private _particlesIntersect;
  27370. private _needs32Bits;
  27371. private _isNotBuilt;
  27372. private _lastParticleId;
  27373. private _idxOfId;
  27374. private _multimaterialEnabled;
  27375. private _useModelMaterial;
  27376. private _indicesByMaterial;
  27377. private _materialIndexes;
  27378. private _depthSortFunction;
  27379. private _materialSortFunction;
  27380. private _materials;
  27381. private _multimaterial;
  27382. private _materialIndexesById;
  27383. private _defaultMaterial;
  27384. private _autoUpdateSubMeshes;
  27385. /**
  27386. * Creates a SPS (Solid Particle System) object.
  27387. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27388. * @param scene (Scene) is the scene in which the SPS is added.
  27389. * @param options defines the options of the sps e.g.
  27390. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27391. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27392. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27393. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27394. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27395. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27396. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27397. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27398. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27399. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27400. */
  27401. constructor(name: string, scene: Scene, options?: {
  27402. updatable?: boolean;
  27403. isPickable?: boolean;
  27404. enableDepthSort?: boolean;
  27405. particleIntersection?: boolean;
  27406. boundingSphereOnly?: boolean;
  27407. bSphereRadiusFactor?: number;
  27408. expandable?: boolean;
  27409. useModelMaterial?: boolean;
  27410. enableMultiMaterial?: boolean;
  27411. });
  27412. /**
  27413. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27414. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27415. * @returns the created mesh
  27416. */
  27417. buildMesh(): Mesh;
  27418. /**
  27419. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27420. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27421. * Thus the particles generated from `digest()` have their property `position` set yet.
  27422. * @param mesh ( Mesh ) is the mesh to be digested
  27423. * @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
  27424. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27425. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27426. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27427. * @returns the current SPS
  27428. */
  27429. digest(mesh: Mesh, options?: {
  27430. facetNb?: number;
  27431. number?: number;
  27432. delta?: number;
  27433. storage?: [];
  27434. }): SolidParticleSystem;
  27435. /**
  27436. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27437. * @hidden
  27438. */
  27439. private _unrotateFixedNormals;
  27440. /**
  27441. * Resets the temporary working copy particle
  27442. * @hidden
  27443. */
  27444. private _resetCopy;
  27445. /**
  27446. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27447. * @param p the current index in the positions array to be updated
  27448. * @param ind the current index in the indices array
  27449. * @param shape a Vector3 array, the shape geometry
  27450. * @param positions the positions array to be updated
  27451. * @param meshInd the shape indices array
  27452. * @param indices the indices array to be updated
  27453. * @param meshUV the shape uv array
  27454. * @param uvs the uv array to be updated
  27455. * @param meshCol the shape color array
  27456. * @param colors the color array to be updated
  27457. * @param meshNor the shape normals array
  27458. * @param normals the normals array to be updated
  27459. * @param idx the particle index
  27460. * @param idxInShape the particle index in its shape
  27461. * @param options the addShape() method passed options
  27462. * @model the particle model
  27463. * @hidden
  27464. */
  27465. private _meshBuilder;
  27466. /**
  27467. * Returns a shape Vector3 array from positions float array
  27468. * @param positions float array
  27469. * @returns a vector3 array
  27470. * @hidden
  27471. */
  27472. private _posToShape;
  27473. /**
  27474. * Returns a shapeUV array from a float uvs (array deep copy)
  27475. * @param uvs as a float array
  27476. * @returns a shapeUV array
  27477. * @hidden
  27478. */
  27479. private _uvsToShapeUV;
  27480. /**
  27481. * Adds a new particle object in the particles array
  27482. * @param idx particle index in particles array
  27483. * @param id particle id
  27484. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27485. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27486. * @param model particle ModelShape object
  27487. * @param shapeId model shape identifier
  27488. * @param idxInShape index of the particle in the current model
  27489. * @param bInfo model bounding info object
  27490. * @param storage target storage array, if any
  27491. * @hidden
  27492. */
  27493. private _addParticle;
  27494. /**
  27495. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27496. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27497. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27498. * @param nb (positive integer) the number of particles to be created from this model
  27499. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27500. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27501. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27502. * @returns the number of shapes in the system
  27503. */
  27504. addShape(mesh: Mesh, nb: number, options?: {
  27505. positionFunction?: any;
  27506. vertexFunction?: any;
  27507. storage?: [];
  27508. }): number;
  27509. /**
  27510. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27511. * @hidden
  27512. */
  27513. private _rebuildParticle;
  27514. /**
  27515. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27516. * @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.
  27517. * @returns the SPS.
  27518. */
  27519. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27520. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27521. * Returns an array with the removed particles.
  27522. * 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.
  27523. * The SPS can't be empty so at least one particle needs to remain in place.
  27524. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27525. * @param start index of the first particle to remove
  27526. * @param end index of the last particle to remove (included)
  27527. * @returns an array populated with the removed particles
  27528. */
  27529. removeParticles(start: number, end: number): SolidParticle[];
  27530. /**
  27531. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27532. * @param solidParticleArray an array populated with Solid Particles objects
  27533. * @returns the SPS
  27534. */
  27535. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27536. /**
  27537. * Creates a new particle and modifies the SPS mesh geometry :
  27538. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27539. * - calls _addParticle() to populate the particle array
  27540. * factorized code from addShape() and insertParticlesFromArray()
  27541. * @param idx particle index in the particles array
  27542. * @param i particle index in its shape
  27543. * @param modelShape particle ModelShape object
  27544. * @param shape shape vertex array
  27545. * @param meshInd shape indices array
  27546. * @param meshUV shape uv array
  27547. * @param meshCol shape color array
  27548. * @param meshNor shape normals array
  27549. * @param bbInfo shape bounding info
  27550. * @param storage target particle storage
  27551. * @options addShape() passed options
  27552. * @hidden
  27553. */
  27554. private _insertNewParticle;
  27555. /**
  27556. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27557. * This method calls `updateParticle()` for each particle of the SPS.
  27558. * For an animated SPS, it is usually called within the render loop.
  27559. * 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.
  27560. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27561. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27562. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27563. * @returns the SPS.
  27564. */
  27565. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27566. /**
  27567. * Disposes the SPS.
  27568. */
  27569. dispose(): void;
  27570. /**
  27571. * Returns a SolidParticle object from its identifier : particle.id
  27572. * @param id (integer) the particle Id
  27573. * @returns the searched particle or null if not found in the SPS.
  27574. */
  27575. getParticleById(id: number): Nullable<SolidParticle>;
  27576. /**
  27577. * Returns a new array populated with the particles having the passed shapeId.
  27578. * @param shapeId (integer) the shape identifier
  27579. * @returns a new solid particle array
  27580. */
  27581. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27582. /**
  27583. * Populates the passed array "ref" with the particles having the passed shapeId.
  27584. * @param shapeId the shape identifier
  27585. * @returns the SPS
  27586. * @param ref
  27587. */
  27588. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27589. /**
  27590. * Computes the required SubMeshes according the materials assigned to the particles.
  27591. * @returns the solid particle system.
  27592. * Does nothing if called before the SPS mesh is built.
  27593. */
  27594. computeSubMeshes(): SolidParticleSystem;
  27595. /**
  27596. * Sorts the solid particles by material when MultiMaterial is enabled.
  27597. * Updates the indices32 array.
  27598. * Updates the indicesByMaterial array.
  27599. * Updates the mesh indices array.
  27600. * @returns the SPS
  27601. * @hidden
  27602. */
  27603. private _sortParticlesByMaterial;
  27604. /**
  27605. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27606. * @hidden
  27607. */
  27608. private _setMaterialIndexesById;
  27609. /**
  27610. * Returns an array with unique values of Materials from the passed array
  27611. * @param array the material array to be checked and filtered
  27612. * @hidden
  27613. */
  27614. private _filterUniqueMaterialId;
  27615. /**
  27616. * Sets a new Standard Material as _defaultMaterial if not already set.
  27617. * @hidden
  27618. */
  27619. private _setDefaultMaterial;
  27620. /**
  27621. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27622. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27623. * @returns the SPS.
  27624. */
  27625. refreshVisibleSize(): SolidParticleSystem;
  27626. /**
  27627. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27628. * @param size the size (float) of the visibility box
  27629. * note : this doesn't lock the SPS mesh bounding box.
  27630. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27631. */
  27632. setVisibilityBox(size: number): void;
  27633. /**
  27634. * Gets whether the SPS as always visible or not
  27635. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27636. */
  27637. /**
  27638. * Sets the SPS as always visible or not
  27639. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27640. */
  27641. isAlwaysVisible: boolean;
  27642. /**
  27643. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27644. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27645. */
  27646. /**
  27647. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27648. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27649. */
  27650. isVisibilityBoxLocked: boolean;
  27651. /**
  27652. * Tells to `setParticles()` to compute the particle rotations or not.
  27653. * Default value : true. The SPS is faster when it's set to false.
  27654. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27655. */
  27656. /**
  27657. * Gets if `setParticles()` computes the particle rotations or not.
  27658. * Default value : true. The SPS is faster when it's set to false.
  27659. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27660. */
  27661. computeParticleRotation: boolean;
  27662. /**
  27663. * Tells to `setParticles()` to compute the particle colors or not.
  27664. * Default value : true. The SPS is faster when it's set to false.
  27665. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27666. */
  27667. /**
  27668. * Gets if `setParticles()` computes the particle colors or not.
  27669. * Default value : true. The SPS is faster when it's set to false.
  27670. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27671. */
  27672. computeParticleColor: boolean;
  27673. /**
  27674. * Gets if `setParticles()` computes the particle textures or not.
  27675. * Default value : true. The SPS is faster when it's set to false.
  27676. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27677. */
  27678. computeParticleTexture: boolean;
  27679. /**
  27680. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27681. * Default value : false. The SPS is faster when it's set to false.
  27682. * Note : the particle custom vertex positions aren't stored values.
  27683. */
  27684. /**
  27685. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27686. * Default value : false. The SPS is faster when it's set to false.
  27687. * Note : the particle custom vertex positions aren't stored values.
  27688. */
  27689. computeParticleVertex: boolean;
  27690. /**
  27691. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27692. */
  27693. /**
  27694. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27695. */
  27696. computeBoundingBox: boolean;
  27697. /**
  27698. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27699. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27700. * Default : `true`
  27701. */
  27702. /**
  27703. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27704. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27705. * Default : `true`
  27706. */
  27707. depthSortParticles: boolean;
  27708. /**
  27709. * Gets if the SPS is created as expandable at construction time.
  27710. * Default : `false`
  27711. */
  27712. readonly expandable: boolean;
  27713. /**
  27714. * Gets if the SPS supports the Multi Materials
  27715. */
  27716. readonly multimaterialEnabled: boolean;
  27717. /**
  27718. * Gets if the SPS uses the model materials for its own multimaterial.
  27719. */
  27720. readonly useModelMaterial: boolean;
  27721. /**
  27722. * The SPS used material array.
  27723. */
  27724. readonly materials: Material[];
  27725. /**
  27726. * Sets the SPS MultiMaterial from the passed materials.
  27727. * Note : the passed array is internally copied and not used then by reference.
  27728. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27729. */
  27730. setMultiMaterial(materials: Material[]): void;
  27731. /**
  27732. * The SPS computed multimaterial object
  27733. */
  27734. multimaterial: MultiMaterial;
  27735. /**
  27736. * If the subMeshes must be updated on the next call to setParticles()
  27737. */
  27738. autoUpdateSubMeshes: boolean;
  27739. /**
  27740. * This function does nothing. It may be overwritten to set all the particle first values.
  27741. * The SPS doesn't call this function, you may have to call it by your own.
  27742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27743. */
  27744. initParticles(): void;
  27745. /**
  27746. * This function does nothing. It may be overwritten to recycle a particle.
  27747. * The SPS doesn't call this function, you may have to call it by your own.
  27748. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27749. * @param particle The particle to recycle
  27750. * @returns the recycled particle
  27751. */
  27752. recycleParticle(particle: SolidParticle): SolidParticle;
  27753. /**
  27754. * Updates a particle : this function should be overwritten by the user.
  27755. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27756. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27757. * @example : just set a particle position or velocity and recycle conditions
  27758. * @param particle The particle to update
  27759. * @returns the updated particle
  27760. */
  27761. updateParticle(particle: SolidParticle): SolidParticle;
  27762. /**
  27763. * Updates a vertex of a particle : it can be overwritten by the user.
  27764. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27765. * @param particle the current particle
  27766. * @param vertex the current index of the current particle
  27767. * @param pt the index of the current vertex in the particle shape
  27768. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27769. * @example : just set a vertex particle position
  27770. * @returns the updated vertex
  27771. */
  27772. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27773. /**
  27774. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27775. * This does nothing and may be overwritten by the user.
  27776. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27777. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27778. * @param update the boolean update value actually passed to setParticles()
  27779. */
  27780. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27781. /**
  27782. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27783. * This will be passed three parameters.
  27784. * This does nothing and may be overwritten by the user.
  27785. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27786. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27787. * @param update the boolean update value actually passed to setParticles()
  27788. */
  27789. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27790. }
  27791. }
  27792. declare module "babylonjs/Particles/solidParticle" {
  27793. import { Nullable } from "babylonjs/types";
  27794. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  27795. import { Color4 } from "babylonjs/Maths/math.color";
  27796. import { Mesh } from "babylonjs/Meshes/mesh";
  27797. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27798. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  27799. import { Plane } from "babylonjs/Maths/math.plane";
  27800. import { Material } from "babylonjs/Materials/material";
  27801. /**
  27802. * Represents one particle of a solid particle system.
  27803. */
  27804. export class SolidParticle {
  27805. /**
  27806. * particle global index
  27807. */
  27808. idx: number;
  27809. /**
  27810. * particle identifier
  27811. */
  27812. id: number;
  27813. /**
  27814. * The color of the particle
  27815. */
  27816. color: Nullable<Color4>;
  27817. /**
  27818. * The world space position of the particle.
  27819. */
  27820. position: Vector3;
  27821. /**
  27822. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27823. */
  27824. rotation: Vector3;
  27825. /**
  27826. * The world space rotation quaternion of the particle.
  27827. */
  27828. rotationQuaternion: Nullable<Quaternion>;
  27829. /**
  27830. * The scaling of the particle.
  27831. */
  27832. scaling: Vector3;
  27833. /**
  27834. * The uvs of the particle.
  27835. */
  27836. uvs: Vector4;
  27837. /**
  27838. * The current speed of the particle.
  27839. */
  27840. velocity: Vector3;
  27841. /**
  27842. * The pivot point in the particle local space.
  27843. */
  27844. pivot: Vector3;
  27845. /**
  27846. * Must the particle be translated from its pivot point in its local space ?
  27847. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27848. * Default : false
  27849. */
  27850. translateFromPivot: boolean;
  27851. /**
  27852. * Is the particle active or not ?
  27853. */
  27854. alive: boolean;
  27855. /**
  27856. * Is the particle visible or not ?
  27857. */
  27858. isVisible: boolean;
  27859. /**
  27860. * Index of this particle in the global "positions" array (Internal use)
  27861. * @hidden
  27862. */
  27863. _pos: number;
  27864. /**
  27865. * @hidden Index of this particle in the global "indices" array (Internal use)
  27866. */
  27867. _ind: number;
  27868. /**
  27869. * @hidden ModelShape of this particle (Internal use)
  27870. */
  27871. _model: ModelShape;
  27872. /**
  27873. * ModelShape id of this particle
  27874. */
  27875. shapeId: number;
  27876. /**
  27877. * Index of the particle in its shape id
  27878. */
  27879. idxInShape: number;
  27880. /**
  27881. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27882. */
  27883. _modelBoundingInfo: BoundingInfo;
  27884. /**
  27885. * @hidden Particle BoundingInfo object (Internal use)
  27886. */
  27887. _boundingInfo: BoundingInfo;
  27888. /**
  27889. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27890. */
  27891. _sps: SolidParticleSystem;
  27892. /**
  27893. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27894. */
  27895. _stillInvisible: boolean;
  27896. /**
  27897. * @hidden Last computed particle rotation matrix
  27898. */
  27899. _rotationMatrix: number[];
  27900. /**
  27901. * Parent particle Id, if any.
  27902. * Default null.
  27903. */
  27904. parentId: Nullable<number>;
  27905. /**
  27906. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27907. */
  27908. materialIndex: Nullable<number>;
  27909. /**
  27910. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27911. * The possible values are :
  27912. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27913. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27915. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27916. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27917. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27918. * */
  27919. cullingStrategy: number;
  27920. /**
  27921. * @hidden Internal global position in the SPS.
  27922. */
  27923. _globalPosition: Vector3;
  27924. /**
  27925. * Creates a Solid Particle object.
  27926. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27927. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27928. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27929. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27930. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27931. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27932. * @param shapeId (integer) is the model shape identifier in the SPS.
  27933. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27934. * @param sps defines the sps it is associated to
  27935. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27936. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27937. */
  27938. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27939. /**
  27940. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27941. * @param target the particle target
  27942. * @returns the current particle
  27943. */
  27944. copyToRef(target: SolidParticle): SolidParticle;
  27945. /**
  27946. * Legacy support, changed scale to scaling
  27947. */
  27948. /**
  27949. * Legacy support, changed scale to scaling
  27950. */
  27951. scale: Vector3;
  27952. /**
  27953. * Legacy support, changed quaternion to rotationQuaternion
  27954. */
  27955. /**
  27956. * Legacy support, changed quaternion to rotationQuaternion
  27957. */
  27958. quaternion: Nullable<Quaternion>;
  27959. /**
  27960. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27961. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27962. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27963. * @returns true if it intersects
  27964. */
  27965. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27966. /**
  27967. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27968. * A particle is in the frustum if its bounding box intersects the frustum
  27969. * @param frustumPlanes defines the frustum to test
  27970. * @returns true if the particle is in the frustum planes
  27971. */
  27972. isInFrustum(frustumPlanes: Plane[]): boolean;
  27973. /**
  27974. * get the rotation matrix of the particle
  27975. * @hidden
  27976. */
  27977. getRotationMatrix(m: Matrix): void;
  27978. }
  27979. /**
  27980. * Represents the shape of the model used by one particle of a solid particle system.
  27981. * SPS internal tool, don't use it manually.
  27982. */
  27983. export class ModelShape {
  27984. /**
  27985. * The shape id
  27986. * @hidden
  27987. */
  27988. shapeID: number;
  27989. /**
  27990. * flat array of model positions (internal use)
  27991. * @hidden
  27992. */
  27993. _shape: Vector3[];
  27994. /**
  27995. * flat array of model UVs (internal use)
  27996. * @hidden
  27997. */
  27998. _shapeUV: number[];
  27999. /**
  28000. * color array of the model
  28001. * @hidden
  28002. */
  28003. _shapeColors: number[];
  28004. /**
  28005. * indices array of the model
  28006. * @hidden
  28007. */
  28008. _indices: number[];
  28009. /**
  28010. * normals array of the model
  28011. * @hidden
  28012. */
  28013. _normals: number[];
  28014. /**
  28015. * length of the shape in the model indices array (internal use)
  28016. * @hidden
  28017. */
  28018. _indicesLength: number;
  28019. /**
  28020. * Custom position function (internal use)
  28021. * @hidden
  28022. */
  28023. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28024. /**
  28025. * Custom vertex function (internal use)
  28026. * @hidden
  28027. */
  28028. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28029. /**
  28030. * Model material (internal use)
  28031. * @hidden
  28032. */
  28033. _material: Nullable<Material>;
  28034. /**
  28035. * 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.
  28036. * SPS internal tool, don't use it manually.
  28037. * @hidden
  28038. */
  28039. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28040. }
  28041. /**
  28042. * Represents a Depth Sorted Particle in the solid particle system.
  28043. * @hidden
  28044. */
  28045. export class DepthSortedParticle {
  28046. /**
  28047. * Index of the particle in the "indices" array
  28048. */
  28049. ind: number;
  28050. /**
  28051. * Length of the particle shape in the "indices" array
  28052. */
  28053. indicesLength: number;
  28054. /**
  28055. * Squared distance from the particle to the camera
  28056. */
  28057. sqDistance: number;
  28058. /**
  28059. * Material index when used with MultiMaterials
  28060. */
  28061. materialIndex: number;
  28062. /**
  28063. * Creates a new sorted particle
  28064. * @param materialIndex
  28065. */
  28066. constructor(ind: number, indLength: number, materialIndex: number);
  28067. }
  28068. }
  28069. declare module "babylonjs/Collisions/meshCollisionData" {
  28070. import { Collider } from "babylonjs/Collisions/collider";
  28071. import { Vector3 } from "babylonjs/Maths/math.vector";
  28072. import { Nullable } from "babylonjs/types";
  28073. import { Observer } from "babylonjs/Misc/observable";
  28074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28075. /**
  28076. * @hidden
  28077. */
  28078. export class _MeshCollisionData {
  28079. _checkCollisions: boolean;
  28080. _collisionMask: number;
  28081. _collisionGroup: number;
  28082. _collider: Nullable<Collider>;
  28083. _oldPositionForCollisions: Vector3;
  28084. _diffPositionForCollisions: Vector3;
  28085. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28086. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28087. }
  28088. }
  28089. declare module "babylonjs/Meshes/abstractMesh" {
  28090. import { Observable } from "babylonjs/Misc/observable";
  28091. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28092. import { Camera } from "babylonjs/Cameras/camera";
  28093. import { Scene, IDisposable } from "babylonjs/scene";
  28094. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28095. import { Node } from "babylonjs/node";
  28096. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28098. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28099. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28100. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28101. import { Material } from "babylonjs/Materials/material";
  28102. import { Light } from "babylonjs/Lights/light";
  28103. import { Skeleton } from "babylonjs/Bones/skeleton";
  28104. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28105. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28106. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28107. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28108. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28109. import { Plane } from "babylonjs/Maths/math.plane";
  28110. import { Ray } from "babylonjs/Culling/ray";
  28111. import { Collider } from "babylonjs/Collisions/collider";
  28112. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28113. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28114. /** @hidden */
  28115. class _FacetDataStorage {
  28116. facetPositions: Vector3[];
  28117. facetNormals: Vector3[];
  28118. facetPartitioning: number[][];
  28119. facetNb: number;
  28120. partitioningSubdivisions: number;
  28121. partitioningBBoxRatio: number;
  28122. facetDataEnabled: boolean;
  28123. facetParameters: any;
  28124. bbSize: Vector3;
  28125. subDiv: {
  28126. max: number;
  28127. X: number;
  28128. Y: number;
  28129. Z: number;
  28130. };
  28131. facetDepthSort: boolean;
  28132. facetDepthSortEnabled: boolean;
  28133. depthSortedIndices: IndicesArray;
  28134. depthSortedFacets: {
  28135. ind: number;
  28136. sqDistance: number;
  28137. }[];
  28138. facetDepthSortFunction: (f1: {
  28139. ind: number;
  28140. sqDistance: number;
  28141. }, f2: {
  28142. ind: number;
  28143. sqDistance: number;
  28144. }) => number;
  28145. facetDepthSortFrom: Vector3;
  28146. facetDepthSortOrigin: Vector3;
  28147. invertedMatrix: Matrix;
  28148. }
  28149. /**
  28150. * @hidden
  28151. **/
  28152. class _InternalAbstractMeshDataInfo {
  28153. _hasVertexAlpha: boolean;
  28154. _useVertexColors: boolean;
  28155. _numBoneInfluencers: number;
  28156. _applyFog: boolean;
  28157. _receiveShadows: boolean;
  28158. _facetData: _FacetDataStorage;
  28159. _visibility: number;
  28160. _skeleton: Nullable<Skeleton>;
  28161. _layerMask: number;
  28162. _computeBonesUsingShaders: boolean;
  28163. _isActive: boolean;
  28164. _onlyForInstances: boolean;
  28165. _isActiveIntermediate: boolean;
  28166. _onlyForInstancesIntermediate: boolean;
  28167. _actAsRegularMesh: boolean;
  28168. }
  28169. /**
  28170. * Class used to store all common mesh properties
  28171. */
  28172. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28173. /** No occlusion */
  28174. static OCCLUSION_TYPE_NONE: number;
  28175. /** Occlusion set to optimisitic */
  28176. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28177. /** Occlusion set to strict */
  28178. static OCCLUSION_TYPE_STRICT: number;
  28179. /** Use an accurante occlusion algorithm */
  28180. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28181. /** Use a conservative occlusion algorithm */
  28182. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28183. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28184. * Test order :
  28185. * Is the bounding sphere outside the frustum ?
  28186. * If not, are the bounding box vertices outside the frustum ?
  28187. * It not, then the cullable object is in the frustum.
  28188. */
  28189. static readonly CULLINGSTRATEGY_STANDARD: number;
  28190. /** Culling strategy : Bounding Sphere Only.
  28191. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28192. * It's also less accurate than the standard because some not visible objects can still be selected.
  28193. * Test : is the bounding sphere outside the frustum ?
  28194. * If not, then the cullable object is in the frustum.
  28195. */
  28196. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28197. /** Culling strategy : Optimistic Inclusion.
  28198. * This in an inclusion test first, then the standard exclusion test.
  28199. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28200. * 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.
  28201. * Anyway, it's as accurate as the standard strategy.
  28202. * Test :
  28203. * Is the cullable object bounding sphere center in the frustum ?
  28204. * If not, apply the default culling strategy.
  28205. */
  28206. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28207. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28208. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28209. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28210. * 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.
  28211. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28212. * Test :
  28213. * Is the cullable object bounding sphere center in the frustum ?
  28214. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28215. */
  28216. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28217. /**
  28218. * No billboard
  28219. */
  28220. static readonly BILLBOARDMODE_NONE: number;
  28221. /** Billboard on X axis */
  28222. static readonly BILLBOARDMODE_X: number;
  28223. /** Billboard on Y axis */
  28224. static readonly BILLBOARDMODE_Y: number;
  28225. /** Billboard on Z axis */
  28226. static readonly BILLBOARDMODE_Z: number;
  28227. /** Billboard on all axes */
  28228. static readonly BILLBOARDMODE_ALL: number;
  28229. /** Billboard on using position instead of orientation */
  28230. static readonly BILLBOARDMODE_USE_POSITION: number;
  28231. /** @hidden */
  28232. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28233. /**
  28234. * The culling strategy to use to check whether the mesh must be rendered or not.
  28235. * This value can be changed at any time and will be used on the next render mesh selection.
  28236. * The possible values are :
  28237. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28238. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28239. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28240. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28241. * Please read each static variable documentation to get details about the culling process.
  28242. * */
  28243. cullingStrategy: number;
  28244. /**
  28245. * Gets the number of facets in the mesh
  28246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28247. */
  28248. readonly facetNb: number;
  28249. /**
  28250. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28252. */
  28253. partitioningSubdivisions: number;
  28254. /**
  28255. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28256. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28258. */
  28259. partitioningBBoxRatio: number;
  28260. /**
  28261. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28262. * Works only for updatable meshes.
  28263. * Doesn't work with multi-materials
  28264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28265. */
  28266. mustDepthSortFacets: boolean;
  28267. /**
  28268. * The location (Vector3) where the facet depth sort must be computed from.
  28269. * By default, the active camera position.
  28270. * Used only when facet depth sort is enabled
  28271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28272. */
  28273. facetDepthSortFrom: Vector3;
  28274. /**
  28275. * gets a boolean indicating if facetData is enabled
  28276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28277. */
  28278. readonly isFacetDataEnabled: boolean;
  28279. /** @hidden */
  28280. _updateNonUniformScalingState(value: boolean): boolean;
  28281. /**
  28282. * An event triggered when this mesh collides with another one
  28283. */
  28284. onCollideObservable: Observable<AbstractMesh>;
  28285. /** Set a function to call when this mesh collides with another one */
  28286. onCollide: () => void;
  28287. /**
  28288. * An event triggered when the collision's position changes
  28289. */
  28290. onCollisionPositionChangeObservable: Observable<Vector3>;
  28291. /** Set a function to call when the collision's position changes */
  28292. onCollisionPositionChange: () => void;
  28293. /**
  28294. * An event triggered when material is changed
  28295. */
  28296. onMaterialChangedObservable: Observable<AbstractMesh>;
  28297. /**
  28298. * Gets or sets the orientation for POV movement & rotation
  28299. */
  28300. definedFacingForward: boolean;
  28301. /** @hidden */
  28302. _occlusionQuery: Nullable<WebGLQuery>;
  28303. /** @hidden */
  28304. _renderingGroup: Nullable<RenderingGroup>;
  28305. /**
  28306. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28307. */
  28308. /**
  28309. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28310. */
  28311. visibility: number;
  28312. /** Gets or sets the alpha index used to sort transparent meshes
  28313. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28314. */
  28315. alphaIndex: number;
  28316. /**
  28317. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28318. */
  28319. isVisible: boolean;
  28320. /**
  28321. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28322. */
  28323. isPickable: boolean;
  28324. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28325. showSubMeshesBoundingBox: boolean;
  28326. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28327. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28328. */
  28329. isBlocker: boolean;
  28330. /**
  28331. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28332. */
  28333. enablePointerMoveEvents: boolean;
  28334. /**
  28335. * Specifies the rendering group id for this mesh (0 by default)
  28336. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28337. */
  28338. renderingGroupId: number;
  28339. private _material;
  28340. /** Gets or sets current material */
  28341. material: Nullable<Material>;
  28342. /**
  28343. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28344. * @see http://doc.babylonjs.com/babylon101/shadows
  28345. */
  28346. receiveShadows: boolean;
  28347. /** Defines color to use when rendering outline */
  28348. outlineColor: Color3;
  28349. /** Define width to use when rendering outline */
  28350. outlineWidth: number;
  28351. /** Defines color to use when rendering overlay */
  28352. overlayColor: Color3;
  28353. /** Defines alpha to use when rendering overlay */
  28354. overlayAlpha: number;
  28355. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28356. hasVertexAlpha: boolean;
  28357. /** 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) */
  28358. useVertexColors: boolean;
  28359. /**
  28360. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28361. */
  28362. computeBonesUsingShaders: boolean;
  28363. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28364. numBoneInfluencers: number;
  28365. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28366. applyFog: boolean;
  28367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28368. useOctreeForRenderingSelection: boolean;
  28369. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28370. useOctreeForPicking: boolean;
  28371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28372. useOctreeForCollisions: boolean;
  28373. /**
  28374. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28375. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28376. */
  28377. layerMask: number;
  28378. /**
  28379. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28380. */
  28381. alwaysSelectAsActiveMesh: boolean;
  28382. /**
  28383. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28384. */
  28385. doNotSyncBoundingInfo: boolean;
  28386. /**
  28387. * Gets or sets the current action manager
  28388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28389. */
  28390. actionManager: Nullable<AbstractActionManager>;
  28391. private _meshCollisionData;
  28392. /**
  28393. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28394. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28395. */
  28396. ellipsoid: Vector3;
  28397. /**
  28398. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28400. */
  28401. ellipsoidOffset: Vector3;
  28402. /**
  28403. * Gets or sets a collision mask used to mask collisions (default is -1).
  28404. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28405. */
  28406. collisionMask: number;
  28407. /**
  28408. * Gets or sets the current collision group mask (-1 by default).
  28409. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28410. */
  28411. collisionGroup: number;
  28412. /**
  28413. * Defines edge width used when edgesRenderer is enabled
  28414. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28415. */
  28416. edgesWidth: number;
  28417. /**
  28418. * Defines edge color used when edgesRenderer is enabled
  28419. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28420. */
  28421. edgesColor: Color4;
  28422. /** @hidden */
  28423. _edgesRenderer: Nullable<IEdgesRenderer>;
  28424. /** @hidden */
  28425. _masterMesh: Nullable<AbstractMesh>;
  28426. /** @hidden */
  28427. _boundingInfo: Nullable<BoundingInfo>;
  28428. /** @hidden */
  28429. _renderId: number;
  28430. /**
  28431. * Gets or sets the list of subMeshes
  28432. * @see http://doc.babylonjs.com/how_to/multi_materials
  28433. */
  28434. subMeshes: SubMesh[];
  28435. /** @hidden */
  28436. _intersectionsInProgress: AbstractMesh[];
  28437. /** @hidden */
  28438. _unIndexed: boolean;
  28439. /** @hidden */
  28440. _lightSources: Light[];
  28441. /** Gets the list of lights affecting that mesh */
  28442. readonly lightSources: Light[];
  28443. /** @hidden */
  28444. readonly _positions: Nullable<Vector3[]>;
  28445. /** @hidden */
  28446. _waitingData: {
  28447. lods: Nullable<any>;
  28448. actions: Nullable<any>;
  28449. freezeWorldMatrix: Nullable<boolean>;
  28450. };
  28451. /** @hidden */
  28452. _bonesTransformMatrices: Nullable<Float32Array>;
  28453. /** @hidden */
  28454. _transformMatrixTexture: Nullable<RawTexture>;
  28455. /**
  28456. * Gets or sets a skeleton to apply skining transformations
  28457. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28458. */
  28459. skeleton: Nullable<Skeleton>;
  28460. /**
  28461. * An event triggered when the mesh is rebuilt.
  28462. */
  28463. onRebuildObservable: Observable<AbstractMesh>;
  28464. /**
  28465. * Creates a new AbstractMesh
  28466. * @param name defines the name of the mesh
  28467. * @param scene defines the hosting scene
  28468. */
  28469. constructor(name: string, scene?: Nullable<Scene>);
  28470. /**
  28471. * Returns the string "AbstractMesh"
  28472. * @returns "AbstractMesh"
  28473. */
  28474. getClassName(): string;
  28475. /**
  28476. * Gets a string representation of the current mesh
  28477. * @param fullDetails defines a boolean indicating if full details must be included
  28478. * @returns a string representation of the current mesh
  28479. */
  28480. toString(fullDetails?: boolean): string;
  28481. /**
  28482. * @hidden
  28483. */
  28484. protected _getEffectiveParent(): Nullable<Node>;
  28485. /** @hidden */
  28486. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28487. /** @hidden */
  28488. _rebuild(): void;
  28489. /** @hidden */
  28490. _resyncLightSources(): void;
  28491. /** @hidden */
  28492. _resyncLightSource(light: Light): void;
  28493. /** @hidden */
  28494. _unBindEffect(): void;
  28495. /** @hidden */
  28496. _removeLightSource(light: Light, dispose: boolean): void;
  28497. private _markSubMeshesAsDirty;
  28498. /** @hidden */
  28499. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28500. /** @hidden */
  28501. _markSubMeshesAsAttributesDirty(): void;
  28502. /** @hidden */
  28503. _markSubMeshesAsMiscDirty(): void;
  28504. /**
  28505. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28506. */
  28507. scaling: Vector3;
  28508. /**
  28509. * Returns true if the mesh is blocked. Implemented by child classes
  28510. */
  28511. readonly isBlocked: boolean;
  28512. /**
  28513. * Returns the mesh itself by default. Implemented by child classes
  28514. * @param camera defines the camera to use to pick the right LOD level
  28515. * @returns the currentAbstractMesh
  28516. */
  28517. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28518. /**
  28519. * Returns 0 by default. Implemented by child classes
  28520. * @returns an integer
  28521. */
  28522. getTotalVertices(): number;
  28523. /**
  28524. * Returns a positive integer : the total number of indices in this mesh geometry.
  28525. * @returns the numner of indices or zero if the mesh has no geometry.
  28526. */
  28527. getTotalIndices(): number;
  28528. /**
  28529. * Returns null by default. Implemented by child classes
  28530. * @returns null
  28531. */
  28532. getIndices(): Nullable<IndicesArray>;
  28533. /**
  28534. * Returns the array of the requested vertex data kind. Implemented by child classes
  28535. * @param kind defines the vertex data kind to use
  28536. * @returns null
  28537. */
  28538. getVerticesData(kind: string): Nullable<FloatArray>;
  28539. /**
  28540. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28541. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28542. * Note that a new underlying VertexBuffer object is created each call.
  28543. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28544. * @param kind defines vertex data kind:
  28545. * * VertexBuffer.PositionKind
  28546. * * VertexBuffer.UVKind
  28547. * * VertexBuffer.UV2Kind
  28548. * * VertexBuffer.UV3Kind
  28549. * * VertexBuffer.UV4Kind
  28550. * * VertexBuffer.UV5Kind
  28551. * * VertexBuffer.UV6Kind
  28552. * * VertexBuffer.ColorKind
  28553. * * VertexBuffer.MatricesIndicesKind
  28554. * * VertexBuffer.MatricesIndicesExtraKind
  28555. * * VertexBuffer.MatricesWeightsKind
  28556. * * VertexBuffer.MatricesWeightsExtraKind
  28557. * @param data defines the data source
  28558. * @param updatable defines if the data must be flagged as updatable (or static)
  28559. * @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
  28560. * @returns the current mesh
  28561. */
  28562. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28563. /**
  28564. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28565. * If the mesh has no geometry, it is simply returned as it is.
  28566. * @param kind defines vertex data kind:
  28567. * * VertexBuffer.PositionKind
  28568. * * VertexBuffer.UVKind
  28569. * * VertexBuffer.UV2Kind
  28570. * * VertexBuffer.UV3Kind
  28571. * * VertexBuffer.UV4Kind
  28572. * * VertexBuffer.UV5Kind
  28573. * * VertexBuffer.UV6Kind
  28574. * * VertexBuffer.ColorKind
  28575. * * VertexBuffer.MatricesIndicesKind
  28576. * * VertexBuffer.MatricesIndicesExtraKind
  28577. * * VertexBuffer.MatricesWeightsKind
  28578. * * VertexBuffer.MatricesWeightsExtraKind
  28579. * @param data defines the data source
  28580. * @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
  28581. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28582. * @returns the current mesh
  28583. */
  28584. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28585. /**
  28586. * Sets the mesh indices,
  28587. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28588. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28589. * @param totalVertices Defines the total number of vertices
  28590. * @returns the current mesh
  28591. */
  28592. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28593. /**
  28594. * Gets a boolean indicating if specific vertex data is present
  28595. * @param kind defines the vertex data kind to use
  28596. * @returns true is data kind is present
  28597. */
  28598. isVerticesDataPresent(kind: string): boolean;
  28599. /**
  28600. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28601. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28602. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28603. * @returns a BoundingInfo
  28604. */
  28605. getBoundingInfo(): BoundingInfo;
  28606. /**
  28607. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28608. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28609. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28610. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28611. * @returns the current mesh
  28612. */
  28613. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28614. /**
  28615. * Overwrite the current bounding info
  28616. * @param boundingInfo defines the new bounding info
  28617. * @returns the current mesh
  28618. */
  28619. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28620. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28621. readonly useBones: boolean;
  28622. /** @hidden */
  28623. _preActivate(): void;
  28624. /** @hidden */
  28625. _preActivateForIntermediateRendering(renderId: number): void;
  28626. /** @hidden */
  28627. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28628. /** @hidden */
  28629. _postActivate(): void;
  28630. /** @hidden */
  28631. _freeze(): void;
  28632. /** @hidden */
  28633. _unFreeze(): void;
  28634. /**
  28635. * Gets the current world matrix
  28636. * @returns a Matrix
  28637. */
  28638. getWorldMatrix(): Matrix;
  28639. /** @hidden */
  28640. _getWorldMatrixDeterminant(): number;
  28641. /**
  28642. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28643. */
  28644. readonly isAnInstance: boolean;
  28645. /**
  28646. * Gets a boolean indicating if this mesh has instances
  28647. */
  28648. readonly hasInstances: boolean;
  28649. /**
  28650. * Perform relative position change from the point of view of behind the front of the mesh.
  28651. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28652. * Supports definition of mesh facing forward or backward
  28653. * @param amountRight defines the distance on the right axis
  28654. * @param amountUp defines the distance on the up axis
  28655. * @param amountForward defines the distance on the forward axis
  28656. * @returns the current mesh
  28657. */
  28658. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28659. /**
  28660. * Calculate relative position change from the point of view of behind the front of the mesh.
  28661. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28662. * Supports definition of mesh facing forward or backward
  28663. * @param amountRight defines the distance on the right axis
  28664. * @param amountUp defines the distance on the up axis
  28665. * @param amountForward defines the distance on the forward axis
  28666. * @returns the new displacement vector
  28667. */
  28668. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28669. /**
  28670. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28671. * Supports definition of mesh facing forward or backward
  28672. * @param flipBack defines the flip
  28673. * @param twirlClockwise defines the twirl
  28674. * @param tiltRight defines the tilt
  28675. * @returns the current mesh
  28676. */
  28677. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28678. /**
  28679. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28680. * Supports definition of mesh facing forward or backward.
  28681. * @param flipBack defines the flip
  28682. * @param twirlClockwise defines the twirl
  28683. * @param tiltRight defines the tilt
  28684. * @returns the new rotation vector
  28685. */
  28686. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28687. /**
  28688. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28689. * This means the mesh underlying bounding box and sphere are recomputed.
  28690. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28691. * @returns the current mesh
  28692. */
  28693. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28694. /** @hidden */
  28695. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28696. /** @hidden */
  28697. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28698. /** @hidden */
  28699. _updateBoundingInfo(): AbstractMesh;
  28700. /** @hidden */
  28701. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28702. /** @hidden */
  28703. protected _afterComputeWorldMatrix(): void;
  28704. /** @hidden */
  28705. readonly _effectiveMesh: AbstractMesh;
  28706. /**
  28707. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28708. * A mesh is in the frustum if its bounding box intersects the frustum
  28709. * @param frustumPlanes defines the frustum to test
  28710. * @returns true if the mesh is in the frustum planes
  28711. */
  28712. isInFrustum(frustumPlanes: Plane[]): boolean;
  28713. /**
  28714. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28715. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28716. * @param frustumPlanes defines the frustum to test
  28717. * @returns true if the mesh is completely in the frustum planes
  28718. */
  28719. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28720. /**
  28721. * True if the mesh intersects another mesh or a SolidParticle object
  28722. * @param mesh defines a target mesh or SolidParticle to test
  28723. * @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)
  28724. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28725. * @returns true if there is an intersection
  28726. */
  28727. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28728. /**
  28729. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28730. * @param point defines the point to test
  28731. * @returns true if there is an intersection
  28732. */
  28733. intersectsPoint(point: Vector3): boolean;
  28734. /**
  28735. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28737. */
  28738. checkCollisions: boolean;
  28739. /**
  28740. * Gets Collider object used to compute collisions (not physics)
  28741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28742. */
  28743. readonly collider: Nullable<Collider>;
  28744. /**
  28745. * Move the mesh using collision engine
  28746. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28747. * @param displacement defines the requested displacement vector
  28748. * @returns the current mesh
  28749. */
  28750. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28751. private _onCollisionPositionChange;
  28752. /** @hidden */
  28753. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28754. /** @hidden */
  28755. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28756. /** @hidden */
  28757. _checkCollision(collider: Collider): AbstractMesh;
  28758. /** @hidden */
  28759. _generatePointsArray(): boolean;
  28760. /**
  28761. * Checks if the passed Ray intersects with the mesh
  28762. * @param ray defines the ray to use
  28763. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28765. * @returns the picking info
  28766. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28767. */
  28768. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28769. /**
  28770. * Clones the current mesh
  28771. * @param name defines the mesh name
  28772. * @param newParent defines the new mesh parent
  28773. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28774. * @returns the new mesh
  28775. */
  28776. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28777. /**
  28778. * Disposes all the submeshes of the current meshnp
  28779. * @returns the current mesh
  28780. */
  28781. releaseSubMeshes(): AbstractMesh;
  28782. /**
  28783. * Releases resources associated with this abstract mesh.
  28784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28786. */
  28787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28788. /**
  28789. * Adds the passed mesh as a child to the current mesh
  28790. * @param mesh defines the child mesh
  28791. * @returns the current mesh
  28792. */
  28793. addChild(mesh: AbstractMesh): AbstractMesh;
  28794. /**
  28795. * Removes the passed mesh from the current mesh children list
  28796. * @param mesh defines the child mesh
  28797. * @returns the current mesh
  28798. */
  28799. removeChild(mesh: AbstractMesh): AbstractMesh;
  28800. /** @hidden */
  28801. private _initFacetData;
  28802. /**
  28803. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28804. * This method can be called within the render loop.
  28805. * 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
  28806. * @returns the current mesh
  28807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28808. */
  28809. updateFacetData(): AbstractMesh;
  28810. /**
  28811. * Returns the facetLocalNormals array.
  28812. * The normals are expressed in the mesh local spac
  28813. * @returns an array of Vector3
  28814. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28815. */
  28816. getFacetLocalNormals(): Vector3[];
  28817. /**
  28818. * Returns the facetLocalPositions array.
  28819. * The facet positions are expressed in the mesh local space
  28820. * @returns an array of Vector3
  28821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28822. */
  28823. getFacetLocalPositions(): Vector3[];
  28824. /**
  28825. * Returns the facetLocalPartioning array
  28826. * @returns an array of array of numbers
  28827. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28828. */
  28829. getFacetLocalPartitioning(): number[][];
  28830. /**
  28831. * Returns the i-th facet position in the world system.
  28832. * This method allocates a new Vector3 per call
  28833. * @param i defines the facet index
  28834. * @returns a new Vector3
  28835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28836. */
  28837. getFacetPosition(i: number): Vector3;
  28838. /**
  28839. * Sets the reference Vector3 with the i-th facet position in the world system
  28840. * @param i defines the facet index
  28841. * @param ref defines the target vector
  28842. * @returns the current mesh
  28843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28844. */
  28845. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28846. /**
  28847. * Returns the i-th facet normal in the world system.
  28848. * This method allocates a new Vector3 per call
  28849. * @param i defines the facet index
  28850. * @returns a new Vector3
  28851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28852. */
  28853. getFacetNormal(i: number): Vector3;
  28854. /**
  28855. * Sets the reference Vector3 with the i-th facet normal in the world system
  28856. * @param i defines the facet index
  28857. * @param ref defines the target vector
  28858. * @returns the current mesh
  28859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28860. */
  28861. getFacetNormalToRef(i: number, ref: Vector3): this;
  28862. /**
  28863. * 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)
  28864. * @param x defines x coordinate
  28865. * @param y defines y coordinate
  28866. * @param z defines z coordinate
  28867. * @returns the array of facet indexes
  28868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28869. */
  28870. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28871. /**
  28872. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28873. * @param projected sets as the (x,y,z) world projection on the facet
  28874. * @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
  28875. * @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
  28876. * @param x defines x coordinate
  28877. * @param y defines y coordinate
  28878. * @param z defines z coordinate
  28879. * @returns the face index if found (or null instead)
  28880. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28881. */
  28882. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28883. /**
  28884. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28885. * @param projected sets as the (x,y,z) local projection on the facet
  28886. * @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
  28887. * @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
  28888. * @param x defines x coordinate
  28889. * @param y defines y coordinate
  28890. * @param z defines z coordinate
  28891. * @returns the face index if found (or null instead)
  28892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28893. */
  28894. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28895. /**
  28896. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28897. * @returns the parameters
  28898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28899. */
  28900. getFacetDataParameters(): any;
  28901. /**
  28902. * Disables the feature FacetData and frees the related memory
  28903. * @returns the current mesh
  28904. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28905. */
  28906. disableFacetData(): AbstractMesh;
  28907. /**
  28908. * Updates the AbstractMesh indices array
  28909. * @param indices defines the data source
  28910. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28911. * @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)
  28912. * @returns the current mesh
  28913. */
  28914. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28915. /**
  28916. * Creates new normals data for the mesh
  28917. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28918. * @returns the current mesh
  28919. */
  28920. createNormals(updatable: boolean): AbstractMesh;
  28921. /**
  28922. * Align the mesh with a normal
  28923. * @param normal defines the normal to use
  28924. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28925. * @returns the current mesh
  28926. */
  28927. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28928. /** @hidden */
  28929. _checkOcclusionQuery(): boolean;
  28930. /**
  28931. * Disables the mesh edge rendering mode
  28932. * @returns the currentAbstractMesh
  28933. */
  28934. disableEdgesRendering(): AbstractMesh;
  28935. /**
  28936. * Enables the edge rendering mode on the mesh.
  28937. * This mode makes the mesh edges visible
  28938. * @param epsilon defines the maximal distance between two angles to detect a face
  28939. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28940. * @returns the currentAbstractMesh
  28941. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28942. */
  28943. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28944. }
  28945. }
  28946. declare module "babylonjs/Actions/actionEvent" {
  28947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28948. import { Nullable } from "babylonjs/types";
  28949. import { Sprite } from "babylonjs/Sprites/sprite";
  28950. import { Scene } from "babylonjs/scene";
  28951. import { Vector2 } from "babylonjs/Maths/math.vector";
  28952. /**
  28953. * Interface used to define ActionEvent
  28954. */
  28955. export interface IActionEvent {
  28956. /** The mesh or sprite that triggered the action */
  28957. source: any;
  28958. /** The X mouse cursor position at the time of the event */
  28959. pointerX: number;
  28960. /** The Y mouse cursor position at the time of the event */
  28961. pointerY: number;
  28962. /** The mesh that is currently pointed at (can be null) */
  28963. meshUnderPointer: Nullable<AbstractMesh>;
  28964. /** the original (browser) event that triggered the ActionEvent */
  28965. sourceEvent?: any;
  28966. /** additional data for the event */
  28967. additionalData?: any;
  28968. }
  28969. /**
  28970. * ActionEvent is the event being sent when an action is triggered.
  28971. */
  28972. export class ActionEvent implements IActionEvent {
  28973. /** The mesh or sprite that triggered the action */
  28974. source: any;
  28975. /** The X mouse cursor position at the time of the event */
  28976. pointerX: number;
  28977. /** The Y mouse cursor position at the time of the event */
  28978. pointerY: number;
  28979. /** The mesh that is currently pointed at (can be null) */
  28980. meshUnderPointer: Nullable<AbstractMesh>;
  28981. /** the original (browser) event that triggered the ActionEvent */
  28982. sourceEvent?: any;
  28983. /** additional data for the event */
  28984. additionalData?: any;
  28985. /**
  28986. * Creates a new ActionEvent
  28987. * @param source The mesh or sprite that triggered the action
  28988. * @param pointerX The X mouse cursor position at the time of the event
  28989. * @param pointerY The Y mouse cursor position at the time of the event
  28990. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28991. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28992. * @param additionalData additional data for the event
  28993. */
  28994. constructor(
  28995. /** The mesh or sprite that triggered the action */
  28996. source: any,
  28997. /** The X mouse cursor position at the time of the event */
  28998. pointerX: number,
  28999. /** The Y mouse cursor position at the time of the event */
  29000. pointerY: number,
  29001. /** The mesh that is currently pointed at (can be null) */
  29002. meshUnderPointer: Nullable<AbstractMesh>,
  29003. /** the original (browser) event that triggered the ActionEvent */
  29004. sourceEvent?: any,
  29005. /** additional data for the event */
  29006. additionalData?: any);
  29007. /**
  29008. * Helper function to auto-create an ActionEvent from a source mesh.
  29009. * @param source The source mesh that triggered the event
  29010. * @param evt The original (browser) event
  29011. * @param additionalData additional data for the event
  29012. * @returns the new ActionEvent
  29013. */
  29014. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29015. /**
  29016. * Helper function to auto-create an ActionEvent from a source sprite
  29017. * @param source The source sprite that triggered the event
  29018. * @param scene Scene associated with the sprite
  29019. * @param evt The original (browser) event
  29020. * @param additionalData additional data for the event
  29021. * @returns the new ActionEvent
  29022. */
  29023. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29024. /**
  29025. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29026. * @param scene the scene where the event occurred
  29027. * @param evt The original (browser) event
  29028. * @returns the new ActionEvent
  29029. */
  29030. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29031. /**
  29032. * Helper function to auto-create an ActionEvent from a primitive
  29033. * @param prim defines the target primitive
  29034. * @param pointerPos defines the pointer position
  29035. * @param evt The original (browser) event
  29036. * @param additionalData additional data for the event
  29037. * @returns the new ActionEvent
  29038. */
  29039. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29040. }
  29041. }
  29042. declare module "babylonjs/Actions/abstractActionManager" {
  29043. import { IDisposable } from "babylonjs/scene";
  29044. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29045. import { IAction } from "babylonjs/Actions/action";
  29046. import { Nullable } from "babylonjs/types";
  29047. /**
  29048. * Abstract class used to decouple action Manager from scene and meshes.
  29049. * Do not instantiate.
  29050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29051. */
  29052. export abstract class AbstractActionManager implements IDisposable {
  29053. /** Gets the list of active triggers */
  29054. static Triggers: {
  29055. [key: string]: number;
  29056. };
  29057. /** Gets the cursor to use when hovering items */
  29058. hoverCursor: string;
  29059. /** Gets the list of actions */
  29060. actions: IAction[];
  29061. /**
  29062. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29063. */
  29064. isRecursive: boolean;
  29065. /**
  29066. * Releases all associated resources
  29067. */
  29068. abstract dispose(): void;
  29069. /**
  29070. * Does this action manager has pointer triggers
  29071. */
  29072. abstract readonly hasPointerTriggers: boolean;
  29073. /**
  29074. * Does this action manager has pick triggers
  29075. */
  29076. abstract readonly hasPickTriggers: boolean;
  29077. /**
  29078. * Process a specific trigger
  29079. * @param trigger defines the trigger to process
  29080. * @param evt defines the event details to be processed
  29081. */
  29082. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29083. /**
  29084. * Does this action manager handles actions of any of the given triggers
  29085. * @param triggers defines the triggers to be tested
  29086. * @return a boolean indicating whether one (or more) of the triggers is handled
  29087. */
  29088. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29089. /**
  29090. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29091. * speed.
  29092. * @param triggerA defines the trigger to be tested
  29093. * @param triggerB defines the trigger to be tested
  29094. * @return a boolean indicating whether one (or more) of the triggers is handled
  29095. */
  29096. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29097. /**
  29098. * Does this action manager handles actions of a given trigger
  29099. * @param trigger defines the trigger to be tested
  29100. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29101. * @return whether the trigger is handled
  29102. */
  29103. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29104. /**
  29105. * Serialize this manager to a JSON object
  29106. * @param name defines the property name to store this manager
  29107. * @returns a JSON representation of this manager
  29108. */
  29109. abstract serialize(name: string): any;
  29110. /**
  29111. * Registers an action to this action manager
  29112. * @param action defines the action to be registered
  29113. * @return the action amended (prepared) after registration
  29114. */
  29115. abstract registerAction(action: IAction): Nullable<IAction>;
  29116. /**
  29117. * Unregisters an action to this action manager
  29118. * @param action defines the action to be unregistered
  29119. * @return a boolean indicating whether the action has been unregistered
  29120. */
  29121. abstract unregisterAction(action: IAction): Boolean;
  29122. /**
  29123. * Does exist one action manager with at least one trigger
  29124. **/
  29125. static readonly HasTriggers: boolean;
  29126. /**
  29127. * Does exist one action manager with at least one pick trigger
  29128. **/
  29129. static readonly HasPickTriggers: boolean;
  29130. /**
  29131. * Does exist one action manager that handles actions of a given trigger
  29132. * @param trigger defines the trigger to be tested
  29133. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29134. **/
  29135. static HasSpecificTrigger(trigger: number): boolean;
  29136. }
  29137. }
  29138. declare module "babylonjs/node" {
  29139. import { Scene } from "babylonjs/scene";
  29140. import { Nullable } from "babylonjs/types";
  29141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29142. import { Engine } from "babylonjs/Engines/engine";
  29143. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29144. import { Observable } from "babylonjs/Misc/observable";
  29145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29146. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29147. import { Animatable } from "babylonjs/Animations/animatable";
  29148. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29149. import { Animation } from "babylonjs/Animations/animation";
  29150. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29152. /**
  29153. * Defines how a node can be built from a string name.
  29154. */
  29155. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29156. /**
  29157. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29158. */
  29159. export class Node implements IBehaviorAware<Node> {
  29160. /** @hidden */
  29161. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29162. private static _NodeConstructors;
  29163. /**
  29164. * Add a new node constructor
  29165. * @param type defines the type name of the node to construct
  29166. * @param constructorFunc defines the constructor function
  29167. */
  29168. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29169. /**
  29170. * Returns a node constructor based on type name
  29171. * @param type defines the type name
  29172. * @param name defines the new node name
  29173. * @param scene defines the hosting scene
  29174. * @param options defines optional options to transmit to constructors
  29175. * @returns the new constructor or null
  29176. */
  29177. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29178. /**
  29179. * Gets or sets the name of the node
  29180. */
  29181. name: string;
  29182. /**
  29183. * Gets or sets the id of the node
  29184. */
  29185. id: string;
  29186. /**
  29187. * Gets or sets the unique id of the node
  29188. */
  29189. uniqueId: number;
  29190. /**
  29191. * Gets or sets a string used to store user defined state for the node
  29192. */
  29193. state: string;
  29194. /**
  29195. * Gets or sets an object used to store user defined information for the node
  29196. */
  29197. metadata: any;
  29198. /**
  29199. * For internal use only. Please do not use.
  29200. */
  29201. reservedDataStore: any;
  29202. /**
  29203. * List of inspectable custom properties (used by the Inspector)
  29204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29205. */
  29206. inspectableCustomProperties: IInspectable[];
  29207. private _doNotSerialize;
  29208. /**
  29209. * Gets or sets a boolean used to define if the node must be serialized
  29210. */
  29211. doNotSerialize: boolean;
  29212. /** @hidden */
  29213. _isDisposed: boolean;
  29214. /**
  29215. * Gets a list of Animations associated with the node
  29216. */
  29217. animations: import("babylonjs/Animations/animation").Animation[];
  29218. protected _ranges: {
  29219. [name: string]: Nullable<AnimationRange>;
  29220. };
  29221. /**
  29222. * Callback raised when the node is ready to be used
  29223. */
  29224. onReady: Nullable<(node: Node) => void>;
  29225. private _isEnabled;
  29226. private _isParentEnabled;
  29227. private _isReady;
  29228. /** @hidden */
  29229. _currentRenderId: number;
  29230. private _parentUpdateId;
  29231. /** @hidden */
  29232. _childUpdateId: number;
  29233. /** @hidden */
  29234. _waitingParentId: Nullable<string>;
  29235. /** @hidden */
  29236. _scene: Scene;
  29237. /** @hidden */
  29238. _cache: any;
  29239. private _parentNode;
  29240. private _children;
  29241. /** @hidden */
  29242. _worldMatrix: Matrix;
  29243. /** @hidden */
  29244. _worldMatrixDeterminant: number;
  29245. /** @hidden */
  29246. _worldMatrixDeterminantIsDirty: boolean;
  29247. /** @hidden */
  29248. private _sceneRootNodesIndex;
  29249. /**
  29250. * Gets a boolean indicating if the node has been disposed
  29251. * @returns true if the node was disposed
  29252. */
  29253. isDisposed(): boolean;
  29254. /**
  29255. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29256. * @see https://doc.babylonjs.com/how_to/parenting
  29257. */
  29258. parent: Nullable<Node>;
  29259. /** @hidden */
  29260. _addToSceneRootNodes(): void;
  29261. /** @hidden */
  29262. _removeFromSceneRootNodes(): void;
  29263. private _animationPropertiesOverride;
  29264. /**
  29265. * Gets or sets the animation properties override
  29266. */
  29267. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  29268. /**
  29269. * Gets a string idenfifying the name of the class
  29270. * @returns "Node" string
  29271. */
  29272. getClassName(): string;
  29273. /** @hidden */
  29274. readonly _isNode: boolean;
  29275. /**
  29276. * An event triggered when the mesh is disposed
  29277. */
  29278. onDisposeObservable: Observable<Node>;
  29279. private _onDisposeObserver;
  29280. /**
  29281. * Sets a callback that will be raised when the node will be disposed
  29282. */
  29283. onDispose: () => void;
  29284. /**
  29285. * Creates a new Node
  29286. * @param name the name and id to be given to this node
  29287. * @param scene the scene this node will be added to
  29288. */
  29289. constructor(name: string, scene?: Nullable<Scene>);
  29290. /**
  29291. * Gets the scene of the node
  29292. * @returns a scene
  29293. */
  29294. getScene(): Scene;
  29295. /**
  29296. * Gets the engine of the node
  29297. * @returns a Engine
  29298. */
  29299. getEngine(): Engine;
  29300. private _behaviors;
  29301. /**
  29302. * Attach a behavior to the node
  29303. * @see http://doc.babylonjs.com/features/behaviour
  29304. * @param behavior defines the behavior to attach
  29305. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29306. * @returns the current Node
  29307. */
  29308. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29309. /**
  29310. * Remove an attached behavior
  29311. * @see http://doc.babylonjs.com/features/behaviour
  29312. * @param behavior defines the behavior to attach
  29313. * @returns the current Node
  29314. */
  29315. removeBehavior(behavior: Behavior<Node>): Node;
  29316. /**
  29317. * Gets the list of attached behaviors
  29318. * @see http://doc.babylonjs.com/features/behaviour
  29319. */
  29320. readonly behaviors: Behavior<Node>[];
  29321. /**
  29322. * Gets an attached behavior by name
  29323. * @param name defines the name of the behavior to look for
  29324. * @see http://doc.babylonjs.com/features/behaviour
  29325. * @returns null if behavior was not found else the requested behavior
  29326. */
  29327. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29328. /**
  29329. * Returns the latest update of the World matrix
  29330. * @returns a Matrix
  29331. */
  29332. getWorldMatrix(): Matrix;
  29333. /** @hidden */
  29334. _getWorldMatrixDeterminant(): number;
  29335. /**
  29336. * Returns directly the latest state of the mesh World matrix.
  29337. * A Matrix is returned.
  29338. */
  29339. readonly worldMatrixFromCache: Matrix;
  29340. /** @hidden */
  29341. _initCache(): void;
  29342. /** @hidden */
  29343. updateCache(force?: boolean): void;
  29344. /** @hidden */
  29345. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29346. /** @hidden */
  29347. _updateCache(ignoreParentClass?: boolean): void;
  29348. /** @hidden */
  29349. _isSynchronized(): boolean;
  29350. /** @hidden */
  29351. _markSyncedWithParent(): void;
  29352. /** @hidden */
  29353. isSynchronizedWithParent(): boolean;
  29354. /** @hidden */
  29355. isSynchronized(): boolean;
  29356. /**
  29357. * Is this node ready to be used/rendered
  29358. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29359. * @return true if the node is ready
  29360. */
  29361. isReady(completeCheck?: boolean): boolean;
  29362. /**
  29363. * Is this node enabled?
  29364. * 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
  29365. * @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
  29366. * @return whether this node (and its parent) is enabled
  29367. */
  29368. isEnabled(checkAncestors?: boolean): boolean;
  29369. /** @hidden */
  29370. protected _syncParentEnabledState(): void;
  29371. /**
  29372. * Set the enabled state of this node
  29373. * @param value defines the new enabled state
  29374. */
  29375. setEnabled(value: boolean): void;
  29376. /**
  29377. * Is this node a descendant of the given node?
  29378. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29379. * @param ancestor defines the parent node to inspect
  29380. * @returns a boolean indicating if this node is a descendant of the given node
  29381. */
  29382. isDescendantOf(ancestor: Node): boolean;
  29383. /** @hidden */
  29384. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29385. /**
  29386. * Will return all nodes that have this node as ascendant
  29387. * @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
  29388. * @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
  29389. * @return all children nodes of all types
  29390. */
  29391. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29392. /**
  29393. * Get all child-meshes of this node
  29394. * @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)
  29395. * @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
  29396. * @returns an array of AbstractMesh
  29397. */
  29398. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29399. /**
  29400. * Get all direct children of this node
  29401. * @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
  29402. * @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)
  29403. * @returns an array of Node
  29404. */
  29405. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29406. /** @hidden */
  29407. _setReady(state: boolean): void;
  29408. /**
  29409. * Get an animation by name
  29410. * @param name defines the name of the animation to look for
  29411. * @returns null if not found else the requested animation
  29412. */
  29413. getAnimationByName(name: string): Nullable<Animation>;
  29414. /**
  29415. * Creates an animation range for this node
  29416. * @param name defines the name of the range
  29417. * @param from defines the starting key
  29418. * @param to defines the end key
  29419. */
  29420. createAnimationRange(name: string, from: number, to: number): void;
  29421. /**
  29422. * Delete a specific animation range
  29423. * @param name defines the name of the range to delete
  29424. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29425. */
  29426. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29427. /**
  29428. * Get an animation range by name
  29429. * @param name defines the name of the animation range to look for
  29430. * @returns null if not found else the requested animation range
  29431. */
  29432. getAnimationRange(name: string): Nullable<AnimationRange>;
  29433. /**
  29434. * Gets the list of all animation ranges defined on this node
  29435. * @returns an array
  29436. */
  29437. getAnimationRanges(): Nullable<AnimationRange>[];
  29438. /**
  29439. * Will start the animation sequence
  29440. * @param name defines the range frames for animation sequence
  29441. * @param loop defines if the animation should loop (false by default)
  29442. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29443. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29444. * @returns the object created for this animation. If range does not exist, it will return null
  29445. */
  29446. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29447. /**
  29448. * Serialize animation ranges into a JSON compatible object
  29449. * @returns serialization object
  29450. */
  29451. serializeAnimationRanges(): any;
  29452. /**
  29453. * Computes the world matrix of the node
  29454. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29455. * @returns the world matrix
  29456. */
  29457. computeWorldMatrix(force?: boolean): Matrix;
  29458. /**
  29459. * Releases resources associated with this node.
  29460. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29461. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29462. */
  29463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29464. /**
  29465. * Parse animation range data from a serialization object and store them into a given node
  29466. * @param node defines where to store the animation ranges
  29467. * @param parsedNode defines the serialization object to read data from
  29468. * @param scene defines the hosting scene
  29469. */
  29470. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29471. /**
  29472. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29473. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29474. * @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
  29475. * @returns the new bounding vectors
  29476. */
  29477. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29478. min: Vector3;
  29479. max: Vector3;
  29480. };
  29481. }
  29482. }
  29483. declare module "babylonjs/Animations/animation" {
  29484. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29485. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29486. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29487. import { Nullable } from "babylonjs/types";
  29488. import { Scene } from "babylonjs/scene";
  29489. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29490. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29491. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29492. import { Node } from "babylonjs/node";
  29493. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29494. import { Size } from "babylonjs/Maths/math.size";
  29495. import { Animatable } from "babylonjs/Animations/animatable";
  29496. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29497. /**
  29498. * @hidden
  29499. */
  29500. export class _IAnimationState {
  29501. key: number;
  29502. repeatCount: number;
  29503. workValue?: any;
  29504. loopMode?: number;
  29505. offsetValue?: any;
  29506. highLimitValue?: any;
  29507. }
  29508. /**
  29509. * Class used to store any kind of animation
  29510. */
  29511. export class Animation {
  29512. /**Name of the animation */
  29513. name: string;
  29514. /**Property to animate */
  29515. targetProperty: string;
  29516. /**The frames per second of the animation */
  29517. framePerSecond: number;
  29518. /**The data type of the animation */
  29519. dataType: number;
  29520. /**The loop mode of the animation */
  29521. loopMode?: number | undefined;
  29522. /**Specifies if blending should be enabled */
  29523. enableBlending?: boolean | undefined;
  29524. /**
  29525. * Use matrix interpolation instead of using direct key value when animating matrices
  29526. */
  29527. static AllowMatricesInterpolation: boolean;
  29528. /**
  29529. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29530. */
  29531. static AllowMatrixDecomposeForInterpolation: boolean;
  29532. /**
  29533. * Stores the key frames of the animation
  29534. */
  29535. private _keys;
  29536. /**
  29537. * Stores the easing function of the animation
  29538. */
  29539. private _easingFunction;
  29540. /**
  29541. * @hidden Internal use only
  29542. */
  29543. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29544. /**
  29545. * The set of event that will be linked to this animation
  29546. */
  29547. private _events;
  29548. /**
  29549. * Stores an array of target property paths
  29550. */
  29551. targetPropertyPath: string[];
  29552. /**
  29553. * Stores the blending speed of the animation
  29554. */
  29555. blendingSpeed: number;
  29556. /**
  29557. * Stores the animation ranges for the animation
  29558. */
  29559. private _ranges;
  29560. /**
  29561. * @hidden Internal use
  29562. */
  29563. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29564. /**
  29565. * Sets up an animation
  29566. * @param property The property to animate
  29567. * @param animationType The animation type to apply
  29568. * @param framePerSecond The frames per second of the animation
  29569. * @param easingFunction The easing function used in the animation
  29570. * @returns The created animation
  29571. */
  29572. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29573. /**
  29574. * Create and start an animation on a node
  29575. * @param name defines the name of the global animation that will be run on all nodes
  29576. * @param node defines the root node where the animation will take place
  29577. * @param targetProperty defines property to animate
  29578. * @param framePerSecond defines the number of frame per second yo use
  29579. * @param totalFrame defines the number of frames in total
  29580. * @param from defines the initial value
  29581. * @param to defines the final value
  29582. * @param loopMode defines which loop mode you want to use (off by default)
  29583. * @param easingFunction defines the easing function to use (linear by default)
  29584. * @param onAnimationEnd defines the callback to call when animation end
  29585. * @returns the animatable created for this animation
  29586. */
  29587. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29588. /**
  29589. * Create and start an animation on a node and its descendants
  29590. * @param name defines the name of the global animation that will be run on all nodes
  29591. * @param node defines the root node where the animation will take place
  29592. * @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
  29593. * @param targetProperty defines property to animate
  29594. * @param framePerSecond defines the number of frame per second to use
  29595. * @param totalFrame defines the number of frames in total
  29596. * @param from defines the initial value
  29597. * @param to defines the final value
  29598. * @param loopMode defines which loop mode you want to use (off by default)
  29599. * @param easingFunction defines the easing function to use (linear by default)
  29600. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29601. * @returns the list of animatables created for all nodes
  29602. * @example https://www.babylonjs-playground.com/#MH0VLI
  29603. */
  29604. 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[]>;
  29605. /**
  29606. * Creates a new animation, merges it with the existing animations and starts it
  29607. * @param name Name of the animation
  29608. * @param node Node which contains the scene that begins the animations
  29609. * @param targetProperty Specifies which property to animate
  29610. * @param framePerSecond The frames per second of the animation
  29611. * @param totalFrame The total number of frames
  29612. * @param from The frame at the beginning of the animation
  29613. * @param to The frame at the end of the animation
  29614. * @param loopMode Specifies the loop mode of the animation
  29615. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29616. * @param onAnimationEnd Callback to run once the animation is complete
  29617. * @returns Nullable animation
  29618. */
  29619. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29620. /**
  29621. * Transition property of an host to the target Value
  29622. * @param property The property to transition
  29623. * @param targetValue The target Value of the property
  29624. * @param host The object where the property to animate belongs
  29625. * @param scene Scene used to run the animation
  29626. * @param frameRate Framerate (in frame/s) to use
  29627. * @param transition The transition type we want to use
  29628. * @param duration The duration of the animation, in milliseconds
  29629. * @param onAnimationEnd Callback trigger at the end of the animation
  29630. * @returns Nullable animation
  29631. */
  29632. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29633. /**
  29634. * Return the array of runtime animations currently using this animation
  29635. */
  29636. readonly runtimeAnimations: RuntimeAnimation[];
  29637. /**
  29638. * Specifies if any of the runtime animations are currently running
  29639. */
  29640. readonly hasRunningRuntimeAnimations: boolean;
  29641. /**
  29642. * Initializes the animation
  29643. * @param name Name of the animation
  29644. * @param targetProperty Property to animate
  29645. * @param framePerSecond The frames per second of the animation
  29646. * @param dataType The data type of the animation
  29647. * @param loopMode The loop mode of the animation
  29648. * @param enableBlending Specifies if blending should be enabled
  29649. */
  29650. constructor(
  29651. /**Name of the animation */
  29652. name: string,
  29653. /**Property to animate */
  29654. targetProperty: string,
  29655. /**The frames per second of the animation */
  29656. framePerSecond: number,
  29657. /**The data type of the animation */
  29658. dataType: number,
  29659. /**The loop mode of the animation */
  29660. loopMode?: number | undefined,
  29661. /**Specifies if blending should be enabled */
  29662. enableBlending?: boolean | undefined);
  29663. /**
  29664. * Converts the animation to a string
  29665. * @param fullDetails support for multiple levels of logging within scene loading
  29666. * @returns String form of the animation
  29667. */
  29668. toString(fullDetails?: boolean): string;
  29669. /**
  29670. * Add an event to this animation
  29671. * @param event Event to add
  29672. */
  29673. addEvent(event: AnimationEvent): void;
  29674. /**
  29675. * Remove all events found at the given frame
  29676. * @param frame The frame to remove events from
  29677. */
  29678. removeEvents(frame: number): void;
  29679. /**
  29680. * Retrieves all the events from the animation
  29681. * @returns Events from the animation
  29682. */
  29683. getEvents(): AnimationEvent[];
  29684. /**
  29685. * Creates an animation range
  29686. * @param name Name of the animation range
  29687. * @param from Starting frame of the animation range
  29688. * @param to Ending frame of the animation
  29689. */
  29690. createRange(name: string, from: number, to: number): void;
  29691. /**
  29692. * Deletes an animation range by name
  29693. * @param name Name of the animation range to delete
  29694. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29695. */
  29696. deleteRange(name: string, deleteFrames?: boolean): void;
  29697. /**
  29698. * Gets the animation range by name, or null if not defined
  29699. * @param name Name of the animation range
  29700. * @returns Nullable animation range
  29701. */
  29702. getRange(name: string): Nullable<AnimationRange>;
  29703. /**
  29704. * Gets the key frames from the animation
  29705. * @returns The key frames of the animation
  29706. */
  29707. getKeys(): Array<IAnimationKey>;
  29708. /**
  29709. * Gets the highest frame rate of the animation
  29710. * @returns Highest frame rate of the animation
  29711. */
  29712. getHighestFrame(): number;
  29713. /**
  29714. * Gets the easing function of the animation
  29715. * @returns Easing function of the animation
  29716. */
  29717. getEasingFunction(): IEasingFunction;
  29718. /**
  29719. * Sets the easing function of the animation
  29720. * @param easingFunction A custom mathematical formula for animation
  29721. */
  29722. setEasingFunction(easingFunction: EasingFunction): void;
  29723. /**
  29724. * Interpolates a scalar linearly
  29725. * @param startValue Start value of the animation curve
  29726. * @param endValue End value of the animation curve
  29727. * @param gradient Scalar amount to interpolate
  29728. * @returns Interpolated scalar value
  29729. */
  29730. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29731. /**
  29732. * Interpolates a scalar cubically
  29733. * @param startValue Start value of the animation curve
  29734. * @param outTangent End tangent of the animation
  29735. * @param endValue End value of the animation curve
  29736. * @param inTangent Start tangent of the animation curve
  29737. * @param gradient Scalar amount to interpolate
  29738. * @returns Interpolated scalar value
  29739. */
  29740. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29741. /**
  29742. * Interpolates a quaternion using a spherical linear interpolation
  29743. * @param startValue Start value of the animation curve
  29744. * @param endValue End value of the animation curve
  29745. * @param gradient Scalar amount to interpolate
  29746. * @returns Interpolated quaternion value
  29747. */
  29748. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29749. /**
  29750. * Interpolates a quaternion cubically
  29751. * @param startValue Start value of the animation curve
  29752. * @param outTangent End tangent of the animation curve
  29753. * @param endValue End value of the animation curve
  29754. * @param inTangent Start tangent of the animation curve
  29755. * @param gradient Scalar amount to interpolate
  29756. * @returns Interpolated quaternion value
  29757. */
  29758. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29759. /**
  29760. * Interpolates a Vector3 linearl
  29761. * @param startValue Start value of the animation curve
  29762. * @param endValue End value of the animation curve
  29763. * @param gradient Scalar amount to interpolate
  29764. * @returns Interpolated scalar value
  29765. */
  29766. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29767. /**
  29768. * Interpolates a Vector3 cubically
  29769. * @param startValue Start value of the animation curve
  29770. * @param outTangent End tangent of the animation
  29771. * @param endValue End value of the animation curve
  29772. * @param inTangent Start tangent of the animation curve
  29773. * @param gradient Scalar amount to interpolate
  29774. * @returns InterpolatedVector3 value
  29775. */
  29776. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29777. /**
  29778. * Interpolates a Vector2 linearly
  29779. * @param startValue Start value of the animation curve
  29780. * @param endValue End value of the animation curve
  29781. * @param gradient Scalar amount to interpolate
  29782. * @returns Interpolated Vector2 value
  29783. */
  29784. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29785. /**
  29786. * Interpolates a Vector2 cubically
  29787. * @param startValue Start value of the animation curve
  29788. * @param outTangent End tangent of the animation
  29789. * @param endValue End value of the animation curve
  29790. * @param inTangent Start tangent of the animation curve
  29791. * @param gradient Scalar amount to interpolate
  29792. * @returns Interpolated Vector2 value
  29793. */
  29794. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29795. /**
  29796. * Interpolates a size linearly
  29797. * @param startValue Start value of the animation curve
  29798. * @param endValue End value of the animation curve
  29799. * @param gradient Scalar amount to interpolate
  29800. * @returns Interpolated Size value
  29801. */
  29802. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29803. /**
  29804. * Interpolates a Color3 linearly
  29805. * @param startValue Start value of the animation curve
  29806. * @param endValue End value of the animation curve
  29807. * @param gradient Scalar amount to interpolate
  29808. * @returns Interpolated Color3 value
  29809. */
  29810. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29811. /**
  29812. * Interpolates a Color4 linearly
  29813. * @param startValue Start value of the animation curve
  29814. * @param endValue End value of the animation curve
  29815. * @param gradient Scalar amount to interpolate
  29816. * @returns Interpolated Color3 value
  29817. */
  29818. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29819. /**
  29820. * @hidden Internal use only
  29821. */
  29822. _getKeyValue(value: any): any;
  29823. /**
  29824. * @hidden Internal use only
  29825. */
  29826. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29827. /**
  29828. * Defines the function to use to interpolate matrices
  29829. * @param startValue defines the start matrix
  29830. * @param endValue defines the end matrix
  29831. * @param gradient defines the gradient between both matrices
  29832. * @param result defines an optional target matrix where to store the interpolation
  29833. * @returns the interpolated matrix
  29834. */
  29835. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29836. /**
  29837. * Makes a copy of the animation
  29838. * @returns Cloned animation
  29839. */
  29840. clone(): Animation;
  29841. /**
  29842. * Sets the key frames of the animation
  29843. * @param values The animation key frames to set
  29844. */
  29845. setKeys(values: Array<IAnimationKey>): void;
  29846. /**
  29847. * Serializes the animation to an object
  29848. * @returns Serialized object
  29849. */
  29850. serialize(): any;
  29851. /**
  29852. * Float animation type
  29853. */
  29854. static readonly ANIMATIONTYPE_FLOAT: number;
  29855. /**
  29856. * Vector3 animation type
  29857. */
  29858. static readonly ANIMATIONTYPE_VECTOR3: number;
  29859. /**
  29860. * Quaternion animation type
  29861. */
  29862. static readonly ANIMATIONTYPE_QUATERNION: number;
  29863. /**
  29864. * Matrix animation type
  29865. */
  29866. static readonly ANIMATIONTYPE_MATRIX: number;
  29867. /**
  29868. * Color3 animation type
  29869. */
  29870. static readonly ANIMATIONTYPE_COLOR3: number;
  29871. /**
  29872. * Color3 animation type
  29873. */
  29874. static readonly ANIMATIONTYPE_COLOR4: number;
  29875. /**
  29876. * Vector2 animation type
  29877. */
  29878. static readonly ANIMATIONTYPE_VECTOR2: number;
  29879. /**
  29880. * Size animation type
  29881. */
  29882. static readonly ANIMATIONTYPE_SIZE: number;
  29883. /**
  29884. * Relative Loop Mode
  29885. */
  29886. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29887. /**
  29888. * Cycle Loop Mode
  29889. */
  29890. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29891. /**
  29892. * Constant Loop Mode
  29893. */
  29894. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29895. /** @hidden */
  29896. static _UniversalLerp(left: any, right: any, amount: number): any;
  29897. /**
  29898. * Parses an animation object and creates an animation
  29899. * @param parsedAnimation Parsed animation object
  29900. * @returns Animation object
  29901. */
  29902. static Parse(parsedAnimation: any): Animation;
  29903. /**
  29904. * Appends the serialized animations from the source animations
  29905. * @param source Source containing the animations
  29906. * @param destination Target to store the animations
  29907. */
  29908. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29909. }
  29910. }
  29911. declare module "babylonjs/Animations/animatable.interface" {
  29912. import { Nullable } from "babylonjs/types";
  29913. import { Animation } from "babylonjs/Animations/animation";
  29914. /**
  29915. * Interface containing an array of animations
  29916. */
  29917. export interface IAnimatable {
  29918. /**
  29919. * Array of animations
  29920. */
  29921. animations: Nullable<Array<Animation>>;
  29922. }
  29923. }
  29924. declare module "babylonjs/Misc/decorators" {
  29925. import { Nullable } from "babylonjs/types";
  29926. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29927. import { Scene } from "babylonjs/scene";
  29928. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29929. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29930. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29931. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29932. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29933. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29934. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29935. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29936. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29937. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29938. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29939. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29940. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29941. /**
  29942. * Decorator used to define property that can be serialized as reference to a camera
  29943. * @param sourceName defines the name of the property to decorate
  29944. */
  29945. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29946. /**
  29947. * Class used to help serialization objects
  29948. */
  29949. export class SerializationHelper {
  29950. /** @hidden */
  29951. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29952. /** @hidden */
  29953. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29954. /** @hidden */
  29955. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29956. /** @hidden */
  29957. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29958. /**
  29959. * Appends the serialized animations from the source animations
  29960. * @param source Source containing the animations
  29961. * @param destination Target to store the animations
  29962. */
  29963. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29964. /**
  29965. * Static function used to serialized a specific entity
  29966. * @param entity defines the entity to serialize
  29967. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29968. * @returns a JSON compatible object representing the serialization of the entity
  29969. */
  29970. static Serialize<T>(entity: T, serializationObject?: any): any;
  29971. /**
  29972. * Creates a new entity from a serialization data object
  29973. * @param creationFunction defines a function used to instanciated the new entity
  29974. * @param source defines the source serialization data
  29975. * @param scene defines the hosting scene
  29976. * @param rootUrl defines the root url for resources
  29977. * @returns a new entity
  29978. */
  29979. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29980. /**
  29981. * Clones an object
  29982. * @param creationFunction defines the function used to instanciate the new object
  29983. * @param source defines the source object
  29984. * @returns the cloned object
  29985. */
  29986. static Clone<T>(creationFunction: () => T, source: T): T;
  29987. /**
  29988. * Instanciates a new object based on a source one (some data will be shared between both object)
  29989. * @param creationFunction defines the function used to instanciate the new object
  29990. * @param source defines the source object
  29991. * @returns the new object
  29992. */
  29993. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29994. }
  29995. }
  29996. declare module "babylonjs/Misc/guid" {
  29997. /**
  29998. * Class used to manipulate GUIDs
  29999. */
  30000. export class GUID {
  30001. /**
  30002. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30003. * Be aware Math.random() could cause collisions, but:
  30004. * "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"
  30005. * @returns a pseudo random id
  30006. */
  30007. static RandomId(): string;
  30008. }
  30009. }
  30010. declare module "babylonjs/Materials/Textures/baseTexture" {
  30011. import { Observable } from "babylonjs/Misc/observable";
  30012. import { Nullable } from "babylonjs/types";
  30013. import { Scene } from "babylonjs/scene";
  30014. import { Matrix } from "babylonjs/Maths/math.vector";
  30015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30016. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30017. import { ISize } from "babylonjs/Maths/math.size";
  30018. /**
  30019. * Base class of all the textures in babylon.
  30020. * It groups all the common properties the materials, post process, lights... might need
  30021. * in order to make a correct use of the texture.
  30022. */
  30023. export class BaseTexture implements IAnimatable {
  30024. /**
  30025. * Default anisotropic filtering level for the application.
  30026. * It is set to 4 as a good tradeoff between perf and quality.
  30027. */
  30028. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30029. /**
  30030. * Gets or sets the unique id of the texture
  30031. */
  30032. uniqueId: number;
  30033. /**
  30034. * Define the name of the texture.
  30035. */
  30036. name: string;
  30037. /**
  30038. * Gets or sets an object used to store user defined information.
  30039. */
  30040. metadata: any;
  30041. /**
  30042. * For internal use only. Please do not use.
  30043. */
  30044. reservedDataStore: any;
  30045. private _hasAlpha;
  30046. /**
  30047. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30048. */
  30049. hasAlpha: boolean;
  30050. /**
  30051. * Defines if the alpha value should be determined via the rgb values.
  30052. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30053. */
  30054. getAlphaFromRGB: boolean;
  30055. /**
  30056. * Intensity or strength of the texture.
  30057. * It is commonly used by materials to fine tune the intensity of the texture
  30058. */
  30059. level: number;
  30060. /**
  30061. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30062. * This is part of the texture as textures usually maps to one uv set.
  30063. */
  30064. coordinatesIndex: number;
  30065. private _coordinatesMode;
  30066. /**
  30067. * How a texture is mapped.
  30068. *
  30069. * | Value | Type | Description |
  30070. * | ----- | ----------------------------------- | ----------- |
  30071. * | 0 | EXPLICIT_MODE | |
  30072. * | 1 | SPHERICAL_MODE | |
  30073. * | 2 | PLANAR_MODE | |
  30074. * | 3 | CUBIC_MODE | |
  30075. * | 4 | PROJECTION_MODE | |
  30076. * | 5 | SKYBOX_MODE | |
  30077. * | 6 | INVCUBIC_MODE | |
  30078. * | 7 | EQUIRECTANGULAR_MODE | |
  30079. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30080. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30081. */
  30082. coordinatesMode: number;
  30083. /**
  30084. * | Value | Type | Description |
  30085. * | ----- | ------------------ | ----------- |
  30086. * | 0 | CLAMP_ADDRESSMODE | |
  30087. * | 1 | WRAP_ADDRESSMODE | |
  30088. * | 2 | MIRROR_ADDRESSMODE | |
  30089. */
  30090. wrapU: number;
  30091. /**
  30092. * | Value | Type | Description |
  30093. * | ----- | ------------------ | ----------- |
  30094. * | 0 | CLAMP_ADDRESSMODE | |
  30095. * | 1 | WRAP_ADDRESSMODE | |
  30096. * | 2 | MIRROR_ADDRESSMODE | |
  30097. */
  30098. wrapV: number;
  30099. /**
  30100. * | Value | Type | Description |
  30101. * | ----- | ------------------ | ----------- |
  30102. * | 0 | CLAMP_ADDRESSMODE | |
  30103. * | 1 | WRAP_ADDRESSMODE | |
  30104. * | 2 | MIRROR_ADDRESSMODE | |
  30105. */
  30106. wrapR: number;
  30107. /**
  30108. * With compliant hardware and browser (supporting anisotropic filtering)
  30109. * this defines the level of anisotropic filtering in the texture.
  30110. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30111. */
  30112. anisotropicFilteringLevel: number;
  30113. /**
  30114. * Define if the texture is a cube texture or if false a 2d texture.
  30115. */
  30116. isCube: boolean;
  30117. /**
  30118. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30119. */
  30120. is3D: boolean;
  30121. /**
  30122. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30123. */
  30124. is2DArray: boolean;
  30125. /**
  30126. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30127. * HDR texture are usually stored in linear space.
  30128. * This only impacts the PBR and Background materials
  30129. */
  30130. gammaSpace: boolean;
  30131. /**
  30132. * Gets or sets whether or not the texture contains RGBD data.
  30133. */
  30134. isRGBD: boolean;
  30135. /**
  30136. * Is Z inverted in the texture (useful in a cube texture).
  30137. */
  30138. invertZ: boolean;
  30139. /**
  30140. * Are mip maps generated for this texture or not.
  30141. */
  30142. readonly noMipmap: boolean;
  30143. /**
  30144. * @hidden
  30145. */
  30146. lodLevelInAlpha: boolean;
  30147. /**
  30148. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30149. */
  30150. lodGenerationOffset: number;
  30151. /**
  30152. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30153. */
  30154. lodGenerationScale: number;
  30155. /**
  30156. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30157. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30158. * average roughness values.
  30159. */
  30160. linearSpecularLOD: boolean;
  30161. /**
  30162. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30163. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30164. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30165. */
  30166. irradianceTexture: Nullable<BaseTexture>;
  30167. /**
  30168. * Define if the texture is a render target.
  30169. */
  30170. isRenderTarget: boolean;
  30171. /**
  30172. * Define the unique id of the texture in the scene.
  30173. */
  30174. readonly uid: string;
  30175. /**
  30176. * Return a string representation of the texture.
  30177. * @returns the texture as a string
  30178. */
  30179. toString(): string;
  30180. /**
  30181. * Get the class name of the texture.
  30182. * @returns "BaseTexture"
  30183. */
  30184. getClassName(): string;
  30185. /**
  30186. * Define the list of animation attached to the texture.
  30187. */
  30188. animations: import("babylonjs/Animations/animation").Animation[];
  30189. /**
  30190. * An event triggered when the texture is disposed.
  30191. */
  30192. onDisposeObservable: Observable<BaseTexture>;
  30193. private _onDisposeObserver;
  30194. /**
  30195. * Callback triggered when the texture has been disposed.
  30196. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30197. */
  30198. onDispose: () => void;
  30199. /**
  30200. * Define the current state of the loading sequence when in delayed load mode.
  30201. */
  30202. delayLoadState: number;
  30203. private _scene;
  30204. /** @hidden */
  30205. _texture: Nullable<InternalTexture>;
  30206. private _uid;
  30207. /**
  30208. * Define if the texture is preventinga material to render or not.
  30209. * If not and the texture is not ready, the engine will use a default black texture instead.
  30210. */
  30211. readonly isBlocking: boolean;
  30212. /**
  30213. * Instantiates a new BaseTexture.
  30214. * Base class of all the textures in babylon.
  30215. * It groups all the common properties the materials, post process, lights... might need
  30216. * in order to make a correct use of the texture.
  30217. * @param scene Define the scene the texture blongs to
  30218. */
  30219. constructor(scene: Nullable<Scene>);
  30220. /**
  30221. * Get the scene the texture belongs to.
  30222. * @returns the scene or null if undefined
  30223. */
  30224. getScene(): Nullable<Scene>;
  30225. /**
  30226. * Get the texture transform matrix used to offset tile the texture for istance.
  30227. * @returns the transformation matrix
  30228. */
  30229. getTextureMatrix(): Matrix;
  30230. /**
  30231. * Get the texture reflection matrix used to rotate/transform the reflection.
  30232. * @returns the reflection matrix
  30233. */
  30234. getReflectionTextureMatrix(): Matrix;
  30235. /**
  30236. * Get the underlying lower level texture from Babylon.
  30237. * @returns the insternal texture
  30238. */
  30239. getInternalTexture(): Nullable<InternalTexture>;
  30240. /**
  30241. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30242. * @returns true if ready or not blocking
  30243. */
  30244. isReadyOrNotBlocking(): boolean;
  30245. /**
  30246. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30247. * @returns true if fully ready
  30248. */
  30249. isReady(): boolean;
  30250. private _cachedSize;
  30251. /**
  30252. * Get the size of the texture.
  30253. * @returns the texture size.
  30254. */
  30255. getSize(): ISize;
  30256. /**
  30257. * Get the base size of the texture.
  30258. * It can be different from the size if the texture has been resized for POT for instance
  30259. * @returns the base size
  30260. */
  30261. getBaseSize(): ISize;
  30262. /**
  30263. * Update the sampling mode of the texture.
  30264. * Default is Trilinear mode.
  30265. *
  30266. * | Value | Type | Description |
  30267. * | ----- | ------------------ | ----------- |
  30268. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30269. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30270. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30271. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30272. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30273. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30274. * | 7 | NEAREST_LINEAR | |
  30275. * | 8 | NEAREST_NEAREST | |
  30276. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30277. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30278. * | 11 | LINEAR_LINEAR | |
  30279. * | 12 | LINEAR_NEAREST | |
  30280. *
  30281. * > _mag_: magnification filter (close to the viewer)
  30282. * > _min_: minification filter (far from the viewer)
  30283. * > _mip_: filter used between mip map levels
  30284. *@param samplingMode Define the new sampling mode of the texture
  30285. */
  30286. updateSamplingMode(samplingMode: number): void;
  30287. /**
  30288. * Scales the texture if is `canRescale()`
  30289. * @param ratio the resize factor we want to use to rescale
  30290. */
  30291. scale(ratio: number): void;
  30292. /**
  30293. * Get if the texture can rescale.
  30294. */
  30295. readonly canRescale: boolean;
  30296. /** @hidden */
  30297. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30298. /** @hidden */
  30299. _rebuild(): void;
  30300. /**
  30301. * Triggers the load sequence in delayed load mode.
  30302. */
  30303. delayLoad(): void;
  30304. /**
  30305. * Clones the texture.
  30306. * @returns the cloned texture
  30307. */
  30308. clone(): Nullable<BaseTexture>;
  30309. /**
  30310. * Get the texture underlying type (INT, FLOAT...)
  30311. */
  30312. readonly textureType: number;
  30313. /**
  30314. * Get the texture underlying format (RGB, RGBA...)
  30315. */
  30316. readonly textureFormat: number;
  30317. /**
  30318. * Indicates that textures need to be re-calculated for all materials
  30319. */
  30320. protected _markAllSubMeshesAsTexturesDirty(): void;
  30321. /**
  30322. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30323. * This will returns an RGBA array buffer containing either in values (0-255) or
  30324. * float values (0-1) depending of the underlying buffer type.
  30325. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30326. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30327. * @param buffer defines a user defined buffer to fill with data (can be null)
  30328. * @returns The Array buffer containing the pixels data.
  30329. */
  30330. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30331. /**
  30332. * Release and destroy the underlying lower level texture aka internalTexture.
  30333. */
  30334. releaseInternalTexture(): void;
  30335. /** @hidden */
  30336. readonly _lodTextureHigh: Nullable<BaseTexture>;
  30337. /** @hidden */
  30338. readonly _lodTextureMid: Nullable<BaseTexture>;
  30339. /** @hidden */
  30340. readonly _lodTextureLow: Nullable<BaseTexture>;
  30341. /**
  30342. * Dispose the texture and release its associated resources.
  30343. */
  30344. dispose(): void;
  30345. /**
  30346. * Serialize the texture into a JSON representation that can be parsed later on.
  30347. * @returns the JSON representation of the texture
  30348. */
  30349. serialize(): any;
  30350. /**
  30351. * Helper function to be called back once a list of texture contains only ready textures.
  30352. * @param textures Define the list of textures to wait for
  30353. * @param callback Define the callback triggered once the entire list will be ready
  30354. */
  30355. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30356. }
  30357. }
  30358. declare module "babylonjs/Materials/effect" {
  30359. import { Observable } from "babylonjs/Misc/observable";
  30360. import { Nullable } from "babylonjs/types";
  30361. import { IDisposable } from "babylonjs/scene";
  30362. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30363. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30364. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30365. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30366. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30367. import { Engine } from "babylonjs/Engines/engine";
  30368. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30371. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30372. /**
  30373. * Options to be used when creating an effect.
  30374. */
  30375. export interface IEffectCreationOptions {
  30376. /**
  30377. * Atrributes that will be used in the shader.
  30378. */
  30379. attributes: string[];
  30380. /**
  30381. * Uniform varible names that will be set in the shader.
  30382. */
  30383. uniformsNames: string[];
  30384. /**
  30385. * Uniform buffer variable names that will be set in the shader.
  30386. */
  30387. uniformBuffersNames: string[];
  30388. /**
  30389. * Sampler texture variable names that will be set in the shader.
  30390. */
  30391. samplers: string[];
  30392. /**
  30393. * Define statements that will be set in the shader.
  30394. */
  30395. defines: any;
  30396. /**
  30397. * Possible fallbacks for this effect to improve performance when needed.
  30398. */
  30399. fallbacks: Nullable<IEffectFallbacks>;
  30400. /**
  30401. * Callback that will be called when the shader is compiled.
  30402. */
  30403. onCompiled: Nullable<(effect: Effect) => void>;
  30404. /**
  30405. * Callback that will be called if an error occurs during shader compilation.
  30406. */
  30407. onError: Nullable<(effect: Effect, errors: string) => void>;
  30408. /**
  30409. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30410. */
  30411. indexParameters?: any;
  30412. /**
  30413. * Max number of lights that can be used in the shader.
  30414. */
  30415. maxSimultaneousLights?: number;
  30416. /**
  30417. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30418. */
  30419. transformFeedbackVaryings?: Nullable<string[]>;
  30420. }
  30421. /**
  30422. * Effect containing vertex and fragment shader that can be executed on an object.
  30423. */
  30424. export class Effect implements IDisposable {
  30425. /**
  30426. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30427. */
  30428. static ShadersRepository: string;
  30429. /**
  30430. * Name of the effect.
  30431. */
  30432. name: any;
  30433. /**
  30434. * String container all the define statements that should be set on the shader.
  30435. */
  30436. defines: string;
  30437. /**
  30438. * Callback that will be called when the shader is compiled.
  30439. */
  30440. onCompiled: Nullable<(effect: Effect) => void>;
  30441. /**
  30442. * Callback that will be called if an error occurs during shader compilation.
  30443. */
  30444. onError: Nullable<(effect: Effect, errors: string) => void>;
  30445. /**
  30446. * Callback that will be called when effect is bound.
  30447. */
  30448. onBind: Nullable<(effect: Effect) => void>;
  30449. /**
  30450. * Unique ID of the effect.
  30451. */
  30452. uniqueId: number;
  30453. /**
  30454. * Observable that will be called when the shader is compiled.
  30455. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30456. */
  30457. onCompileObservable: Observable<Effect>;
  30458. /**
  30459. * Observable that will be called if an error occurs during shader compilation.
  30460. */
  30461. onErrorObservable: Observable<Effect>;
  30462. /** @hidden */
  30463. _onBindObservable: Nullable<Observable<Effect>>;
  30464. /**
  30465. * Observable that will be called when effect is bound.
  30466. */
  30467. readonly onBindObservable: Observable<Effect>;
  30468. /** @hidden */
  30469. _bonesComputationForcedToCPU: boolean;
  30470. private static _uniqueIdSeed;
  30471. private _engine;
  30472. private _uniformBuffersNames;
  30473. private _uniformsNames;
  30474. private _samplerList;
  30475. private _samplers;
  30476. private _isReady;
  30477. private _compilationError;
  30478. private _allFallbacksProcessed;
  30479. private _attributesNames;
  30480. private _attributes;
  30481. private _attributeLocationByName;
  30482. private _uniforms;
  30483. /**
  30484. * Key for the effect.
  30485. * @hidden
  30486. */
  30487. _key: string;
  30488. private _indexParameters;
  30489. private _fallbacks;
  30490. private _vertexSourceCode;
  30491. private _fragmentSourceCode;
  30492. private _vertexSourceCodeOverride;
  30493. private _fragmentSourceCodeOverride;
  30494. private _transformFeedbackVaryings;
  30495. /**
  30496. * Compiled shader to webGL program.
  30497. * @hidden
  30498. */
  30499. _pipelineContext: Nullable<IPipelineContext>;
  30500. private _valueCache;
  30501. private static _baseCache;
  30502. /**
  30503. * Instantiates an effect.
  30504. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30505. * @param baseName Name of the effect.
  30506. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30507. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30508. * @param samplers List of sampler variables that will be passed to the shader.
  30509. * @param engine Engine to be used to render the effect
  30510. * @param defines Define statements to be added to the shader.
  30511. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30512. * @param onCompiled Callback that will be called when the shader is compiled.
  30513. * @param onError Callback that will be called if an error occurs during shader compilation.
  30514. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30515. */
  30516. 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);
  30517. private _useFinalCode;
  30518. /**
  30519. * Unique key for this effect
  30520. */
  30521. readonly key: string;
  30522. /**
  30523. * If the effect has been compiled and prepared.
  30524. * @returns if the effect is compiled and prepared.
  30525. */
  30526. isReady(): boolean;
  30527. private _isReadyInternal;
  30528. /**
  30529. * The engine the effect was initialized with.
  30530. * @returns the engine.
  30531. */
  30532. getEngine(): Engine;
  30533. /**
  30534. * The pipeline context for this effect
  30535. * @returns the associated pipeline context
  30536. */
  30537. getPipelineContext(): Nullable<IPipelineContext>;
  30538. /**
  30539. * The set of names of attribute variables for the shader.
  30540. * @returns An array of attribute names.
  30541. */
  30542. getAttributesNames(): string[];
  30543. /**
  30544. * Returns the attribute at the given index.
  30545. * @param index The index of the attribute.
  30546. * @returns The location of the attribute.
  30547. */
  30548. getAttributeLocation(index: number): number;
  30549. /**
  30550. * Returns the attribute based on the name of the variable.
  30551. * @param name of the attribute to look up.
  30552. * @returns the attribute location.
  30553. */
  30554. getAttributeLocationByName(name: string): number;
  30555. /**
  30556. * The number of attributes.
  30557. * @returns the numnber of attributes.
  30558. */
  30559. getAttributesCount(): number;
  30560. /**
  30561. * Gets the index of a uniform variable.
  30562. * @param uniformName of the uniform to look up.
  30563. * @returns the index.
  30564. */
  30565. getUniformIndex(uniformName: string): number;
  30566. /**
  30567. * Returns the attribute based on the name of the variable.
  30568. * @param uniformName of the uniform to look up.
  30569. * @returns the location of the uniform.
  30570. */
  30571. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30572. /**
  30573. * Returns an array of sampler variable names
  30574. * @returns The array of sampler variable neames.
  30575. */
  30576. getSamplers(): string[];
  30577. /**
  30578. * The error from the last compilation.
  30579. * @returns the error string.
  30580. */
  30581. getCompilationError(): string;
  30582. /**
  30583. * Gets a boolean indicating that all fallbacks were used during compilation
  30584. * @returns true if all fallbacks were used
  30585. */
  30586. allFallbacksProcessed(): boolean;
  30587. /**
  30588. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30589. * @param func The callback to be used.
  30590. */
  30591. executeWhenCompiled(func: (effect: Effect) => void): void;
  30592. private _checkIsReady;
  30593. private _loadShader;
  30594. /**
  30595. * Recompiles the webGL program
  30596. * @param vertexSourceCode The source code for the vertex shader.
  30597. * @param fragmentSourceCode The source code for the fragment shader.
  30598. * @param onCompiled Callback called when completed.
  30599. * @param onError Callback called on error.
  30600. * @hidden
  30601. */
  30602. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30603. /**
  30604. * Prepares the effect
  30605. * @hidden
  30606. */
  30607. _prepareEffect(): void;
  30608. private _processCompilationErrors;
  30609. /**
  30610. * Checks if the effect is supported. (Must be called after compilation)
  30611. */
  30612. readonly isSupported: boolean;
  30613. /**
  30614. * Binds a texture to the engine to be used as output of the shader.
  30615. * @param channel Name of the output variable.
  30616. * @param texture Texture to bind.
  30617. * @hidden
  30618. */
  30619. _bindTexture(channel: string, texture: InternalTexture): void;
  30620. /**
  30621. * Sets a texture on the engine to be used in the shader.
  30622. * @param channel Name of the sampler variable.
  30623. * @param texture Texture to set.
  30624. */
  30625. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30626. /**
  30627. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30628. * @param channel Name of the sampler variable.
  30629. * @param texture Texture to set.
  30630. */
  30631. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30632. /**
  30633. * Sets an array of textures on the engine to be used in the shader.
  30634. * @param channel Name of the variable.
  30635. * @param textures Textures to set.
  30636. */
  30637. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30638. /**
  30639. * 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)
  30640. * @param channel Name of the sampler variable.
  30641. * @param postProcess Post process to get the input texture from.
  30642. */
  30643. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30644. /**
  30645. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30646. * 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)
  30647. * @param channel Name of the sampler variable.
  30648. * @param postProcess Post process to get the output texture from.
  30649. */
  30650. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30651. /** @hidden */
  30652. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30653. /** @hidden */
  30654. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30655. /** @hidden */
  30656. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30657. /** @hidden */
  30658. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30659. /**
  30660. * Binds a buffer to a uniform.
  30661. * @param buffer Buffer to bind.
  30662. * @param name Name of the uniform variable to bind to.
  30663. */
  30664. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30665. /**
  30666. * Binds block to a uniform.
  30667. * @param blockName Name of the block to bind.
  30668. * @param index Index to bind.
  30669. */
  30670. bindUniformBlock(blockName: string, index: number): void;
  30671. /**
  30672. * Sets an interger value on a uniform variable.
  30673. * @param uniformName Name of the variable.
  30674. * @param value Value to be set.
  30675. * @returns this effect.
  30676. */
  30677. setInt(uniformName: string, value: number): Effect;
  30678. /**
  30679. * Sets an int array on a uniform variable.
  30680. * @param uniformName Name of the variable.
  30681. * @param array array to be set.
  30682. * @returns this effect.
  30683. */
  30684. setIntArray(uniformName: string, array: Int32Array): Effect;
  30685. /**
  30686. * 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)
  30687. * @param uniformName Name of the variable.
  30688. * @param array array to be set.
  30689. * @returns this effect.
  30690. */
  30691. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30692. /**
  30693. * 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)
  30694. * @param uniformName Name of the variable.
  30695. * @param array array to be set.
  30696. * @returns this effect.
  30697. */
  30698. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30699. /**
  30700. * 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)
  30701. * @param uniformName Name of the variable.
  30702. * @param array array to be set.
  30703. * @returns this effect.
  30704. */
  30705. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30706. /**
  30707. * Sets an float array on a uniform variable.
  30708. * @param uniformName Name of the variable.
  30709. * @param array array to be set.
  30710. * @returns this effect.
  30711. */
  30712. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30713. /**
  30714. * 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)
  30715. * @param uniformName Name of the variable.
  30716. * @param array array to be set.
  30717. * @returns this effect.
  30718. */
  30719. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30720. /**
  30721. * 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)
  30722. * @param uniformName Name of the variable.
  30723. * @param array array to be set.
  30724. * @returns this effect.
  30725. */
  30726. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30727. /**
  30728. * 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)
  30729. * @param uniformName Name of the variable.
  30730. * @param array array to be set.
  30731. * @returns this effect.
  30732. */
  30733. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30734. /**
  30735. * Sets an array on a uniform variable.
  30736. * @param uniformName Name of the variable.
  30737. * @param array array to be set.
  30738. * @returns this effect.
  30739. */
  30740. setArray(uniformName: string, array: number[]): Effect;
  30741. /**
  30742. * 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)
  30743. * @param uniformName Name of the variable.
  30744. * @param array array to be set.
  30745. * @returns this effect.
  30746. */
  30747. setArray2(uniformName: string, array: number[]): Effect;
  30748. /**
  30749. * 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)
  30750. * @param uniformName Name of the variable.
  30751. * @param array array to be set.
  30752. * @returns this effect.
  30753. */
  30754. setArray3(uniformName: string, array: number[]): Effect;
  30755. /**
  30756. * 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)
  30757. * @param uniformName Name of the variable.
  30758. * @param array array to be set.
  30759. * @returns this effect.
  30760. */
  30761. setArray4(uniformName: string, array: number[]): Effect;
  30762. /**
  30763. * Sets matrices on a uniform variable.
  30764. * @param uniformName Name of the variable.
  30765. * @param matrices matrices to be set.
  30766. * @returns this effect.
  30767. */
  30768. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30769. /**
  30770. * Sets matrix on a uniform variable.
  30771. * @param uniformName Name of the variable.
  30772. * @param matrix matrix to be set.
  30773. * @returns this effect.
  30774. */
  30775. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30776. /**
  30777. * 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)
  30778. * @param uniformName Name of the variable.
  30779. * @param matrix matrix to be set.
  30780. * @returns this effect.
  30781. */
  30782. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30783. /**
  30784. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30785. * @param uniformName Name of the variable.
  30786. * @param matrix matrix to be set.
  30787. * @returns this effect.
  30788. */
  30789. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30790. /**
  30791. * Sets a float on a uniform variable.
  30792. * @param uniformName Name of the variable.
  30793. * @param value value to be set.
  30794. * @returns this effect.
  30795. */
  30796. setFloat(uniformName: string, value: number): Effect;
  30797. /**
  30798. * Sets a boolean on a uniform variable.
  30799. * @param uniformName Name of the variable.
  30800. * @param bool value to be set.
  30801. * @returns this effect.
  30802. */
  30803. setBool(uniformName: string, bool: boolean): Effect;
  30804. /**
  30805. * Sets a Vector2 on a uniform variable.
  30806. * @param uniformName Name of the variable.
  30807. * @param vector2 vector2 to be set.
  30808. * @returns this effect.
  30809. */
  30810. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30811. /**
  30812. * Sets a float2 on a uniform variable.
  30813. * @param uniformName Name of the variable.
  30814. * @param x First float in float2.
  30815. * @param y Second float in float2.
  30816. * @returns this effect.
  30817. */
  30818. setFloat2(uniformName: string, x: number, y: number): Effect;
  30819. /**
  30820. * Sets a Vector3 on a uniform variable.
  30821. * @param uniformName Name of the variable.
  30822. * @param vector3 Value to be set.
  30823. * @returns this effect.
  30824. */
  30825. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30826. /**
  30827. * Sets a float3 on a uniform variable.
  30828. * @param uniformName Name of the variable.
  30829. * @param x First float in float3.
  30830. * @param y Second float in float3.
  30831. * @param z Third float in float3.
  30832. * @returns this effect.
  30833. */
  30834. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30835. /**
  30836. * Sets a Vector4 on a uniform variable.
  30837. * @param uniformName Name of the variable.
  30838. * @param vector4 Value to be set.
  30839. * @returns this effect.
  30840. */
  30841. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30842. /**
  30843. * Sets a float4 on a uniform variable.
  30844. * @param uniformName Name of the variable.
  30845. * @param x First float in float4.
  30846. * @param y Second float in float4.
  30847. * @param z Third float in float4.
  30848. * @param w Fourth float in float4.
  30849. * @returns this effect.
  30850. */
  30851. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30852. /**
  30853. * Sets a Color3 on a uniform variable.
  30854. * @param uniformName Name of the variable.
  30855. * @param color3 Value to be set.
  30856. * @returns this effect.
  30857. */
  30858. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30859. /**
  30860. * Sets a Color4 on a uniform variable.
  30861. * @param uniformName Name of the variable.
  30862. * @param color3 Value to be set.
  30863. * @param alpha Alpha value to be set.
  30864. * @returns this effect.
  30865. */
  30866. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30867. /**
  30868. * Sets a Color4 on a uniform variable
  30869. * @param uniformName defines the name of the variable
  30870. * @param color4 defines the value to be set
  30871. * @returns this effect.
  30872. */
  30873. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30874. /** Release all associated resources */
  30875. dispose(): void;
  30876. /**
  30877. * This function will add a new shader to the shader store
  30878. * @param name the name of the shader
  30879. * @param pixelShader optional pixel shader content
  30880. * @param vertexShader optional vertex shader content
  30881. */
  30882. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30883. /**
  30884. * Store of each shader (The can be looked up using effect.key)
  30885. */
  30886. static ShadersStore: {
  30887. [key: string]: string;
  30888. };
  30889. /**
  30890. * Store of each included file for a shader (The can be looked up using effect.key)
  30891. */
  30892. static IncludesShadersStore: {
  30893. [key: string]: string;
  30894. };
  30895. /**
  30896. * Resets the cache of effects.
  30897. */
  30898. static ResetCache(): void;
  30899. }
  30900. }
  30901. declare module "babylonjs/Engines/engineCapabilities" {
  30902. /**
  30903. * Interface used to describe the capabilities of the engine relatively to the current browser
  30904. */
  30905. export interface EngineCapabilities {
  30906. /** Maximum textures units per fragment shader */
  30907. maxTexturesImageUnits: number;
  30908. /** Maximum texture units per vertex shader */
  30909. maxVertexTextureImageUnits: number;
  30910. /** Maximum textures units in the entire pipeline */
  30911. maxCombinedTexturesImageUnits: number;
  30912. /** Maximum texture size */
  30913. maxTextureSize: number;
  30914. /** Maximum texture samples */
  30915. maxSamples?: number;
  30916. /** Maximum cube texture size */
  30917. maxCubemapTextureSize: number;
  30918. /** Maximum render texture size */
  30919. maxRenderTextureSize: number;
  30920. /** Maximum number of vertex attributes */
  30921. maxVertexAttribs: number;
  30922. /** Maximum number of varyings */
  30923. maxVaryingVectors: number;
  30924. /** Maximum number of uniforms per vertex shader */
  30925. maxVertexUniformVectors: number;
  30926. /** Maximum number of uniforms per fragment shader */
  30927. maxFragmentUniformVectors: number;
  30928. /** Defines if standard derivates (dx/dy) are supported */
  30929. standardDerivatives: boolean;
  30930. /** Defines if s3tc texture compression is supported */
  30931. s3tc?: WEBGL_compressed_texture_s3tc;
  30932. /** Defines if pvrtc texture compression is supported */
  30933. pvrtc: any;
  30934. /** Defines if etc1 texture compression is supported */
  30935. etc1: any;
  30936. /** Defines if etc2 texture compression is supported */
  30937. etc2: any;
  30938. /** Defines if astc texture compression is supported */
  30939. astc: any;
  30940. /** Defines if float textures are supported */
  30941. textureFloat: boolean;
  30942. /** Defines if vertex array objects are supported */
  30943. vertexArrayObject: boolean;
  30944. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30945. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30946. /** Gets the maximum level of anisotropy supported */
  30947. maxAnisotropy: number;
  30948. /** Defines if instancing is supported */
  30949. instancedArrays: boolean;
  30950. /** Defines if 32 bits indices are supported */
  30951. uintIndices: boolean;
  30952. /** Defines if high precision shaders are supported */
  30953. highPrecisionShaderSupported: boolean;
  30954. /** Defines if depth reading in the fragment shader is supported */
  30955. fragmentDepthSupported: boolean;
  30956. /** Defines if float texture linear filtering is supported*/
  30957. textureFloatLinearFiltering: boolean;
  30958. /** Defines if rendering to float textures is supported */
  30959. textureFloatRender: boolean;
  30960. /** Defines if half float textures are supported*/
  30961. textureHalfFloat: boolean;
  30962. /** Defines if half float texture linear filtering is supported*/
  30963. textureHalfFloatLinearFiltering: boolean;
  30964. /** Defines if rendering to half float textures is supported */
  30965. textureHalfFloatRender: boolean;
  30966. /** Defines if textureLOD shader command is supported */
  30967. textureLOD: boolean;
  30968. /** Defines if draw buffers extension is supported */
  30969. drawBuffersExtension: boolean;
  30970. /** Defines if depth textures are supported */
  30971. depthTextureExtension: boolean;
  30972. /** Defines if float color buffer are supported */
  30973. colorBufferFloat: boolean;
  30974. /** Gets disjoint timer query extension (null if not supported) */
  30975. timerQuery?: EXT_disjoint_timer_query;
  30976. /** Defines if timestamp can be used with timer query */
  30977. canUseTimestampForTimerQuery: boolean;
  30978. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30979. multiview?: any;
  30980. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30981. oculusMultiview?: any;
  30982. /** Function used to let the system compiles shaders in background */
  30983. parallelShaderCompile?: {
  30984. COMPLETION_STATUS_KHR: number;
  30985. };
  30986. /** Max number of texture samples for MSAA */
  30987. maxMSAASamples: number;
  30988. /** Defines if the blend min max extension is supported */
  30989. blendMinMax: boolean;
  30990. }
  30991. }
  30992. declare module "babylonjs/States/depthCullingState" {
  30993. import { Nullable } from "babylonjs/types";
  30994. /**
  30995. * @hidden
  30996. **/
  30997. export class DepthCullingState {
  30998. private _isDepthTestDirty;
  30999. private _isDepthMaskDirty;
  31000. private _isDepthFuncDirty;
  31001. private _isCullFaceDirty;
  31002. private _isCullDirty;
  31003. private _isZOffsetDirty;
  31004. private _isFrontFaceDirty;
  31005. private _depthTest;
  31006. private _depthMask;
  31007. private _depthFunc;
  31008. private _cull;
  31009. private _cullFace;
  31010. private _zOffset;
  31011. private _frontFace;
  31012. /**
  31013. * Initializes the state.
  31014. */
  31015. constructor();
  31016. readonly isDirty: boolean;
  31017. zOffset: number;
  31018. cullFace: Nullable<number>;
  31019. cull: Nullable<boolean>;
  31020. depthFunc: Nullable<number>;
  31021. depthMask: boolean;
  31022. depthTest: boolean;
  31023. frontFace: Nullable<number>;
  31024. reset(): void;
  31025. apply(gl: WebGLRenderingContext): void;
  31026. }
  31027. }
  31028. declare module "babylonjs/States/stencilState" {
  31029. /**
  31030. * @hidden
  31031. **/
  31032. export class StencilState {
  31033. /** 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 */
  31034. static readonly ALWAYS: number;
  31035. /** Passed to stencilOperation to specify that stencil value must be kept */
  31036. static readonly KEEP: number;
  31037. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31038. static readonly REPLACE: number;
  31039. private _isStencilTestDirty;
  31040. private _isStencilMaskDirty;
  31041. private _isStencilFuncDirty;
  31042. private _isStencilOpDirty;
  31043. private _stencilTest;
  31044. private _stencilMask;
  31045. private _stencilFunc;
  31046. private _stencilFuncRef;
  31047. private _stencilFuncMask;
  31048. private _stencilOpStencilFail;
  31049. private _stencilOpDepthFail;
  31050. private _stencilOpStencilDepthPass;
  31051. readonly isDirty: boolean;
  31052. stencilFunc: number;
  31053. stencilFuncRef: number;
  31054. stencilFuncMask: number;
  31055. stencilOpStencilFail: number;
  31056. stencilOpDepthFail: number;
  31057. stencilOpStencilDepthPass: number;
  31058. stencilMask: number;
  31059. stencilTest: boolean;
  31060. constructor();
  31061. reset(): void;
  31062. apply(gl: WebGLRenderingContext): void;
  31063. }
  31064. }
  31065. declare module "babylonjs/States/alphaCullingState" {
  31066. /**
  31067. * @hidden
  31068. **/
  31069. export class AlphaState {
  31070. private _isAlphaBlendDirty;
  31071. private _isBlendFunctionParametersDirty;
  31072. private _isBlendEquationParametersDirty;
  31073. private _isBlendConstantsDirty;
  31074. private _alphaBlend;
  31075. private _blendFunctionParameters;
  31076. private _blendEquationParameters;
  31077. private _blendConstants;
  31078. /**
  31079. * Initializes the state.
  31080. */
  31081. constructor();
  31082. readonly isDirty: boolean;
  31083. alphaBlend: boolean;
  31084. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31085. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31086. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31087. reset(): void;
  31088. apply(gl: WebGLRenderingContext): void;
  31089. }
  31090. }
  31091. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31092. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31093. /** @hidden */
  31094. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31095. attributeProcessor(attribute: string): string;
  31096. varyingProcessor(varying: string, isFragment: boolean): string;
  31097. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31098. }
  31099. }
  31100. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31101. /**
  31102. * Interface for attribute information associated with buffer instanciation
  31103. */
  31104. export interface InstancingAttributeInfo {
  31105. /**
  31106. * Name of the GLSL attribute
  31107. * if attribute index is not specified, this is used to retrieve the index from the effect
  31108. */
  31109. attributeName: string;
  31110. /**
  31111. * Index/offset of the attribute in the vertex shader
  31112. * if not specified, this will be computes from the name.
  31113. */
  31114. index?: number;
  31115. /**
  31116. * size of the attribute, 1, 2, 3 or 4
  31117. */
  31118. attributeSize: number;
  31119. /**
  31120. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31121. */
  31122. offset: number;
  31123. /**
  31124. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31125. * default to 1
  31126. */
  31127. divisor?: number;
  31128. /**
  31129. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31130. * default is FLOAT
  31131. */
  31132. attributeType?: number;
  31133. /**
  31134. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31135. */
  31136. normalized?: boolean;
  31137. }
  31138. }
  31139. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31140. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31141. import { Nullable } from "babylonjs/types";
  31142. module "babylonjs/Engines/thinEngine" {
  31143. interface ThinEngine {
  31144. /**
  31145. * Update a video texture
  31146. * @param texture defines the texture to update
  31147. * @param video defines the video element to use
  31148. * @param invertY defines if data must be stored with Y axis inverted
  31149. */
  31150. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31151. }
  31152. }
  31153. }
  31154. declare module "babylonjs/Materials/Textures/videoTexture" {
  31155. import { Observable } from "babylonjs/Misc/observable";
  31156. import { Nullable } from "babylonjs/types";
  31157. import { Scene } from "babylonjs/scene";
  31158. import { Texture } from "babylonjs/Materials/Textures/texture";
  31159. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31160. /**
  31161. * Settings for finer control over video usage
  31162. */
  31163. export interface VideoTextureSettings {
  31164. /**
  31165. * Applies `autoplay` to video, if specified
  31166. */
  31167. autoPlay?: boolean;
  31168. /**
  31169. * Applies `loop` to video, if specified
  31170. */
  31171. loop?: boolean;
  31172. /**
  31173. * Automatically updates internal texture from video at every frame in the render loop
  31174. */
  31175. autoUpdateTexture: boolean;
  31176. /**
  31177. * Image src displayed during the video loading or until the user interacts with the video.
  31178. */
  31179. poster?: string;
  31180. }
  31181. /**
  31182. * If you want to display a video in your scene, this is the special texture for that.
  31183. * This special texture works similar to other textures, with the exception of a few parameters.
  31184. * @see https://doc.babylonjs.com/how_to/video_texture
  31185. */
  31186. export class VideoTexture extends Texture {
  31187. /**
  31188. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31189. */
  31190. readonly autoUpdateTexture: boolean;
  31191. /**
  31192. * The video instance used by the texture internally
  31193. */
  31194. readonly video: HTMLVideoElement;
  31195. private _onUserActionRequestedObservable;
  31196. /**
  31197. * Event triggerd when a dom action is required by the user to play the video.
  31198. * This happens due to recent changes in browser policies preventing video to auto start.
  31199. */
  31200. readonly onUserActionRequestedObservable: Observable<Texture>;
  31201. private _generateMipMaps;
  31202. private _engine;
  31203. private _stillImageCaptured;
  31204. private _displayingPosterTexture;
  31205. private _settings;
  31206. private _createInternalTextureOnEvent;
  31207. private _frameId;
  31208. /**
  31209. * Creates a video texture.
  31210. * If you want to display a video in your scene, this is the special texture for that.
  31211. * This special texture works similar to other textures, with the exception of a few parameters.
  31212. * @see https://doc.babylonjs.com/how_to/video_texture
  31213. * @param name optional name, will detect from video source, if not defined
  31214. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31215. * @param scene is obviously the current scene.
  31216. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31217. * @param invertY is false by default but can be used to invert video on Y axis
  31218. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31219. * @param settings allows finer control over video usage
  31220. */
  31221. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31222. private _getName;
  31223. private _getVideo;
  31224. private _createInternalTexture;
  31225. private reset;
  31226. /**
  31227. * @hidden Internal method to initiate `update`.
  31228. */
  31229. _rebuild(): void;
  31230. /**
  31231. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31232. */
  31233. update(): void;
  31234. /**
  31235. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31236. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31237. */
  31238. updateTexture(isVisible: boolean): void;
  31239. protected _updateInternalTexture: () => void;
  31240. /**
  31241. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31242. * @param url New url.
  31243. */
  31244. updateURL(url: string): void;
  31245. /**
  31246. * Dispose the texture and release its associated resources.
  31247. */
  31248. dispose(): void;
  31249. /**
  31250. * Creates a video texture straight from a stream.
  31251. * @param scene Define the scene the texture should be created in
  31252. * @param stream Define the stream the texture should be created from
  31253. * @returns The created video texture as a promise
  31254. */
  31255. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31256. /**
  31257. * Creates a video texture straight from your WebCam video feed.
  31258. * @param scene Define the scene the texture should be created in
  31259. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31260. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31261. * @returns The created video texture as a promise
  31262. */
  31263. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31264. minWidth: number;
  31265. maxWidth: number;
  31266. minHeight: number;
  31267. maxHeight: number;
  31268. deviceId: string;
  31269. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31270. /**
  31271. * Creates a video texture straight from your WebCam video feed.
  31272. * @param scene Define the scene the texture should be created in
  31273. * @param onReady Define a callback to triggered once the texture will be ready
  31274. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31275. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31276. */
  31277. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31278. minWidth: number;
  31279. maxWidth: number;
  31280. minHeight: number;
  31281. maxHeight: number;
  31282. deviceId: string;
  31283. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31284. }
  31285. }
  31286. declare module "babylonjs/Engines/thinEngine" {
  31287. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31288. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31289. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31290. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31291. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31292. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31293. import { Observable } from "babylonjs/Misc/observable";
  31294. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31295. import { StencilState } from "babylonjs/States/stencilState";
  31296. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31298. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31299. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31300. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31301. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31302. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31303. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31304. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31306. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31307. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31308. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31309. /**
  31310. * Defines the interface used by objects working like Scene
  31311. * @hidden
  31312. */
  31313. interface ISceneLike {
  31314. _addPendingData(data: any): void;
  31315. _removePendingData(data: any): void;
  31316. offlineProvider: IOfflineProvider;
  31317. }
  31318. /** Interface defining initialization parameters for Engine class */
  31319. export interface EngineOptions extends WebGLContextAttributes {
  31320. /**
  31321. * Defines if the engine should no exceed a specified device ratio
  31322. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31323. */
  31324. limitDeviceRatio?: number;
  31325. /**
  31326. * Defines if webvr should be enabled automatically
  31327. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31328. */
  31329. autoEnableWebVR?: boolean;
  31330. /**
  31331. * Defines if webgl2 should be turned off even if supported
  31332. * @see http://doc.babylonjs.com/features/webgl2
  31333. */
  31334. disableWebGL2Support?: boolean;
  31335. /**
  31336. * Defines if webaudio should be initialized as well
  31337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31338. */
  31339. audioEngine?: boolean;
  31340. /**
  31341. * Defines if animations should run using a deterministic lock step
  31342. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31343. */
  31344. deterministicLockstep?: boolean;
  31345. /** Defines the maximum steps to use with deterministic lock step mode */
  31346. lockstepMaxSteps?: number;
  31347. /** Defines the seconds between each deterministic lock step */
  31348. timeStep?: number;
  31349. /**
  31350. * Defines that engine should ignore context lost events
  31351. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31352. */
  31353. doNotHandleContextLost?: boolean;
  31354. /**
  31355. * Defines that engine should ignore modifying touch action attribute and style
  31356. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31357. */
  31358. doNotHandleTouchAction?: boolean;
  31359. /**
  31360. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31361. */
  31362. useHighPrecisionFloats?: boolean;
  31363. }
  31364. /**
  31365. * The base engine class (root of all engines)
  31366. */
  31367. export class ThinEngine {
  31368. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31369. static ExceptionList: ({
  31370. key: string;
  31371. capture: string;
  31372. captureConstraint: number;
  31373. targets: string[];
  31374. } | {
  31375. key: string;
  31376. capture: null;
  31377. captureConstraint: null;
  31378. targets: string[];
  31379. })[];
  31380. /** @hidden */
  31381. static _TextureLoaders: IInternalTextureLoader[];
  31382. /**
  31383. * Returns the current npm package of the sdk
  31384. */
  31385. static readonly NpmPackage: string;
  31386. /**
  31387. * Returns the current version of the framework
  31388. */
  31389. static readonly Version: string;
  31390. /**
  31391. * Returns a string describing the current engine
  31392. */
  31393. readonly description: string;
  31394. /**
  31395. * Gets or sets the epsilon value used by collision engine
  31396. */
  31397. static CollisionsEpsilon: number;
  31398. /**
  31399. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31400. */
  31401. static ShadersRepository: string;
  31402. /**
  31403. * Gets or sets the textures that the engine should not attempt to load as compressed
  31404. */
  31405. protected _excludedCompressedTextures: string[];
  31406. /**
  31407. * Filters the compressed texture formats to only include
  31408. * files that are not included in the skippable list
  31409. *
  31410. * @param url the current extension
  31411. * @param textureFormatInUse the current compressed texture format
  31412. * @returns "format" string
  31413. */
  31414. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31415. /** @hidden */
  31416. _shaderProcessor: IShaderProcessor;
  31417. /**
  31418. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31419. */
  31420. forcePOTTextures: boolean;
  31421. /**
  31422. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31423. */
  31424. isFullscreen: boolean;
  31425. /**
  31426. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31427. */
  31428. cullBackFaces: boolean;
  31429. /**
  31430. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31431. */
  31432. renderEvenInBackground: boolean;
  31433. /**
  31434. * Gets or sets a boolean indicating that cache can be kept between frames
  31435. */
  31436. preventCacheWipeBetweenFrames: boolean;
  31437. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31438. validateShaderPrograms: boolean;
  31439. /**
  31440. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31441. * This can provide greater z depth for distant objects.
  31442. */
  31443. useReverseDepthBuffer: boolean;
  31444. /**
  31445. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31446. */
  31447. disableUniformBuffers: boolean;
  31448. /** @hidden */
  31449. _uniformBuffers: UniformBuffer[];
  31450. /**
  31451. * Gets a boolean indicating that the engine supports uniform buffers
  31452. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31453. */
  31454. readonly supportsUniformBuffers: boolean;
  31455. /** @hidden */
  31456. _gl: WebGLRenderingContext;
  31457. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31458. protected _windowIsBackground: boolean;
  31459. protected _webGLVersion: number;
  31460. protected _creationOptions: EngineOptions;
  31461. protected _highPrecisionShadersAllowed: boolean;
  31462. /** @hidden */
  31463. readonly _shouldUseHighPrecisionShader: boolean;
  31464. /**
  31465. * Gets a boolean indicating that only power of 2 textures are supported
  31466. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31467. */
  31468. readonly needPOTTextures: boolean;
  31469. /** @hidden */
  31470. _badOS: boolean;
  31471. /** @hidden */
  31472. _badDesktopOS: boolean;
  31473. private _hardwareScalingLevel;
  31474. /** @hidden */
  31475. _caps: EngineCapabilities;
  31476. private _isStencilEnable;
  31477. private _glVersion;
  31478. private _glRenderer;
  31479. private _glVendor;
  31480. /** @hidden */
  31481. _videoTextureSupported: boolean;
  31482. protected _renderingQueueLaunched: boolean;
  31483. protected _activeRenderLoops: (() => void)[];
  31484. /**
  31485. * Observable signaled when a context lost event is raised
  31486. */
  31487. onContextLostObservable: Observable<ThinEngine>;
  31488. /**
  31489. * Observable signaled when a context restored event is raised
  31490. */
  31491. onContextRestoredObservable: Observable<ThinEngine>;
  31492. private _onContextLost;
  31493. private _onContextRestored;
  31494. protected _contextWasLost: boolean;
  31495. /** @hidden */
  31496. _doNotHandleContextLost: boolean;
  31497. /**
  31498. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31500. */
  31501. doNotHandleContextLost: boolean;
  31502. /**
  31503. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31504. */
  31505. disableVertexArrayObjects: boolean;
  31506. /** @hidden */
  31507. protected _colorWrite: boolean;
  31508. /** @hidden */
  31509. protected _colorWriteChanged: boolean;
  31510. /** @hidden */
  31511. protected _depthCullingState: DepthCullingState;
  31512. /** @hidden */
  31513. protected _stencilState: StencilState;
  31514. /** @hidden */
  31515. _alphaState: AlphaState;
  31516. /** @hidden */
  31517. _alphaMode: number;
  31518. /** @hidden */
  31519. _alphaEquation: number;
  31520. /** @hidden */
  31521. _internalTexturesCache: InternalTexture[];
  31522. /** @hidden */
  31523. protected _activeChannel: number;
  31524. private _currentTextureChannel;
  31525. /** @hidden */
  31526. protected _boundTexturesCache: {
  31527. [key: string]: Nullable<InternalTexture>;
  31528. };
  31529. /** @hidden */
  31530. protected _currentEffect: Nullable<Effect>;
  31531. /** @hidden */
  31532. protected _currentProgram: Nullable<WebGLProgram>;
  31533. private _compiledEffects;
  31534. private _vertexAttribArraysEnabled;
  31535. /** @hidden */
  31536. protected _cachedViewport: Nullable<IViewportLike>;
  31537. private _cachedVertexArrayObject;
  31538. /** @hidden */
  31539. protected _cachedVertexBuffers: any;
  31540. /** @hidden */
  31541. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31542. /** @hidden */
  31543. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31544. /** @hidden */
  31545. _currentRenderTarget: Nullable<InternalTexture>;
  31546. private _uintIndicesCurrentlySet;
  31547. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31548. /** @hidden */
  31549. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31550. private _currentBufferPointers;
  31551. private _currentInstanceLocations;
  31552. private _currentInstanceBuffers;
  31553. private _textureUnits;
  31554. /** @hidden */
  31555. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31556. /** @hidden */
  31557. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31558. /** @hidden */
  31559. _boundRenderFunction: any;
  31560. private _vaoRecordInProgress;
  31561. private _mustWipeVertexAttributes;
  31562. private _emptyTexture;
  31563. private _emptyCubeTexture;
  31564. private _emptyTexture3D;
  31565. private _emptyTexture2DArray;
  31566. /** @hidden */
  31567. _frameHandler: number;
  31568. private _nextFreeTextureSlots;
  31569. private _maxSimultaneousTextures;
  31570. private _activeRequests;
  31571. protected _texturesSupported: string[];
  31572. /** @hidden */
  31573. _textureFormatInUse: Nullable<string>;
  31574. protected readonly _supportsHardwareTextureRescaling: boolean;
  31575. /**
  31576. * Gets the list of texture formats supported
  31577. */
  31578. readonly texturesSupported: Array<string>;
  31579. /**
  31580. * Gets the list of texture formats in use
  31581. */
  31582. readonly textureFormatInUse: Nullable<string>;
  31583. /**
  31584. * Gets the current viewport
  31585. */
  31586. readonly currentViewport: Nullable<IViewportLike>;
  31587. /**
  31588. * Gets the default empty texture
  31589. */
  31590. readonly emptyTexture: InternalTexture;
  31591. /**
  31592. * Gets the default empty 3D texture
  31593. */
  31594. readonly emptyTexture3D: InternalTexture;
  31595. /**
  31596. * Gets the default empty 2D array texture
  31597. */
  31598. readonly emptyTexture2DArray: InternalTexture;
  31599. /**
  31600. * Gets the default empty cube texture
  31601. */
  31602. readonly emptyCubeTexture: InternalTexture;
  31603. /**
  31604. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31605. */
  31606. readonly premultipliedAlpha: boolean;
  31607. /**
  31608. * Observable event triggered before each texture is initialized
  31609. */
  31610. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31611. /**
  31612. * Creates a new engine
  31613. * @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
  31614. * @param antialias defines enable antialiasing (default: false)
  31615. * @param options defines further options to be sent to the getContext() function
  31616. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31617. */
  31618. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31619. private _rebuildInternalTextures;
  31620. private _rebuildEffects;
  31621. /**
  31622. * Gets a boolean indicating if all created effects are ready
  31623. * @returns true if all effects are ready
  31624. */
  31625. areAllEffectsReady(): boolean;
  31626. protected _rebuildBuffers(): void;
  31627. private _initGLContext;
  31628. /**
  31629. * Gets version of the current webGL context
  31630. */
  31631. readonly webGLVersion: number;
  31632. /**
  31633. * Gets a string idenfifying the name of the class
  31634. * @returns "Engine" string
  31635. */
  31636. getClassName(): string;
  31637. /**
  31638. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31639. */
  31640. readonly isStencilEnable: boolean;
  31641. /** @hidden */
  31642. _prepareWorkingCanvas(): void;
  31643. /**
  31644. * Reset the texture cache to empty state
  31645. */
  31646. resetTextureCache(): void;
  31647. /**
  31648. * Gets an object containing information about the current webGL context
  31649. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31650. */
  31651. getGlInfo(): {
  31652. vendor: string;
  31653. renderer: string;
  31654. version: string;
  31655. };
  31656. /**
  31657. * Defines the hardware scaling level.
  31658. * By default the hardware scaling level is computed from the window device ratio.
  31659. * 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.
  31660. * @param level defines the level to use
  31661. */
  31662. setHardwareScalingLevel(level: number): void;
  31663. /**
  31664. * Gets the current hardware scaling level.
  31665. * By default the hardware scaling level is computed from the window device ratio.
  31666. * 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.
  31667. * @returns a number indicating the current hardware scaling level
  31668. */
  31669. getHardwareScalingLevel(): number;
  31670. /**
  31671. * Gets the list of loaded textures
  31672. * @returns an array containing all loaded textures
  31673. */
  31674. getLoadedTexturesCache(): InternalTexture[];
  31675. /**
  31676. * Gets the object containing all engine capabilities
  31677. * @returns the EngineCapabilities object
  31678. */
  31679. getCaps(): EngineCapabilities;
  31680. /**
  31681. * stop executing a render loop function and remove it from the execution array
  31682. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31683. */
  31684. stopRenderLoop(renderFunction?: () => void): void;
  31685. /** @hidden */
  31686. _renderLoop(): void;
  31687. /**
  31688. * Gets the HTML canvas attached with the current webGL context
  31689. * @returns a HTML canvas
  31690. */
  31691. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31692. /**
  31693. * Gets host window
  31694. * @returns the host window object
  31695. */
  31696. getHostWindow(): Nullable<Window>;
  31697. /**
  31698. * Gets the current render width
  31699. * @param useScreen defines if screen size must be used (or the current render target if any)
  31700. * @returns a number defining the current render width
  31701. */
  31702. getRenderWidth(useScreen?: boolean): number;
  31703. /**
  31704. * Gets the current render height
  31705. * @param useScreen defines if screen size must be used (or the current render target if any)
  31706. * @returns a number defining the current render height
  31707. */
  31708. getRenderHeight(useScreen?: boolean): number;
  31709. /**
  31710. * Can be used to override the current requestAnimationFrame requester.
  31711. * @hidden
  31712. */
  31713. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31714. /**
  31715. * Register and execute a render loop. The engine can have more than one render function
  31716. * @param renderFunction defines the function to continuously execute
  31717. */
  31718. runRenderLoop(renderFunction: () => void): void;
  31719. /**
  31720. * Clear the current render buffer or the current render target (if any is set up)
  31721. * @param color defines the color to use
  31722. * @param backBuffer defines if the back buffer must be cleared
  31723. * @param depth defines if the depth buffer must be cleared
  31724. * @param stencil defines if the stencil buffer must be cleared
  31725. */
  31726. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31727. private _viewportCached;
  31728. /** @hidden */
  31729. _viewport(x: number, y: number, width: number, height: number): void;
  31730. /**
  31731. * Set the WebGL's viewport
  31732. * @param viewport defines the viewport element to be used
  31733. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31734. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31735. */
  31736. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31737. /**
  31738. * Begin a new frame
  31739. */
  31740. beginFrame(): void;
  31741. /**
  31742. * Enf the current frame
  31743. */
  31744. endFrame(): void;
  31745. /**
  31746. * Resize the view according to the canvas' size
  31747. */
  31748. resize(): void;
  31749. /**
  31750. * Force a specific size of the canvas
  31751. * @param width defines the new canvas' width
  31752. * @param height defines the new canvas' height
  31753. */
  31754. setSize(width: number, height: number): void;
  31755. /**
  31756. * Binds the frame buffer to the specified texture.
  31757. * @param texture The texture to render to or null for the default canvas
  31758. * @param faceIndex The face of the texture to render to in case of cube texture
  31759. * @param requiredWidth The width of the target to render to
  31760. * @param requiredHeight The height of the target to render to
  31761. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31762. * @param depthStencilTexture The depth stencil texture to use to render
  31763. * @param lodLevel defines le lod level to bind to the frame buffer
  31764. */
  31765. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31766. /** @hidden */
  31767. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31768. /**
  31769. * Unbind the current render target texture from the webGL context
  31770. * @param texture defines the render target texture to unbind
  31771. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31772. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31773. */
  31774. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31775. /**
  31776. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31777. */
  31778. flushFramebuffer(): void;
  31779. /**
  31780. * Unbind the current render target and bind the default framebuffer
  31781. */
  31782. restoreDefaultFramebuffer(): void;
  31783. /** @hidden */
  31784. protected _resetVertexBufferBinding(): void;
  31785. /**
  31786. * Creates a vertex buffer
  31787. * @param data the data for the vertex buffer
  31788. * @returns the new WebGL static buffer
  31789. */
  31790. createVertexBuffer(data: DataArray): DataBuffer;
  31791. private _createVertexBuffer;
  31792. /**
  31793. * Creates a dynamic vertex buffer
  31794. * @param data the data for the dynamic vertex buffer
  31795. * @returns the new WebGL dynamic buffer
  31796. */
  31797. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31798. protected _resetIndexBufferBinding(): void;
  31799. /**
  31800. * Creates a new index buffer
  31801. * @param indices defines the content of the index buffer
  31802. * @param updatable defines if the index buffer must be updatable
  31803. * @returns a new webGL buffer
  31804. */
  31805. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31806. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31807. /**
  31808. * Bind a webGL buffer to the webGL context
  31809. * @param buffer defines the buffer to bind
  31810. */
  31811. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31812. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31813. private bindBuffer;
  31814. /**
  31815. * update the bound buffer with the given data
  31816. * @param data defines the data to update
  31817. */
  31818. updateArrayBuffer(data: Float32Array): void;
  31819. private _vertexAttribPointer;
  31820. private _bindIndexBufferWithCache;
  31821. private _bindVertexBuffersAttributes;
  31822. /**
  31823. * Records a vertex array object
  31824. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31825. * @param vertexBuffers defines the list of vertex buffers to store
  31826. * @param indexBuffer defines the index buffer to store
  31827. * @param effect defines the effect to store
  31828. * @returns the new vertex array object
  31829. */
  31830. recordVertexArrayObject(vertexBuffers: {
  31831. [key: string]: VertexBuffer;
  31832. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31833. /**
  31834. * Bind a specific vertex array object
  31835. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31836. * @param vertexArrayObject defines the vertex array object to bind
  31837. * @param indexBuffer defines the index buffer to bind
  31838. */
  31839. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31840. /**
  31841. * Bind webGl buffers directly to the webGL context
  31842. * @param vertexBuffer defines the vertex buffer to bind
  31843. * @param indexBuffer defines the index buffer to bind
  31844. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31845. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31846. * @param effect defines the effect associated with the vertex buffer
  31847. */
  31848. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31849. private _unbindVertexArrayObject;
  31850. /**
  31851. * Bind a list of vertex buffers to the webGL context
  31852. * @param vertexBuffers defines the list of vertex buffers to bind
  31853. * @param indexBuffer defines the index buffer to bind
  31854. * @param effect defines the effect associated with the vertex buffers
  31855. */
  31856. bindBuffers(vertexBuffers: {
  31857. [key: string]: Nullable<VertexBuffer>;
  31858. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31859. /**
  31860. * Unbind all instance attributes
  31861. */
  31862. unbindInstanceAttributes(): void;
  31863. /**
  31864. * Release and free the memory of a vertex array object
  31865. * @param vao defines the vertex array object to delete
  31866. */
  31867. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31868. /** @hidden */
  31869. _releaseBuffer(buffer: DataBuffer): boolean;
  31870. protected _deleteBuffer(buffer: DataBuffer): void;
  31871. /**
  31872. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31873. * @param instancesBuffer defines the webGL buffer to update and bind
  31874. * @param data defines the data to store in the buffer
  31875. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31876. */
  31877. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31878. /**
  31879. * Bind the content of a webGL buffer used with instanciation
  31880. * @param instancesBuffer defines the webGL buffer to bind
  31881. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31882. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31883. */
  31884. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31885. /**
  31886. * Disable the instance attribute corresponding to the name in parameter
  31887. * @param name defines the name of the attribute to disable
  31888. */
  31889. disableInstanceAttributeByName(name: string): void;
  31890. /**
  31891. * Disable the instance attribute corresponding to the location in parameter
  31892. * @param attributeLocation defines the attribute location of the attribute to disable
  31893. */
  31894. disableInstanceAttribute(attributeLocation: number): void;
  31895. /**
  31896. * Disable the attribute corresponding to the location in parameter
  31897. * @param attributeLocation defines the attribute location of the attribute to disable
  31898. */
  31899. disableAttributeByIndex(attributeLocation: number): void;
  31900. /**
  31901. * Send a draw order
  31902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31903. * @param indexStart defines the starting index
  31904. * @param indexCount defines the number of index to draw
  31905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31906. */
  31907. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31908. /**
  31909. * Draw a list of points
  31910. * @param verticesStart defines the index of first vertex to draw
  31911. * @param verticesCount defines the count of vertices to draw
  31912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31913. */
  31914. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31915. /**
  31916. * Draw a list of unindexed primitives
  31917. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31918. * @param verticesStart defines the index of first vertex to draw
  31919. * @param verticesCount defines the count of vertices to draw
  31920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31921. */
  31922. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31923. /**
  31924. * Draw a list of indexed primitives
  31925. * @param fillMode defines the primitive to use
  31926. * @param indexStart defines the starting index
  31927. * @param indexCount defines the number of index to draw
  31928. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31929. */
  31930. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31931. /**
  31932. * Draw a list of unindexed primitives
  31933. * @param fillMode defines the primitive to use
  31934. * @param verticesStart defines the index of first vertex to draw
  31935. * @param verticesCount defines the count of vertices to draw
  31936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31937. */
  31938. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31939. private _drawMode;
  31940. /** @hidden */
  31941. protected _reportDrawCall(): void;
  31942. /** @hidden */
  31943. _releaseEffect(effect: Effect): void;
  31944. /** @hidden */
  31945. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31946. /**
  31947. * Create a new effect (used to store vertex/fragment shaders)
  31948. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31949. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31950. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31951. * @param samplers defines an array of string used to represent textures
  31952. * @param defines defines the string containing the defines to use to compile the shaders
  31953. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31954. * @param onCompiled defines a function to call when the effect creation is successful
  31955. * @param onError defines a function to call when the effect creation has failed
  31956. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31957. * @returns the new Effect
  31958. */
  31959. 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;
  31960. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31961. private _compileShader;
  31962. private _compileRawShader;
  31963. /**
  31964. * Directly creates a webGL program
  31965. * @param pipelineContext defines the pipeline context to attach to
  31966. * @param vertexCode defines the vertex shader code to use
  31967. * @param fragmentCode defines the fragment shader code to use
  31968. * @param context defines the webGL context to use (if not set, the current one will be used)
  31969. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31970. * @returns the new webGL program
  31971. */
  31972. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31973. /**
  31974. * Creates a webGL program
  31975. * @param pipelineContext defines the pipeline context to attach to
  31976. * @param vertexCode defines the vertex shader code to use
  31977. * @param fragmentCode defines the fragment shader code to use
  31978. * @param defines defines the string containing the defines to use to compile the shaders
  31979. * @param context defines the webGL context to use (if not set, the current one will be used)
  31980. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31981. * @returns the new webGL program
  31982. */
  31983. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31984. /**
  31985. * Creates a new pipeline context
  31986. * @returns the new pipeline
  31987. */
  31988. createPipelineContext(): IPipelineContext;
  31989. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31990. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31991. /** @hidden */
  31992. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31993. /** @hidden */
  31994. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31995. /** @hidden */
  31996. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31997. /**
  31998. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31999. * @param pipelineContext defines the pipeline context to use
  32000. * @param uniformsNames defines the list of uniform names
  32001. * @returns an array of webGL uniform locations
  32002. */
  32003. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32004. /**
  32005. * Gets the lsit of active attributes for a given webGL program
  32006. * @param pipelineContext defines the pipeline context to use
  32007. * @param attributesNames defines the list of attribute names to get
  32008. * @returns an array of indices indicating the offset of each attribute
  32009. */
  32010. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32011. /**
  32012. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32013. * @param effect defines the effect to activate
  32014. */
  32015. enableEffect(effect: Nullable<Effect>): void;
  32016. /**
  32017. * Set the value of an uniform to a number (int)
  32018. * @param uniform defines the webGL uniform location where to store the value
  32019. * @param value defines the int number to store
  32020. */
  32021. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32022. /**
  32023. * Set the value of an uniform to an array of int32
  32024. * @param uniform defines the webGL uniform location where to store the value
  32025. * @param array defines the array of int32 to store
  32026. */
  32027. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32028. /**
  32029. * Set the value of an uniform to an array of int32 (stored as vec2)
  32030. * @param uniform defines the webGL uniform location where to store the value
  32031. * @param array defines the array of int32 to store
  32032. */
  32033. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32034. /**
  32035. * Set the value of an uniform to an array of int32 (stored as vec3)
  32036. * @param uniform defines the webGL uniform location where to store the value
  32037. * @param array defines the array of int32 to store
  32038. */
  32039. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32040. /**
  32041. * Set the value of an uniform to an array of int32 (stored as vec4)
  32042. * @param uniform defines the webGL uniform location where to store the value
  32043. * @param array defines the array of int32 to store
  32044. */
  32045. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32046. /**
  32047. * Set the value of an uniform to an array of number
  32048. * @param uniform defines the webGL uniform location where to store the value
  32049. * @param array defines the array of number to store
  32050. */
  32051. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32052. /**
  32053. * Set the value of an uniform to an array of number (stored as vec2)
  32054. * @param uniform defines the webGL uniform location where to store the value
  32055. * @param array defines the array of number to store
  32056. */
  32057. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32058. /**
  32059. * Set the value of an uniform to an array of number (stored as vec3)
  32060. * @param uniform defines the webGL uniform location where to store the value
  32061. * @param array defines the array of number to store
  32062. */
  32063. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32064. /**
  32065. * Set the value of an uniform to an array of number (stored as vec4)
  32066. * @param uniform defines the webGL uniform location where to store the value
  32067. * @param array defines the array of number to store
  32068. */
  32069. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32070. /**
  32071. * Set the value of an uniform to an array of float32 (stored as matrices)
  32072. * @param uniform defines the webGL uniform location where to store the value
  32073. * @param matrices defines the array of float32 to store
  32074. */
  32075. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32076. /**
  32077. * Set the value of an uniform to a matrix (3x3)
  32078. * @param uniform defines the webGL uniform location where to store the value
  32079. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32080. */
  32081. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32082. /**
  32083. * Set the value of an uniform to a matrix (2x2)
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32086. */
  32087. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32088. /**
  32089. * Set the value of an uniform to a number (float)
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param value defines the float number to store
  32092. */
  32093. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32094. /**
  32095. * Set the value of an uniform to a vec2
  32096. * @param uniform defines the webGL uniform location where to store the value
  32097. * @param x defines the 1st component of the value
  32098. * @param y defines the 2nd component of the value
  32099. */
  32100. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32101. /**
  32102. * Set the value of an uniform to a vec3
  32103. * @param uniform defines the webGL uniform location where to store the value
  32104. * @param x defines the 1st component of the value
  32105. * @param y defines the 2nd component of the value
  32106. * @param z defines the 3rd component of the value
  32107. */
  32108. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32109. /**
  32110. * Set the value of an uniform to a vec4
  32111. * @param uniform defines the webGL uniform location where to store the value
  32112. * @param x defines the 1st component of the value
  32113. * @param y defines the 2nd component of the value
  32114. * @param z defines the 3rd component of the value
  32115. * @param w defines the 4th component of the value
  32116. */
  32117. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32118. /**
  32119. * Apply all cached states (depth, culling, stencil and alpha)
  32120. */
  32121. applyStates(): void;
  32122. /**
  32123. * Enable or disable color writing
  32124. * @param enable defines the state to set
  32125. */
  32126. setColorWrite(enable: boolean): void;
  32127. /**
  32128. * Gets a boolean indicating if color writing is enabled
  32129. * @returns the current color writing state
  32130. */
  32131. getColorWrite(): boolean;
  32132. /**
  32133. * Gets the depth culling state manager
  32134. */
  32135. readonly depthCullingState: DepthCullingState;
  32136. /**
  32137. * Gets the alpha state manager
  32138. */
  32139. readonly alphaState: AlphaState;
  32140. /**
  32141. * Gets the stencil state manager
  32142. */
  32143. readonly stencilState: StencilState;
  32144. /**
  32145. * Clears the list of texture accessible through engine.
  32146. * This can help preventing texture load conflict due to name collision.
  32147. */
  32148. clearInternalTexturesCache(): void;
  32149. /**
  32150. * Force the entire cache to be cleared
  32151. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32152. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32153. */
  32154. wipeCaches(bruteForce?: boolean): void;
  32155. /** @hidden */
  32156. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32157. min: number;
  32158. mag: number;
  32159. };
  32160. /** @hidden */
  32161. _createTexture(): WebGLTexture;
  32162. /**
  32163. * Usually called from Texture.ts.
  32164. * Passed information to create a WebGLTexture
  32165. * @param urlArg defines a value which contains one of the following:
  32166. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32167. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32168. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32169. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32170. * @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)
  32171. * @param scene needed for loading to the correct scene
  32172. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32173. * @param onLoad optional callback to be called upon successful completion
  32174. * @param onError optional callback to be called upon failure
  32175. * @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
  32176. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32177. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32178. * @param forcedExtension defines the extension to use to pick the right loader
  32179. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32180. * @param mimeType defines an optional mime type
  32181. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32182. */
  32183. 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;
  32184. /**
  32185. * @hidden
  32186. */
  32187. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32188. /**
  32189. * Creates a raw texture
  32190. * @param data defines the data to store in the texture
  32191. * @param width defines the width of the texture
  32192. * @param height defines the height of the texture
  32193. * @param format defines the format of the data
  32194. * @param generateMipMaps defines if the engine should generate the mip levels
  32195. * @param invertY defines if data must be stored with Y axis inverted
  32196. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32197. * @param compression defines the compression used (null by default)
  32198. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32199. * @returns the raw texture inside an InternalTexture
  32200. */
  32201. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32202. /**
  32203. * Creates a new raw cube texture
  32204. * @param data defines the array of data to use to create each face
  32205. * @param size defines the size of the textures
  32206. * @param format defines the format of the data
  32207. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32208. * @param generateMipMaps defines if the engine should generate the mip levels
  32209. * @param invertY defines if data must be stored with Y axis inverted
  32210. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32211. * @param compression defines the compression used (null by default)
  32212. * @returns the cube texture as an InternalTexture
  32213. */
  32214. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32215. /**
  32216. * Creates a new raw 3D texture
  32217. * @param data defines the data used to create the texture
  32218. * @param width defines the width of the texture
  32219. * @param height defines the height of the texture
  32220. * @param depth defines the depth of the texture
  32221. * @param format defines the format of the texture
  32222. * @param generateMipMaps defines if the engine must generate mip levels
  32223. * @param invertY defines if data must be stored with Y axis inverted
  32224. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32225. * @param compression defines the compressed used (can be null)
  32226. * @param textureType defines the compressed used (can be null)
  32227. * @returns a new raw 3D texture (stored in an InternalTexture)
  32228. */
  32229. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32230. /**
  32231. * Creates a new raw 2D array texture
  32232. * @param data defines the data used to create the texture
  32233. * @param width defines the width of the texture
  32234. * @param height defines the height of the texture
  32235. * @param depth defines the number of layers of the texture
  32236. * @param format defines the format of the texture
  32237. * @param generateMipMaps defines if the engine must generate mip levels
  32238. * @param invertY defines if data must be stored with Y axis inverted
  32239. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32240. * @param compression defines the compressed used (can be null)
  32241. * @param textureType defines the compressed used (can be null)
  32242. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32243. */
  32244. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32245. private _unpackFlipYCached;
  32246. /**
  32247. * In case you are sharing the context with other applications, it might
  32248. * be interested to not cache the unpack flip y state to ensure a consistent
  32249. * value would be set.
  32250. */
  32251. enableUnpackFlipYCached: boolean;
  32252. /** @hidden */
  32253. _unpackFlipY(value: boolean): void;
  32254. /** @hidden */
  32255. _getUnpackAlignement(): number;
  32256. /**
  32257. * Update the sampling mode of a given texture
  32258. * @param samplingMode defines the required sampling mode
  32259. * @param texture defines the texture to update
  32260. */
  32261. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32262. /** @hidden */
  32263. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32264. width: number;
  32265. height: number;
  32266. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32267. /** @hidden */
  32268. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32269. /** @hidden */
  32270. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32271. /** @hidden */
  32272. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32273. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32274. private _prepareWebGLTexture;
  32275. /** @hidden */
  32276. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32277. private _getDepthStencilBuffer;
  32278. /** @hidden */
  32279. _releaseFramebufferObjects(texture: InternalTexture): void;
  32280. /** @hidden */
  32281. _releaseTexture(texture: InternalTexture): void;
  32282. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32283. protected _setProgram(program: WebGLProgram): void;
  32284. protected _boundUniforms: {
  32285. [key: number]: WebGLUniformLocation;
  32286. };
  32287. /**
  32288. * Binds an effect to the webGL context
  32289. * @param effect defines the effect to bind
  32290. */
  32291. bindSamplers(effect: Effect): void;
  32292. private _activateCurrentTexture;
  32293. /** @hidden */
  32294. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32295. /** @hidden */
  32296. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32297. /**
  32298. * Unbind all textures from the webGL context
  32299. */
  32300. unbindAllTextures(): void;
  32301. /**
  32302. * Sets a texture to the according uniform.
  32303. * @param channel The texture channel
  32304. * @param uniform The uniform to set
  32305. * @param texture The texture to apply
  32306. */
  32307. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32308. private _bindSamplerUniformToChannel;
  32309. private _getTextureWrapMode;
  32310. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32311. /**
  32312. * Sets an array of texture to the webGL context
  32313. * @param channel defines the channel where the texture array must be set
  32314. * @param uniform defines the associated uniform location
  32315. * @param textures defines the array of textures to bind
  32316. */
  32317. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32318. /** @hidden */
  32319. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32320. private _setTextureParameterFloat;
  32321. private _setTextureParameterInteger;
  32322. /**
  32323. * Unbind all vertex attributes from the webGL context
  32324. */
  32325. unbindAllAttributes(): void;
  32326. /**
  32327. * 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
  32328. */
  32329. releaseEffects(): void;
  32330. /**
  32331. * Dispose and release all associated resources
  32332. */
  32333. dispose(): void;
  32334. /**
  32335. * Attach a new callback raised when context lost event is fired
  32336. * @param callback defines the callback to call
  32337. */
  32338. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32339. /**
  32340. * Attach a new callback raised when context restored event is fired
  32341. * @param callback defines the callback to call
  32342. */
  32343. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32344. /**
  32345. * Get the current error code of the webGL context
  32346. * @returns the error code
  32347. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32348. */
  32349. getError(): number;
  32350. private _canRenderToFloatFramebuffer;
  32351. private _canRenderToHalfFloatFramebuffer;
  32352. private _canRenderToFramebuffer;
  32353. /** @hidden */
  32354. _getWebGLTextureType(type: number): number;
  32355. /** @hidden */
  32356. _getInternalFormat(format: number): number;
  32357. /** @hidden */
  32358. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32359. /** @hidden */
  32360. _getRGBAMultiSampleBufferFormat(type: number): number;
  32361. /** @hidden */
  32362. _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;
  32363. /**
  32364. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32365. * @returns true if the engine can be created
  32366. * @ignorenaming
  32367. */
  32368. static isSupported(): boolean;
  32369. /**
  32370. * Find the next highest power of two.
  32371. * @param x Number to start search from.
  32372. * @return Next highest power of two.
  32373. */
  32374. static CeilingPOT(x: number): number;
  32375. /**
  32376. * Find the next lowest power of two.
  32377. * @param x Number to start search from.
  32378. * @return Next lowest power of two.
  32379. */
  32380. static FloorPOT(x: number): number;
  32381. /**
  32382. * Find the nearest power of two.
  32383. * @param x Number to start search from.
  32384. * @return Next nearest power of two.
  32385. */
  32386. static NearestPOT(x: number): number;
  32387. /**
  32388. * Get the closest exponent of two
  32389. * @param value defines the value to approximate
  32390. * @param max defines the maximum value to return
  32391. * @param mode defines how to define the closest value
  32392. * @returns closest exponent of two of the given value
  32393. */
  32394. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32395. /**
  32396. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32397. * @param func - the function to be called
  32398. * @param requester - the object that will request the next frame. Falls back to window.
  32399. * @returns frame number
  32400. */
  32401. static QueueNewFrame(func: () => void, requester?: any): number;
  32402. /**
  32403. * Gets host document
  32404. * @returns the host document object
  32405. */
  32406. getHostDocument(): Document;
  32407. }
  32408. }
  32409. declare module "babylonjs/Maths/sphericalPolynomial" {
  32410. import { Vector3 } from "babylonjs/Maths/math.vector";
  32411. import { Color3 } from "babylonjs/Maths/math.color";
  32412. /**
  32413. * Class representing spherical harmonics coefficients to the 3rd degree
  32414. */
  32415. export class SphericalHarmonics {
  32416. /**
  32417. * Defines whether or not the harmonics have been prescaled for rendering.
  32418. */
  32419. preScaled: boolean;
  32420. /**
  32421. * The l0,0 coefficients of the spherical harmonics
  32422. */
  32423. l00: Vector3;
  32424. /**
  32425. * The l1,-1 coefficients of the spherical harmonics
  32426. */
  32427. l1_1: Vector3;
  32428. /**
  32429. * The l1,0 coefficients of the spherical harmonics
  32430. */
  32431. l10: Vector3;
  32432. /**
  32433. * The l1,1 coefficients of the spherical harmonics
  32434. */
  32435. l11: Vector3;
  32436. /**
  32437. * The l2,-2 coefficients of the spherical harmonics
  32438. */
  32439. l2_2: Vector3;
  32440. /**
  32441. * The l2,-1 coefficients of the spherical harmonics
  32442. */
  32443. l2_1: Vector3;
  32444. /**
  32445. * The l2,0 coefficients of the spherical harmonics
  32446. */
  32447. l20: Vector3;
  32448. /**
  32449. * The l2,1 coefficients of the spherical harmonics
  32450. */
  32451. l21: Vector3;
  32452. /**
  32453. * The l2,2 coefficients of the spherical harmonics
  32454. */
  32455. l22: Vector3;
  32456. /**
  32457. * Adds a light to the spherical harmonics
  32458. * @param direction the direction of the light
  32459. * @param color the color of the light
  32460. * @param deltaSolidAngle the delta solid angle of the light
  32461. */
  32462. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32463. /**
  32464. * Scales the spherical harmonics by the given amount
  32465. * @param scale the amount to scale
  32466. */
  32467. scaleInPlace(scale: number): void;
  32468. /**
  32469. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32470. *
  32471. * ```
  32472. * E_lm = A_l * L_lm
  32473. * ```
  32474. *
  32475. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32476. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32477. * the scaling factors are given in equation 9.
  32478. */
  32479. convertIncidentRadianceToIrradiance(): void;
  32480. /**
  32481. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32482. *
  32483. * ```
  32484. * L = (1/pi) * E * rho
  32485. * ```
  32486. *
  32487. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32488. */
  32489. convertIrradianceToLambertianRadiance(): void;
  32490. /**
  32491. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32492. * required operations at run time.
  32493. *
  32494. * This is simply done by scaling back the SH with Ylm constants parameter.
  32495. * The trigonometric part being applied by the shader at run time.
  32496. */
  32497. preScaleForRendering(): void;
  32498. /**
  32499. * Constructs a spherical harmonics from an array.
  32500. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32501. * @returns the spherical harmonics
  32502. */
  32503. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32504. /**
  32505. * Gets the spherical harmonics from polynomial
  32506. * @param polynomial the spherical polynomial
  32507. * @returns the spherical harmonics
  32508. */
  32509. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32510. }
  32511. /**
  32512. * Class representing spherical polynomial coefficients to the 3rd degree
  32513. */
  32514. export class SphericalPolynomial {
  32515. private _harmonics;
  32516. /**
  32517. * The spherical harmonics used to create the polynomials.
  32518. */
  32519. readonly preScaledHarmonics: SphericalHarmonics;
  32520. /**
  32521. * The x coefficients of the spherical polynomial
  32522. */
  32523. x: Vector3;
  32524. /**
  32525. * The y coefficients of the spherical polynomial
  32526. */
  32527. y: Vector3;
  32528. /**
  32529. * The z coefficients of the spherical polynomial
  32530. */
  32531. z: Vector3;
  32532. /**
  32533. * The xx coefficients of the spherical polynomial
  32534. */
  32535. xx: Vector3;
  32536. /**
  32537. * The yy coefficients of the spherical polynomial
  32538. */
  32539. yy: Vector3;
  32540. /**
  32541. * The zz coefficients of the spherical polynomial
  32542. */
  32543. zz: Vector3;
  32544. /**
  32545. * The xy coefficients of the spherical polynomial
  32546. */
  32547. xy: Vector3;
  32548. /**
  32549. * The yz coefficients of the spherical polynomial
  32550. */
  32551. yz: Vector3;
  32552. /**
  32553. * The zx coefficients of the spherical polynomial
  32554. */
  32555. zx: Vector3;
  32556. /**
  32557. * Adds an ambient color to the spherical polynomial
  32558. * @param color the color to add
  32559. */
  32560. addAmbient(color: Color3): void;
  32561. /**
  32562. * Scales the spherical polynomial by the given amount
  32563. * @param scale the amount to scale
  32564. */
  32565. scaleInPlace(scale: number): void;
  32566. /**
  32567. * Gets the spherical polynomial from harmonics
  32568. * @param harmonics the spherical harmonics
  32569. * @returns the spherical polynomial
  32570. */
  32571. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32572. /**
  32573. * Constructs a spherical polynomial from an array.
  32574. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32575. * @returns the spherical polynomial
  32576. */
  32577. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32578. }
  32579. }
  32580. declare module "babylonjs/Materials/Textures/internalTexture" {
  32581. import { Observable } from "babylonjs/Misc/observable";
  32582. import { Nullable, int } from "babylonjs/types";
  32583. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32584. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32585. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32586. /**
  32587. * Defines the source of the internal texture
  32588. */
  32589. export enum InternalTextureSource {
  32590. /**
  32591. * The source of the texture data is unknown
  32592. */
  32593. Unknown = 0,
  32594. /**
  32595. * Texture data comes from an URL
  32596. */
  32597. Url = 1,
  32598. /**
  32599. * Texture data is only used for temporary storage
  32600. */
  32601. Temp = 2,
  32602. /**
  32603. * Texture data comes from raw data (ArrayBuffer)
  32604. */
  32605. Raw = 3,
  32606. /**
  32607. * Texture content is dynamic (video or dynamic texture)
  32608. */
  32609. Dynamic = 4,
  32610. /**
  32611. * Texture content is generated by rendering to it
  32612. */
  32613. RenderTarget = 5,
  32614. /**
  32615. * Texture content is part of a multi render target process
  32616. */
  32617. MultiRenderTarget = 6,
  32618. /**
  32619. * Texture data comes from a cube data file
  32620. */
  32621. Cube = 7,
  32622. /**
  32623. * Texture data comes from a raw cube data
  32624. */
  32625. CubeRaw = 8,
  32626. /**
  32627. * Texture data come from a prefiltered cube data file
  32628. */
  32629. CubePrefiltered = 9,
  32630. /**
  32631. * Texture content is raw 3D data
  32632. */
  32633. Raw3D = 10,
  32634. /**
  32635. * Texture content is raw 2D array data
  32636. */
  32637. Raw2DArray = 11,
  32638. /**
  32639. * Texture content is a depth texture
  32640. */
  32641. Depth = 12,
  32642. /**
  32643. * Texture data comes from a raw cube data encoded with RGBD
  32644. */
  32645. CubeRawRGBD = 13
  32646. }
  32647. /**
  32648. * Class used to store data associated with WebGL texture data for the engine
  32649. * This class should not be used directly
  32650. */
  32651. export class InternalTexture {
  32652. /** @hidden */
  32653. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32654. /**
  32655. * Defines if the texture is ready
  32656. */
  32657. isReady: boolean;
  32658. /**
  32659. * Defines if the texture is a cube texture
  32660. */
  32661. isCube: boolean;
  32662. /**
  32663. * Defines if the texture contains 3D data
  32664. */
  32665. is3D: boolean;
  32666. /**
  32667. * Defines if the texture contains 2D array data
  32668. */
  32669. is2DArray: boolean;
  32670. /**
  32671. * Defines if the texture contains multiview data
  32672. */
  32673. isMultiview: boolean;
  32674. /**
  32675. * Gets the URL used to load this texture
  32676. */
  32677. url: string;
  32678. /**
  32679. * Gets the sampling mode of the texture
  32680. */
  32681. samplingMode: number;
  32682. /**
  32683. * Gets a boolean indicating if the texture needs mipmaps generation
  32684. */
  32685. generateMipMaps: boolean;
  32686. /**
  32687. * Gets the number of samples used by the texture (WebGL2+ only)
  32688. */
  32689. samples: number;
  32690. /**
  32691. * Gets the type of the texture (int, float...)
  32692. */
  32693. type: number;
  32694. /**
  32695. * Gets the format of the texture (RGB, RGBA...)
  32696. */
  32697. format: number;
  32698. /**
  32699. * Observable called when the texture is loaded
  32700. */
  32701. onLoadedObservable: Observable<InternalTexture>;
  32702. /**
  32703. * Gets the width of the texture
  32704. */
  32705. width: number;
  32706. /**
  32707. * Gets the height of the texture
  32708. */
  32709. height: number;
  32710. /**
  32711. * Gets the depth of the texture
  32712. */
  32713. depth: number;
  32714. /**
  32715. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32716. */
  32717. baseWidth: number;
  32718. /**
  32719. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32720. */
  32721. baseHeight: number;
  32722. /**
  32723. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32724. */
  32725. baseDepth: number;
  32726. /**
  32727. * Gets a boolean indicating if the texture is inverted on Y axis
  32728. */
  32729. invertY: boolean;
  32730. /** @hidden */
  32731. _invertVScale: boolean;
  32732. /** @hidden */
  32733. _associatedChannel: number;
  32734. /** @hidden */
  32735. _source: InternalTextureSource;
  32736. /** @hidden */
  32737. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32738. /** @hidden */
  32739. _bufferView: Nullable<ArrayBufferView>;
  32740. /** @hidden */
  32741. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32742. /** @hidden */
  32743. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32744. /** @hidden */
  32745. _size: number;
  32746. /** @hidden */
  32747. _extension: string;
  32748. /** @hidden */
  32749. _files: Nullable<string[]>;
  32750. /** @hidden */
  32751. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32752. /** @hidden */
  32753. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32754. /** @hidden */
  32755. _framebuffer: Nullable<WebGLFramebuffer>;
  32756. /** @hidden */
  32757. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32758. /** @hidden */
  32759. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32760. /** @hidden */
  32761. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32762. /** @hidden */
  32763. _attachments: Nullable<number[]>;
  32764. /** @hidden */
  32765. _cachedCoordinatesMode: Nullable<number>;
  32766. /** @hidden */
  32767. _cachedWrapU: Nullable<number>;
  32768. /** @hidden */
  32769. _cachedWrapV: Nullable<number>;
  32770. /** @hidden */
  32771. _cachedWrapR: Nullable<number>;
  32772. /** @hidden */
  32773. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32774. /** @hidden */
  32775. _isDisabled: boolean;
  32776. /** @hidden */
  32777. _compression: Nullable<string>;
  32778. /** @hidden */
  32779. _generateStencilBuffer: boolean;
  32780. /** @hidden */
  32781. _generateDepthBuffer: boolean;
  32782. /** @hidden */
  32783. _comparisonFunction: number;
  32784. /** @hidden */
  32785. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32786. /** @hidden */
  32787. _lodGenerationScale: number;
  32788. /** @hidden */
  32789. _lodGenerationOffset: number;
  32790. /** @hidden */
  32791. _colorTextureArray: Nullable<WebGLTexture>;
  32792. /** @hidden */
  32793. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32794. /** @hidden */
  32795. _lodTextureHigh: Nullable<BaseTexture>;
  32796. /** @hidden */
  32797. _lodTextureMid: Nullable<BaseTexture>;
  32798. /** @hidden */
  32799. _lodTextureLow: Nullable<BaseTexture>;
  32800. /** @hidden */
  32801. _isRGBD: boolean;
  32802. /** @hidden */
  32803. _linearSpecularLOD: boolean;
  32804. /** @hidden */
  32805. _irradianceTexture: Nullable<BaseTexture>;
  32806. /** @hidden */
  32807. _webGLTexture: Nullable<WebGLTexture>;
  32808. /** @hidden */
  32809. _references: number;
  32810. private _engine;
  32811. /**
  32812. * Gets the Engine the texture belongs to.
  32813. * @returns The babylon engine
  32814. */
  32815. getEngine(): ThinEngine;
  32816. /**
  32817. * Gets the data source type of the texture
  32818. */
  32819. readonly source: InternalTextureSource;
  32820. /**
  32821. * Creates a new InternalTexture
  32822. * @param engine defines the engine to use
  32823. * @param source defines the type of data that will be used
  32824. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32825. */
  32826. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32827. /**
  32828. * Increments the number of references (ie. the number of Texture that point to it)
  32829. */
  32830. incrementReferences(): void;
  32831. /**
  32832. * Change the size of the texture (not the size of the content)
  32833. * @param width defines the new width
  32834. * @param height defines the new height
  32835. * @param depth defines the new depth (1 by default)
  32836. */
  32837. updateSize(width: int, height: int, depth?: int): void;
  32838. /** @hidden */
  32839. _rebuild(): void;
  32840. /** @hidden */
  32841. _swapAndDie(target: InternalTexture): void;
  32842. /**
  32843. * Dispose the current allocated resources
  32844. */
  32845. dispose(): void;
  32846. }
  32847. }
  32848. declare module "babylonjs/Audio/analyser" {
  32849. import { Scene } from "babylonjs/scene";
  32850. /**
  32851. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32852. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32853. */
  32854. export class Analyser {
  32855. /**
  32856. * Gets or sets the smoothing
  32857. * @ignorenaming
  32858. */
  32859. SMOOTHING: number;
  32860. /**
  32861. * Gets or sets the FFT table size
  32862. * @ignorenaming
  32863. */
  32864. FFT_SIZE: number;
  32865. /**
  32866. * Gets or sets the bar graph amplitude
  32867. * @ignorenaming
  32868. */
  32869. BARGRAPHAMPLITUDE: number;
  32870. /**
  32871. * Gets or sets the position of the debug canvas
  32872. * @ignorenaming
  32873. */
  32874. DEBUGCANVASPOS: {
  32875. x: number;
  32876. y: number;
  32877. };
  32878. /**
  32879. * Gets or sets the debug canvas size
  32880. * @ignorenaming
  32881. */
  32882. DEBUGCANVASSIZE: {
  32883. width: number;
  32884. height: number;
  32885. };
  32886. private _byteFreqs;
  32887. private _byteTime;
  32888. private _floatFreqs;
  32889. private _webAudioAnalyser;
  32890. private _debugCanvas;
  32891. private _debugCanvasContext;
  32892. private _scene;
  32893. private _registerFunc;
  32894. private _audioEngine;
  32895. /**
  32896. * Creates a new analyser
  32897. * @param scene defines hosting scene
  32898. */
  32899. constructor(scene: Scene);
  32900. /**
  32901. * Get the number of data values you will have to play with for the visualization
  32902. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32903. * @returns a number
  32904. */
  32905. getFrequencyBinCount(): number;
  32906. /**
  32907. * Gets the current frequency data as a byte array
  32908. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32909. * @returns a Uint8Array
  32910. */
  32911. getByteFrequencyData(): Uint8Array;
  32912. /**
  32913. * Gets the current waveform as a byte array
  32914. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32915. * @returns a Uint8Array
  32916. */
  32917. getByteTimeDomainData(): Uint8Array;
  32918. /**
  32919. * Gets the current frequency data as a float array
  32920. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32921. * @returns a Float32Array
  32922. */
  32923. getFloatFrequencyData(): Float32Array;
  32924. /**
  32925. * Renders the debug canvas
  32926. */
  32927. drawDebugCanvas(): void;
  32928. /**
  32929. * Stops rendering the debug canvas and removes it
  32930. */
  32931. stopDebugCanvas(): void;
  32932. /**
  32933. * Connects two audio nodes
  32934. * @param inputAudioNode defines first node to connect
  32935. * @param outputAudioNode defines second node to connect
  32936. */
  32937. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32938. /**
  32939. * Releases all associated resources
  32940. */
  32941. dispose(): void;
  32942. }
  32943. }
  32944. declare module "babylonjs/Audio/audioEngine" {
  32945. import { IDisposable } from "babylonjs/scene";
  32946. import { Analyser } from "babylonjs/Audio/analyser";
  32947. import { Nullable } from "babylonjs/types";
  32948. import { Observable } from "babylonjs/Misc/observable";
  32949. /**
  32950. * This represents an audio engine and it is responsible
  32951. * to play, synchronize and analyse sounds throughout the application.
  32952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32953. */
  32954. export interface IAudioEngine extends IDisposable {
  32955. /**
  32956. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32957. */
  32958. readonly canUseWebAudio: boolean;
  32959. /**
  32960. * Gets the current AudioContext if available.
  32961. */
  32962. readonly audioContext: Nullable<AudioContext>;
  32963. /**
  32964. * The master gain node defines the global audio volume of your audio engine.
  32965. */
  32966. readonly masterGain: GainNode;
  32967. /**
  32968. * Gets whether or not mp3 are supported by your browser.
  32969. */
  32970. readonly isMP3supported: boolean;
  32971. /**
  32972. * Gets whether or not ogg are supported by your browser.
  32973. */
  32974. readonly isOGGsupported: boolean;
  32975. /**
  32976. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32977. * @ignoreNaming
  32978. */
  32979. WarnedWebAudioUnsupported: boolean;
  32980. /**
  32981. * Defines if the audio engine relies on a custom unlocked button.
  32982. * In this case, the embedded button will not be displayed.
  32983. */
  32984. useCustomUnlockedButton: boolean;
  32985. /**
  32986. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32987. */
  32988. readonly unlocked: boolean;
  32989. /**
  32990. * Event raised when audio has been unlocked on the browser.
  32991. */
  32992. onAudioUnlockedObservable: Observable<AudioEngine>;
  32993. /**
  32994. * Event raised when audio has been locked on the browser.
  32995. */
  32996. onAudioLockedObservable: Observable<AudioEngine>;
  32997. /**
  32998. * Flags the audio engine in Locked state.
  32999. * This happens due to new browser policies preventing audio to autoplay.
  33000. */
  33001. lock(): void;
  33002. /**
  33003. * Unlocks the audio engine once a user action has been done on the dom.
  33004. * This is helpful to resume play once browser policies have been satisfied.
  33005. */
  33006. unlock(): void;
  33007. }
  33008. /**
  33009. * This represents the default audio engine used in babylon.
  33010. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33012. */
  33013. export class AudioEngine implements IAudioEngine {
  33014. private _audioContext;
  33015. private _audioContextInitialized;
  33016. private _muteButton;
  33017. private _hostElement;
  33018. /**
  33019. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33020. */
  33021. canUseWebAudio: boolean;
  33022. /**
  33023. * The master gain node defines the global audio volume of your audio engine.
  33024. */
  33025. masterGain: GainNode;
  33026. /**
  33027. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33028. * @ignoreNaming
  33029. */
  33030. WarnedWebAudioUnsupported: boolean;
  33031. /**
  33032. * Gets whether or not mp3 are supported by your browser.
  33033. */
  33034. isMP3supported: boolean;
  33035. /**
  33036. * Gets whether or not ogg are supported by your browser.
  33037. */
  33038. isOGGsupported: boolean;
  33039. /**
  33040. * Gets whether audio has been unlocked on the device.
  33041. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33042. * a user interaction has happened.
  33043. */
  33044. unlocked: boolean;
  33045. /**
  33046. * Defines if the audio engine relies on a custom unlocked button.
  33047. * In this case, the embedded button will not be displayed.
  33048. */
  33049. useCustomUnlockedButton: boolean;
  33050. /**
  33051. * Event raised when audio has been unlocked on the browser.
  33052. */
  33053. onAudioUnlockedObservable: Observable<AudioEngine>;
  33054. /**
  33055. * Event raised when audio has been locked on the browser.
  33056. */
  33057. onAudioLockedObservable: Observable<AudioEngine>;
  33058. /**
  33059. * Gets the current AudioContext if available.
  33060. */
  33061. readonly audioContext: Nullable<AudioContext>;
  33062. private _connectedAnalyser;
  33063. /**
  33064. * Instantiates a new audio engine.
  33065. *
  33066. * There should be only one per page as some browsers restrict the number
  33067. * of audio contexts you can create.
  33068. * @param hostElement defines the host element where to display the mute icon if necessary
  33069. */
  33070. constructor(hostElement?: Nullable<HTMLElement>);
  33071. /**
  33072. * Flags the audio engine in Locked state.
  33073. * This happens due to new browser policies preventing audio to autoplay.
  33074. */
  33075. lock(): void;
  33076. /**
  33077. * Unlocks the audio engine once a user action has been done on the dom.
  33078. * This is helpful to resume play once browser policies have been satisfied.
  33079. */
  33080. unlock(): void;
  33081. private _resumeAudioContext;
  33082. private _initializeAudioContext;
  33083. private _tryToRun;
  33084. private _triggerRunningState;
  33085. private _triggerSuspendedState;
  33086. private _displayMuteButton;
  33087. private _moveButtonToTopLeft;
  33088. private _onResize;
  33089. private _hideMuteButton;
  33090. /**
  33091. * Destroy and release the resources associated with the audio ccontext.
  33092. */
  33093. dispose(): void;
  33094. /**
  33095. * Gets the global volume sets on the master gain.
  33096. * @returns the global volume if set or -1 otherwise
  33097. */
  33098. getGlobalVolume(): number;
  33099. /**
  33100. * Sets the global volume of your experience (sets on the master gain).
  33101. * @param newVolume Defines the new global volume of the application
  33102. */
  33103. setGlobalVolume(newVolume: number): void;
  33104. /**
  33105. * Connect the audio engine to an audio analyser allowing some amazing
  33106. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33108. * @param analyser The analyser to connect to the engine
  33109. */
  33110. connectToAnalyser(analyser: Analyser): void;
  33111. }
  33112. }
  33113. declare module "babylonjs/Loading/loadingScreen" {
  33114. /**
  33115. * Interface used to present a loading screen while loading a scene
  33116. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33117. */
  33118. export interface ILoadingScreen {
  33119. /**
  33120. * Function called to display the loading screen
  33121. */
  33122. displayLoadingUI: () => void;
  33123. /**
  33124. * Function called to hide the loading screen
  33125. */
  33126. hideLoadingUI: () => void;
  33127. /**
  33128. * Gets or sets the color to use for the background
  33129. */
  33130. loadingUIBackgroundColor: string;
  33131. /**
  33132. * Gets or sets the text to display while loading
  33133. */
  33134. loadingUIText: string;
  33135. }
  33136. /**
  33137. * Class used for the default loading screen
  33138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33139. */
  33140. export class DefaultLoadingScreen implements ILoadingScreen {
  33141. private _renderingCanvas;
  33142. private _loadingText;
  33143. private _loadingDivBackgroundColor;
  33144. private _loadingDiv;
  33145. private _loadingTextDiv;
  33146. /** Gets or sets the logo url to use for the default loading screen */
  33147. static DefaultLogoUrl: string;
  33148. /** Gets or sets the spinner url to use for the default loading screen */
  33149. static DefaultSpinnerUrl: string;
  33150. /**
  33151. * Creates a new default loading screen
  33152. * @param _renderingCanvas defines the canvas used to render the scene
  33153. * @param _loadingText defines the default text to display
  33154. * @param _loadingDivBackgroundColor defines the default background color
  33155. */
  33156. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33157. /**
  33158. * Function called to display the loading screen
  33159. */
  33160. displayLoadingUI(): void;
  33161. /**
  33162. * Function called to hide the loading screen
  33163. */
  33164. hideLoadingUI(): void;
  33165. /**
  33166. * Gets or sets the text to display while loading
  33167. */
  33168. loadingUIText: string;
  33169. /**
  33170. * Gets or sets the color to use for the background
  33171. */
  33172. loadingUIBackgroundColor: string;
  33173. private _resizeLoadingUI;
  33174. }
  33175. }
  33176. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33177. /**
  33178. * Interface for any object that can request an animation frame
  33179. */
  33180. export interface ICustomAnimationFrameRequester {
  33181. /**
  33182. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33183. */
  33184. renderFunction?: Function;
  33185. /**
  33186. * Called to request the next frame to render to
  33187. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33188. */
  33189. requestAnimationFrame: Function;
  33190. /**
  33191. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33192. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33193. */
  33194. requestID?: number;
  33195. }
  33196. }
  33197. declare module "babylonjs/Misc/performanceMonitor" {
  33198. /**
  33199. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33200. */
  33201. export class PerformanceMonitor {
  33202. private _enabled;
  33203. private _rollingFrameTime;
  33204. private _lastFrameTimeMs;
  33205. /**
  33206. * constructor
  33207. * @param frameSampleSize The number of samples required to saturate the sliding window
  33208. */
  33209. constructor(frameSampleSize?: number);
  33210. /**
  33211. * Samples current frame
  33212. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33213. */
  33214. sampleFrame(timeMs?: number): void;
  33215. /**
  33216. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33217. */
  33218. readonly averageFrameTime: number;
  33219. /**
  33220. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33221. */
  33222. readonly averageFrameTimeVariance: number;
  33223. /**
  33224. * Returns the frame time of the most recent frame
  33225. */
  33226. readonly instantaneousFrameTime: number;
  33227. /**
  33228. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33229. */
  33230. readonly averageFPS: number;
  33231. /**
  33232. * Returns the average framerate in frames per second using the most recent frame time
  33233. */
  33234. readonly instantaneousFPS: number;
  33235. /**
  33236. * Returns true if enough samples have been taken to completely fill the sliding window
  33237. */
  33238. readonly isSaturated: boolean;
  33239. /**
  33240. * Enables contributions to the sliding window sample set
  33241. */
  33242. enable(): void;
  33243. /**
  33244. * Disables contributions to the sliding window sample set
  33245. * Samples will not be interpolated over the disabled period
  33246. */
  33247. disable(): void;
  33248. /**
  33249. * Returns true if sampling is enabled
  33250. */
  33251. readonly isEnabled: boolean;
  33252. /**
  33253. * Resets performance monitor
  33254. */
  33255. reset(): void;
  33256. }
  33257. /**
  33258. * RollingAverage
  33259. *
  33260. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33261. */
  33262. export class RollingAverage {
  33263. /**
  33264. * Current average
  33265. */
  33266. average: number;
  33267. /**
  33268. * Current variance
  33269. */
  33270. variance: number;
  33271. protected _samples: Array<number>;
  33272. protected _sampleCount: number;
  33273. protected _pos: number;
  33274. protected _m2: number;
  33275. /**
  33276. * constructor
  33277. * @param length The number of samples required to saturate the sliding window
  33278. */
  33279. constructor(length: number);
  33280. /**
  33281. * Adds a sample to the sample set
  33282. * @param v The sample value
  33283. */
  33284. add(v: number): void;
  33285. /**
  33286. * Returns previously added values or null if outside of history or outside the sliding window domain
  33287. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33288. * @return Value previously recorded with add() or null if outside of range
  33289. */
  33290. history(i: number): number;
  33291. /**
  33292. * Returns true if enough samples have been taken to completely fill the sliding window
  33293. * @return true if sample-set saturated
  33294. */
  33295. isSaturated(): boolean;
  33296. /**
  33297. * Resets the rolling average (equivalent to 0 samples taken so far)
  33298. */
  33299. reset(): void;
  33300. /**
  33301. * Wraps a value around the sample range boundaries
  33302. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33303. * @return Wrapped position in sample range
  33304. */
  33305. protected _wrapPosition(i: number): number;
  33306. }
  33307. }
  33308. declare module "babylonjs/Misc/perfCounter" {
  33309. /**
  33310. * This class is used to track a performance counter which is number based.
  33311. * The user has access to many properties which give statistics of different nature.
  33312. *
  33313. * The implementer can track two kinds of Performance Counter: time and count.
  33314. * 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.
  33315. * 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.
  33316. */
  33317. export class PerfCounter {
  33318. /**
  33319. * Gets or sets a global boolean to turn on and off all the counters
  33320. */
  33321. static Enabled: boolean;
  33322. /**
  33323. * Returns the smallest value ever
  33324. */
  33325. readonly min: number;
  33326. /**
  33327. * Returns the biggest value ever
  33328. */
  33329. readonly max: number;
  33330. /**
  33331. * Returns the average value since the performance counter is running
  33332. */
  33333. readonly average: number;
  33334. /**
  33335. * Returns the average value of the last second the counter was monitored
  33336. */
  33337. readonly lastSecAverage: number;
  33338. /**
  33339. * Returns the current value
  33340. */
  33341. readonly current: number;
  33342. /**
  33343. * Gets the accumulated total
  33344. */
  33345. readonly total: number;
  33346. /**
  33347. * Gets the total value count
  33348. */
  33349. readonly count: number;
  33350. /**
  33351. * Creates a new counter
  33352. */
  33353. constructor();
  33354. /**
  33355. * Call this method to start monitoring a new frame.
  33356. * 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.
  33357. */
  33358. fetchNewFrame(): void;
  33359. /**
  33360. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33361. * @param newCount the count value to add to the monitored count
  33362. * @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.
  33363. */
  33364. addCount(newCount: number, fetchResult: boolean): void;
  33365. /**
  33366. * Start monitoring this performance counter
  33367. */
  33368. beginMonitoring(): void;
  33369. /**
  33370. * Compute the time lapsed since the previous beginMonitoring() call.
  33371. * @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
  33372. */
  33373. endMonitoring(newFrame?: boolean): void;
  33374. private _fetchResult;
  33375. private _startMonitoringTime;
  33376. private _min;
  33377. private _max;
  33378. private _average;
  33379. private _current;
  33380. private _totalValueCount;
  33381. private _totalAccumulated;
  33382. private _lastSecAverage;
  33383. private _lastSecAccumulated;
  33384. private _lastSecTime;
  33385. private _lastSecValueCount;
  33386. }
  33387. }
  33388. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33389. module "babylonjs/Engines/thinEngine" {
  33390. interface ThinEngine {
  33391. /**
  33392. * Sets alpha constants used by some alpha blending modes
  33393. * @param r defines the red component
  33394. * @param g defines the green component
  33395. * @param b defines the blue component
  33396. * @param a defines the alpha component
  33397. */
  33398. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33399. /**
  33400. * Sets the current alpha mode
  33401. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33402. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33403. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33404. */
  33405. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33406. /**
  33407. * Gets the current alpha mode
  33408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33409. * @returns the current alpha mode
  33410. */
  33411. getAlphaMode(): number;
  33412. /**
  33413. * Sets the current alpha equation
  33414. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33415. */
  33416. setAlphaEquation(equation: number): void;
  33417. /**
  33418. * Gets the current alpha equation.
  33419. * @returns the current alpha equation
  33420. */
  33421. getAlphaEquation(): number;
  33422. }
  33423. }
  33424. }
  33425. declare module "babylonjs/Engines/engine" {
  33426. import { Observable } from "babylonjs/Misc/observable";
  33427. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33428. import { Scene } from "babylonjs/scene";
  33429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33430. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33431. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33432. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33433. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33435. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33436. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33437. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33438. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33439. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33440. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33441. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33442. import "babylonjs/Engines/Extensions/engine.alpha";
  33443. import { Material } from "babylonjs/Materials/material";
  33444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33445. /**
  33446. * Defines the interface used by display changed events
  33447. */
  33448. export interface IDisplayChangedEventArgs {
  33449. /** Gets the vrDisplay object (if any) */
  33450. vrDisplay: Nullable<any>;
  33451. /** Gets a boolean indicating if webVR is supported */
  33452. vrSupported: boolean;
  33453. }
  33454. /**
  33455. * Defines the interface used by objects containing a viewport (like a camera)
  33456. */
  33457. interface IViewportOwnerLike {
  33458. /**
  33459. * Gets or sets the viewport
  33460. */
  33461. viewport: IViewportLike;
  33462. }
  33463. /**
  33464. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33465. */
  33466. export class Engine extends ThinEngine {
  33467. /** Defines that alpha blending is disabled */
  33468. static readonly ALPHA_DISABLE: number;
  33469. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33470. static readonly ALPHA_ADD: number;
  33471. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33472. static readonly ALPHA_COMBINE: number;
  33473. /** Defines that alpha blending to DEST - SRC * DEST */
  33474. static readonly ALPHA_SUBTRACT: number;
  33475. /** Defines that alpha blending to SRC * DEST */
  33476. static readonly ALPHA_MULTIPLY: number;
  33477. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33478. static readonly ALPHA_MAXIMIZED: number;
  33479. /** Defines that alpha blending to SRC + DEST */
  33480. static readonly ALPHA_ONEONE: number;
  33481. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33482. static readonly ALPHA_PREMULTIPLIED: number;
  33483. /**
  33484. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33485. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33486. */
  33487. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33488. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33489. static readonly ALPHA_INTERPOLATE: number;
  33490. /**
  33491. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33492. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33493. */
  33494. static readonly ALPHA_SCREENMODE: number;
  33495. /** Defines that the ressource is not delayed*/
  33496. static readonly DELAYLOADSTATE_NONE: number;
  33497. /** Defines that the ressource was successfully delay loaded */
  33498. static readonly DELAYLOADSTATE_LOADED: number;
  33499. /** Defines that the ressource is currently delay loading */
  33500. static readonly DELAYLOADSTATE_LOADING: number;
  33501. /** Defines that the ressource is delayed and has not started loading */
  33502. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33503. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33504. static readonly NEVER: number;
  33505. /** 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 */
  33506. static readonly ALWAYS: number;
  33507. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33508. static readonly LESS: number;
  33509. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33510. static readonly EQUAL: number;
  33511. /** 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 */
  33512. static readonly LEQUAL: number;
  33513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33514. static readonly GREATER: number;
  33515. /** 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 */
  33516. static readonly GEQUAL: number;
  33517. /** 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 */
  33518. static readonly NOTEQUAL: number;
  33519. /** Passed to stencilOperation to specify that stencil value must be kept */
  33520. static readonly KEEP: number;
  33521. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33522. static readonly REPLACE: number;
  33523. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33524. static readonly INCR: number;
  33525. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33526. static readonly DECR: number;
  33527. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33528. static readonly INVERT: number;
  33529. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33530. static readonly INCR_WRAP: number;
  33531. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33532. static readonly DECR_WRAP: number;
  33533. /** Texture is not repeating outside of 0..1 UVs */
  33534. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33535. /** Texture is repeating outside of 0..1 UVs */
  33536. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33537. /** Texture is repeating and mirrored */
  33538. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33539. /** ALPHA */
  33540. static readonly TEXTUREFORMAT_ALPHA: number;
  33541. /** LUMINANCE */
  33542. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33543. /** LUMINANCE_ALPHA */
  33544. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33545. /** RGB */
  33546. static readonly TEXTUREFORMAT_RGB: number;
  33547. /** RGBA */
  33548. static readonly TEXTUREFORMAT_RGBA: number;
  33549. /** RED */
  33550. static readonly TEXTUREFORMAT_RED: number;
  33551. /** RED (2nd reference) */
  33552. static readonly TEXTUREFORMAT_R: number;
  33553. /** RG */
  33554. static readonly TEXTUREFORMAT_RG: number;
  33555. /** RED_INTEGER */
  33556. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33557. /** RED_INTEGER (2nd reference) */
  33558. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33559. /** RG_INTEGER */
  33560. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33561. /** RGB_INTEGER */
  33562. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33563. /** RGBA_INTEGER */
  33564. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33565. /** UNSIGNED_BYTE */
  33566. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33567. /** UNSIGNED_BYTE (2nd reference) */
  33568. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33569. /** FLOAT */
  33570. static readonly TEXTURETYPE_FLOAT: number;
  33571. /** HALF_FLOAT */
  33572. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33573. /** BYTE */
  33574. static readonly TEXTURETYPE_BYTE: number;
  33575. /** SHORT */
  33576. static readonly TEXTURETYPE_SHORT: number;
  33577. /** UNSIGNED_SHORT */
  33578. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33579. /** INT */
  33580. static readonly TEXTURETYPE_INT: number;
  33581. /** UNSIGNED_INT */
  33582. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33583. /** UNSIGNED_SHORT_4_4_4_4 */
  33584. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33585. /** UNSIGNED_SHORT_5_5_5_1 */
  33586. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33587. /** UNSIGNED_SHORT_5_6_5 */
  33588. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33589. /** UNSIGNED_INT_2_10_10_10_REV */
  33590. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33591. /** UNSIGNED_INT_24_8 */
  33592. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33593. /** UNSIGNED_INT_10F_11F_11F_REV */
  33594. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33595. /** UNSIGNED_INT_5_9_9_9_REV */
  33596. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33597. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33598. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33599. /** nearest is mag = nearest and min = nearest and mip = linear */
  33600. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33601. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33602. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33603. /** Trilinear is mag = linear and min = linear and mip = linear */
  33604. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33605. /** nearest is mag = nearest and min = nearest and mip = linear */
  33606. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33607. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33608. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33609. /** Trilinear is mag = linear and min = linear and mip = linear */
  33610. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33611. /** mag = nearest and min = nearest and mip = nearest */
  33612. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33613. /** mag = nearest and min = linear and mip = nearest */
  33614. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33615. /** mag = nearest and min = linear and mip = linear */
  33616. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33617. /** mag = nearest and min = linear and mip = none */
  33618. static readonly TEXTURE_NEAREST_LINEAR: number;
  33619. /** mag = nearest and min = nearest and mip = none */
  33620. static readonly TEXTURE_NEAREST_NEAREST: number;
  33621. /** mag = linear and min = nearest and mip = nearest */
  33622. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33623. /** mag = linear and min = nearest and mip = linear */
  33624. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33625. /** mag = linear and min = linear and mip = none */
  33626. static readonly TEXTURE_LINEAR_LINEAR: number;
  33627. /** mag = linear and min = nearest and mip = none */
  33628. static readonly TEXTURE_LINEAR_NEAREST: number;
  33629. /** Explicit coordinates mode */
  33630. static readonly TEXTURE_EXPLICIT_MODE: number;
  33631. /** Spherical coordinates mode */
  33632. static readonly TEXTURE_SPHERICAL_MODE: number;
  33633. /** Planar coordinates mode */
  33634. static readonly TEXTURE_PLANAR_MODE: number;
  33635. /** Cubic coordinates mode */
  33636. static readonly TEXTURE_CUBIC_MODE: number;
  33637. /** Projection coordinates mode */
  33638. static readonly TEXTURE_PROJECTION_MODE: number;
  33639. /** Skybox coordinates mode */
  33640. static readonly TEXTURE_SKYBOX_MODE: number;
  33641. /** Inverse Cubic coordinates mode */
  33642. static readonly TEXTURE_INVCUBIC_MODE: number;
  33643. /** Equirectangular coordinates mode */
  33644. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33645. /** Equirectangular Fixed coordinates mode */
  33646. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33647. /** Equirectangular Fixed Mirrored coordinates mode */
  33648. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33649. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33650. static readonly SCALEMODE_FLOOR: number;
  33651. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33652. static readonly SCALEMODE_NEAREST: number;
  33653. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33654. static readonly SCALEMODE_CEILING: number;
  33655. /**
  33656. * Returns the current npm package of the sdk
  33657. */
  33658. static readonly NpmPackage: string;
  33659. /**
  33660. * Returns the current version of the framework
  33661. */
  33662. static readonly Version: string;
  33663. /** Gets the list of created engines */
  33664. static readonly Instances: Engine[];
  33665. /**
  33666. * Gets the latest created engine
  33667. */
  33668. static readonly LastCreatedEngine: Nullable<Engine>;
  33669. /**
  33670. * Gets the latest created scene
  33671. */
  33672. static readonly LastCreatedScene: Nullable<Scene>;
  33673. /**
  33674. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33675. * @param flag defines which part of the materials must be marked as dirty
  33676. * @param predicate defines a predicate used to filter which materials should be affected
  33677. */
  33678. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33679. /**
  33680. * Method called to create the default loading screen.
  33681. * This can be overriden in your own app.
  33682. * @param canvas The rendering canvas element
  33683. * @returns The loading screen
  33684. */
  33685. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33686. /**
  33687. * Method called to create the default rescale post process on each engine.
  33688. */
  33689. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33690. /**
  33691. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33692. **/
  33693. enableOfflineSupport: boolean;
  33694. /**
  33695. * 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)
  33696. **/
  33697. disableManifestCheck: boolean;
  33698. /**
  33699. * Gets the list of created scenes
  33700. */
  33701. scenes: Scene[];
  33702. /**
  33703. * Event raised when a new scene is created
  33704. */
  33705. onNewSceneAddedObservable: Observable<Scene>;
  33706. /**
  33707. * Gets the list of created postprocesses
  33708. */
  33709. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  33710. /**
  33711. * Gets a boolean indicating if the pointer is currently locked
  33712. */
  33713. isPointerLock: boolean;
  33714. /**
  33715. * Observable event triggered each time the rendering canvas is resized
  33716. */
  33717. onResizeObservable: Observable<Engine>;
  33718. /**
  33719. * Observable event triggered each time the canvas loses focus
  33720. */
  33721. onCanvasBlurObservable: Observable<Engine>;
  33722. /**
  33723. * Observable event triggered each time the canvas gains focus
  33724. */
  33725. onCanvasFocusObservable: Observable<Engine>;
  33726. /**
  33727. * Observable event triggered each time the canvas receives pointerout event
  33728. */
  33729. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33730. /**
  33731. * Observable raised when the engine begins a new frame
  33732. */
  33733. onBeginFrameObservable: Observable<Engine>;
  33734. /**
  33735. * If set, will be used to request the next animation frame for the render loop
  33736. */
  33737. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33738. /**
  33739. * Observable raised when the engine ends the current frame
  33740. */
  33741. onEndFrameObservable: Observable<Engine>;
  33742. /**
  33743. * Observable raised when the engine is about to compile a shader
  33744. */
  33745. onBeforeShaderCompilationObservable: Observable<Engine>;
  33746. /**
  33747. * Observable raised when the engine has jsut compiled a shader
  33748. */
  33749. onAfterShaderCompilationObservable: Observable<Engine>;
  33750. /**
  33751. * Gets the audio engine
  33752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33753. * @ignorenaming
  33754. */
  33755. static audioEngine: IAudioEngine;
  33756. /**
  33757. * Default AudioEngine factory responsible of creating the Audio Engine.
  33758. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33759. */
  33760. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33761. /**
  33762. * Default offline support factory responsible of creating a tool used to store data locally.
  33763. * By default, this will create a Database object if the workload has been embedded.
  33764. */
  33765. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33766. private _loadingScreen;
  33767. private _pointerLockRequested;
  33768. private _dummyFramebuffer;
  33769. private _rescalePostProcess;
  33770. private _deterministicLockstep;
  33771. private _lockstepMaxSteps;
  33772. private _timeStep;
  33773. protected readonly _supportsHardwareTextureRescaling: boolean;
  33774. private _fps;
  33775. private _deltaTime;
  33776. /** @hidden */
  33777. _drawCalls: PerfCounter;
  33778. /**
  33779. * Turn this value on if you want to pause FPS computation when in background
  33780. */
  33781. disablePerformanceMonitorInBackground: boolean;
  33782. private _performanceMonitor;
  33783. /**
  33784. * Gets the performance monitor attached to this engine
  33785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33786. */
  33787. readonly performanceMonitor: PerformanceMonitor;
  33788. private _onFocus;
  33789. private _onBlur;
  33790. private _onCanvasPointerOut;
  33791. private _onCanvasBlur;
  33792. private _onCanvasFocus;
  33793. private _onFullscreenChange;
  33794. private _onPointerLockChange;
  33795. /**
  33796. * Gets the HTML element used to attach event listeners
  33797. * @returns a HTML element
  33798. */
  33799. getInputElement(): Nullable<HTMLElement>;
  33800. /**
  33801. * Creates a new engine
  33802. * @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
  33803. * @param antialias defines enable antialiasing (default: false)
  33804. * @param options defines further options to be sent to the getContext() function
  33805. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33806. */
  33807. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33808. /**
  33809. * Gets current aspect ratio
  33810. * @param viewportOwner defines the camera to use to get the aspect ratio
  33811. * @param useScreen defines if screen size must be used (or the current render target if any)
  33812. * @returns a number defining the aspect ratio
  33813. */
  33814. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33815. /**
  33816. * Gets current screen aspect ratio
  33817. * @returns a number defining the aspect ratio
  33818. */
  33819. getScreenAspectRatio(): number;
  33820. /**
  33821. * Gets the client rect of the HTML canvas attached with the current webGL context
  33822. * @returns a client rectanglee
  33823. */
  33824. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33825. /**
  33826. * Gets the client rect of the HTML element used for events
  33827. * @returns a client rectanglee
  33828. */
  33829. getInputElementClientRect(): Nullable<ClientRect>;
  33830. /**
  33831. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33832. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33833. * @returns true if engine is in deterministic lock step mode
  33834. */
  33835. isDeterministicLockStep(): boolean;
  33836. /**
  33837. * Gets the max steps when engine is running in deterministic lock step
  33838. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33839. * @returns the max steps
  33840. */
  33841. getLockstepMaxSteps(): number;
  33842. /**
  33843. * Returns the time in ms between steps when using deterministic lock step.
  33844. * @returns time step in (ms)
  33845. */
  33846. getTimeStep(): number;
  33847. /**
  33848. * Force the mipmap generation for the given render target texture
  33849. * @param texture defines the render target texture to use
  33850. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33851. */
  33852. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33853. /** States */
  33854. /**
  33855. * Set various states to the webGL context
  33856. * @param culling defines backface culling state
  33857. * @param zOffset defines the value to apply to zOffset (0 by default)
  33858. * @param force defines if states must be applied even if cache is up to date
  33859. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33860. */
  33861. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33862. /**
  33863. * Set the z offset to apply to current rendering
  33864. * @param value defines the offset to apply
  33865. */
  33866. setZOffset(value: number): void;
  33867. /**
  33868. * Gets the current value of the zOffset
  33869. * @returns the current zOffset state
  33870. */
  33871. getZOffset(): number;
  33872. /**
  33873. * Enable or disable depth buffering
  33874. * @param enable defines the state to set
  33875. */
  33876. setDepthBuffer(enable: boolean): void;
  33877. /**
  33878. * Gets a boolean indicating if depth writing is enabled
  33879. * @returns the current depth writing state
  33880. */
  33881. getDepthWrite(): boolean;
  33882. /**
  33883. * Enable or disable depth writing
  33884. * @param enable defines the state to set
  33885. */
  33886. setDepthWrite(enable: boolean): void;
  33887. /**
  33888. * Gets a boolean indicating if stencil buffer is enabled
  33889. * @returns the current stencil buffer state
  33890. */
  33891. getStencilBuffer(): boolean;
  33892. /**
  33893. * Enable or disable the stencil buffer
  33894. * @param enable defines if the stencil buffer must be enabled or disabled
  33895. */
  33896. setStencilBuffer(enable: boolean): void;
  33897. /**
  33898. * Gets the current stencil mask
  33899. * @returns a number defining the new stencil mask to use
  33900. */
  33901. getStencilMask(): number;
  33902. /**
  33903. * Sets the current stencil mask
  33904. * @param mask defines the new stencil mask to use
  33905. */
  33906. setStencilMask(mask: number): void;
  33907. /**
  33908. * Gets the current stencil function
  33909. * @returns a number defining the stencil function to use
  33910. */
  33911. getStencilFunction(): number;
  33912. /**
  33913. * Gets the current stencil reference value
  33914. * @returns a number defining the stencil reference value to use
  33915. */
  33916. getStencilFunctionReference(): number;
  33917. /**
  33918. * Gets the current stencil mask
  33919. * @returns a number defining the stencil mask to use
  33920. */
  33921. getStencilFunctionMask(): number;
  33922. /**
  33923. * Sets the current stencil function
  33924. * @param stencilFunc defines the new stencil function to use
  33925. */
  33926. setStencilFunction(stencilFunc: number): void;
  33927. /**
  33928. * Sets the current stencil reference
  33929. * @param reference defines the new stencil reference to use
  33930. */
  33931. setStencilFunctionReference(reference: number): void;
  33932. /**
  33933. * Sets the current stencil mask
  33934. * @param mask defines the new stencil mask to use
  33935. */
  33936. setStencilFunctionMask(mask: number): void;
  33937. /**
  33938. * Gets the current stencil operation when stencil fails
  33939. * @returns a number defining stencil operation to use when stencil fails
  33940. */
  33941. getStencilOperationFail(): number;
  33942. /**
  33943. * Gets the current stencil operation when depth fails
  33944. * @returns a number defining stencil operation to use when depth fails
  33945. */
  33946. getStencilOperationDepthFail(): number;
  33947. /**
  33948. * Gets the current stencil operation when stencil passes
  33949. * @returns a number defining stencil operation to use when stencil passes
  33950. */
  33951. getStencilOperationPass(): number;
  33952. /**
  33953. * Sets the stencil operation to use when stencil fails
  33954. * @param operation defines the stencil operation to use when stencil fails
  33955. */
  33956. setStencilOperationFail(operation: number): void;
  33957. /**
  33958. * Sets the stencil operation to use when depth fails
  33959. * @param operation defines the stencil operation to use when depth fails
  33960. */
  33961. setStencilOperationDepthFail(operation: number): void;
  33962. /**
  33963. * Sets the stencil operation to use when stencil passes
  33964. * @param operation defines the stencil operation to use when stencil passes
  33965. */
  33966. setStencilOperationPass(operation: number): void;
  33967. /**
  33968. * Sets a boolean indicating if the dithering state is enabled or disabled
  33969. * @param value defines the dithering state
  33970. */
  33971. setDitheringState(value: boolean): void;
  33972. /**
  33973. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33974. * @param value defines the rasterizer state
  33975. */
  33976. setRasterizerState(value: boolean): void;
  33977. /**
  33978. * Gets the current depth function
  33979. * @returns a number defining the depth function
  33980. */
  33981. getDepthFunction(): Nullable<number>;
  33982. /**
  33983. * Sets the current depth function
  33984. * @param depthFunc defines the function to use
  33985. */
  33986. setDepthFunction(depthFunc: number): void;
  33987. /**
  33988. * Sets the current depth function to GREATER
  33989. */
  33990. setDepthFunctionToGreater(): void;
  33991. /**
  33992. * Sets the current depth function to GEQUAL
  33993. */
  33994. setDepthFunctionToGreaterOrEqual(): void;
  33995. /**
  33996. * Sets the current depth function to LESS
  33997. */
  33998. setDepthFunctionToLess(): void;
  33999. /**
  34000. * Sets the current depth function to LEQUAL
  34001. */
  34002. setDepthFunctionToLessOrEqual(): void;
  34003. private _cachedStencilBuffer;
  34004. private _cachedStencilFunction;
  34005. private _cachedStencilMask;
  34006. private _cachedStencilOperationPass;
  34007. private _cachedStencilOperationFail;
  34008. private _cachedStencilOperationDepthFail;
  34009. private _cachedStencilReference;
  34010. /**
  34011. * Caches the the state of the stencil buffer
  34012. */
  34013. cacheStencilState(): void;
  34014. /**
  34015. * Restores the state of the stencil buffer
  34016. */
  34017. restoreStencilState(): void;
  34018. /**
  34019. * Directly set the WebGL Viewport
  34020. * @param x defines the x coordinate of the viewport (in screen space)
  34021. * @param y defines the y coordinate of the viewport (in screen space)
  34022. * @param width defines the width of the viewport (in screen space)
  34023. * @param height defines the height of the viewport (in screen space)
  34024. * @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
  34025. */
  34026. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34027. /**
  34028. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34029. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34030. * @param y defines the y-coordinate of the corner of the clear rectangle
  34031. * @param width defines the width of the clear rectangle
  34032. * @param height defines the height of the clear rectangle
  34033. * @param clearColor defines the clear color
  34034. */
  34035. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34036. /**
  34037. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34038. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34039. * @param y defines the y-coordinate of the corner of the clear rectangle
  34040. * @param width defines the width of the clear rectangle
  34041. * @param height defines the height of the clear rectangle
  34042. */
  34043. enableScissor(x: number, y: number, width: number, height: number): void;
  34044. /**
  34045. * Disable previously set scissor test rectangle
  34046. */
  34047. disableScissor(): void;
  34048. protected _reportDrawCall(): void;
  34049. /**
  34050. * Initializes a webVR display and starts listening to display change events
  34051. * The onVRDisplayChangedObservable will be notified upon these changes
  34052. * @returns The onVRDisplayChangedObservable
  34053. */
  34054. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34055. /** @hidden */
  34056. _prepareVRComponent(): void;
  34057. /** @hidden */
  34058. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34059. /** @hidden */
  34060. _submitVRFrame(): void;
  34061. /**
  34062. * Call this function to leave webVR mode
  34063. * Will do nothing if webVR is not supported or if there is no webVR device
  34064. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34065. */
  34066. disableVR(): void;
  34067. /**
  34068. * Gets a boolean indicating that the system is in VR mode and is presenting
  34069. * @returns true if VR mode is engaged
  34070. */
  34071. isVRPresenting(): boolean;
  34072. /** @hidden */
  34073. _requestVRFrame(): void;
  34074. /** @hidden */
  34075. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34076. /**
  34077. * Gets the source code of the vertex shader associated with a specific webGL program
  34078. * @param program defines the program to use
  34079. * @returns a string containing the source code of the vertex shader associated with the program
  34080. */
  34081. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34082. /**
  34083. * Gets the source code of the fragment shader associated with a specific webGL program
  34084. * @param program defines the program to use
  34085. * @returns a string containing the source code of the fragment shader associated with the program
  34086. */
  34087. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34088. /**
  34089. * Reads pixels from the current frame buffer. Please note that this function can be slow
  34090. * @param x defines the x coordinate of the rectangle where pixels must be read
  34091. * @param y defines the y coordinate of the rectangle where pixels must be read
  34092. * @param width defines the width of the rectangle where pixels must be read
  34093. * @param height defines the height of the rectangle where pixels must be read
  34094. * @returns a Uint8Array containing RGBA colors
  34095. */
  34096. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  34097. /**
  34098. * Sets a depth stencil texture from a render target to the according uniform.
  34099. * @param channel The texture channel
  34100. * @param uniform The uniform to set
  34101. * @param texture The render target texture containing the depth stencil texture to apply
  34102. */
  34103. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34104. /**
  34105. * Sets a texture to the webGL context from a postprocess
  34106. * @param channel defines the channel to use
  34107. * @param postProcess defines the source postprocess
  34108. */
  34109. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34110. /**
  34111. * Binds the output of the passed in post process to the texture channel specified
  34112. * @param channel The channel the texture should be bound to
  34113. * @param postProcess The post process which's output should be bound
  34114. */
  34115. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34116. /** @hidden */
  34117. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34118. protected _rebuildBuffers(): void;
  34119. /** @hidden */
  34120. _renderFrame(): void;
  34121. _renderLoop(): void;
  34122. /** @hidden */
  34123. _renderViews(): boolean;
  34124. /**
  34125. * Toggle full screen mode
  34126. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34127. */
  34128. switchFullscreen(requestPointerLock: boolean): void;
  34129. /**
  34130. * Enters full screen mode
  34131. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34132. */
  34133. enterFullscreen(requestPointerLock: boolean): void;
  34134. /**
  34135. * Exits full screen mode
  34136. */
  34137. exitFullscreen(): void;
  34138. /**
  34139. * Enters Pointerlock mode
  34140. */
  34141. enterPointerlock(): void;
  34142. /**
  34143. * Exits Pointerlock mode
  34144. */
  34145. exitPointerlock(): void;
  34146. /**
  34147. * Begin a new frame
  34148. */
  34149. beginFrame(): void;
  34150. /**
  34151. * Enf the current frame
  34152. */
  34153. endFrame(): void;
  34154. resize(): void;
  34155. /**
  34156. * Set the compressed texture format to use, based on the formats you have, and the formats
  34157. * supported by the hardware / browser.
  34158. *
  34159. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34160. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34161. * to API arguments needed to compressed textures. This puts the burden on the container
  34162. * generator to house the arcane code for determining these for current & future formats.
  34163. *
  34164. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34165. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34166. *
  34167. * Note: The result of this call is not taken into account when a texture is base64.
  34168. *
  34169. * @param formatsAvailable defines the list of those format families you have created
  34170. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34171. *
  34172. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34173. * @returns The extension selected.
  34174. */
  34175. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34176. /**
  34177. * Set the compressed texture extensions or file names to skip.
  34178. *
  34179. * @param skippedFiles defines the list of those texture files you want to skip
  34180. * Example: [".dds", ".env", "myfile.png"]
  34181. */
  34182. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34183. /**
  34184. * Force a specific size of the canvas
  34185. * @param width defines the new canvas' width
  34186. * @param height defines the new canvas' height
  34187. */
  34188. setSize(width: number, height: number): void;
  34189. /**
  34190. * Updates a dynamic vertex buffer.
  34191. * @param vertexBuffer the vertex buffer to update
  34192. * @param data the data used to update the vertex buffer
  34193. * @param byteOffset the byte offset of the data
  34194. * @param byteLength the byte length of the data
  34195. */
  34196. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34197. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34199. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34200. _releaseTexture(texture: InternalTexture): void;
  34201. /**
  34202. * @hidden
  34203. * Rescales a texture
  34204. * @param source input texutre
  34205. * @param destination destination texture
  34206. * @param scene scene to use to render the resize
  34207. * @param internalFormat format to use when resizing
  34208. * @param onComplete callback to be called when resize has completed
  34209. */
  34210. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34211. /**
  34212. * Gets the current framerate
  34213. * @returns a number representing the framerate
  34214. */
  34215. getFps(): number;
  34216. /**
  34217. * Gets the time spent between current and previous frame
  34218. * @returns a number representing the delta time in ms
  34219. */
  34220. getDeltaTime(): number;
  34221. private _measureFps;
  34222. /** @hidden */
  34223. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34224. /**
  34225. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34226. * @param renderTarget The render target to set the frame buffer for
  34227. */
  34228. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34229. /**
  34230. * Update a dynamic index buffer
  34231. * @param indexBuffer defines the target index buffer
  34232. * @param indices defines the data to update
  34233. * @param offset defines the offset in the target index buffer where update should start
  34234. */
  34235. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34236. /**
  34237. * Updates the sample count of a render target texture
  34238. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34239. * @param texture defines the texture to update
  34240. * @param samples defines the sample count to set
  34241. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34242. */
  34243. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34244. /**
  34245. * Updates a depth texture Comparison Mode and Function.
  34246. * If the comparison Function is equal to 0, the mode will be set to none.
  34247. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34248. * @param texture The texture to set the comparison function for
  34249. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34250. */
  34251. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34252. /**
  34253. * Creates a webGL buffer to use with instanciation
  34254. * @param capacity defines the size of the buffer
  34255. * @returns the webGL buffer
  34256. */
  34257. createInstancesBuffer(capacity: number): DataBuffer;
  34258. /**
  34259. * Delete a webGL buffer used with instanciation
  34260. * @param buffer defines the webGL buffer to delete
  34261. */
  34262. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34263. /** @hidden */
  34264. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34265. dispose(): void;
  34266. private _disableTouchAction;
  34267. /**
  34268. * Display the loading screen
  34269. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34270. */
  34271. displayLoadingUI(): void;
  34272. /**
  34273. * Hide the loading screen
  34274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34275. */
  34276. hideLoadingUI(): void;
  34277. /**
  34278. * Gets the current loading screen object
  34279. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34280. */
  34281. /**
  34282. * Sets the current loading screen object
  34283. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34284. */
  34285. loadingScreen: ILoadingScreen;
  34286. /**
  34287. * Sets the current loading screen text
  34288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34289. */
  34290. loadingUIText: string;
  34291. /**
  34292. * Sets the current loading screen background color
  34293. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34294. */
  34295. loadingUIBackgroundColor: string;
  34296. /** Pointerlock and fullscreen */
  34297. /**
  34298. * Ask the browser to promote the current element to pointerlock mode
  34299. * @param element defines the DOM element to promote
  34300. */
  34301. static _RequestPointerlock(element: HTMLElement): void;
  34302. /**
  34303. * Asks the browser to exit pointerlock mode
  34304. */
  34305. static _ExitPointerlock(): void;
  34306. /**
  34307. * Ask the browser to promote the current element to fullscreen rendering mode
  34308. * @param element defines the DOM element to promote
  34309. */
  34310. static _RequestFullscreen(element: HTMLElement): void;
  34311. /**
  34312. * Asks the browser to exit fullscreen mode
  34313. */
  34314. static _ExitFullscreen(): void;
  34315. }
  34316. }
  34317. declare module "babylonjs/Engines/engineStore" {
  34318. import { Nullable } from "babylonjs/types";
  34319. import { Engine } from "babylonjs/Engines/engine";
  34320. import { Scene } from "babylonjs/scene";
  34321. /**
  34322. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34323. * during the life time of the application.
  34324. */
  34325. export class EngineStore {
  34326. /** Gets the list of created engines */
  34327. static Instances: import("babylonjs/Engines/engine").Engine[];
  34328. /** @hidden */
  34329. static _LastCreatedScene: Nullable<Scene>;
  34330. /**
  34331. * Gets the latest created engine
  34332. */
  34333. static readonly LastCreatedEngine: Nullable<Engine>;
  34334. /**
  34335. * Gets the latest created scene
  34336. */
  34337. static readonly LastCreatedScene: Nullable<Scene>;
  34338. /**
  34339. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34340. * @ignorenaming
  34341. */
  34342. static UseFallbackTexture: boolean;
  34343. /**
  34344. * Texture content used if a texture cannot loaded
  34345. * @ignorenaming
  34346. */
  34347. static FallbackTexture: string;
  34348. }
  34349. }
  34350. declare module "babylonjs/Misc/promise" {
  34351. /**
  34352. * Helper class that provides a small promise polyfill
  34353. */
  34354. export class PromisePolyfill {
  34355. /**
  34356. * Static function used to check if the polyfill is required
  34357. * If this is the case then the function will inject the polyfill to window.Promise
  34358. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34359. */
  34360. static Apply(force?: boolean): void;
  34361. }
  34362. }
  34363. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34364. /**
  34365. * Interface for screenshot methods with describe argument called `size` as object with options
  34366. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34367. */
  34368. export interface IScreenshotSize {
  34369. /**
  34370. * number in pixels for canvas height
  34371. */
  34372. height?: number;
  34373. /**
  34374. * multiplier allowing render at a higher or lower resolution
  34375. * If value is defined then height and width will be ignored and taken from camera
  34376. */
  34377. precision?: number;
  34378. /**
  34379. * number in pixels for canvas width
  34380. */
  34381. width?: number;
  34382. }
  34383. }
  34384. declare module "babylonjs/Misc/tools" {
  34385. import { Nullable, float } from "babylonjs/types";
  34386. import { DomManagement } from "babylonjs/Misc/domManagement";
  34387. import { WebRequest } from "babylonjs/Misc/webRequest";
  34388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34389. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34390. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34391. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34392. import { Camera } from "babylonjs/Cameras/camera";
  34393. import { Engine } from "babylonjs/Engines/engine";
  34394. interface IColor4Like {
  34395. r: float;
  34396. g: float;
  34397. b: float;
  34398. a: float;
  34399. }
  34400. /**
  34401. * Class containing a set of static utilities functions
  34402. */
  34403. export class Tools {
  34404. /**
  34405. * Gets or sets the base URL to use to load assets
  34406. */
  34407. static BaseUrl: string;
  34408. /**
  34409. * Enable/Disable Custom HTTP Request Headers globally.
  34410. * default = false
  34411. * @see CustomRequestHeaders
  34412. */
  34413. static UseCustomRequestHeaders: boolean;
  34414. /**
  34415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34416. * i.e. when loading files, where the server/service expects an Authorization header
  34417. */
  34418. static CustomRequestHeaders: {
  34419. [key: string]: string;
  34420. };
  34421. /**
  34422. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34423. */
  34424. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  34425. /**
  34426. * Default behaviour for cors in the application.
  34427. * It can be a string if the expected behavior is identical in the entire app.
  34428. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34429. */
  34430. static CorsBehavior: string | ((url: string | string[]) => string);
  34431. /**
  34432. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34433. * @ignorenaming
  34434. */
  34435. static UseFallbackTexture: boolean;
  34436. /**
  34437. * Use this object to register external classes like custom textures or material
  34438. * to allow the laoders to instantiate them
  34439. */
  34440. static RegisteredExternalClasses: {
  34441. [key: string]: Object;
  34442. };
  34443. /**
  34444. * Texture content used if a texture cannot loaded
  34445. * @ignorenaming
  34446. */
  34447. static fallbackTexture: string;
  34448. /**
  34449. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34450. * @param u defines the coordinate on X axis
  34451. * @param v defines the coordinate on Y axis
  34452. * @param width defines the width of the source data
  34453. * @param height defines the height of the source data
  34454. * @param pixels defines the source byte array
  34455. * @param color defines the output color
  34456. */
  34457. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34458. /**
  34459. * Interpolates between a and b via alpha
  34460. * @param a The lower value (returned when alpha = 0)
  34461. * @param b The upper value (returned when alpha = 1)
  34462. * @param alpha The interpolation-factor
  34463. * @return The mixed value
  34464. */
  34465. static Mix(a: number, b: number, alpha: number): number;
  34466. /**
  34467. * Tries to instantiate a new object from a given class name
  34468. * @param className defines the class name to instantiate
  34469. * @returns the new object or null if the system was not able to do the instantiation
  34470. */
  34471. static Instantiate(className: string): any;
  34472. /**
  34473. * Provides a slice function that will work even on IE
  34474. * @param data defines the array to slice
  34475. * @param start defines the start of the data (optional)
  34476. * @param end defines the end of the data (optional)
  34477. * @returns the new sliced array
  34478. */
  34479. static Slice<T>(data: T, start?: number, end?: number): T;
  34480. /**
  34481. * Polyfill for setImmediate
  34482. * @param action defines the action to execute after the current execution block
  34483. */
  34484. static SetImmediate(action: () => void): void;
  34485. /**
  34486. * Function indicating if a number is an exponent of 2
  34487. * @param value defines the value to test
  34488. * @returns true if the value is an exponent of 2
  34489. */
  34490. static IsExponentOfTwo(value: number): boolean;
  34491. private static _tmpFloatArray;
  34492. /**
  34493. * Returns the nearest 32-bit single precision float representation of a Number
  34494. * @param value A Number. If the parameter is of a different type, it will get converted
  34495. * to a number or to NaN if it cannot be converted
  34496. * @returns number
  34497. */
  34498. static FloatRound(value: number): number;
  34499. /**
  34500. * Extracts the filename from a path
  34501. * @param path defines the path to use
  34502. * @returns the filename
  34503. */
  34504. static GetFilename(path: string): string;
  34505. /**
  34506. * Extracts the "folder" part of a path (everything before the filename).
  34507. * @param uri The URI to extract the info from
  34508. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34509. * @returns The "folder" part of the path
  34510. */
  34511. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34512. /**
  34513. * Extracts text content from a DOM element hierarchy
  34514. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34515. */
  34516. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34517. /**
  34518. * Convert an angle in radians to degrees
  34519. * @param angle defines the angle to convert
  34520. * @returns the angle in degrees
  34521. */
  34522. static ToDegrees(angle: number): number;
  34523. /**
  34524. * Convert an angle in degrees to radians
  34525. * @param angle defines the angle to convert
  34526. * @returns the angle in radians
  34527. */
  34528. static ToRadians(angle: number): number;
  34529. /**
  34530. * Returns an array if obj is not an array
  34531. * @param obj defines the object to evaluate as an array
  34532. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34533. * @returns either obj directly if obj is an array or a new array containing obj
  34534. */
  34535. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34536. /**
  34537. * Gets the pointer prefix to use
  34538. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34539. */
  34540. static GetPointerPrefix(): string;
  34541. /**
  34542. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34543. * @param url define the url we are trying
  34544. * @param element define the dom element where to configure the cors policy
  34545. */
  34546. static SetCorsBehavior(url: string | string[], element: {
  34547. crossOrigin: string | null;
  34548. }): void;
  34549. /**
  34550. * Removes unwanted characters from an url
  34551. * @param url defines the url to clean
  34552. * @returns the cleaned url
  34553. */
  34554. static CleanUrl(url: string): string;
  34555. /**
  34556. * Gets or sets a function used to pre-process url before using them to load assets
  34557. */
  34558. static PreprocessUrl: (url: string) => string;
  34559. /**
  34560. * Loads an image as an HTMLImageElement.
  34561. * @param input url string, ArrayBuffer, or Blob to load
  34562. * @param onLoad callback called when the image successfully loads
  34563. * @param onError callback called when the image fails to load
  34564. * @param offlineProvider offline provider for caching
  34565. * @param mimeType optional mime type
  34566. * @returns the HTMLImageElement of the loaded image
  34567. */
  34568. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34569. /**
  34570. * Loads a file from a url
  34571. * @param url url string, ArrayBuffer, or Blob to load
  34572. * @param onSuccess callback called when the file successfully loads
  34573. * @param onProgress callback called while file is loading (if the server supports this mode)
  34574. * @param offlineProvider defines the offline provider for caching
  34575. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34576. * @param onError callback called when the file fails to load
  34577. * @returns a file request object
  34578. */
  34579. 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;
  34580. /**
  34581. * Loads a file from a url
  34582. * @param url the file url to load
  34583. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34584. */
  34585. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34586. /**
  34587. * Load a script (identified by an url). When the url returns, the
  34588. * content of this file is added into a new script element, attached to the DOM (body element)
  34589. * @param scriptUrl defines the url of the script to laod
  34590. * @param onSuccess defines the callback called when the script is loaded
  34591. * @param onError defines the callback to call if an error occurs
  34592. * @param scriptId defines the id of the script element
  34593. */
  34594. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34595. /**
  34596. * Load an asynchronous script (identified by an url). When the url returns, the
  34597. * content of this file is added into a new script element, attached to the DOM (body element)
  34598. * @param scriptUrl defines the url of the script to laod
  34599. * @param scriptId defines the id of the script element
  34600. * @returns a promise request object
  34601. */
  34602. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  34603. /**
  34604. * Loads a file from a blob
  34605. * @param fileToLoad defines the blob to use
  34606. * @param callback defines the callback to call when data is loaded
  34607. * @param progressCallback defines the callback to call during loading process
  34608. * @returns a file request object
  34609. */
  34610. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34611. /**
  34612. * Reads a file from a File object
  34613. * @param file defines the file to load
  34614. * @param onSuccess defines the callback to call when data is loaded
  34615. * @param onProgress defines the callback to call during loading process
  34616. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34617. * @param onError defines the callback to call when an error occurs
  34618. * @returns a file request object
  34619. */
  34620. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34621. /**
  34622. * Creates a data url from a given string content
  34623. * @param content defines the content to convert
  34624. * @returns the new data url link
  34625. */
  34626. static FileAsURL(content: string): string;
  34627. /**
  34628. * Format the given number to a specific decimal format
  34629. * @param value defines the number to format
  34630. * @param decimals defines the number of decimals to use
  34631. * @returns the formatted string
  34632. */
  34633. static Format(value: number, decimals?: number): string;
  34634. /**
  34635. * Tries to copy an object by duplicating every property
  34636. * @param source defines the source object
  34637. * @param destination defines the target object
  34638. * @param doNotCopyList defines a list of properties to avoid
  34639. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34640. */
  34641. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34642. /**
  34643. * Gets a boolean indicating if the given object has no own property
  34644. * @param obj defines the object to test
  34645. * @returns true if object has no own property
  34646. */
  34647. static IsEmpty(obj: any): boolean;
  34648. /**
  34649. * Function used to register events at window level
  34650. * @param windowElement defines the Window object to use
  34651. * @param events defines the events to register
  34652. */
  34653. static RegisterTopRootEvents(windowElement: Window, events: {
  34654. name: string;
  34655. handler: Nullable<(e: FocusEvent) => any>;
  34656. }[]): void;
  34657. /**
  34658. * Function used to unregister events from window level
  34659. * @param windowElement defines the Window object to use
  34660. * @param events defines the events to unregister
  34661. */
  34662. static UnregisterTopRootEvents(windowElement: Window, events: {
  34663. name: string;
  34664. handler: Nullable<(e: FocusEvent) => any>;
  34665. }[]): void;
  34666. /**
  34667. * @ignore
  34668. */
  34669. static _ScreenshotCanvas: HTMLCanvasElement;
  34670. /**
  34671. * Dumps the current bound framebuffer
  34672. * @param width defines the rendering width
  34673. * @param height defines the rendering height
  34674. * @param engine defines the hosting engine
  34675. * @param successCallback defines the callback triggered once the data are available
  34676. * @param mimeType defines the mime type of the result
  34677. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34678. */
  34679. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34680. /**
  34681. * Converts the canvas data to blob.
  34682. * This acts as a polyfill for browsers not supporting the to blob function.
  34683. * @param canvas Defines the canvas to extract the data from
  34684. * @param successCallback Defines the callback triggered once the data are available
  34685. * @param mimeType Defines the mime type of the result
  34686. */
  34687. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34688. /**
  34689. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34690. * @param successCallback defines the callback triggered once the data are available
  34691. * @param mimeType defines the mime type of the result
  34692. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34693. */
  34694. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34695. /**
  34696. * Downloads a blob in the browser
  34697. * @param blob defines the blob to download
  34698. * @param fileName defines the name of the downloaded file
  34699. */
  34700. static Download(blob: Blob, fileName: string): void;
  34701. /**
  34702. * Captures a screenshot of the current rendering
  34703. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34704. * @param engine defines the rendering engine
  34705. * @param camera defines the source camera
  34706. * @param size This parameter can be set to a single number or to an object with the
  34707. * following (optional) properties: precision, width, height. If a single number is passed,
  34708. * it will be used for both width and height. If an object is passed, the screenshot size
  34709. * will be derived from the parameters. The precision property is a multiplier allowing
  34710. * rendering at a higher or lower resolution
  34711. * @param successCallback defines the callback receives a single parameter which contains the
  34712. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34713. * src parameter of an <img> to display it
  34714. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34715. * Check your browser for supported MIME types
  34716. */
  34717. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34718. /**
  34719. * Captures a screenshot of the current rendering
  34720. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34721. * @param engine defines the rendering engine
  34722. * @param camera defines the source camera
  34723. * @param size This parameter can be set to a single number or to an object with the
  34724. * following (optional) properties: precision, width, height. If a single number is passed,
  34725. * it will be used for both width and height. If an object is passed, the screenshot size
  34726. * will be derived from the parameters. The precision property is a multiplier allowing
  34727. * rendering at a higher or lower resolution
  34728. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34729. * Check your browser for supported MIME types
  34730. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34731. * to the src parameter of an <img> to display it
  34732. */
  34733. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34734. /**
  34735. * Generates an image screenshot from the specified camera.
  34736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34737. * @param engine The engine to use for rendering
  34738. * @param camera The camera to use for rendering
  34739. * @param size This parameter can be set to a single number or to an object with the
  34740. * following (optional) properties: precision, width, height. If a single number is passed,
  34741. * it will be used for both width and height. If an object is passed, the screenshot size
  34742. * will be derived from the parameters. The precision property is a multiplier allowing
  34743. * rendering at a higher or lower resolution
  34744. * @param successCallback The callback receives a single parameter which contains the
  34745. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34746. * src parameter of an <img> to display it
  34747. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34748. * Check your browser for supported MIME types
  34749. * @param samples Texture samples (default: 1)
  34750. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34751. * @param fileName A name for for the downloaded file.
  34752. */
  34753. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34754. /**
  34755. * Generates an image screenshot from the specified camera.
  34756. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34757. * @param engine The engine to use for rendering
  34758. * @param camera The camera to use for rendering
  34759. * @param size This parameter can be set to a single number or to an object with the
  34760. * following (optional) properties: precision, width, height. If a single number is passed,
  34761. * it will be used for both width and height. If an object is passed, the screenshot size
  34762. * will be derived from the parameters. The precision property is a multiplier allowing
  34763. * rendering at a higher or lower resolution
  34764. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34765. * Check your browser for supported MIME types
  34766. * @param samples Texture samples (default: 1)
  34767. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34768. * @param fileName A name for for the downloaded file.
  34769. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34770. * to the src parameter of an <img> to display it
  34771. */
  34772. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34773. /**
  34774. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34775. * Be aware Math.random() could cause collisions, but:
  34776. * "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"
  34777. * @returns a pseudo random id
  34778. */
  34779. static RandomId(): string;
  34780. /**
  34781. * Test if the given uri is a base64 string
  34782. * @param uri The uri to test
  34783. * @return True if the uri is a base64 string or false otherwise
  34784. */
  34785. static IsBase64(uri: string): boolean;
  34786. /**
  34787. * Decode the given base64 uri.
  34788. * @param uri The uri to decode
  34789. * @return The decoded base64 data.
  34790. */
  34791. static DecodeBase64(uri: string): ArrayBuffer;
  34792. /**
  34793. * Gets the absolute url.
  34794. * @param url the input url
  34795. * @return the absolute url
  34796. */
  34797. static GetAbsoluteUrl(url: string): string;
  34798. /**
  34799. * No log
  34800. */
  34801. static readonly NoneLogLevel: number;
  34802. /**
  34803. * Only message logs
  34804. */
  34805. static readonly MessageLogLevel: number;
  34806. /**
  34807. * Only warning logs
  34808. */
  34809. static readonly WarningLogLevel: number;
  34810. /**
  34811. * Only error logs
  34812. */
  34813. static readonly ErrorLogLevel: number;
  34814. /**
  34815. * All logs
  34816. */
  34817. static readonly AllLogLevel: number;
  34818. /**
  34819. * Gets a value indicating the number of loading errors
  34820. * @ignorenaming
  34821. */
  34822. static readonly errorsCount: number;
  34823. /**
  34824. * Callback called when a new log is added
  34825. */
  34826. static OnNewCacheEntry: (entry: string) => void;
  34827. /**
  34828. * Log a message to the console
  34829. * @param message defines the message to log
  34830. */
  34831. static Log(message: string): void;
  34832. /**
  34833. * Write a warning message to the console
  34834. * @param message defines the message to log
  34835. */
  34836. static Warn(message: string): void;
  34837. /**
  34838. * Write an error message to the console
  34839. * @param message defines the message to log
  34840. */
  34841. static Error(message: string): void;
  34842. /**
  34843. * Gets current log cache (list of logs)
  34844. */
  34845. static readonly LogCache: string;
  34846. /**
  34847. * Clears the log cache
  34848. */
  34849. static ClearLogCache(): void;
  34850. /**
  34851. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34852. */
  34853. static LogLevels: number;
  34854. /**
  34855. * Checks if the window object exists
  34856. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34857. */
  34858. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34859. /**
  34860. * No performance log
  34861. */
  34862. static readonly PerformanceNoneLogLevel: number;
  34863. /**
  34864. * Use user marks to log performance
  34865. */
  34866. static readonly PerformanceUserMarkLogLevel: number;
  34867. /**
  34868. * Log performance to the console
  34869. */
  34870. static readonly PerformanceConsoleLogLevel: number;
  34871. private static _performance;
  34872. /**
  34873. * Sets the current performance log level
  34874. */
  34875. static PerformanceLogLevel: number;
  34876. private static _StartPerformanceCounterDisabled;
  34877. private static _EndPerformanceCounterDisabled;
  34878. private static _StartUserMark;
  34879. private static _EndUserMark;
  34880. private static _StartPerformanceConsole;
  34881. private static _EndPerformanceConsole;
  34882. /**
  34883. * Starts a performance counter
  34884. */
  34885. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34886. /**
  34887. * Ends a specific performance coutner
  34888. */
  34889. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34890. /**
  34891. * Gets either window.performance.now() if supported or Date.now() else
  34892. */
  34893. static readonly Now: number;
  34894. /**
  34895. * This method will return the name of the class used to create the instance of the given object.
  34896. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34897. * @param object the object to get the class name from
  34898. * @param isType defines if the object is actually a type
  34899. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34900. */
  34901. static GetClassName(object: any, isType?: boolean): string;
  34902. /**
  34903. * Gets the first element of an array satisfying a given predicate
  34904. * @param array defines the array to browse
  34905. * @param predicate defines the predicate to use
  34906. * @returns null if not found or the element
  34907. */
  34908. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34909. /**
  34910. * This method will return the name of the full name of the class, including its owning module (if any).
  34911. * 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).
  34912. * @param object the object to get the class name from
  34913. * @param isType defines if the object is actually a type
  34914. * @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.
  34915. * @ignorenaming
  34916. */
  34917. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34918. /**
  34919. * Returns a promise that resolves after the given amount of time.
  34920. * @param delay Number of milliseconds to delay
  34921. * @returns Promise that resolves after the given amount of time
  34922. */
  34923. static DelayAsync(delay: number): Promise<void>;
  34924. }
  34925. /**
  34926. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34927. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34928. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34929. * @param name The name of the class, case should be preserved
  34930. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34931. */
  34932. export function className(name: string, module?: string): (target: Object) => void;
  34933. /**
  34934. * An implementation of a loop for asynchronous functions.
  34935. */
  34936. export class AsyncLoop {
  34937. /**
  34938. * Defines the number of iterations for the loop
  34939. */
  34940. iterations: number;
  34941. /**
  34942. * Defines the current index of the loop.
  34943. */
  34944. index: number;
  34945. private _done;
  34946. private _fn;
  34947. private _successCallback;
  34948. /**
  34949. * Constructor.
  34950. * @param iterations the number of iterations.
  34951. * @param func the function to run each iteration
  34952. * @param successCallback the callback that will be called upon succesful execution
  34953. * @param offset starting offset.
  34954. */
  34955. constructor(
  34956. /**
  34957. * Defines the number of iterations for the loop
  34958. */
  34959. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34960. /**
  34961. * Execute the next iteration. Must be called after the last iteration was finished.
  34962. */
  34963. executeNext(): void;
  34964. /**
  34965. * Break the loop and run the success callback.
  34966. */
  34967. breakLoop(): void;
  34968. /**
  34969. * Create and run an async loop.
  34970. * @param iterations the number of iterations.
  34971. * @param fn the function to run each iteration
  34972. * @param successCallback the callback that will be called upon succesful execution
  34973. * @param offset starting offset.
  34974. * @returns the created async loop object
  34975. */
  34976. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34977. /**
  34978. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34979. * @param iterations total number of iterations
  34980. * @param syncedIterations number of synchronous iterations in each async iteration.
  34981. * @param fn the function to call each iteration.
  34982. * @param callback a success call back that will be called when iterating stops.
  34983. * @param breakFunction a break condition (optional)
  34984. * @param timeout timeout settings for the setTimeout function. default - 0.
  34985. * @returns the created async loop object
  34986. */
  34987. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34988. }
  34989. }
  34990. declare module "babylonjs/Misc/stringDictionary" {
  34991. import { Nullable } from "babylonjs/types";
  34992. /**
  34993. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34994. * The underlying implementation relies on an associative array to ensure the best performances.
  34995. * The value can be anything including 'null' but except 'undefined'
  34996. */
  34997. export class StringDictionary<T> {
  34998. /**
  34999. * This will clear this dictionary and copy the content from the 'source' one.
  35000. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35001. * @param source the dictionary to take the content from and copy to this dictionary
  35002. */
  35003. copyFrom(source: StringDictionary<T>): void;
  35004. /**
  35005. * Get a value based from its key
  35006. * @param key the given key to get the matching value from
  35007. * @return the value if found, otherwise undefined is returned
  35008. */
  35009. get(key: string): T | undefined;
  35010. /**
  35011. * Get a value from its key or add it if it doesn't exist.
  35012. * This method will ensure you that a given key/data will be present in the dictionary.
  35013. * @param key the given key to get the matching value from
  35014. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35015. * The factory will only be invoked if there's no data for the given key.
  35016. * @return the value corresponding to the key.
  35017. */
  35018. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35019. /**
  35020. * Get a value from its key if present in the dictionary otherwise add it
  35021. * @param key the key to get the value from
  35022. * @param val if there's no such key/value pair in the dictionary add it with this value
  35023. * @return the value corresponding to the key
  35024. */
  35025. getOrAdd(key: string, val: T): T;
  35026. /**
  35027. * Check if there's a given key in the dictionary
  35028. * @param key the key to check for
  35029. * @return true if the key is present, false otherwise
  35030. */
  35031. contains(key: string): boolean;
  35032. /**
  35033. * Add a new key and its corresponding value
  35034. * @param key the key to add
  35035. * @param value the value corresponding to the key
  35036. * @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
  35037. */
  35038. add(key: string, value: T): boolean;
  35039. /**
  35040. * Update a specific value associated to a key
  35041. * @param key defines the key to use
  35042. * @param value defines the value to store
  35043. * @returns true if the value was updated (or false if the key was not found)
  35044. */
  35045. set(key: string, value: T): boolean;
  35046. /**
  35047. * Get the element of the given key and remove it from the dictionary
  35048. * @param key defines the key to search
  35049. * @returns the value associated with the key or null if not found
  35050. */
  35051. getAndRemove(key: string): Nullable<T>;
  35052. /**
  35053. * Remove a key/value from the dictionary.
  35054. * @param key the key to remove
  35055. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35056. */
  35057. remove(key: string): boolean;
  35058. /**
  35059. * Clear the whole content of the dictionary
  35060. */
  35061. clear(): void;
  35062. /**
  35063. * Gets the current count
  35064. */
  35065. readonly count: number;
  35066. /**
  35067. * Execute a callback on each key/val of the dictionary.
  35068. * Note that you can remove any element in this dictionary in the callback implementation
  35069. * @param callback the callback to execute on a given key/value pair
  35070. */
  35071. forEach(callback: (key: string, val: T) => void): void;
  35072. /**
  35073. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35074. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35075. * Note that you can remove any element in this dictionary in the callback implementation
  35076. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35077. * @returns the first item
  35078. */
  35079. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35080. private _count;
  35081. private _data;
  35082. }
  35083. }
  35084. declare module "babylonjs/Collisions/collisionCoordinator" {
  35085. import { Nullable } from "babylonjs/types";
  35086. import { Scene } from "babylonjs/scene";
  35087. import { Vector3 } from "babylonjs/Maths/math.vector";
  35088. import { Collider } from "babylonjs/Collisions/collider";
  35089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35090. /** @hidden */
  35091. export interface ICollisionCoordinator {
  35092. createCollider(): Collider;
  35093. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35094. init(scene: Scene): void;
  35095. }
  35096. /** @hidden */
  35097. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35098. private _scene;
  35099. private _scaledPosition;
  35100. private _scaledVelocity;
  35101. private _finalPosition;
  35102. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35103. createCollider(): Collider;
  35104. init(scene: Scene): void;
  35105. private _collideWithWorld;
  35106. }
  35107. }
  35108. declare module "babylonjs/Inputs/scene.inputManager" {
  35109. import { Nullable } from "babylonjs/types";
  35110. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35111. import { Vector2 } from "babylonjs/Maths/math.vector";
  35112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35113. import { Scene } from "babylonjs/scene";
  35114. /**
  35115. * Class used to manage all inputs for the scene.
  35116. */
  35117. export class InputManager {
  35118. /** The distance in pixel that you have to move to prevent some events */
  35119. static DragMovementThreshold: number;
  35120. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35121. static LongPressDelay: number;
  35122. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35123. static DoubleClickDelay: number;
  35124. /** If you need to check double click without raising a single click at first click, enable this flag */
  35125. static ExclusiveDoubleClickMode: boolean;
  35126. private _wheelEventName;
  35127. private _onPointerMove;
  35128. private _onPointerDown;
  35129. private _onPointerUp;
  35130. private _initClickEvent;
  35131. private _initActionManager;
  35132. private _delayedSimpleClick;
  35133. private _delayedSimpleClickTimeout;
  35134. private _previousDelayedSimpleClickTimeout;
  35135. private _meshPickProceed;
  35136. private _previousButtonPressed;
  35137. private _currentPickResult;
  35138. private _previousPickResult;
  35139. private _totalPointersPressed;
  35140. private _doubleClickOccured;
  35141. private _pointerOverMesh;
  35142. private _pickedDownMesh;
  35143. private _pickedUpMesh;
  35144. private _pointerX;
  35145. private _pointerY;
  35146. private _unTranslatedPointerX;
  35147. private _unTranslatedPointerY;
  35148. private _startingPointerPosition;
  35149. private _previousStartingPointerPosition;
  35150. private _startingPointerTime;
  35151. private _previousStartingPointerTime;
  35152. private _pointerCaptures;
  35153. private _onKeyDown;
  35154. private _onKeyUp;
  35155. private _onCanvasFocusObserver;
  35156. private _onCanvasBlurObserver;
  35157. private _scene;
  35158. /**
  35159. * Creates a new InputManager
  35160. * @param scene defines the hosting scene
  35161. */
  35162. constructor(scene: Scene);
  35163. /**
  35164. * Gets the mesh that is currently under the pointer
  35165. */
  35166. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35167. /**
  35168. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35169. */
  35170. readonly unTranslatedPointer: Vector2;
  35171. /**
  35172. * Gets or sets the current on-screen X position of the pointer
  35173. */
  35174. pointerX: number;
  35175. /**
  35176. * Gets or sets the current on-screen Y position of the pointer
  35177. */
  35178. pointerY: number;
  35179. private _updatePointerPosition;
  35180. private _processPointerMove;
  35181. private _setRayOnPointerInfo;
  35182. private _checkPrePointerObservable;
  35183. /**
  35184. * Use this method to simulate a pointer move on a mesh
  35185. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35186. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35187. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35188. */
  35189. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35190. /**
  35191. * Use this method to simulate a pointer down on a mesh
  35192. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35193. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35194. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35195. */
  35196. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35197. private _processPointerDown;
  35198. /** @hidden */
  35199. _isPointerSwiping(): boolean;
  35200. /**
  35201. * Use this method to simulate a pointer up on a mesh
  35202. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35203. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35204. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35205. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35206. */
  35207. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35208. private _processPointerUp;
  35209. /**
  35210. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35211. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35212. * @returns true if the pointer was captured
  35213. */
  35214. isPointerCaptured(pointerId?: number): boolean;
  35215. /**
  35216. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35217. * @param attachUp defines if you want to attach events to pointerup
  35218. * @param attachDown defines if you want to attach events to pointerdown
  35219. * @param attachMove defines if you want to attach events to pointermove
  35220. */
  35221. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35222. /**
  35223. * Detaches all event handlers
  35224. */
  35225. detachControl(): void;
  35226. /**
  35227. * Force the value of meshUnderPointer
  35228. * @param mesh defines the mesh to use
  35229. */
  35230. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35231. /**
  35232. * Gets the mesh under the pointer
  35233. * @returns a Mesh or null if no mesh is under the pointer
  35234. */
  35235. getPointerOverMesh(): Nullable<AbstractMesh>;
  35236. }
  35237. }
  35238. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35239. /**
  35240. * Helper class used to generate session unique ID
  35241. */
  35242. export class UniqueIdGenerator {
  35243. private static _UniqueIdCounter;
  35244. /**
  35245. * Gets an unique (relatively to the current scene) Id
  35246. */
  35247. static readonly UniqueId: number;
  35248. }
  35249. }
  35250. declare module "babylonjs/Animations/animationGroup" {
  35251. import { Animatable } from "babylonjs/Animations/animatable";
  35252. import { Animation } from "babylonjs/Animations/animation";
  35253. import { Scene, IDisposable } from "babylonjs/scene";
  35254. import { Observable } from "babylonjs/Misc/observable";
  35255. import { Nullable } from "babylonjs/types";
  35256. import "babylonjs/Animations/animatable";
  35257. /**
  35258. * This class defines the direct association between an animation and a target
  35259. */
  35260. export class TargetedAnimation {
  35261. /**
  35262. * Animation to perform
  35263. */
  35264. animation: Animation;
  35265. /**
  35266. * Target to animate
  35267. */
  35268. target: any;
  35269. /**
  35270. * Serialize the object
  35271. * @returns the JSON object representing the current entity
  35272. */
  35273. serialize(): any;
  35274. }
  35275. /**
  35276. * Use this class to create coordinated animations on multiple targets
  35277. */
  35278. export class AnimationGroup implements IDisposable {
  35279. /** The name of the animation group */
  35280. name: string;
  35281. private _scene;
  35282. private _targetedAnimations;
  35283. private _animatables;
  35284. private _from;
  35285. private _to;
  35286. private _isStarted;
  35287. private _isPaused;
  35288. private _speedRatio;
  35289. private _loopAnimation;
  35290. /**
  35291. * Gets or sets the unique id of the node
  35292. */
  35293. uniqueId: number;
  35294. /**
  35295. * This observable will notify when one animation have ended
  35296. */
  35297. onAnimationEndObservable: Observable<TargetedAnimation>;
  35298. /**
  35299. * Observer raised when one animation loops
  35300. */
  35301. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35302. /**
  35303. * Observer raised when all animations have looped
  35304. */
  35305. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35306. /**
  35307. * This observable will notify when all animations have ended.
  35308. */
  35309. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35310. /**
  35311. * This observable will notify when all animations have paused.
  35312. */
  35313. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35314. /**
  35315. * This observable will notify when all animations are playing.
  35316. */
  35317. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35318. /**
  35319. * Gets the first frame
  35320. */
  35321. readonly from: number;
  35322. /**
  35323. * Gets the last frame
  35324. */
  35325. readonly to: number;
  35326. /**
  35327. * Define if the animations are started
  35328. */
  35329. readonly isStarted: boolean;
  35330. /**
  35331. * Gets a value indicating that the current group is playing
  35332. */
  35333. readonly isPlaying: boolean;
  35334. /**
  35335. * Gets or sets the speed ratio to use for all animations
  35336. */
  35337. /**
  35338. * Gets or sets the speed ratio to use for all animations
  35339. */
  35340. speedRatio: number;
  35341. /**
  35342. * Gets or sets if all animations should loop or not
  35343. */
  35344. loopAnimation: boolean;
  35345. /**
  35346. * Gets the targeted animations for this animation group
  35347. */
  35348. readonly targetedAnimations: Array<TargetedAnimation>;
  35349. /**
  35350. * returning the list of animatables controlled by this animation group.
  35351. */
  35352. readonly animatables: Array<Animatable>;
  35353. /**
  35354. * Instantiates a new Animation Group.
  35355. * This helps managing several animations at once.
  35356. * @see http://doc.babylonjs.com/how_to/group
  35357. * @param name Defines the name of the group
  35358. * @param scene Defines the scene the group belongs to
  35359. */
  35360. constructor(
  35361. /** The name of the animation group */
  35362. name: string, scene?: Nullable<Scene>);
  35363. /**
  35364. * Add an animation (with its target) in the group
  35365. * @param animation defines the animation we want to add
  35366. * @param target defines the target of the animation
  35367. * @returns the TargetedAnimation object
  35368. */
  35369. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35370. /**
  35371. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35372. * It can add constant keys at begin or end
  35373. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35374. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35375. * @returns the animation group
  35376. */
  35377. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35378. private _animationLoopCount;
  35379. private _animationLoopFlags;
  35380. private _processLoop;
  35381. /**
  35382. * Start all animations on given targets
  35383. * @param loop defines if animations must loop
  35384. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35385. * @param from defines the from key (optional)
  35386. * @param to defines the to key (optional)
  35387. * @returns the current animation group
  35388. */
  35389. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35390. /**
  35391. * Pause all animations
  35392. * @returns the animation group
  35393. */
  35394. pause(): AnimationGroup;
  35395. /**
  35396. * Play all animations to initial state
  35397. * This function will start() the animations if they were not started or will restart() them if they were paused
  35398. * @param loop defines if animations must loop
  35399. * @returns the animation group
  35400. */
  35401. play(loop?: boolean): AnimationGroup;
  35402. /**
  35403. * Reset all animations to initial state
  35404. * @returns the animation group
  35405. */
  35406. reset(): AnimationGroup;
  35407. /**
  35408. * Restart animations from key 0
  35409. * @returns the animation group
  35410. */
  35411. restart(): AnimationGroup;
  35412. /**
  35413. * Stop all animations
  35414. * @returns the animation group
  35415. */
  35416. stop(): AnimationGroup;
  35417. /**
  35418. * Set animation weight for all animatables
  35419. * @param weight defines the weight to use
  35420. * @return the animationGroup
  35421. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35422. */
  35423. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35424. /**
  35425. * Synchronize and normalize all animatables with a source animatable
  35426. * @param root defines the root animatable to synchronize with
  35427. * @return the animationGroup
  35428. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35429. */
  35430. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35431. /**
  35432. * Goes to a specific frame in this animation group
  35433. * @param frame the frame number to go to
  35434. * @return the animationGroup
  35435. */
  35436. goToFrame(frame: number): AnimationGroup;
  35437. /**
  35438. * Dispose all associated resources
  35439. */
  35440. dispose(): void;
  35441. private _checkAnimationGroupEnded;
  35442. /**
  35443. * Clone the current animation group and returns a copy
  35444. * @param newName defines the name of the new group
  35445. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35446. * @returns the new aniamtion group
  35447. */
  35448. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35449. /**
  35450. * Serializes the animationGroup to an object
  35451. * @returns Serialized object
  35452. */
  35453. serialize(): any;
  35454. /**
  35455. * Returns a new AnimationGroup object parsed from the source provided.
  35456. * @param parsedAnimationGroup defines the source
  35457. * @param scene defines the scene that will receive the animationGroup
  35458. * @returns a new AnimationGroup
  35459. */
  35460. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35461. /**
  35462. * Returns the string "AnimationGroup"
  35463. * @returns "AnimationGroup"
  35464. */
  35465. getClassName(): string;
  35466. /**
  35467. * Creates a detailled string about the object
  35468. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35469. * @returns a string representing the object
  35470. */
  35471. toString(fullDetails?: boolean): string;
  35472. }
  35473. }
  35474. declare module "babylonjs/scene" {
  35475. import { Nullable } from "babylonjs/types";
  35476. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35477. import { Observable } from "babylonjs/Misc/observable";
  35478. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35479. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35480. import { Geometry } from "babylonjs/Meshes/geometry";
  35481. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35484. import { Mesh } from "babylonjs/Meshes/mesh";
  35485. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35486. import { Bone } from "babylonjs/Bones/bone";
  35487. import { Skeleton } from "babylonjs/Bones/skeleton";
  35488. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35489. import { Camera } from "babylonjs/Cameras/camera";
  35490. import { AbstractScene } from "babylonjs/abstractScene";
  35491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35492. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35493. import { Material } from "babylonjs/Materials/material";
  35494. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35495. import { Effect } from "babylonjs/Materials/effect";
  35496. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35497. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35498. import { Light } from "babylonjs/Lights/light";
  35499. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35500. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35501. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35502. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35503. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35504. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35505. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35506. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35507. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35508. import { Engine } from "babylonjs/Engines/engine";
  35509. import { Node } from "babylonjs/node";
  35510. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35511. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35512. import { WebRequest } from "babylonjs/Misc/webRequest";
  35513. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35514. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35515. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35516. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35517. import { Plane } from "babylonjs/Maths/math.plane";
  35518. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35519. import { Ray } from "babylonjs/Culling/ray";
  35520. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35521. import { Animation } from "babylonjs/Animations/animation";
  35522. import { Animatable } from "babylonjs/Animations/animatable";
  35523. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35524. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35525. import { Collider } from "babylonjs/Collisions/collider";
  35526. /**
  35527. * Define an interface for all classes that will hold resources
  35528. */
  35529. export interface IDisposable {
  35530. /**
  35531. * Releases all held resources
  35532. */
  35533. dispose(): void;
  35534. }
  35535. /** Interface defining initialization parameters for Scene class */
  35536. export interface SceneOptions {
  35537. /**
  35538. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35539. * It will improve performance when the number of geometries becomes important.
  35540. */
  35541. useGeometryUniqueIdsMap?: boolean;
  35542. /**
  35543. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35544. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35545. */
  35546. useMaterialMeshMap?: boolean;
  35547. /**
  35548. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35549. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35550. */
  35551. useClonedMeshhMap?: boolean;
  35552. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35553. virtual?: boolean;
  35554. }
  35555. /**
  35556. * Represents a scene to be rendered by the engine.
  35557. * @see http://doc.babylonjs.com/features/scene
  35558. */
  35559. export class Scene extends AbstractScene implements IAnimatable {
  35560. /** The fog is deactivated */
  35561. static readonly FOGMODE_NONE: number;
  35562. /** The fog density is following an exponential function */
  35563. static readonly FOGMODE_EXP: number;
  35564. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35565. static readonly FOGMODE_EXP2: number;
  35566. /** The fog density is following a linear function. */
  35567. static readonly FOGMODE_LINEAR: number;
  35568. /**
  35569. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35570. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35571. */
  35572. static MinDeltaTime: number;
  35573. /**
  35574. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35575. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35576. */
  35577. static MaxDeltaTime: number;
  35578. /**
  35579. * Factory used to create the default material.
  35580. * @param name The name of the material to create
  35581. * @param scene The scene to create the material for
  35582. * @returns The default material
  35583. */
  35584. static DefaultMaterialFactory(scene: Scene): Material;
  35585. /**
  35586. * Factory used to create the a collision coordinator.
  35587. * @returns The collision coordinator
  35588. */
  35589. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35590. /** @hidden */
  35591. _inputManager: InputManager;
  35592. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35593. cameraToUseForPointers: Nullable<Camera>;
  35594. /** @hidden */
  35595. readonly _isScene: boolean;
  35596. /**
  35597. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35598. */
  35599. autoClear: boolean;
  35600. /**
  35601. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35602. */
  35603. autoClearDepthAndStencil: boolean;
  35604. /**
  35605. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35606. */
  35607. clearColor: Color4;
  35608. /**
  35609. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35610. */
  35611. ambientColor: Color3;
  35612. /**
  35613. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35614. * It should only be one of the following (if not the default embedded one):
  35615. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35616. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35617. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35618. * The material properties need to be setup according to the type of texture in use.
  35619. */
  35620. environmentBRDFTexture: BaseTexture;
  35621. /** @hidden */
  35622. protected _environmentTexture: Nullable<BaseTexture>;
  35623. /**
  35624. * Texture used in all pbr material as the reflection texture.
  35625. * As in the majority of the scene they are the same (exception for multi room and so on),
  35626. * this is easier to reference from here than from all the materials.
  35627. */
  35628. /**
  35629. * Texture used in all pbr material as the reflection texture.
  35630. * As in the majority of the scene they are the same (exception for multi room and so on),
  35631. * this is easier to set here than in all the materials.
  35632. */
  35633. environmentTexture: Nullable<BaseTexture>;
  35634. /** @hidden */
  35635. protected _environmentIntensity: number;
  35636. /**
  35637. * Intensity of the environment in all pbr material.
  35638. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35639. * As in the majority of the scene they are the same (exception for multi room and so on),
  35640. * this is easier to reference from here than from all the materials.
  35641. */
  35642. /**
  35643. * Intensity of the environment in all pbr material.
  35644. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35645. * As in the majority of the scene they are the same (exception for multi room and so on),
  35646. * this is easier to set here than in all the materials.
  35647. */
  35648. environmentIntensity: number;
  35649. /** @hidden */
  35650. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35651. /**
  35652. * Default image processing configuration used either in the rendering
  35653. * Forward main pass or through the imageProcessingPostProcess if present.
  35654. * As in the majority of the scene they are the same (exception for multi camera),
  35655. * this is easier to reference from here than from all the materials and post process.
  35656. *
  35657. * No setter as we it is a shared configuration, you can set the values instead.
  35658. */
  35659. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  35660. private _forceWireframe;
  35661. /**
  35662. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35663. */
  35664. forceWireframe: boolean;
  35665. private _forcePointsCloud;
  35666. /**
  35667. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35668. */
  35669. forcePointsCloud: boolean;
  35670. /**
  35671. * Gets or sets the active clipplane 1
  35672. */
  35673. clipPlane: Nullable<Plane>;
  35674. /**
  35675. * Gets or sets the active clipplane 2
  35676. */
  35677. clipPlane2: Nullable<Plane>;
  35678. /**
  35679. * Gets or sets the active clipplane 3
  35680. */
  35681. clipPlane3: Nullable<Plane>;
  35682. /**
  35683. * Gets or sets the active clipplane 4
  35684. */
  35685. clipPlane4: Nullable<Plane>;
  35686. /**
  35687. * Gets or sets a boolean indicating if animations are enabled
  35688. */
  35689. animationsEnabled: boolean;
  35690. private _animationPropertiesOverride;
  35691. /**
  35692. * Gets or sets the animation properties override
  35693. */
  35694. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  35695. /**
  35696. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35697. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35698. */
  35699. useConstantAnimationDeltaTime: boolean;
  35700. /**
  35701. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35702. * Please note that it requires to run a ray cast through the scene on every frame
  35703. */
  35704. constantlyUpdateMeshUnderPointer: boolean;
  35705. /**
  35706. * Defines the HTML cursor to use when hovering over interactive elements
  35707. */
  35708. hoverCursor: string;
  35709. /**
  35710. * Defines the HTML default cursor to use (empty by default)
  35711. */
  35712. defaultCursor: string;
  35713. /**
  35714. * Defines wether cursors are handled by the scene.
  35715. */
  35716. doNotHandleCursors: boolean;
  35717. /**
  35718. * This is used to call preventDefault() on pointer down
  35719. * in order to block unwanted artifacts like system double clicks
  35720. */
  35721. preventDefaultOnPointerDown: boolean;
  35722. /**
  35723. * This is used to call preventDefault() on pointer up
  35724. * in order to block unwanted artifacts like system double clicks
  35725. */
  35726. preventDefaultOnPointerUp: boolean;
  35727. /**
  35728. * Gets or sets user defined metadata
  35729. */
  35730. metadata: any;
  35731. /**
  35732. * For internal use only. Please do not use.
  35733. */
  35734. reservedDataStore: any;
  35735. /**
  35736. * Gets the name of the plugin used to load this scene (null by default)
  35737. */
  35738. loadingPluginName: string;
  35739. /**
  35740. * Use this array to add regular expressions used to disable offline support for specific urls
  35741. */
  35742. disableOfflineSupportExceptionRules: RegExp[];
  35743. /**
  35744. * An event triggered when the scene is disposed.
  35745. */
  35746. onDisposeObservable: Observable<Scene>;
  35747. private _onDisposeObserver;
  35748. /** Sets a function to be executed when this scene is disposed. */
  35749. onDispose: () => void;
  35750. /**
  35751. * An event triggered before rendering the scene (right after animations and physics)
  35752. */
  35753. onBeforeRenderObservable: Observable<Scene>;
  35754. private _onBeforeRenderObserver;
  35755. /** Sets a function to be executed before rendering this scene */
  35756. beforeRender: Nullable<() => void>;
  35757. /**
  35758. * An event triggered after rendering the scene
  35759. */
  35760. onAfterRenderObservable: Observable<Scene>;
  35761. /**
  35762. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35763. */
  35764. onAfterRenderCameraObservable: Observable<Camera>;
  35765. private _onAfterRenderObserver;
  35766. /** Sets a function to be executed after rendering this scene */
  35767. afterRender: Nullable<() => void>;
  35768. /**
  35769. * An event triggered before animating the scene
  35770. */
  35771. onBeforeAnimationsObservable: Observable<Scene>;
  35772. /**
  35773. * An event triggered after animations processing
  35774. */
  35775. onAfterAnimationsObservable: Observable<Scene>;
  35776. /**
  35777. * An event triggered before draw calls are ready to be sent
  35778. */
  35779. onBeforeDrawPhaseObservable: Observable<Scene>;
  35780. /**
  35781. * An event triggered after draw calls have been sent
  35782. */
  35783. onAfterDrawPhaseObservable: Observable<Scene>;
  35784. /**
  35785. * An event triggered when the scene is ready
  35786. */
  35787. onReadyObservable: Observable<Scene>;
  35788. /**
  35789. * An event triggered before rendering a camera
  35790. */
  35791. onBeforeCameraRenderObservable: Observable<Camera>;
  35792. private _onBeforeCameraRenderObserver;
  35793. /** Sets a function to be executed before rendering a camera*/
  35794. beforeCameraRender: () => void;
  35795. /**
  35796. * An event triggered after rendering a camera
  35797. */
  35798. onAfterCameraRenderObservable: Observable<Camera>;
  35799. private _onAfterCameraRenderObserver;
  35800. /** Sets a function to be executed after rendering a camera*/
  35801. afterCameraRender: () => void;
  35802. /**
  35803. * An event triggered when active meshes evaluation is about to start
  35804. */
  35805. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35806. /**
  35807. * An event triggered when active meshes evaluation is done
  35808. */
  35809. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35810. /**
  35811. * An event triggered when particles rendering is about to start
  35812. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35813. */
  35814. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35815. /**
  35816. * An event triggered when particles rendering is done
  35817. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35818. */
  35819. onAfterParticlesRenderingObservable: Observable<Scene>;
  35820. /**
  35821. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35822. */
  35823. onDataLoadedObservable: Observable<Scene>;
  35824. /**
  35825. * An event triggered when a camera is created
  35826. */
  35827. onNewCameraAddedObservable: Observable<Camera>;
  35828. /**
  35829. * An event triggered when a camera is removed
  35830. */
  35831. onCameraRemovedObservable: Observable<Camera>;
  35832. /**
  35833. * An event triggered when a light is created
  35834. */
  35835. onNewLightAddedObservable: Observable<Light>;
  35836. /**
  35837. * An event triggered when a light is removed
  35838. */
  35839. onLightRemovedObservable: Observable<Light>;
  35840. /**
  35841. * An event triggered when a geometry is created
  35842. */
  35843. onNewGeometryAddedObservable: Observable<Geometry>;
  35844. /**
  35845. * An event triggered when a geometry is removed
  35846. */
  35847. onGeometryRemovedObservable: Observable<Geometry>;
  35848. /**
  35849. * An event triggered when a transform node is created
  35850. */
  35851. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35852. /**
  35853. * An event triggered when a transform node is removed
  35854. */
  35855. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35856. /**
  35857. * An event triggered when a mesh is created
  35858. */
  35859. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35860. /**
  35861. * An event triggered when a mesh is removed
  35862. */
  35863. onMeshRemovedObservable: Observable<AbstractMesh>;
  35864. /**
  35865. * An event triggered when a skeleton is created
  35866. */
  35867. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35868. /**
  35869. * An event triggered when a skeleton is removed
  35870. */
  35871. onSkeletonRemovedObservable: Observable<Skeleton>;
  35872. /**
  35873. * An event triggered when a material is created
  35874. */
  35875. onNewMaterialAddedObservable: Observable<Material>;
  35876. /**
  35877. * An event triggered when a material is removed
  35878. */
  35879. onMaterialRemovedObservable: Observable<Material>;
  35880. /**
  35881. * An event triggered when a texture is created
  35882. */
  35883. onNewTextureAddedObservable: Observable<BaseTexture>;
  35884. /**
  35885. * An event triggered when a texture is removed
  35886. */
  35887. onTextureRemovedObservable: Observable<BaseTexture>;
  35888. /**
  35889. * An event triggered when render targets are about to be rendered
  35890. * Can happen multiple times per frame.
  35891. */
  35892. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35893. /**
  35894. * An event triggered when render targets were rendered.
  35895. * Can happen multiple times per frame.
  35896. */
  35897. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35898. /**
  35899. * An event triggered before calculating deterministic simulation step
  35900. */
  35901. onBeforeStepObservable: Observable<Scene>;
  35902. /**
  35903. * An event triggered after calculating deterministic simulation step
  35904. */
  35905. onAfterStepObservable: Observable<Scene>;
  35906. /**
  35907. * An event triggered when the activeCamera property is updated
  35908. */
  35909. onActiveCameraChanged: Observable<Scene>;
  35910. /**
  35911. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35912. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35913. * 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)
  35914. */
  35915. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35916. /**
  35917. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35918. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35919. * 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)
  35920. */
  35921. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35922. /**
  35923. * This Observable will when a mesh has been imported into the scene.
  35924. */
  35925. onMeshImportedObservable: Observable<AbstractMesh>;
  35926. /**
  35927. * This Observable will when an animation file has been imported into the scene.
  35928. */
  35929. onAnimationFileImportedObservable: Observable<Scene>;
  35930. /**
  35931. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35932. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35933. */
  35934. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35935. /** @hidden */
  35936. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35937. /**
  35938. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35939. */
  35940. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35941. /**
  35942. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35943. */
  35944. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35945. /**
  35946. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35947. */
  35948. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35949. /** Callback called when a pointer move is detected */
  35950. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35951. /** Callback called when a pointer down is detected */
  35952. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35953. /** Callback called when a pointer up is detected */
  35954. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35955. /** Callback called when a pointer pick is detected */
  35956. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35957. /**
  35958. * 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).
  35959. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35960. */
  35961. onPrePointerObservable: Observable<PointerInfoPre>;
  35962. /**
  35963. * Observable event triggered each time an input event is received from the rendering canvas
  35964. */
  35965. onPointerObservable: Observable<PointerInfo>;
  35966. /**
  35967. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35968. */
  35969. readonly unTranslatedPointer: Vector2;
  35970. /**
  35971. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35972. */
  35973. static DragMovementThreshold: number;
  35974. /**
  35975. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35976. */
  35977. static LongPressDelay: number;
  35978. /**
  35979. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35980. */
  35981. static DoubleClickDelay: number;
  35982. /** If you need to check double click without raising a single click at first click, enable this flag */
  35983. static ExclusiveDoubleClickMode: boolean;
  35984. /** @hidden */
  35985. _mirroredCameraPosition: Nullable<Vector3>;
  35986. /**
  35987. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35988. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35989. */
  35990. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35991. /**
  35992. * Observable event triggered each time an keyboard event is received from the hosting window
  35993. */
  35994. onKeyboardObservable: Observable<KeyboardInfo>;
  35995. private _useRightHandedSystem;
  35996. /**
  35997. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35998. */
  35999. useRightHandedSystem: boolean;
  36000. private _timeAccumulator;
  36001. private _currentStepId;
  36002. private _currentInternalStep;
  36003. /**
  36004. * Sets the step Id used by deterministic lock step
  36005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36006. * @param newStepId defines the step Id
  36007. */
  36008. setStepId(newStepId: number): void;
  36009. /**
  36010. * Gets the step Id used by deterministic lock step
  36011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36012. * @returns the step Id
  36013. */
  36014. getStepId(): number;
  36015. /**
  36016. * Gets the internal step used by deterministic lock step
  36017. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36018. * @returns the internal step
  36019. */
  36020. getInternalStep(): number;
  36021. private _fogEnabled;
  36022. /**
  36023. * Gets or sets a boolean indicating if fog is enabled on this scene
  36024. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36025. * (Default is true)
  36026. */
  36027. fogEnabled: boolean;
  36028. private _fogMode;
  36029. /**
  36030. * Gets or sets the fog mode to use
  36031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36032. * | mode | value |
  36033. * | --- | --- |
  36034. * | FOGMODE_NONE | 0 |
  36035. * | FOGMODE_EXP | 1 |
  36036. * | FOGMODE_EXP2 | 2 |
  36037. * | FOGMODE_LINEAR | 3 |
  36038. */
  36039. fogMode: number;
  36040. /**
  36041. * Gets or sets the fog color to use
  36042. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36043. * (Default is Color3(0.2, 0.2, 0.3))
  36044. */
  36045. fogColor: Color3;
  36046. /**
  36047. * Gets or sets the fog density to use
  36048. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36049. * (Default is 0.1)
  36050. */
  36051. fogDensity: number;
  36052. /**
  36053. * Gets or sets the fog start distance to use
  36054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36055. * (Default is 0)
  36056. */
  36057. fogStart: number;
  36058. /**
  36059. * Gets or sets the fog end distance to use
  36060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36061. * (Default is 1000)
  36062. */
  36063. fogEnd: number;
  36064. private _shadowsEnabled;
  36065. /**
  36066. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36067. */
  36068. shadowsEnabled: boolean;
  36069. private _lightsEnabled;
  36070. /**
  36071. * Gets or sets a boolean indicating if lights are enabled on this scene
  36072. */
  36073. lightsEnabled: boolean;
  36074. /** All of the active cameras added to this scene. */
  36075. activeCameras: Camera[];
  36076. /** @hidden */
  36077. _activeCamera: Nullable<Camera>;
  36078. /** Gets or sets the current active camera */
  36079. activeCamera: Nullable<Camera>;
  36080. private _defaultMaterial;
  36081. /** The default material used on meshes when no material is affected */
  36082. /** The default material used on meshes when no material is affected */
  36083. defaultMaterial: Material;
  36084. private _texturesEnabled;
  36085. /**
  36086. * Gets or sets a boolean indicating if textures are enabled on this scene
  36087. */
  36088. texturesEnabled: boolean;
  36089. /**
  36090. * Gets or sets a boolean indicating if particles are enabled on this scene
  36091. */
  36092. particlesEnabled: boolean;
  36093. /**
  36094. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36095. */
  36096. spritesEnabled: boolean;
  36097. private _skeletonsEnabled;
  36098. /**
  36099. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36100. */
  36101. skeletonsEnabled: boolean;
  36102. /**
  36103. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36104. */
  36105. lensFlaresEnabled: boolean;
  36106. /**
  36107. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36108. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36109. */
  36110. collisionsEnabled: boolean;
  36111. private _collisionCoordinator;
  36112. /** @hidden */
  36113. readonly collisionCoordinator: ICollisionCoordinator;
  36114. /**
  36115. * Defines the gravity applied to this scene (used only for collisions)
  36116. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36117. */
  36118. gravity: Vector3;
  36119. /**
  36120. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36121. */
  36122. postProcessesEnabled: boolean;
  36123. /**
  36124. * The list of postprocesses added to the scene
  36125. */
  36126. postProcesses: PostProcess[];
  36127. /**
  36128. * Gets the current postprocess manager
  36129. */
  36130. postProcessManager: PostProcessManager;
  36131. /**
  36132. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36133. */
  36134. renderTargetsEnabled: boolean;
  36135. /**
  36136. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36137. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36138. */
  36139. dumpNextRenderTargets: boolean;
  36140. /**
  36141. * The list of user defined render targets added to the scene
  36142. */
  36143. customRenderTargets: RenderTargetTexture[];
  36144. /**
  36145. * Defines if texture loading must be delayed
  36146. * If true, textures will only be loaded when they need to be rendered
  36147. */
  36148. useDelayedTextureLoading: boolean;
  36149. /**
  36150. * Gets the list of meshes imported to the scene through SceneLoader
  36151. */
  36152. importedMeshesFiles: String[];
  36153. /**
  36154. * Gets or sets a boolean indicating if probes are enabled on this scene
  36155. */
  36156. probesEnabled: boolean;
  36157. /**
  36158. * Gets or sets the current offline provider to use to store scene data
  36159. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36160. */
  36161. offlineProvider: IOfflineProvider;
  36162. /**
  36163. * Gets or sets the action manager associated with the scene
  36164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36165. */
  36166. actionManager: AbstractActionManager;
  36167. private _meshesForIntersections;
  36168. /**
  36169. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36170. */
  36171. proceduralTexturesEnabled: boolean;
  36172. private _engine;
  36173. private _totalVertices;
  36174. /** @hidden */
  36175. _activeIndices: PerfCounter;
  36176. /** @hidden */
  36177. _activeParticles: PerfCounter;
  36178. /** @hidden */
  36179. _activeBones: PerfCounter;
  36180. private _animationRatio;
  36181. /** @hidden */
  36182. _animationTimeLast: number;
  36183. /** @hidden */
  36184. _animationTime: number;
  36185. /**
  36186. * Gets or sets a general scale for animation speed
  36187. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36188. */
  36189. animationTimeScale: number;
  36190. /** @hidden */
  36191. _cachedMaterial: Nullable<Material>;
  36192. /** @hidden */
  36193. _cachedEffect: Nullable<Effect>;
  36194. /** @hidden */
  36195. _cachedVisibility: Nullable<number>;
  36196. private _renderId;
  36197. private _frameId;
  36198. private _executeWhenReadyTimeoutId;
  36199. private _intermediateRendering;
  36200. private _viewUpdateFlag;
  36201. private _projectionUpdateFlag;
  36202. /** @hidden */
  36203. _toBeDisposed: Nullable<IDisposable>[];
  36204. private _activeRequests;
  36205. /** @hidden */
  36206. _pendingData: any[];
  36207. private _isDisposed;
  36208. /**
  36209. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36210. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36211. */
  36212. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36213. private _activeMeshes;
  36214. private _processedMaterials;
  36215. private _renderTargets;
  36216. /** @hidden */
  36217. _activeParticleSystems: SmartArray<IParticleSystem>;
  36218. private _activeSkeletons;
  36219. private _softwareSkinnedMeshes;
  36220. private _renderingManager;
  36221. /** @hidden */
  36222. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36223. private _transformMatrix;
  36224. private _sceneUbo;
  36225. /** @hidden */
  36226. _viewMatrix: Matrix;
  36227. private _projectionMatrix;
  36228. /** @hidden */
  36229. _forcedViewPosition: Nullable<Vector3>;
  36230. /** @hidden */
  36231. _frustumPlanes: Plane[];
  36232. /**
  36233. * Gets the list of frustum planes (built from the active camera)
  36234. */
  36235. readonly frustumPlanes: Plane[];
  36236. /**
  36237. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36238. * This is useful if there are more lights that the maximum simulteanous authorized
  36239. */
  36240. requireLightSorting: boolean;
  36241. /** @hidden */
  36242. readonly useMaterialMeshMap: boolean;
  36243. /** @hidden */
  36244. readonly useClonedMeshhMap: boolean;
  36245. private _externalData;
  36246. private _uid;
  36247. /**
  36248. * @hidden
  36249. * Backing store of defined scene components.
  36250. */
  36251. _components: ISceneComponent[];
  36252. /**
  36253. * @hidden
  36254. * Backing store of defined scene components.
  36255. */
  36256. _serializableComponents: ISceneSerializableComponent[];
  36257. /**
  36258. * List of components to register on the next registration step.
  36259. */
  36260. private _transientComponents;
  36261. /**
  36262. * Registers the transient components if needed.
  36263. */
  36264. private _registerTransientComponents;
  36265. /**
  36266. * @hidden
  36267. * Add a component to the scene.
  36268. * Note that the ccomponent could be registered on th next frame if this is called after
  36269. * the register component stage.
  36270. * @param component Defines the component to add to the scene
  36271. */
  36272. _addComponent(component: ISceneComponent): void;
  36273. /**
  36274. * @hidden
  36275. * Gets a component from the scene.
  36276. * @param name defines the name of the component to retrieve
  36277. * @returns the component or null if not present
  36278. */
  36279. _getComponent(name: string): Nullable<ISceneComponent>;
  36280. /**
  36281. * @hidden
  36282. * Defines the actions happening before camera updates.
  36283. */
  36284. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36285. /**
  36286. * @hidden
  36287. * Defines the actions happening before clear the canvas.
  36288. */
  36289. _beforeClearStage: Stage<SimpleStageAction>;
  36290. /**
  36291. * @hidden
  36292. * Defines the actions when collecting render targets for the frame.
  36293. */
  36294. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36295. /**
  36296. * @hidden
  36297. * Defines the actions happening for one camera in the frame.
  36298. */
  36299. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36300. /**
  36301. * @hidden
  36302. * Defines the actions happening during the per mesh ready checks.
  36303. */
  36304. _isReadyForMeshStage: Stage<MeshStageAction>;
  36305. /**
  36306. * @hidden
  36307. * Defines the actions happening before evaluate active mesh checks.
  36308. */
  36309. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36310. /**
  36311. * @hidden
  36312. * Defines the actions happening during the evaluate sub mesh checks.
  36313. */
  36314. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36315. /**
  36316. * @hidden
  36317. * Defines the actions happening during the active mesh stage.
  36318. */
  36319. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36320. /**
  36321. * @hidden
  36322. * Defines the actions happening during the per camera render target step.
  36323. */
  36324. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36325. /**
  36326. * @hidden
  36327. * Defines the actions happening just before the active camera is drawing.
  36328. */
  36329. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36330. /**
  36331. * @hidden
  36332. * Defines the actions happening just before a render target is drawing.
  36333. */
  36334. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36335. /**
  36336. * @hidden
  36337. * Defines the actions happening just before a rendering group is drawing.
  36338. */
  36339. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36340. /**
  36341. * @hidden
  36342. * Defines the actions happening just before a mesh is drawing.
  36343. */
  36344. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36345. /**
  36346. * @hidden
  36347. * Defines the actions happening just after a mesh has been drawn.
  36348. */
  36349. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36350. /**
  36351. * @hidden
  36352. * Defines the actions happening just after a rendering group has been drawn.
  36353. */
  36354. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36355. /**
  36356. * @hidden
  36357. * Defines the actions happening just after the active camera has been drawn.
  36358. */
  36359. _afterCameraDrawStage: Stage<CameraStageAction>;
  36360. /**
  36361. * @hidden
  36362. * Defines the actions happening just after a render target has been drawn.
  36363. */
  36364. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36365. /**
  36366. * @hidden
  36367. * Defines the actions happening just after rendering all cameras and computing intersections.
  36368. */
  36369. _afterRenderStage: Stage<SimpleStageAction>;
  36370. /**
  36371. * @hidden
  36372. * Defines the actions happening when a pointer move event happens.
  36373. */
  36374. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36375. /**
  36376. * @hidden
  36377. * Defines the actions happening when a pointer down event happens.
  36378. */
  36379. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36380. /**
  36381. * @hidden
  36382. * Defines the actions happening when a pointer up event happens.
  36383. */
  36384. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36385. /**
  36386. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36387. */
  36388. private geometriesByUniqueId;
  36389. /**
  36390. * Creates a new Scene
  36391. * @param engine defines the engine to use to render this scene
  36392. * @param options defines the scene options
  36393. */
  36394. constructor(engine: Engine, options?: SceneOptions);
  36395. /**
  36396. * Gets a string idenfifying the name of the class
  36397. * @returns "Scene" string
  36398. */
  36399. getClassName(): string;
  36400. private _defaultMeshCandidates;
  36401. /**
  36402. * @hidden
  36403. */
  36404. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36405. private _defaultSubMeshCandidates;
  36406. /**
  36407. * @hidden
  36408. */
  36409. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36410. /**
  36411. * Sets the default candidate providers for the scene.
  36412. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36413. * and getCollidingSubMeshCandidates to their default function
  36414. */
  36415. setDefaultCandidateProviders(): void;
  36416. /**
  36417. * Gets the mesh that is currently under the pointer
  36418. */
  36419. readonly meshUnderPointer: Nullable<AbstractMesh>;
  36420. /**
  36421. * Gets or sets the current on-screen X position of the pointer
  36422. */
  36423. pointerX: number;
  36424. /**
  36425. * Gets or sets the current on-screen Y position of the pointer
  36426. */
  36427. pointerY: number;
  36428. /**
  36429. * Gets the cached material (ie. the latest rendered one)
  36430. * @returns the cached material
  36431. */
  36432. getCachedMaterial(): Nullable<Material>;
  36433. /**
  36434. * Gets the cached effect (ie. the latest rendered one)
  36435. * @returns the cached effect
  36436. */
  36437. getCachedEffect(): Nullable<Effect>;
  36438. /**
  36439. * Gets the cached visibility state (ie. the latest rendered one)
  36440. * @returns the cached visibility state
  36441. */
  36442. getCachedVisibility(): Nullable<number>;
  36443. /**
  36444. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36445. * @param material defines the current material
  36446. * @param effect defines the current effect
  36447. * @param visibility defines the current visibility state
  36448. * @returns true if one parameter is not cached
  36449. */
  36450. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36451. /**
  36452. * Gets the engine associated with the scene
  36453. * @returns an Engine
  36454. */
  36455. getEngine(): Engine;
  36456. /**
  36457. * Gets the total number of vertices rendered per frame
  36458. * @returns the total number of vertices rendered per frame
  36459. */
  36460. getTotalVertices(): number;
  36461. /**
  36462. * Gets the performance counter for total vertices
  36463. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36464. */
  36465. readonly totalVerticesPerfCounter: PerfCounter;
  36466. /**
  36467. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36468. * @returns the total number of active indices rendered per frame
  36469. */
  36470. getActiveIndices(): number;
  36471. /**
  36472. * Gets the performance counter for active indices
  36473. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36474. */
  36475. readonly totalActiveIndicesPerfCounter: PerfCounter;
  36476. /**
  36477. * Gets the total number of active particles rendered per frame
  36478. * @returns the total number of active particles rendered per frame
  36479. */
  36480. getActiveParticles(): number;
  36481. /**
  36482. * Gets the performance counter for active particles
  36483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36484. */
  36485. readonly activeParticlesPerfCounter: PerfCounter;
  36486. /**
  36487. * Gets the total number of active bones rendered per frame
  36488. * @returns the total number of active bones rendered per frame
  36489. */
  36490. getActiveBones(): number;
  36491. /**
  36492. * Gets the performance counter for active bones
  36493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36494. */
  36495. readonly activeBonesPerfCounter: PerfCounter;
  36496. /**
  36497. * Gets the array of active meshes
  36498. * @returns an array of AbstractMesh
  36499. */
  36500. getActiveMeshes(): SmartArray<AbstractMesh>;
  36501. /**
  36502. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36503. * @returns a number
  36504. */
  36505. getAnimationRatio(): number;
  36506. /**
  36507. * Gets an unique Id for the current render phase
  36508. * @returns a number
  36509. */
  36510. getRenderId(): number;
  36511. /**
  36512. * Gets an unique Id for the current frame
  36513. * @returns a number
  36514. */
  36515. getFrameId(): number;
  36516. /** Call this function if you want to manually increment the render Id*/
  36517. incrementRenderId(): void;
  36518. private _createUbo;
  36519. /**
  36520. * Use this method to simulate a pointer move on a mesh
  36521. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36522. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36523. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36524. * @returns the current scene
  36525. */
  36526. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36527. /**
  36528. * Use this method to simulate a pointer down on a mesh
  36529. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36530. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36531. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36532. * @returns the current scene
  36533. */
  36534. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36535. /**
  36536. * Use this method to simulate a pointer up on a mesh
  36537. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36538. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36539. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36540. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36541. * @returns the current scene
  36542. */
  36543. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36544. /**
  36545. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36546. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36547. * @returns true if the pointer was captured
  36548. */
  36549. isPointerCaptured(pointerId?: number): boolean;
  36550. /**
  36551. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36552. * @param attachUp defines if you want to attach events to pointerup
  36553. * @param attachDown defines if you want to attach events to pointerdown
  36554. * @param attachMove defines if you want to attach events to pointermove
  36555. */
  36556. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36557. /** Detaches all event handlers*/
  36558. detachControl(): void;
  36559. /**
  36560. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36561. * Delay loaded resources are not taking in account
  36562. * @return true if all required resources are ready
  36563. */
  36564. isReady(): boolean;
  36565. /** Resets all cached information relative to material (including effect and visibility) */
  36566. resetCachedMaterial(): void;
  36567. /**
  36568. * Registers a function to be called before every frame render
  36569. * @param func defines the function to register
  36570. */
  36571. registerBeforeRender(func: () => void): void;
  36572. /**
  36573. * Unregisters a function called before every frame render
  36574. * @param func defines the function to unregister
  36575. */
  36576. unregisterBeforeRender(func: () => void): void;
  36577. /**
  36578. * Registers a function to be called after every frame render
  36579. * @param func defines the function to register
  36580. */
  36581. registerAfterRender(func: () => void): void;
  36582. /**
  36583. * Unregisters a function called after every frame render
  36584. * @param func defines the function to unregister
  36585. */
  36586. unregisterAfterRender(func: () => void): void;
  36587. private _executeOnceBeforeRender;
  36588. /**
  36589. * The provided function will run before render once and will be disposed afterwards.
  36590. * A timeout delay can be provided so that the function will be executed in N ms.
  36591. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36592. * @param func The function to be executed.
  36593. * @param timeout optional delay in ms
  36594. */
  36595. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36596. /** @hidden */
  36597. _addPendingData(data: any): void;
  36598. /** @hidden */
  36599. _removePendingData(data: any): void;
  36600. /**
  36601. * Returns the number of items waiting to be loaded
  36602. * @returns the number of items waiting to be loaded
  36603. */
  36604. getWaitingItemsCount(): number;
  36605. /**
  36606. * Returns a boolean indicating if the scene is still loading data
  36607. */
  36608. readonly isLoading: boolean;
  36609. /**
  36610. * Registers a function to be executed when the scene is ready
  36611. * @param {Function} func - the function to be executed
  36612. */
  36613. executeWhenReady(func: () => void): void;
  36614. /**
  36615. * Returns a promise that resolves when the scene is ready
  36616. * @returns A promise that resolves when the scene is ready
  36617. */
  36618. whenReadyAsync(): Promise<void>;
  36619. /** @hidden */
  36620. _checkIsReady(): void;
  36621. /**
  36622. * Gets all animatable attached to the scene
  36623. */
  36624. readonly animatables: Animatable[];
  36625. /**
  36626. * Resets the last animation time frame.
  36627. * Useful to override when animations start running when loading a scene for the first time.
  36628. */
  36629. resetLastAnimationTimeFrame(): void;
  36630. /**
  36631. * Gets the current view matrix
  36632. * @returns a Matrix
  36633. */
  36634. getViewMatrix(): Matrix;
  36635. /**
  36636. * Gets the current projection matrix
  36637. * @returns a Matrix
  36638. */
  36639. getProjectionMatrix(): Matrix;
  36640. /**
  36641. * Gets the current transform matrix
  36642. * @returns a Matrix made of View * Projection
  36643. */
  36644. getTransformMatrix(): Matrix;
  36645. /**
  36646. * Sets the current transform matrix
  36647. * @param viewL defines the View matrix to use
  36648. * @param projectionL defines the Projection matrix to use
  36649. * @param viewR defines the right View matrix to use (if provided)
  36650. * @param projectionR defines the right Projection matrix to use (if provided)
  36651. */
  36652. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36653. /**
  36654. * Gets the uniform buffer used to store scene data
  36655. * @returns a UniformBuffer
  36656. */
  36657. getSceneUniformBuffer(): UniformBuffer;
  36658. /**
  36659. * Gets an unique (relatively to the current scene) Id
  36660. * @returns an unique number for the scene
  36661. */
  36662. getUniqueId(): number;
  36663. /**
  36664. * Add a mesh to the list of scene's meshes
  36665. * @param newMesh defines the mesh to add
  36666. * @param recursive if all child meshes should also be added to the scene
  36667. */
  36668. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36669. /**
  36670. * Remove a mesh for the list of scene's meshes
  36671. * @param toRemove defines the mesh to remove
  36672. * @param recursive if all child meshes should also be removed from the scene
  36673. * @returns the index where the mesh was in the mesh list
  36674. */
  36675. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36676. /**
  36677. * Add a transform node to the list of scene's transform nodes
  36678. * @param newTransformNode defines the transform node to add
  36679. */
  36680. addTransformNode(newTransformNode: TransformNode): void;
  36681. /**
  36682. * Remove a transform node for the list of scene's transform nodes
  36683. * @param toRemove defines the transform node to remove
  36684. * @returns the index where the transform node was in the transform node list
  36685. */
  36686. removeTransformNode(toRemove: TransformNode): number;
  36687. /**
  36688. * Remove a skeleton for the list of scene's skeletons
  36689. * @param toRemove defines the skeleton to remove
  36690. * @returns the index where the skeleton was in the skeleton list
  36691. */
  36692. removeSkeleton(toRemove: Skeleton): number;
  36693. /**
  36694. * Remove a morph target for the list of scene's morph targets
  36695. * @param toRemove defines the morph target to remove
  36696. * @returns the index where the morph target was in the morph target list
  36697. */
  36698. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36699. /**
  36700. * Remove a light for the list of scene's lights
  36701. * @param toRemove defines the light to remove
  36702. * @returns the index where the light was in the light list
  36703. */
  36704. removeLight(toRemove: Light): number;
  36705. /**
  36706. * Remove a camera for the list of scene's cameras
  36707. * @param toRemove defines the camera to remove
  36708. * @returns the index where the camera was in the camera list
  36709. */
  36710. removeCamera(toRemove: Camera): number;
  36711. /**
  36712. * Remove a particle system for the list of scene's particle systems
  36713. * @param toRemove defines the particle system to remove
  36714. * @returns the index where the particle system was in the particle system list
  36715. */
  36716. removeParticleSystem(toRemove: IParticleSystem): number;
  36717. /**
  36718. * Remove a animation for the list of scene's animations
  36719. * @param toRemove defines the animation to remove
  36720. * @returns the index where the animation was in the animation list
  36721. */
  36722. removeAnimation(toRemove: Animation): number;
  36723. /**
  36724. * Will stop the animation of the given target
  36725. * @param target - the target
  36726. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36727. * @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)
  36728. */
  36729. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36730. /**
  36731. * Removes the given animation group from this scene.
  36732. * @param toRemove The animation group to remove
  36733. * @returns The index of the removed animation group
  36734. */
  36735. removeAnimationGroup(toRemove: AnimationGroup): number;
  36736. /**
  36737. * Removes the given multi-material from this scene.
  36738. * @param toRemove The multi-material to remove
  36739. * @returns The index of the removed multi-material
  36740. */
  36741. removeMultiMaterial(toRemove: MultiMaterial): number;
  36742. /**
  36743. * Removes the given material from this scene.
  36744. * @param toRemove The material to remove
  36745. * @returns The index of the removed material
  36746. */
  36747. removeMaterial(toRemove: Material): number;
  36748. /**
  36749. * Removes the given action manager from this scene.
  36750. * @param toRemove The action manager to remove
  36751. * @returns The index of the removed action manager
  36752. */
  36753. removeActionManager(toRemove: AbstractActionManager): number;
  36754. /**
  36755. * Removes the given texture from this scene.
  36756. * @param toRemove The texture to remove
  36757. * @returns The index of the removed texture
  36758. */
  36759. removeTexture(toRemove: BaseTexture): number;
  36760. /**
  36761. * Adds the given light to this scene
  36762. * @param newLight The light to add
  36763. */
  36764. addLight(newLight: Light): void;
  36765. /**
  36766. * Sorts the list list based on light priorities
  36767. */
  36768. sortLightsByPriority(): void;
  36769. /**
  36770. * Adds the given camera to this scene
  36771. * @param newCamera The camera to add
  36772. */
  36773. addCamera(newCamera: Camera): void;
  36774. /**
  36775. * Adds the given skeleton to this scene
  36776. * @param newSkeleton The skeleton to add
  36777. */
  36778. addSkeleton(newSkeleton: Skeleton): void;
  36779. /**
  36780. * Adds the given particle system to this scene
  36781. * @param newParticleSystem The particle system to add
  36782. */
  36783. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36784. /**
  36785. * Adds the given animation to this scene
  36786. * @param newAnimation The animation to add
  36787. */
  36788. addAnimation(newAnimation: Animation): void;
  36789. /**
  36790. * Adds the given animation group to this scene.
  36791. * @param newAnimationGroup The animation group to add
  36792. */
  36793. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36794. /**
  36795. * Adds the given multi-material to this scene
  36796. * @param newMultiMaterial The multi-material to add
  36797. */
  36798. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36799. /**
  36800. * Adds the given material to this scene
  36801. * @param newMaterial The material to add
  36802. */
  36803. addMaterial(newMaterial: Material): void;
  36804. /**
  36805. * Adds the given morph target to this scene
  36806. * @param newMorphTargetManager The morph target to add
  36807. */
  36808. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36809. /**
  36810. * Adds the given geometry to this scene
  36811. * @param newGeometry The geometry to add
  36812. */
  36813. addGeometry(newGeometry: Geometry): void;
  36814. /**
  36815. * Adds the given action manager to this scene
  36816. * @param newActionManager The action manager to add
  36817. */
  36818. addActionManager(newActionManager: AbstractActionManager): void;
  36819. /**
  36820. * Adds the given texture to this scene.
  36821. * @param newTexture The texture to add
  36822. */
  36823. addTexture(newTexture: BaseTexture): void;
  36824. /**
  36825. * Switch active camera
  36826. * @param newCamera defines the new active camera
  36827. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36828. */
  36829. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36830. /**
  36831. * sets the active camera of the scene using its ID
  36832. * @param id defines the camera's ID
  36833. * @return the new active camera or null if none found.
  36834. */
  36835. setActiveCameraByID(id: string): Nullable<Camera>;
  36836. /**
  36837. * sets the active camera of the scene using its name
  36838. * @param name defines the camera's name
  36839. * @returns the new active camera or null if none found.
  36840. */
  36841. setActiveCameraByName(name: string): Nullable<Camera>;
  36842. /**
  36843. * get an animation group using its name
  36844. * @param name defines the material's name
  36845. * @return the animation group or null if none found.
  36846. */
  36847. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36848. /**
  36849. * Get a material using its unique id
  36850. * @param uniqueId defines the material's unique id
  36851. * @return the material or null if none found.
  36852. */
  36853. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36854. /**
  36855. * get a material using its id
  36856. * @param id defines the material's ID
  36857. * @return the material or null if none found.
  36858. */
  36859. getMaterialByID(id: string): Nullable<Material>;
  36860. /**
  36861. * Gets a the last added material using a given id
  36862. * @param id defines the material's ID
  36863. * @return the last material with the given id or null if none found.
  36864. */
  36865. getLastMaterialByID(id: string): Nullable<Material>;
  36866. /**
  36867. * Gets a material using its name
  36868. * @param name defines the material's name
  36869. * @return the material or null if none found.
  36870. */
  36871. getMaterialByName(name: string): Nullable<Material>;
  36872. /**
  36873. * Get a texture using its unique id
  36874. * @param uniqueId defines the texture's unique id
  36875. * @return the texture or null if none found.
  36876. */
  36877. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36878. /**
  36879. * Gets a camera using its id
  36880. * @param id defines the id to look for
  36881. * @returns the camera or null if not found
  36882. */
  36883. getCameraByID(id: string): Nullable<Camera>;
  36884. /**
  36885. * Gets a camera using its unique id
  36886. * @param uniqueId defines the unique id to look for
  36887. * @returns the camera or null if not found
  36888. */
  36889. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36890. /**
  36891. * Gets a camera using its name
  36892. * @param name defines the camera's name
  36893. * @return the camera or null if none found.
  36894. */
  36895. getCameraByName(name: string): Nullable<Camera>;
  36896. /**
  36897. * Gets a bone using its id
  36898. * @param id defines the bone's id
  36899. * @return the bone or null if not found
  36900. */
  36901. getBoneByID(id: string): Nullable<Bone>;
  36902. /**
  36903. * Gets a bone using its id
  36904. * @param name defines the bone's name
  36905. * @return the bone or null if not found
  36906. */
  36907. getBoneByName(name: string): Nullable<Bone>;
  36908. /**
  36909. * Gets a light node using its name
  36910. * @param name defines the the light's name
  36911. * @return the light or null if none found.
  36912. */
  36913. getLightByName(name: string): Nullable<Light>;
  36914. /**
  36915. * Gets a light node using its id
  36916. * @param id defines the light's id
  36917. * @return the light or null if none found.
  36918. */
  36919. getLightByID(id: string): Nullable<Light>;
  36920. /**
  36921. * Gets a light node using its scene-generated unique ID
  36922. * @param uniqueId defines the light's unique id
  36923. * @return the light or null if none found.
  36924. */
  36925. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36926. /**
  36927. * Gets a particle system by id
  36928. * @param id defines the particle system id
  36929. * @return the corresponding system or null if none found
  36930. */
  36931. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36932. /**
  36933. * Gets a geometry using its ID
  36934. * @param id defines the geometry's id
  36935. * @return the geometry or null if none found.
  36936. */
  36937. getGeometryByID(id: string): Nullable<Geometry>;
  36938. private _getGeometryByUniqueID;
  36939. /**
  36940. * Add a new geometry to this scene
  36941. * @param geometry defines the geometry to be added to the scene.
  36942. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36943. * @return a boolean defining if the geometry was added or not
  36944. */
  36945. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36946. /**
  36947. * Removes an existing geometry
  36948. * @param geometry defines the geometry to be removed from the scene
  36949. * @return a boolean defining if the geometry was removed or not
  36950. */
  36951. removeGeometry(geometry: Geometry): boolean;
  36952. /**
  36953. * Gets the list of geometries attached to the scene
  36954. * @returns an array of Geometry
  36955. */
  36956. getGeometries(): Geometry[];
  36957. /**
  36958. * Gets the first added mesh found of a given ID
  36959. * @param id defines the id to search for
  36960. * @return the mesh found or null if not found at all
  36961. */
  36962. getMeshByID(id: string): Nullable<AbstractMesh>;
  36963. /**
  36964. * Gets a list of meshes using their id
  36965. * @param id defines the id to search for
  36966. * @returns a list of meshes
  36967. */
  36968. getMeshesByID(id: string): Array<AbstractMesh>;
  36969. /**
  36970. * Gets the first added transform node found of a given ID
  36971. * @param id defines the id to search for
  36972. * @return the found transform node or null if not found at all.
  36973. */
  36974. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36975. /**
  36976. * Gets a transform node with its auto-generated unique id
  36977. * @param uniqueId efines the unique id to search for
  36978. * @return the found transform node or null if not found at all.
  36979. */
  36980. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36981. /**
  36982. * Gets a list of transform nodes using their id
  36983. * @param id defines the id to search for
  36984. * @returns a list of transform nodes
  36985. */
  36986. getTransformNodesByID(id: string): Array<TransformNode>;
  36987. /**
  36988. * Gets a mesh with its auto-generated unique id
  36989. * @param uniqueId defines the unique id to search for
  36990. * @return the found mesh or null if not found at all.
  36991. */
  36992. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36993. /**
  36994. * Gets a the last added mesh using a given id
  36995. * @param id defines the id to search for
  36996. * @return the found mesh or null if not found at all.
  36997. */
  36998. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36999. /**
  37000. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37001. * @param id defines the id to search for
  37002. * @return the found node or null if not found at all
  37003. */
  37004. getLastEntryByID(id: string): Nullable<Node>;
  37005. /**
  37006. * Gets a node (Mesh, Camera, Light) using a given id
  37007. * @param id defines the id to search for
  37008. * @return the found node or null if not found at all
  37009. */
  37010. getNodeByID(id: string): Nullable<Node>;
  37011. /**
  37012. * Gets a node (Mesh, Camera, Light) using a given name
  37013. * @param name defines the name to search for
  37014. * @return the found node or null if not found at all.
  37015. */
  37016. getNodeByName(name: string): Nullable<Node>;
  37017. /**
  37018. * Gets a mesh using a given name
  37019. * @param name defines the name to search for
  37020. * @return the found mesh or null if not found at all.
  37021. */
  37022. getMeshByName(name: string): Nullable<AbstractMesh>;
  37023. /**
  37024. * Gets a transform node using a given name
  37025. * @param name defines the name to search for
  37026. * @return the found transform node or null if not found at all.
  37027. */
  37028. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37029. /**
  37030. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37031. * @param id defines the id to search for
  37032. * @return the found skeleton or null if not found at all.
  37033. */
  37034. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37035. /**
  37036. * Gets a skeleton using a given auto generated unique id
  37037. * @param uniqueId defines the unique id to search for
  37038. * @return the found skeleton or null if not found at all.
  37039. */
  37040. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37041. /**
  37042. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37043. * @param id defines the id to search for
  37044. * @return the found skeleton or null if not found at all.
  37045. */
  37046. getSkeletonById(id: string): Nullable<Skeleton>;
  37047. /**
  37048. * Gets a skeleton using a given name
  37049. * @param name defines the name to search for
  37050. * @return the found skeleton or null if not found at all.
  37051. */
  37052. getSkeletonByName(name: string): Nullable<Skeleton>;
  37053. /**
  37054. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37055. * @param id defines the id to search for
  37056. * @return the found morph target manager or null if not found at all.
  37057. */
  37058. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37059. /**
  37060. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37061. * @param id defines the id to search for
  37062. * @return the found morph target or null if not found at all.
  37063. */
  37064. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37065. /**
  37066. * Gets a boolean indicating if the given mesh is active
  37067. * @param mesh defines the mesh to look for
  37068. * @returns true if the mesh is in the active list
  37069. */
  37070. isActiveMesh(mesh: AbstractMesh): boolean;
  37071. /**
  37072. * Return a unique id as a string which can serve as an identifier for the scene
  37073. */
  37074. readonly uid: string;
  37075. /**
  37076. * Add an externaly attached data from its key.
  37077. * This method call will fail and return false, if such key already exists.
  37078. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37079. * @param key the unique key that identifies the data
  37080. * @param data the data object to associate to the key for this Engine instance
  37081. * @return true if no such key were already present and the data was added successfully, false otherwise
  37082. */
  37083. addExternalData<T>(key: string, data: T): boolean;
  37084. /**
  37085. * Get an externaly attached data from its key
  37086. * @param key the unique key that identifies the data
  37087. * @return the associated data, if present (can be null), or undefined if not present
  37088. */
  37089. getExternalData<T>(key: string): Nullable<T>;
  37090. /**
  37091. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37092. * @param key the unique key that identifies the data
  37093. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37094. * @return the associated data, can be null if the factory returned null.
  37095. */
  37096. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37097. /**
  37098. * Remove an externaly attached data from the Engine instance
  37099. * @param key the unique key that identifies the data
  37100. * @return true if the data was successfully removed, false if it doesn't exist
  37101. */
  37102. removeExternalData(key: string): boolean;
  37103. private _evaluateSubMesh;
  37104. /**
  37105. * Clear the processed materials smart array preventing retention point in material dispose.
  37106. */
  37107. freeProcessedMaterials(): void;
  37108. private _preventFreeActiveMeshesAndRenderingGroups;
  37109. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37110. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37111. * when disposing several meshes in a row or a hierarchy of meshes.
  37112. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37113. */
  37114. blockfreeActiveMeshesAndRenderingGroups: boolean;
  37115. /**
  37116. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37117. */
  37118. freeActiveMeshes(): void;
  37119. /**
  37120. * Clear the info related to rendering groups preventing retention points during dispose.
  37121. */
  37122. freeRenderingGroups(): void;
  37123. /** @hidden */
  37124. _isInIntermediateRendering(): boolean;
  37125. /**
  37126. * Lambda returning the list of potentially active meshes.
  37127. */
  37128. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37129. /**
  37130. * Lambda returning the list of potentially active sub meshes.
  37131. */
  37132. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37133. /**
  37134. * Lambda returning the list of potentially intersecting sub meshes.
  37135. */
  37136. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37137. /**
  37138. * Lambda returning the list of potentially colliding sub meshes.
  37139. */
  37140. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37141. private _activeMeshesFrozen;
  37142. private _skipEvaluateActiveMeshesCompletely;
  37143. /**
  37144. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37145. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37146. * @returns the current scene
  37147. */
  37148. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37149. /**
  37150. * Use this function to restart evaluating active meshes on every frame
  37151. * @returns the current scene
  37152. */
  37153. unfreezeActiveMeshes(): Scene;
  37154. private _evaluateActiveMeshes;
  37155. private _activeMesh;
  37156. /**
  37157. * Update the transform matrix to update from the current active camera
  37158. * @param force defines a boolean used to force the update even if cache is up to date
  37159. */
  37160. updateTransformMatrix(force?: boolean): void;
  37161. private _bindFrameBuffer;
  37162. /** @hidden */
  37163. _allowPostProcessClearColor: boolean;
  37164. /** @hidden */
  37165. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37166. private _processSubCameras;
  37167. private _checkIntersections;
  37168. /** @hidden */
  37169. _advancePhysicsEngineStep(step: number): void;
  37170. /**
  37171. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37172. */
  37173. getDeterministicFrameTime: () => number;
  37174. /** @hidden */
  37175. _animate(): void;
  37176. /** Execute all animations (for a frame) */
  37177. animate(): void;
  37178. /**
  37179. * Render the scene
  37180. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37181. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37182. */
  37183. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37184. /**
  37185. * Freeze all materials
  37186. * A frozen material will not be updatable but should be faster to render
  37187. */
  37188. freezeMaterials(): void;
  37189. /**
  37190. * Unfreeze all materials
  37191. * A frozen material will not be updatable but should be faster to render
  37192. */
  37193. unfreezeMaterials(): void;
  37194. /**
  37195. * Releases all held ressources
  37196. */
  37197. dispose(): void;
  37198. /**
  37199. * Gets if the scene is already disposed
  37200. */
  37201. readonly isDisposed: boolean;
  37202. /**
  37203. * Call this function to reduce memory footprint of the scene.
  37204. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37205. */
  37206. clearCachedVertexData(): void;
  37207. /**
  37208. * This function will remove the local cached buffer data from texture.
  37209. * It will save memory but will prevent the texture from being rebuilt
  37210. */
  37211. cleanCachedTextureBuffer(): void;
  37212. /**
  37213. * Get the world extend vectors with an optional filter
  37214. *
  37215. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37216. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37217. */
  37218. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37219. min: Vector3;
  37220. max: Vector3;
  37221. };
  37222. /**
  37223. * Creates a ray that can be used to pick in the scene
  37224. * @param x defines the x coordinate of the origin (on-screen)
  37225. * @param y defines the y coordinate of the origin (on-screen)
  37226. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37227. * @param camera defines the camera to use for the picking
  37228. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37229. * @returns a Ray
  37230. */
  37231. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37232. /**
  37233. * Creates a ray that can be used to pick in the scene
  37234. * @param x defines the x coordinate of the origin (on-screen)
  37235. * @param y defines the y coordinate of the origin (on-screen)
  37236. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37237. * @param result defines the ray where to store the picking ray
  37238. * @param camera defines the camera to use for the picking
  37239. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37240. * @returns the current scene
  37241. */
  37242. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37243. /**
  37244. * Creates a ray that can be used to pick in the scene
  37245. * @param x defines the x coordinate of the origin (on-screen)
  37246. * @param y defines the y coordinate of the origin (on-screen)
  37247. * @param camera defines the camera to use for the picking
  37248. * @returns a Ray
  37249. */
  37250. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37251. /**
  37252. * Creates a ray that can be used to pick in the scene
  37253. * @param x defines the x coordinate of the origin (on-screen)
  37254. * @param y defines the y coordinate of the origin (on-screen)
  37255. * @param result defines the ray where to store the picking ray
  37256. * @param camera defines the camera to use for the picking
  37257. * @returns the current scene
  37258. */
  37259. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37260. /** Launch a ray to try to pick a mesh in the scene
  37261. * @param x position on screen
  37262. * @param y position on screen
  37263. * @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
  37264. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37265. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37266. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37267. * @returns a PickingInfo
  37268. */
  37269. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37270. /** Use the given ray to pick a mesh in the scene
  37271. * @param ray The ray to use to pick meshes
  37272. * @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
  37273. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37275. * @returns a PickingInfo
  37276. */
  37277. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37278. /**
  37279. * Launch a ray to try to pick a mesh in the scene
  37280. * @param x X position on screen
  37281. * @param y Y position on screen
  37282. * @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
  37283. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37284. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37285. * @returns an array of PickingInfo
  37286. */
  37287. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37288. /**
  37289. * Launch a ray to try to pick a mesh in the scene
  37290. * @param ray Ray to use
  37291. * @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
  37292. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37293. * @returns an array of PickingInfo
  37294. */
  37295. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37296. /**
  37297. * Force the value of meshUnderPointer
  37298. * @param mesh defines the mesh to use
  37299. */
  37300. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37301. /**
  37302. * Gets the mesh under the pointer
  37303. * @returns a Mesh or null if no mesh is under the pointer
  37304. */
  37305. getPointerOverMesh(): Nullable<AbstractMesh>;
  37306. /** @hidden */
  37307. _rebuildGeometries(): void;
  37308. /** @hidden */
  37309. _rebuildTextures(): void;
  37310. private _getByTags;
  37311. /**
  37312. * Get a list of meshes by tags
  37313. * @param tagsQuery defines the tags query to use
  37314. * @param forEach defines a predicate used to filter results
  37315. * @returns an array of Mesh
  37316. */
  37317. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37318. /**
  37319. * Get a list of cameras by tags
  37320. * @param tagsQuery defines the tags query to use
  37321. * @param forEach defines a predicate used to filter results
  37322. * @returns an array of Camera
  37323. */
  37324. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37325. /**
  37326. * Get a list of lights by tags
  37327. * @param tagsQuery defines the tags query to use
  37328. * @param forEach defines a predicate used to filter results
  37329. * @returns an array of Light
  37330. */
  37331. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37332. /**
  37333. * Get a list of materials by tags
  37334. * @param tagsQuery defines the tags query to use
  37335. * @param forEach defines a predicate used to filter results
  37336. * @returns an array of Material
  37337. */
  37338. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37339. /**
  37340. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37341. * This allowed control for front to back rendering or reversly depending of the special needs.
  37342. *
  37343. * @param renderingGroupId The rendering group id corresponding to its index
  37344. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37345. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37346. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37347. */
  37348. 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;
  37349. /**
  37350. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37351. *
  37352. * @param renderingGroupId The rendering group id corresponding to its index
  37353. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37354. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37355. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37356. */
  37357. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37358. /**
  37359. * Gets the current auto clear configuration for one rendering group of the rendering
  37360. * manager.
  37361. * @param index the rendering group index to get the information for
  37362. * @returns The auto clear setup for the requested rendering group
  37363. */
  37364. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37365. private _blockMaterialDirtyMechanism;
  37366. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37367. blockMaterialDirtyMechanism: boolean;
  37368. /**
  37369. * Will flag all materials as dirty to trigger new shader compilation
  37370. * @param flag defines the flag used to specify which material part must be marked as dirty
  37371. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37372. */
  37373. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37374. /** @hidden */
  37375. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37376. /** @hidden */
  37377. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37378. /** @hidden */
  37379. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37380. /** @hidden */
  37381. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37382. /** @hidden */
  37383. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37384. /** @hidden */
  37385. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37386. }
  37387. }
  37388. declare module "babylonjs/assetContainer" {
  37389. import { AbstractScene } from "babylonjs/abstractScene";
  37390. import { Scene } from "babylonjs/scene";
  37391. import { Mesh } from "babylonjs/Meshes/mesh";
  37392. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37393. import { Skeleton } from "babylonjs/Bones/skeleton";
  37394. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37395. import { Animatable } from "babylonjs/Animations/animatable";
  37396. import { Nullable } from "babylonjs/types";
  37397. import { Node } from "babylonjs/node";
  37398. /**
  37399. * Set of assets to keep when moving a scene into an asset container.
  37400. */
  37401. export class KeepAssets extends AbstractScene {
  37402. }
  37403. /**
  37404. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37405. */
  37406. export class InstantiatedEntries {
  37407. /**
  37408. * List of new root nodes (eg. nodes with no parent)
  37409. */
  37410. rootNodes: TransformNode[];
  37411. /**
  37412. * List of new skeletons
  37413. */
  37414. skeletons: Skeleton[];
  37415. /**
  37416. * List of new animation groups
  37417. */
  37418. animationGroups: AnimationGroup[];
  37419. }
  37420. /**
  37421. * Container with a set of assets that can be added or removed from a scene.
  37422. */
  37423. export class AssetContainer extends AbstractScene {
  37424. /**
  37425. * The scene the AssetContainer belongs to.
  37426. */
  37427. scene: Scene;
  37428. /**
  37429. * Instantiates an AssetContainer.
  37430. * @param scene The scene the AssetContainer belongs to.
  37431. */
  37432. constructor(scene: Scene);
  37433. /**
  37434. * Instantiate or clone all meshes and add the new ones to the scene.
  37435. * Skeletons and animation groups will all be cloned
  37436. * @param nameFunction defines an optional function used to get new names for clones
  37437. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37438. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37439. */
  37440. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37441. /**
  37442. * Adds all the assets from the container to the scene.
  37443. */
  37444. addAllToScene(): void;
  37445. /**
  37446. * Removes all the assets in the container from the scene
  37447. */
  37448. removeAllFromScene(): void;
  37449. /**
  37450. * Disposes all the assets in the container
  37451. */
  37452. dispose(): void;
  37453. private _moveAssets;
  37454. /**
  37455. * Removes all the assets contained in the scene and adds them to the container.
  37456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37457. */
  37458. moveAllFromScene(keepAssets?: KeepAssets): void;
  37459. /**
  37460. * 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.
  37461. * @returns the root mesh
  37462. */
  37463. createRootMesh(): Mesh;
  37464. /**
  37465. * Merge animations from this asset container into a scene
  37466. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37467. * @param animatables set of animatables to retarget to a node from the scene
  37468. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37469. */
  37470. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37471. }
  37472. }
  37473. declare module "babylonjs/abstractScene" {
  37474. import { Scene } from "babylonjs/scene";
  37475. import { Nullable } from "babylonjs/types";
  37476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37477. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37478. import { Geometry } from "babylonjs/Meshes/geometry";
  37479. import { Skeleton } from "babylonjs/Bones/skeleton";
  37480. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37481. import { AssetContainer } from "babylonjs/assetContainer";
  37482. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37483. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37485. import { Material } from "babylonjs/Materials/material";
  37486. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37487. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37488. import { Camera } from "babylonjs/Cameras/camera";
  37489. import { Light } from "babylonjs/Lights/light";
  37490. import { Node } from "babylonjs/node";
  37491. import { Animation } from "babylonjs/Animations/animation";
  37492. /**
  37493. * Defines how the parser contract is defined.
  37494. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37495. */
  37496. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37497. /**
  37498. * Defines how the individual parser contract is defined.
  37499. * These parser can parse an individual asset
  37500. */
  37501. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37502. /**
  37503. * Base class of the scene acting as a container for the different elements composing a scene.
  37504. * This class is dynamically extended by the different components of the scene increasing
  37505. * flexibility and reducing coupling
  37506. */
  37507. export abstract class AbstractScene {
  37508. /**
  37509. * Stores the list of available parsers in the application.
  37510. */
  37511. private static _BabylonFileParsers;
  37512. /**
  37513. * Stores the list of available individual parsers in the application.
  37514. */
  37515. private static _IndividualBabylonFileParsers;
  37516. /**
  37517. * Adds a parser in the list of available ones
  37518. * @param name Defines the name of the parser
  37519. * @param parser Defines the parser to add
  37520. */
  37521. static AddParser(name: string, parser: BabylonFileParser): void;
  37522. /**
  37523. * Gets a general parser from the list of avaialble ones
  37524. * @param name Defines the name of the parser
  37525. * @returns the requested parser or null
  37526. */
  37527. static GetParser(name: string): Nullable<BabylonFileParser>;
  37528. /**
  37529. * Adds n individual parser in the list of available ones
  37530. * @param name Defines the name of the parser
  37531. * @param parser Defines the parser to add
  37532. */
  37533. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37534. /**
  37535. * Gets an individual parser from the list of avaialble ones
  37536. * @param name Defines the name of the parser
  37537. * @returns the requested parser or null
  37538. */
  37539. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37540. /**
  37541. * Parser json data and populate both a scene and its associated container object
  37542. * @param jsonData Defines the data to parse
  37543. * @param scene Defines the scene to parse the data for
  37544. * @param container Defines the container attached to the parsing sequence
  37545. * @param rootUrl Defines the root url of the data
  37546. */
  37547. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37548. /**
  37549. * Gets the list of root nodes (ie. nodes with no parent)
  37550. */
  37551. rootNodes: Node[];
  37552. /** All of the cameras added to this scene
  37553. * @see http://doc.babylonjs.com/babylon101/cameras
  37554. */
  37555. cameras: Camera[];
  37556. /**
  37557. * All of the lights added to this scene
  37558. * @see http://doc.babylonjs.com/babylon101/lights
  37559. */
  37560. lights: Light[];
  37561. /**
  37562. * All of the (abstract) meshes added to this scene
  37563. */
  37564. meshes: AbstractMesh[];
  37565. /**
  37566. * The list of skeletons added to the scene
  37567. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37568. */
  37569. skeletons: Skeleton[];
  37570. /**
  37571. * All of the particle systems added to this scene
  37572. * @see http://doc.babylonjs.com/babylon101/particles
  37573. */
  37574. particleSystems: IParticleSystem[];
  37575. /**
  37576. * Gets a list of Animations associated with the scene
  37577. */
  37578. animations: Animation[];
  37579. /**
  37580. * All of the animation groups added to this scene
  37581. * @see http://doc.babylonjs.com/how_to/group
  37582. */
  37583. animationGroups: AnimationGroup[];
  37584. /**
  37585. * All of the multi-materials added to this scene
  37586. * @see http://doc.babylonjs.com/how_to/multi_materials
  37587. */
  37588. multiMaterials: MultiMaterial[];
  37589. /**
  37590. * All of the materials added to this scene
  37591. * In the context of a Scene, it is not supposed to be modified manually.
  37592. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37593. * Note also that the order of the Material within the array is not significant and might change.
  37594. * @see http://doc.babylonjs.com/babylon101/materials
  37595. */
  37596. materials: Material[];
  37597. /**
  37598. * The list of morph target managers added to the scene
  37599. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37600. */
  37601. morphTargetManagers: MorphTargetManager[];
  37602. /**
  37603. * The list of geometries used in the scene.
  37604. */
  37605. geometries: Geometry[];
  37606. /**
  37607. * All of the tranform nodes added to this scene
  37608. * In the context of a Scene, it is not supposed to be modified manually.
  37609. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37610. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37611. * @see http://doc.babylonjs.com/how_to/transformnode
  37612. */
  37613. transformNodes: TransformNode[];
  37614. /**
  37615. * ActionManagers available on the scene.
  37616. */
  37617. actionManagers: AbstractActionManager[];
  37618. /**
  37619. * Textures to keep.
  37620. */
  37621. textures: BaseTexture[];
  37622. /**
  37623. * Environment texture for the scene
  37624. */
  37625. environmentTexture: Nullable<BaseTexture>;
  37626. /**
  37627. * @returns all meshes, lights, cameras, transformNodes and bones
  37628. */
  37629. getNodes(): Array<Node>;
  37630. }
  37631. }
  37632. declare module "babylonjs/Audio/sound" {
  37633. import { Observable } from "babylonjs/Misc/observable";
  37634. import { Vector3 } from "babylonjs/Maths/math.vector";
  37635. import { Nullable } from "babylonjs/types";
  37636. import { Scene } from "babylonjs/scene";
  37637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37638. /**
  37639. * Interface used to define options for Sound class
  37640. */
  37641. export interface ISoundOptions {
  37642. /**
  37643. * Does the sound autoplay once loaded.
  37644. */
  37645. autoplay?: boolean;
  37646. /**
  37647. * Does the sound loop after it finishes playing once.
  37648. */
  37649. loop?: boolean;
  37650. /**
  37651. * Sound's volume
  37652. */
  37653. volume?: number;
  37654. /**
  37655. * Is it a spatial sound?
  37656. */
  37657. spatialSound?: boolean;
  37658. /**
  37659. * Maximum distance to hear that sound
  37660. */
  37661. maxDistance?: number;
  37662. /**
  37663. * Uses user defined attenuation function
  37664. */
  37665. useCustomAttenuation?: boolean;
  37666. /**
  37667. * Define the roll off factor of spatial sounds.
  37668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37669. */
  37670. rolloffFactor?: number;
  37671. /**
  37672. * Define the reference distance the sound should be heard perfectly.
  37673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37674. */
  37675. refDistance?: number;
  37676. /**
  37677. * Define the distance attenuation model the sound will follow.
  37678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37679. */
  37680. distanceModel?: string;
  37681. /**
  37682. * Defines the playback speed (1 by default)
  37683. */
  37684. playbackRate?: number;
  37685. /**
  37686. * Defines if the sound is from a streaming source
  37687. */
  37688. streaming?: boolean;
  37689. /**
  37690. * Defines an optional length (in seconds) inside the sound file
  37691. */
  37692. length?: number;
  37693. /**
  37694. * Defines an optional offset (in seconds) inside the sound file
  37695. */
  37696. offset?: number;
  37697. /**
  37698. * If true, URLs will not be required to state the audio file codec to use.
  37699. */
  37700. skipCodecCheck?: boolean;
  37701. }
  37702. /**
  37703. * Defines a sound that can be played in the application.
  37704. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37706. */
  37707. export class Sound {
  37708. /**
  37709. * The name of the sound in the scene.
  37710. */
  37711. name: string;
  37712. /**
  37713. * Does the sound autoplay once loaded.
  37714. */
  37715. autoplay: boolean;
  37716. /**
  37717. * Does the sound loop after it finishes playing once.
  37718. */
  37719. loop: boolean;
  37720. /**
  37721. * Does the sound use a custom attenuation curve to simulate the falloff
  37722. * happening when the source gets further away from the camera.
  37723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37724. */
  37725. useCustomAttenuation: boolean;
  37726. /**
  37727. * The sound track id this sound belongs to.
  37728. */
  37729. soundTrackId: number;
  37730. /**
  37731. * Is this sound currently played.
  37732. */
  37733. isPlaying: boolean;
  37734. /**
  37735. * Is this sound currently paused.
  37736. */
  37737. isPaused: boolean;
  37738. /**
  37739. * Does this sound enables spatial sound.
  37740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37741. */
  37742. spatialSound: boolean;
  37743. /**
  37744. * Define the reference distance the sound should be heard perfectly.
  37745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37746. */
  37747. refDistance: number;
  37748. /**
  37749. * Define the roll off factor of spatial sounds.
  37750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37751. */
  37752. rolloffFactor: number;
  37753. /**
  37754. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37756. */
  37757. maxDistance: number;
  37758. /**
  37759. * Define the distance attenuation model the sound will follow.
  37760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37761. */
  37762. distanceModel: string;
  37763. /**
  37764. * @hidden
  37765. * Back Compat
  37766. **/
  37767. onended: () => any;
  37768. /**
  37769. * Observable event when the current playing sound finishes.
  37770. */
  37771. onEndedObservable: Observable<Sound>;
  37772. private _panningModel;
  37773. private _playbackRate;
  37774. private _streaming;
  37775. private _startTime;
  37776. private _startOffset;
  37777. private _position;
  37778. /** @hidden */
  37779. _positionInEmitterSpace: boolean;
  37780. private _localDirection;
  37781. private _volume;
  37782. private _isReadyToPlay;
  37783. private _isDirectional;
  37784. private _readyToPlayCallback;
  37785. private _audioBuffer;
  37786. private _soundSource;
  37787. private _streamingSource;
  37788. private _soundPanner;
  37789. private _soundGain;
  37790. private _inputAudioNode;
  37791. private _outputAudioNode;
  37792. private _coneInnerAngle;
  37793. private _coneOuterAngle;
  37794. private _coneOuterGain;
  37795. private _scene;
  37796. private _connectedTransformNode;
  37797. private _customAttenuationFunction;
  37798. private _registerFunc;
  37799. private _isOutputConnected;
  37800. private _htmlAudioElement;
  37801. private _urlType;
  37802. private _length?;
  37803. private _offset?;
  37804. /** @hidden */
  37805. static _SceneComponentInitialization: (scene: Scene) => void;
  37806. /**
  37807. * Create a sound and attach it to a scene
  37808. * @param name Name of your sound
  37809. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37810. * @param scene defines the scene the sound belongs to
  37811. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37812. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37813. */
  37814. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37815. /**
  37816. * Release the sound and its associated resources
  37817. */
  37818. dispose(): void;
  37819. /**
  37820. * Gets if the sounds is ready to be played or not.
  37821. * @returns true if ready, otherwise false
  37822. */
  37823. isReady(): boolean;
  37824. private _soundLoaded;
  37825. /**
  37826. * Sets the data of the sound from an audiobuffer
  37827. * @param audioBuffer The audioBuffer containing the data
  37828. */
  37829. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37830. /**
  37831. * Updates the current sounds options such as maxdistance, loop...
  37832. * @param options A JSON object containing values named as the object properties
  37833. */
  37834. updateOptions(options: ISoundOptions): void;
  37835. private _createSpatialParameters;
  37836. private _updateSpatialParameters;
  37837. /**
  37838. * Switch the panning model to HRTF:
  37839. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37841. */
  37842. switchPanningModelToHRTF(): void;
  37843. /**
  37844. * Switch the panning model to Equal Power:
  37845. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37846. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37847. */
  37848. switchPanningModelToEqualPower(): void;
  37849. private _switchPanningModel;
  37850. /**
  37851. * Connect this sound to a sound track audio node like gain...
  37852. * @param soundTrackAudioNode the sound track audio node to connect to
  37853. */
  37854. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37855. /**
  37856. * Transform this sound into a directional source
  37857. * @param coneInnerAngle Size of the inner cone in degree
  37858. * @param coneOuterAngle Size of the outer cone in degree
  37859. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37860. */
  37861. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37862. /**
  37863. * Gets or sets the inner angle for the directional cone.
  37864. */
  37865. /**
  37866. * Gets or sets the inner angle for the directional cone.
  37867. */
  37868. directionalConeInnerAngle: number;
  37869. /**
  37870. * Gets or sets the outer angle for the directional cone.
  37871. */
  37872. /**
  37873. * Gets or sets the outer angle for the directional cone.
  37874. */
  37875. directionalConeOuterAngle: number;
  37876. /**
  37877. * Sets the position of the emitter if spatial sound is enabled
  37878. * @param newPosition Defines the new posisiton
  37879. */
  37880. setPosition(newPosition: Vector3): void;
  37881. /**
  37882. * Sets the local direction of the emitter if spatial sound is enabled
  37883. * @param newLocalDirection Defines the new local direction
  37884. */
  37885. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37886. private _updateDirection;
  37887. /** @hidden */
  37888. updateDistanceFromListener(): void;
  37889. /**
  37890. * Sets a new custom attenuation function for the sound.
  37891. * @param callback Defines the function used for the attenuation
  37892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37893. */
  37894. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37895. /**
  37896. * Play the sound
  37897. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37898. * @param offset (optional) Start the sound at a specific time in seconds
  37899. * @param length (optional) Sound duration (in seconds)
  37900. */
  37901. play(time?: number, offset?: number, length?: number): void;
  37902. private _onended;
  37903. /**
  37904. * Stop the sound
  37905. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37906. */
  37907. stop(time?: number): void;
  37908. /**
  37909. * Put the sound in pause
  37910. */
  37911. pause(): void;
  37912. /**
  37913. * Sets a dedicated volume for this sounds
  37914. * @param newVolume Define the new volume of the sound
  37915. * @param time Define time for gradual change to new volume
  37916. */
  37917. setVolume(newVolume: number, time?: number): void;
  37918. /**
  37919. * Set the sound play back rate
  37920. * @param newPlaybackRate Define the playback rate the sound should be played at
  37921. */
  37922. setPlaybackRate(newPlaybackRate: number): void;
  37923. /**
  37924. * Gets the volume of the sound.
  37925. * @returns the volume of the sound
  37926. */
  37927. getVolume(): number;
  37928. /**
  37929. * Attach the sound to a dedicated mesh
  37930. * @param transformNode The transform node to connect the sound with
  37931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37932. */
  37933. attachToMesh(transformNode: TransformNode): void;
  37934. /**
  37935. * Detach the sound from the previously attached mesh
  37936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37937. */
  37938. detachFromMesh(): void;
  37939. private _onRegisterAfterWorldMatrixUpdate;
  37940. /**
  37941. * Clone the current sound in the scene.
  37942. * @returns the new sound clone
  37943. */
  37944. clone(): Nullable<Sound>;
  37945. /**
  37946. * Gets the current underlying audio buffer containing the data
  37947. * @returns the audio buffer
  37948. */
  37949. getAudioBuffer(): Nullable<AudioBuffer>;
  37950. /**
  37951. * Serializes the Sound in a JSON representation
  37952. * @returns the JSON representation of the sound
  37953. */
  37954. serialize(): any;
  37955. /**
  37956. * Parse a JSON representation of a sound to innstantiate in a given scene
  37957. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37958. * @param scene Define the scene the new parsed sound should be created in
  37959. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37960. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37961. * @returns the newly parsed sound
  37962. */
  37963. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37964. }
  37965. }
  37966. declare module "babylonjs/Actions/directAudioActions" {
  37967. import { Action } from "babylonjs/Actions/action";
  37968. import { Condition } from "babylonjs/Actions/condition";
  37969. import { Sound } from "babylonjs/Audio/sound";
  37970. /**
  37971. * This defines an action helpful to play a defined sound on a triggered action.
  37972. */
  37973. export class PlaySoundAction extends Action {
  37974. private _sound;
  37975. /**
  37976. * Instantiate the action
  37977. * @param triggerOptions defines the trigger options
  37978. * @param sound defines the sound to play
  37979. * @param condition defines the trigger related conditions
  37980. */
  37981. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37982. /** @hidden */
  37983. _prepare(): void;
  37984. /**
  37985. * Execute the action and play the sound.
  37986. */
  37987. execute(): void;
  37988. /**
  37989. * Serializes the actions and its related information.
  37990. * @param parent defines the object to serialize in
  37991. * @returns the serialized object
  37992. */
  37993. serialize(parent: any): any;
  37994. }
  37995. /**
  37996. * This defines an action helpful to stop a defined sound on a triggered action.
  37997. */
  37998. export class StopSoundAction extends Action {
  37999. private _sound;
  38000. /**
  38001. * Instantiate the action
  38002. * @param triggerOptions defines the trigger options
  38003. * @param sound defines the sound to stop
  38004. * @param condition defines the trigger related conditions
  38005. */
  38006. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38007. /** @hidden */
  38008. _prepare(): void;
  38009. /**
  38010. * Execute the action and stop the sound.
  38011. */
  38012. execute(): void;
  38013. /**
  38014. * Serializes the actions and its related information.
  38015. * @param parent defines the object to serialize in
  38016. * @returns the serialized object
  38017. */
  38018. serialize(parent: any): any;
  38019. }
  38020. }
  38021. declare module "babylonjs/Actions/interpolateValueAction" {
  38022. import { Action } from "babylonjs/Actions/action";
  38023. import { Condition } from "babylonjs/Actions/condition";
  38024. import { Observable } from "babylonjs/Misc/observable";
  38025. /**
  38026. * This defines an action responsible to change the value of a property
  38027. * by interpolating between its current value and the newly set one once triggered.
  38028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38029. */
  38030. export class InterpolateValueAction extends Action {
  38031. /**
  38032. * Defines the path of the property where the value should be interpolated
  38033. */
  38034. propertyPath: string;
  38035. /**
  38036. * Defines the target value at the end of the interpolation.
  38037. */
  38038. value: any;
  38039. /**
  38040. * Defines the time it will take for the property to interpolate to the value.
  38041. */
  38042. duration: number;
  38043. /**
  38044. * Defines if the other scene animations should be stopped when the action has been triggered
  38045. */
  38046. stopOtherAnimations?: boolean;
  38047. /**
  38048. * Defines a callback raised once the interpolation animation has been done.
  38049. */
  38050. onInterpolationDone?: () => void;
  38051. /**
  38052. * Observable triggered once the interpolation animation has been done.
  38053. */
  38054. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38055. private _target;
  38056. private _effectiveTarget;
  38057. private _property;
  38058. /**
  38059. * Instantiate the action
  38060. * @param triggerOptions defines the trigger options
  38061. * @param target defines the object containing the value to interpolate
  38062. * @param propertyPath defines the path to the property in the target object
  38063. * @param value defines the target value at the end of the interpolation
  38064. * @param duration deines the time it will take for the property to interpolate to the value.
  38065. * @param condition defines the trigger related conditions
  38066. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38067. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38068. */
  38069. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38070. /** @hidden */
  38071. _prepare(): void;
  38072. /**
  38073. * Execute the action starts the value interpolation.
  38074. */
  38075. execute(): void;
  38076. /**
  38077. * Serializes the actions and its related information.
  38078. * @param parent defines the object to serialize in
  38079. * @returns the serialized object
  38080. */
  38081. serialize(parent: any): any;
  38082. }
  38083. }
  38084. declare module "babylonjs/Actions/index" {
  38085. export * from "babylonjs/Actions/abstractActionManager";
  38086. export * from "babylonjs/Actions/action";
  38087. export * from "babylonjs/Actions/actionEvent";
  38088. export * from "babylonjs/Actions/actionManager";
  38089. export * from "babylonjs/Actions/condition";
  38090. export * from "babylonjs/Actions/directActions";
  38091. export * from "babylonjs/Actions/directAudioActions";
  38092. export * from "babylonjs/Actions/interpolateValueAction";
  38093. }
  38094. declare module "babylonjs/Animations/index" {
  38095. export * from "babylonjs/Animations/animatable";
  38096. export * from "babylonjs/Animations/animation";
  38097. export * from "babylonjs/Animations/animationGroup";
  38098. export * from "babylonjs/Animations/animationPropertiesOverride";
  38099. export * from "babylonjs/Animations/easing";
  38100. export * from "babylonjs/Animations/runtimeAnimation";
  38101. export * from "babylonjs/Animations/animationEvent";
  38102. export * from "babylonjs/Animations/animationGroup";
  38103. export * from "babylonjs/Animations/animationKey";
  38104. export * from "babylonjs/Animations/animationRange";
  38105. export * from "babylonjs/Animations/animatable.interface";
  38106. }
  38107. declare module "babylonjs/Audio/soundTrack" {
  38108. import { Sound } from "babylonjs/Audio/sound";
  38109. import { Analyser } from "babylonjs/Audio/analyser";
  38110. import { Scene } from "babylonjs/scene";
  38111. /**
  38112. * Options allowed during the creation of a sound track.
  38113. */
  38114. export interface ISoundTrackOptions {
  38115. /**
  38116. * The volume the sound track should take during creation
  38117. */
  38118. volume?: number;
  38119. /**
  38120. * Define if the sound track is the main sound track of the scene
  38121. */
  38122. mainTrack?: boolean;
  38123. }
  38124. /**
  38125. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38126. * It will be also used in a future release to apply effects on a specific track.
  38127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38128. */
  38129. export class SoundTrack {
  38130. /**
  38131. * The unique identifier of the sound track in the scene.
  38132. */
  38133. id: number;
  38134. /**
  38135. * The list of sounds included in the sound track.
  38136. */
  38137. soundCollection: Array<Sound>;
  38138. private _outputAudioNode;
  38139. private _scene;
  38140. private _connectedAnalyser;
  38141. private _options;
  38142. private _isInitialized;
  38143. /**
  38144. * Creates a new sound track.
  38145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38146. * @param scene Define the scene the sound track belongs to
  38147. * @param options
  38148. */
  38149. constructor(scene: Scene, options?: ISoundTrackOptions);
  38150. private _initializeSoundTrackAudioGraph;
  38151. /**
  38152. * Release the sound track and its associated resources
  38153. */
  38154. dispose(): void;
  38155. /**
  38156. * Adds a sound to this sound track
  38157. * @param sound define the cound to add
  38158. * @ignoreNaming
  38159. */
  38160. AddSound(sound: Sound): void;
  38161. /**
  38162. * Removes a sound to this sound track
  38163. * @param sound define the cound to remove
  38164. * @ignoreNaming
  38165. */
  38166. RemoveSound(sound: Sound): void;
  38167. /**
  38168. * Set a global volume for the full sound track.
  38169. * @param newVolume Define the new volume of the sound track
  38170. */
  38171. setVolume(newVolume: number): void;
  38172. /**
  38173. * Switch the panning model to HRTF:
  38174. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38176. */
  38177. switchPanningModelToHRTF(): void;
  38178. /**
  38179. * Switch the panning model to Equal Power:
  38180. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38181. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38182. */
  38183. switchPanningModelToEqualPower(): void;
  38184. /**
  38185. * Connect the sound track to an audio analyser allowing some amazing
  38186. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38188. * @param analyser The analyser to connect to the engine
  38189. */
  38190. connectToAnalyser(analyser: Analyser): void;
  38191. }
  38192. }
  38193. declare module "babylonjs/Audio/audioSceneComponent" {
  38194. import { Sound } from "babylonjs/Audio/sound";
  38195. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38196. import { Nullable } from "babylonjs/types";
  38197. import { Vector3 } from "babylonjs/Maths/math.vector";
  38198. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38199. import { Scene } from "babylonjs/scene";
  38200. import { AbstractScene } from "babylonjs/abstractScene";
  38201. import "babylonjs/Audio/audioEngine";
  38202. module "babylonjs/abstractScene" {
  38203. interface AbstractScene {
  38204. /**
  38205. * The list of sounds used in the scene.
  38206. */
  38207. sounds: Nullable<Array<Sound>>;
  38208. }
  38209. }
  38210. module "babylonjs/scene" {
  38211. interface Scene {
  38212. /**
  38213. * @hidden
  38214. * Backing field
  38215. */
  38216. _mainSoundTrack: SoundTrack;
  38217. /**
  38218. * The main sound track played by the scene.
  38219. * It cotains your primary collection of sounds.
  38220. */
  38221. mainSoundTrack: SoundTrack;
  38222. /**
  38223. * The list of sound tracks added to the scene
  38224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38225. */
  38226. soundTracks: Nullable<Array<SoundTrack>>;
  38227. /**
  38228. * Gets a sound using a given name
  38229. * @param name defines the name to search for
  38230. * @return the found sound or null if not found at all.
  38231. */
  38232. getSoundByName(name: string): Nullable<Sound>;
  38233. /**
  38234. * Gets or sets if audio support is enabled
  38235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38236. */
  38237. audioEnabled: boolean;
  38238. /**
  38239. * Gets or sets if audio will be output to headphones
  38240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38241. */
  38242. headphone: boolean;
  38243. /**
  38244. * Gets or sets custom audio listener position provider
  38245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38246. */
  38247. audioListenerPositionProvider: Nullable<() => Vector3>;
  38248. /**
  38249. * Gets or sets a refresh rate when using 3D audio positioning
  38250. */
  38251. audioPositioningRefreshRate: number;
  38252. }
  38253. }
  38254. /**
  38255. * Defines the sound scene component responsible to manage any sounds
  38256. * in a given scene.
  38257. */
  38258. export class AudioSceneComponent implements ISceneSerializableComponent {
  38259. /**
  38260. * The component name helpfull to identify the component in the list of scene components.
  38261. */
  38262. readonly name: string;
  38263. /**
  38264. * The scene the component belongs to.
  38265. */
  38266. scene: Scene;
  38267. private _audioEnabled;
  38268. /**
  38269. * Gets whether audio is enabled or not.
  38270. * Please use related enable/disable method to switch state.
  38271. */
  38272. readonly audioEnabled: boolean;
  38273. private _headphone;
  38274. /**
  38275. * Gets whether audio is outputing to headphone or not.
  38276. * Please use the according Switch methods to change output.
  38277. */
  38278. readonly headphone: boolean;
  38279. /**
  38280. * Gets or sets a refresh rate when using 3D audio positioning
  38281. */
  38282. audioPositioningRefreshRate: number;
  38283. private _audioListenerPositionProvider;
  38284. /**
  38285. * Gets the current audio listener position provider
  38286. */
  38287. /**
  38288. * Sets a custom listener position for all sounds in the scene
  38289. * By default, this is the position of the first active camera
  38290. */
  38291. audioListenerPositionProvider: Nullable<() => Vector3>;
  38292. /**
  38293. * Creates a new instance of the component for the given scene
  38294. * @param scene Defines the scene to register the component in
  38295. */
  38296. constructor(scene: Scene);
  38297. /**
  38298. * Registers the component in a given scene
  38299. */
  38300. register(): void;
  38301. /**
  38302. * Rebuilds the elements related to this component in case of
  38303. * context lost for instance.
  38304. */
  38305. rebuild(): void;
  38306. /**
  38307. * Serializes the component data to the specified json object
  38308. * @param serializationObject The object to serialize to
  38309. */
  38310. serialize(serializationObject: any): void;
  38311. /**
  38312. * Adds all the elements from the container to the scene
  38313. * @param container the container holding the elements
  38314. */
  38315. addFromContainer(container: AbstractScene): void;
  38316. /**
  38317. * Removes all the elements in the container from the scene
  38318. * @param container contains the elements to remove
  38319. * @param dispose if the removed element should be disposed (default: false)
  38320. */
  38321. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38322. /**
  38323. * Disposes the component and the associated ressources.
  38324. */
  38325. dispose(): void;
  38326. /**
  38327. * Disables audio in the associated scene.
  38328. */
  38329. disableAudio(): void;
  38330. /**
  38331. * Enables audio in the associated scene.
  38332. */
  38333. enableAudio(): void;
  38334. /**
  38335. * Switch audio to headphone output.
  38336. */
  38337. switchAudioModeForHeadphones(): void;
  38338. /**
  38339. * Switch audio to normal speakers.
  38340. */
  38341. switchAudioModeForNormalSpeakers(): void;
  38342. private _cachedCameraDirection;
  38343. private _cachedCameraPosition;
  38344. private _lastCheck;
  38345. private _afterRender;
  38346. }
  38347. }
  38348. declare module "babylonjs/Audio/weightedsound" {
  38349. import { Sound } from "babylonjs/Audio/sound";
  38350. /**
  38351. * Wraps one or more Sound objects and selects one with random weight for playback.
  38352. */
  38353. export class WeightedSound {
  38354. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38355. loop: boolean;
  38356. private _coneInnerAngle;
  38357. private _coneOuterAngle;
  38358. private _volume;
  38359. /** A Sound is currently playing. */
  38360. isPlaying: boolean;
  38361. /** A Sound is currently paused. */
  38362. isPaused: boolean;
  38363. private _sounds;
  38364. private _weights;
  38365. private _currentIndex?;
  38366. /**
  38367. * Creates a new WeightedSound from the list of sounds given.
  38368. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38369. * @param sounds Array of Sounds that will be selected from.
  38370. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38371. */
  38372. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38373. /**
  38374. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38375. */
  38376. /**
  38377. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38378. */
  38379. directionalConeInnerAngle: number;
  38380. /**
  38381. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38382. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38383. */
  38384. /**
  38385. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38386. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38387. */
  38388. directionalConeOuterAngle: number;
  38389. /**
  38390. * Playback volume.
  38391. */
  38392. /**
  38393. * Playback volume.
  38394. */
  38395. volume: number;
  38396. private _onended;
  38397. /**
  38398. * Suspend playback
  38399. */
  38400. pause(): void;
  38401. /**
  38402. * Stop playback
  38403. */
  38404. stop(): void;
  38405. /**
  38406. * Start playback.
  38407. * @param startOffset Position the clip head at a specific time in seconds.
  38408. */
  38409. play(startOffset?: number): void;
  38410. }
  38411. }
  38412. declare module "babylonjs/Audio/index" {
  38413. export * from "babylonjs/Audio/analyser";
  38414. export * from "babylonjs/Audio/audioEngine";
  38415. export * from "babylonjs/Audio/audioSceneComponent";
  38416. export * from "babylonjs/Audio/sound";
  38417. export * from "babylonjs/Audio/soundTrack";
  38418. export * from "babylonjs/Audio/weightedsound";
  38419. }
  38420. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38421. import { Behavior } from "babylonjs/Behaviors/behavior";
  38422. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38423. import { BackEase } from "babylonjs/Animations/easing";
  38424. /**
  38425. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38427. */
  38428. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38429. /**
  38430. * Gets the name of the behavior.
  38431. */
  38432. readonly name: string;
  38433. /**
  38434. * The easing function used by animations
  38435. */
  38436. static EasingFunction: BackEase;
  38437. /**
  38438. * The easing mode used by animations
  38439. */
  38440. static EasingMode: number;
  38441. /**
  38442. * The duration of the animation, in milliseconds
  38443. */
  38444. transitionDuration: number;
  38445. /**
  38446. * Length of the distance animated by the transition when lower radius is reached
  38447. */
  38448. lowerRadiusTransitionRange: number;
  38449. /**
  38450. * Length of the distance animated by the transition when upper radius is reached
  38451. */
  38452. upperRadiusTransitionRange: number;
  38453. private _autoTransitionRange;
  38454. /**
  38455. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38456. */
  38457. /**
  38458. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38459. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38460. */
  38461. autoTransitionRange: boolean;
  38462. private _attachedCamera;
  38463. private _onAfterCheckInputsObserver;
  38464. private _onMeshTargetChangedObserver;
  38465. /**
  38466. * Initializes the behavior.
  38467. */
  38468. init(): void;
  38469. /**
  38470. * Attaches the behavior to its arc rotate camera.
  38471. * @param camera Defines the camera to attach the behavior to
  38472. */
  38473. attach(camera: ArcRotateCamera): void;
  38474. /**
  38475. * Detaches the behavior from its current arc rotate camera.
  38476. */
  38477. detach(): void;
  38478. private _radiusIsAnimating;
  38479. private _radiusBounceTransition;
  38480. private _animatables;
  38481. private _cachedWheelPrecision;
  38482. /**
  38483. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38484. * @param radiusLimit The limit to check against.
  38485. * @return Bool to indicate if at limit.
  38486. */
  38487. private _isRadiusAtLimit;
  38488. /**
  38489. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38490. * @param radiusDelta The delta by which to animate to. Can be negative.
  38491. */
  38492. private _applyBoundRadiusAnimation;
  38493. /**
  38494. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38495. */
  38496. protected _clearAnimationLocks(): void;
  38497. /**
  38498. * Stops and removes all animations that have been applied to the camera
  38499. */
  38500. stopAllAnimations(): void;
  38501. }
  38502. }
  38503. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38504. import { Behavior } from "babylonjs/Behaviors/behavior";
  38505. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38506. import { ExponentialEase } from "babylonjs/Animations/easing";
  38507. import { Nullable } from "babylonjs/types";
  38508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38509. import { Vector3 } from "babylonjs/Maths/math.vector";
  38510. /**
  38511. * 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.
  38512. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38513. */
  38514. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38515. /**
  38516. * Gets the name of the behavior.
  38517. */
  38518. readonly name: string;
  38519. private _mode;
  38520. private _radiusScale;
  38521. private _positionScale;
  38522. private _defaultElevation;
  38523. private _elevationReturnTime;
  38524. private _elevationReturnWaitTime;
  38525. private _zoomStopsAnimation;
  38526. private _framingTime;
  38527. /**
  38528. * The easing function used by animations
  38529. */
  38530. static EasingFunction: ExponentialEase;
  38531. /**
  38532. * The easing mode used by animations
  38533. */
  38534. static EasingMode: number;
  38535. /**
  38536. * Sets the current mode used by the behavior
  38537. */
  38538. /**
  38539. * Gets current mode used by the behavior.
  38540. */
  38541. mode: number;
  38542. /**
  38543. * Sets the scale applied to the radius (1 by default)
  38544. */
  38545. /**
  38546. * Gets the scale applied to the radius
  38547. */
  38548. radiusScale: number;
  38549. /**
  38550. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38551. */
  38552. /**
  38553. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38554. */
  38555. positionScale: number;
  38556. /**
  38557. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38558. * behaviour is triggered, in radians.
  38559. */
  38560. /**
  38561. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38562. * behaviour is triggered, in radians.
  38563. */
  38564. defaultElevation: number;
  38565. /**
  38566. * Sets the time (in milliseconds) taken to return to the default beta position.
  38567. * Negative value indicates camera should not return to default.
  38568. */
  38569. /**
  38570. * Gets the time (in milliseconds) taken to return to the default beta position.
  38571. * Negative value indicates camera should not return to default.
  38572. */
  38573. elevationReturnTime: number;
  38574. /**
  38575. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38576. */
  38577. /**
  38578. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38579. */
  38580. elevationReturnWaitTime: number;
  38581. /**
  38582. * Sets the flag that indicates if user zooming should stop animation.
  38583. */
  38584. /**
  38585. * Gets the flag that indicates if user zooming should stop animation.
  38586. */
  38587. zoomStopsAnimation: boolean;
  38588. /**
  38589. * Sets the transition time when framing the mesh, in milliseconds
  38590. */
  38591. /**
  38592. * Gets the transition time when framing the mesh, in milliseconds
  38593. */
  38594. framingTime: number;
  38595. /**
  38596. * Define if the behavior should automatically change the configured
  38597. * camera limits and sensibilities.
  38598. */
  38599. autoCorrectCameraLimitsAndSensibility: boolean;
  38600. private _onPrePointerObservableObserver;
  38601. private _onAfterCheckInputsObserver;
  38602. private _onMeshTargetChangedObserver;
  38603. private _attachedCamera;
  38604. private _isPointerDown;
  38605. private _lastInteractionTime;
  38606. /**
  38607. * Initializes the behavior.
  38608. */
  38609. init(): void;
  38610. /**
  38611. * Attaches the behavior to its arc rotate camera.
  38612. * @param camera Defines the camera to attach the behavior to
  38613. */
  38614. attach(camera: ArcRotateCamera): void;
  38615. /**
  38616. * Detaches the behavior from its current arc rotate camera.
  38617. */
  38618. detach(): void;
  38619. private _animatables;
  38620. private _betaIsAnimating;
  38621. private _betaTransition;
  38622. private _radiusTransition;
  38623. private _vectorTransition;
  38624. /**
  38625. * Targets the given mesh and updates zoom level accordingly.
  38626. * @param mesh The mesh to target.
  38627. * @param radius Optional. If a cached radius position already exists, overrides default.
  38628. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38629. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38630. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38631. */
  38632. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38633. /**
  38634. * Targets the given mesh with its children and updates zoom level accordingly.
  38635. * @param mesh The mesh to target.
  38636. * @param radius Optional. If a cached radius position already exists, overrides default.
  38637. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38638. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38639. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38640. */
  38641. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38642. /**
  38643. * Targets the given meshes with their children and updates zoom level accordingly.
  38644. * @param meshes The mesh to target.
  38645. * @param radius Optional. If a cached radius position already exists, overrides default.
  38646. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38647. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38648. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38649. */
  38650. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38651. /**
  38652. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38653. * @param minimumWorld Determines the smaller position of the bounding box extend
  38654. * @param maximumWorld Determines the bigger position of the bounding box extend
  38655. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38656. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38657. */
  38658. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38659. /**
  38660. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38661. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38662. * frustum width.
  38663. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38664. * to fully enclose the mesh in the viewing frustum.
  38665. */
  38666. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38667. /**
  38668. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38669. * is automatically returned to its default position (expected to be above ground plane).
  38670. */
  38671. private _maintainCameraAboveGround;
  38672. /**
  38673. * Returns the frustum slope based on the canvas ratio and camera FOV
  38674. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38675. */
  38676. private _getFrustumSlope;
  38677. /**
  38678. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38679. */
  38680. private _clearAnimationLocks;
  38681. /**
  38682. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38683. */
  38684. private _applyUserInteraction;
  38685. /**
  38686. * Stops and removes all animations that have been applied to the camera
  38687. */
  38688. stopAllAnimations(): void;
  38689. /**
  38690. * Gets a value indicating if the user is moving the camera
  38691. */
  38692. readonly isUserIsMoving: boolean;
  38693. /**
  38694. * The camera can move all the way towards the mesh.
  38695. */
  38696. static IgnoreBoundsSizeMode: number;
  38697. /**
  38698. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38699. */
  38700. static FitFrustumSidesMode: number;
  38701. }
  38702. }
  38703. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  38704. import { Nullable } from "babylonjs/types";
  38705. import { Camera } from "babylonjs/Cameras/camera";
  38706. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38707. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38708. /**
  38709. * Base class for Camera Pointer Inputs.
  38710. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38711. * for example usage.
  38712. */
  38713. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38714. /**
  38715. * Defines the camera the input is attached to.
  38716. */
  38717. abstract camera: Camera;
  38718. /**
  38719. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38720. */
  38721. protected _altKey: boolean;
  38722. protected _ctrlKey: boolean;
  38723. protected _metaKey: boolean;
  38724. protected _shiftKey: boolean;
  38725. /**
  38726. * Which mouse buttons were pressed at time of last mouse event.
  38727. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38728. */
  38729. protected _buttonsPressed: number;
  38730. /**
  38731. * Defines the buttons associated with the input to handle camera move.
  38732. */
  38733. buttons: number[];
  38734. /**
  38735. * Attach the input controls to a specific dom element to get the input from.
  38736. * @param element Defines the element the controls should be listened from
  38737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38738. */
  38739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38740. /**
  38741. * Detach the current controls from the specified dom element.
  38742. * @param element Defines the element to stop listening the inputs from
  38743. */
  38744. detachControl(element: Nullable<HTMLElement>): void;
  38745. /**
  38746. * Gets the class name of the current input.
  38747. * @returns the class name
  38748. */
  38749. getClassName(): string;
  38750. /**
  38751. * Get the friendly name associated with the input class.
  38752. * @returns the input friendly name
  38753. */
  38754. getSimpleName(): string;
  38755. /**
  38756. * Called on pointer POINTERDOUBLETAP event.
  38757. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38758. */
  38759. protected onDoubleTap(type: string): void;
  38760. /**
  38761. * Called on pointer POINTERMOVE event if only a single touch is active.
  38762. * Override this method to provide functionality.
  38763. */
  38764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38765. /**
  38766. * Called on pointer POINTERMOVE event if multiple touches are active.
  38767. * Override this method to provide functionality.
  38768. */
  38769. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38770. /**
  38771. * Called on JS contextmenu event.
  38772. * Override this method to provide functionality.
  38773. */
  38774. protected onContextMenu(evt: PointerEvent): void;
  38775. /**
  38776. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38777. * press.
  38778. * Override this method to provide functionality.
  38779. */
  38780. protected onButtonDown(evt: PointerEvent): void;
  38781. /**
  38782. * Called each time a new POINTERUP event occurs. Ie, for each button
  38783. * release.
  38784. * Override this method to provide functionality.
  38785. */
  38786. protected onButtonUp(evt: PointerEvent): void;
  38787. /**
  38788. * Called when window becomes inactive.
  38789. * Override this method to provide functionality.
  38790. */
  38791. protected onLostFocus(): void;
  38792. private _pointerInput;
  38793. private _observer;
  38794. private _onLostFocus;
  38795. private pointA;
  38796. private pointB;
  38797. }
  38798. }
  38799. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  38800. import { Nullable } from "babylonjs/types";
  38801. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38802. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38803. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38804. /**
  38805. * Manage the pointers inputs to control an arc rotate camera.
  38806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38807. */
  38808. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38809. /**
  38810. * Defines the camera the input is attached to.
  38811. */
  38812. camera: ArcRotateCamera;
  38813. /**
  38814. * Gets the class name of the current input.
  38815. * @returns the class name
  38816. */
  38817. getClassName(): string;
  38818. /**
  38819. * Defines the buttons associated with the input to handle camera move.
  38820. */
  38821. buttons: number[];
  38822. /**
  38823. * Defines the pointer angular sensibility along the X axis or how fast is
  38824. * the camera rotating.
  38825. */
  38826. angularSensibilityX: number;
  38827. /**
  38828. * Defines the pointer angular sensibility along the Y axis or how fast is
  38829. * the camera rotating.
  38830. */
  38831. angularSensibilityY: number;
  38832. /**
  38833. * Defines the pointer pinch precision or how fast is the camera zooming.
  38834. */
  38835. pinchPrecision: number;
  38836. /**
  38837. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38838. * from 0.
  38839. * It defines the percentage of current camera.radius to use as delta when
  38840. * pinch zoom is used.
  38841. */
  38842. pinchDeltaPercentage: number;
  38843. /**
  38844. * Defines the pointer panning sensibility or how fast is the camera moving.
  38845. */
  38846. panningSensibility: number;
  38847. /**
  38848. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38849. */
  38850. multiTouchPanning: boolean;
  38851. /**
  38852. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38853. * zoom (pinch) through multitouch.
  38854. */
  38855. multiTouchPanAndZoom: boolean;
  38856. /**
  38857. * Revers pinch action direction.
  38858. */
  38859. pinchInwards: boolean;
  38860. private _isPanClick;
  38861. private _twoFingerActivityCount;
  38862. private _isPinching;
  38863. /**
  38864. * Called on pointer POINTERMOVE event if only a single touch is active.
  38865. */
  38866. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38867. /**
  38868. * Called on pointer POINTERDOUBLETAP event.
  38869. */
  38870. protected onDoubleTap(type: string): void;
  38871. /**
  38872. * Called on pointer POINTERMOVE event if multiple touches are active.
  38873. */
  38874. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38875. /**
  38876. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38877. * press.
  38878. */
  38879. protected onButtonDown(evt: PointerEvent): void;
  38880. /**
  38881. * Called each time a new POINTERUP event occurs. Ie, for each button
  38882. * release.
  38883. */
  38884. protected onButtonUp(evt: PointerEvent): void;
  38885. /**
  38886. * Called when window becomes inactive.
  38887. */
  38888. protected onLostFocus(): void;
  38889. }
  38890. }
  38891. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  38892. import { Nullable } from "babylonjs/types";
  38893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38895. /**
  38896. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38898. */
  38899. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38900. /**
  38901. * Defines the camera the input is attached to.
  38902. */
  38903. camera: ArcRotateCamera;
  38904. /**
  38905. * Defines the list of key codes associated with the up action (increase alpha)
  38906. */
  38907. keysUp: number[];
  38908. /**
  38909. * Defines the list of key codes associated with the down action (decrease alpha)
  38910. */
  38911. keysDown: number[];
  38912. /**
  38913. * Defines the list of key codes associated with the left action (increase beta)
  38914. */
  38915. keysLeft: number[];
  38916. /**
  38917. * Defines the list of key codes associated with the right action (decrease beta)
  38918. */
  38919. keysRight: number[];
  38920. /**
  38921. * Defines the list of key codes associated with the reset action.
  38922. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38923. */
  38924. keysReset: number[];
  38925. /**
  38926. * Defines the panning sensibility of the inputs.
  38927. * (How fast is the camera paning)
  38928. */
  38929. panningSensibility: number;
  38930. /**
  38931. * Defines the zooming sensibility of the inputs.
  38932. * (How fast is the camera zooming)
  38933. */
  38934. zoomingSensibility: number;
  38935. /**
  38936. * Defines wether maintaining the alt key down switch the movement mode from
  38937. * orientation to zoom.
  38938. */
  38939. useAltToZoom: boolean;
  38940. /**
  38941. * Rotation speed of the camera
  38942. */
  38943. angularSpeed: number;
  38944. private _keys;
  38945. private _ctrlPressed;
  38946. private _altPressed;
  38947. private _onCanvasBlurObserver;
  38948. private _onKeyboardObserver;
  38949. private _engine;
  38950. private _scene;
  38951. /**
  38952. * Attach the input controls to a specific dom element to get the input from.
  38953. * @param element Defines the element the controls should be listened from
  38954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38955. */
  38956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38957. /**
  38958. * Detach the current controls from the specified dom element.
  38959. * @param element Defines the element to stop listening the inputs from
  38960. */
  38961. detachControl(element: Nullable<HTMLElement>): void;
  38962. /**
  38963. * Update the current camera state depending on the inputs that have been used this frame.
  38964. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38965. */
  38966. checkInputs(): void;
  38967. /**
  38968. * Gets the class name of the current intput.
  38969. * @returns the class name
  38970. */
  38971. getClassName(): string;
  38972. /**
  38973. * Get the friendly name associated with the input class.
  38974. * @returns the input friendly name
  38975. */
  38976. getSimpleName(): string;
  38977. }
  38978. }
  38979. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  38980. import { Nullable } from "babylonjs/types";
  38981. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38982. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38983. /**
  38984. * Manage the mouse wheel inputs to control an arc rotate camera.
  38985. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38986. */
  38987. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38988. /**
  38989. * Defines the camera the input is attached to.
  38990. */
  38991. camera: ArcRotateCamera;
  38992. /**
  38993. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38994. */
  38995. wheelPrecision: number;
  38996. /**
  38997. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38998. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38999. */
  39000. wheelDeltaPercentage: number;
  39001. private _wheel;
  39002. private _observer;
  39003. private computeDeltaFromMouseWheelLegacyEvent;
  39004. /**
  39005. * Attach the input controls to a specific dom element to get the input from.
  39006. * @param element Defines the element the controls should be listened from
  39007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39008. */
  39009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39010. /**
  39011. * Detach the current controls from the specified dom element.
  39012. * @param element Defines the element to stop listening the inputs from
  39013. */
  39014. detachControl(element: Nullable<HTMLElement>): void;
  39015. /**
  39016. * Gets the class name of the current intput.
  39017. * @returns the class name
  39018. */
  39019. getClassName(): string;
  39020. /**
  39021. * Get the friendly name associated with the input class.
  39022. * @returns the input friendly name
  39023. */
  39024. getSimpleName(): string;
  39025. }
  39026. }
  39027. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39028. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39030. /**
  39031. * Default Inputs manager for the ArcRotateCamera.
  39032. * It groups all the default supported inputs for ease of use.
  39033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39034. */
  39035. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39036. /**
  39037. * Instantiates a new ArcRotateCameraInputsManager.
  39038. * @param camera Defines the camera the inputs belong to
  39039. */
  39040. constructor(camera: ArcRotateCamera);
  39041. /**
  39042. * Add mouse wheel input support to the input manager.
  39043. * @returns the current input manager
  39044. */
  39045. addMouseWheel(): ArcRotateCameraInputsManager;
  39046. /**
  39047. * Add pointers input support to the input manager.
  39048. * @returns the current input manager
  39049. */
  39050. addPointers(): ArcRotateCameraInputsManager;
  39051. /**
  39052. * Add keyboard input support to the input manager.
  39053. * @returns the current input manager
  39054. */
  39055. addKeyboard(): ArcRotateCameraInputsManager;
  39056. }
  39057. }
  39058. declare module "babylonjs/Cameras/arcRotateCamera" {
  39059. import { Observable } from "babylonjs/Misc/observable";
  39060. import { Nullable } from "babylonjs/types";
  39061. import { Scene } from "babylonjs/scene";
  39062. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39064. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39065. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39066. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39067. import { Camera } from "babylonjs/Cameras/camera";
  39068. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39069. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39070. import { Collider } from "babylonjs/Collisions/collider";
  39071. /**
  39072. * This represents an orbital type of camera.
  39073. *
  39074. * 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.
  39075. * 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.
  39076. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39077. */
  39078. export class ArcRotateCamera extends TargetCamera {
  39079. /**
  39080. * Defines the rotation angle of the camera along the longitudinal axis.
  39081. */
  39082. alpha: number;
  39083. /**
  39084. * Defines the rotation angle of the camera along the latitudinal axis.
  39085. */
  39086. beta: number;
  39087. /**
  39088. * Defines the radius of the camera from it s target point.
  39089. */
  39090. radius: number;
  39091. protected _target: Vector3;
  39092. protected _targetHost: Nullable<AbstractMesh>;
  39093. /**
  39094. * Defines the target point of the camera.
  39095. * The camera looks towards it form the radius distance.
  39096. */
  39097. target: Vector3;
  39098. /**
  39099. * Define the current local position of the camera in the scene
  39100. */
  39101. position: Vector3;
  39102. protected _upVector: Vector3;
  39103. protected _upToYMatrix: Matrix;
  39104. protected _YToUpMatrix: Matrix;
  39105. /**
  39106. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39107. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39108. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39109. */
  39110. upVector: Vector3;
  39111. /**
  39112. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39113. */
  39114. setMatUp(): void;
  39115. /**
  39116. * Current inertia value on the longitudinal axis.
  39117. * The bigger this number the longer it will take for the camera to stop.
  39118. */
  39119. inertialAlphaOffset: number;
  39120. /**
  39121. * Current inertia value on the latitudinal axis.
  39122. * The bigger this number the longer it will take for the camera to stop.
  39123. */
  39124. inertialBetaOffset: number;
  39125. /**
  39126. * Current inertia value on the radius axis.
  39127. * The bigger this number the longer it will take for the camera to stop.
  39128. */
  39129. inertialRadiusOffset: number;
  39130. /**
  39131. * Minimum allowed angle on the longitudinal axis.
  39132. * This can help limiting how the Camera is able to move in the scene.
  39133. */
  39134. lowerAlphaLimit: Nullable<number>;
  39135. /**
  39136. * Maximum allowed angle on the longitudinal axis.
  39137. * This can help limiting how the Camera is able to move in the scene.
  39138. */
  39139. upperAlphaLimit: Nullable<number>;
  39140. /**
  39141. * Minimum allowed angle on the latitudinal axis.
  39142. * This can help limiting how the Camera is able to move in the scene.
  39143. */
  39144. lowerBetaLimit: number;
  39145. /**
  39146. * Maximum allowed angle on the latitudinal axis.
  39147. * This can help limiting how the Camera is able to move in the scene.
  39148. */
  39149. upperBetaLimit: number;
  39150. /**
  39151. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39152. * This can help limiting how the Camera is able to move in the scene.
  39153. */
  39154. lowerRadiusLimit: Nullable<number>;
  39155. /**
  39156. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39157. * This can help limiting how the Camera is able to move in the scene.
  39158. */
  39159. upperRadiusLimit: Nullable<number>;
  39160. /**
  39161. * Defines the current inertia value used during panning of the camera along the X axis.
  39162. */
  39163. inertialPanningX: number;
  39164. /**
  39165. * Defines the current inertia value used during panning of the camera along the Y axis.
  39166. */
  39167. inertialPanningY: number;
  39168. /**
  39169. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39170. * Basically if your fingers moves away from more than this distance you will be considered
  39171. * in pinch mode.
  39172. */
  39173. pinchToPanMaxDistance: number;
  39174. /**
  39175. * Defines the maximum distance the camera can pan.
  39176. * This could help keeping the cammera always in your scene.
  39177. */
  39178. panningDistanceLimit: Nullable<number>;
  39179. /**
  39180. * Defines the target of the camera before paning.
  39181. */
  39182. panningOriginTarget: Vector3;
  39183. /**
  39184. * Defines the value of the inertia used during panning.
  39185. * 0 would mean stop inertia and one would mean no decelleration at all.
  39186. */
  39187. panningInertia: number;
  39188. /**
  39189. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39190. */
  39191. angularSensibilityX: number;
  39192. /**
  39193. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39194. */
  39195. angularSensibilityY: number;
  39196. /**
  39197. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39198. */
  39199. pinchPrecision: number;
  39200. /**
  39201. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39202. * It will be used instead of pinchDeltaPrecision if different from 0.
  39203. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39204. */
  39205. pinchDeltaPercentage: number;
  39206. /**
  39207. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39208. */
  39209. panningSensibility: number;
  39210. /**
  39211. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39212. */
  39213. keysUp: number[];
  39214. /**
  39215. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39216. */
  39217. keysDown: number[];
  39218. /**
  39219. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39220. */
  39221. keysLeft: number[];
  39222. /**
  39223. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39224. */
  39225. keysRight: number[];
  39226. /**
  39227. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39228. */
  39229. wheelPrecision: number;
  39230. /**
  39231. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39232. * It will be used instead of pinchDeltaPrecision if different from 0.
  39233. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39234. */
  39235. wheelDeltaPercentage: number;
  39236. /**
  39237. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39238. */
  39239. zoomOnFactor: number;
  39240. /**
  39241. * Defines a screen offset for the camera position.
  39242. */
  39243. targetScreenOffset: Vector2;
  39244. /**
  39245. * Allows the camera to be completely reversed.
  39246. * If false the camera can not arrive upside down.
  39247. */
  39248. allowUpsideDown: boolean;
  39249. /**
  39250. * Define if double tap/click is used to restore the previously saved state of the camera.
  39251. */
  39252. useInputToRestoreState: boolean;
  39253. /** @hidden */
  39254. _viewMatrix: Matrix;
  39255. /** @hidden */
  39256. _useCtrlForPanning: boolean;
  39257. /** @hidden */
  39258. _panningMouseButton: number;
  39259. /**
  39260. * Defines the input associated to the camera.
  39261. */
  39262. inputs: ArcRotateCameraInputsManager;
  39263. /** @hidden */
  39264. _reset: () => void;
  39265. /**
  39266. * Defines the allowed panning axis.
  39267. */
  39268. panningAxis: Vector3;
  39269. protected _localDirection: Vector3;
  39270. protected _transformedDirection: Vector3;
  39271. private _bouncingBehavior;
  39272. /**
  39273. * Gets the bouncing behavior of the camera if it has been enabled.
  39274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39275. */
  39276. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  39277. /**
  39278. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39280. */
  39281. useBouncingBehavior: boolean;
  39282. private _framingBehavior;
  39283. /**
  39284. * Gets the framing behavior of the camera if it has been enabled.
  39285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39286. */
  39287. readonly framingBehavior: Nullable<FramingBehavior>;
  39288. /**
  39289. * Defines if the framing behavior of the camera is enabled on the camera.
  39290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39291. */
  39292. useFramingBehavior: boolean;
  39293. private _autoRotationBehavior;
  39294. /**
  39295. * Gets the auto rotation behavior of the camera if it has been enabled.
  39296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39297. */
  39298. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  39299. /**
  39300. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39301. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39302. */
  39303. useAutoRotationBehavior: boolean;
  39304. /**
  39305. * Observable triggered when the mesh target has been changed on the camera.
  39306. */
  39307. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39308. /**
  39309. * Event raised when the camera is colliding with a mesh.
  39310. */
  39311. onCollide: (collidedMesh: AbstractMesh) => void;
  39312. /**
  39313. * Defines whether the camera should check collision with the objects oh the scene.
  39314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39315. */
  39316. checkCollisions: boolean;
  39317. /**
  39318. * Defines the collision radius of the camera.
  39319. * This simulates a sphere around the camera.
  39320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39321. */
  39322. collisionRadius: Vector3;
  39323. protected _collider: Collider;
  39324. protected _previousPosition: Vector3;
  39325. protected _collisionVelocity: Vector3;
  39326. protected _newPosition: Vector3;
  39327. protected _previousAlpha: number;
  39328. protected _previousBeta: number;
  39329. protected _previousRadius: number;
  39330. protected _collisionTriggered: boolean;
  39331. protected _targetBoundingCenter: Nullable<Vector3>;
  39332. private _computationVector;
  39333. /**
  39334. * Instantiates a new ArcRotateCamera in a given scene
  39335. * @param name Defines the name of the camera
  39336. * @param alpha Defines the camera rotation along the logitudinal axis
  39337. * @param beta Defines the camera rotation along the latitudinal axis
  39338. * @param radius Defines the camera distance from its target
  39339. * @param target Defines the camera target
  39340. * @param scene Defines the scene the camera belongs to
  39341. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39342. */
  39343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39344. /** @hidden */
  39345. _initCache(): void;
  39346. /** @hidden */
  39347. _updateCache(ignoreParentClass?: boolean): void;
  39348. protected _getTargetPosition(): Vector3;
  39349. private _storedAlpha;
  39350. private _storedBeta;
  39351. private _storedRadius;
  39352. private _storedTarget;
  39353. private _storedTargetScreenOffset;
  39354. /**
  39355. * Stores the current state of the camera (alpha, beta, radius and target)
  39356. * @returns the camera itself
  39357. */
  39358. storeState(): Camera;
  39359. /**
  39360. * @hidden
  39361. * Restored camera state. You must call storeState() first
  39362. */
  39363. _restoreStateValues(): boolean;
  39364. /** @hidden */
  39365. _isSynchronizedViewMatrix(): boolean;
  39366. /**
  39367. * Attached controls to the current camera.
  39368. * @param element Defines the element the controls should be listened from
  39369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39370. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39371. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39372. */
  39373. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39374. /**
  39375. * Detach the current controls from the camera.
  39376. * The camera will stop reacting to inputs.
  39377. * @param element Defines the element to stop listening the inputs from
  39378. */
  39379. detachControl(element: HTMLElement): void;
  39380. /** @hidden */
  39381. _checkInputs(): void;
  39382. protected _checkLimits(): void;
  39383. /**
  39384. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39385. */
  39386. rebuildAnglesAndRadius(): void;
  39387. /**
  39388. * Use a position to define the current camera related information like alpha, beta and radius
  39389. * @param position Defines the position to set the camera at
  39390. */
  39391. setPosition(position: Vector3): void;
  39392. /**
  39393. * Defines the target the camera should look at.
  39394. * This will automatically adapt alpha beta and radius to fit within the new target.
  39395. * @param target Defines the new target as a Vector or a mesh
  39396. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39397. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39398. */
  39399. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39400. /** @hidden */
  39401. _getViewMatrix(): Matrix;
  39402. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39403. /**
  39404. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39405. * @param meshes Defines the mesh to zoom on
  39406. * @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)
  39407. */
  39408. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39409. /**
  39410. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39411. * The target will be changed but the radius
  39412. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39413. * @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)
  39414. */
  39415. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39416. min: Vector3;
  39417. max: Vector3;
  39418. distance: number;
  39419. }, doNotUpdateMaxZ?: boolean): void;
  39420. /**
  39421. * @override
  39422. * Override Camera.createRigCamera
  39423. */
  39424. createRigCamera(name: string, cameraIndex: number): Camera;
  39425. /**
  39426. * @hidden
  39427. * @override
  39428. * Override Camera._updateRigCameras
  39429. */
  39430. _updateRigCameras(): void;
  39431. /**
  39432. * Destroy the camera and release the current resources hold by it.
  39433. */
  39434. dispose(): void;
  39435. /**
  39436. * Gets the current object class name.
  39437. * @return the class name
  39438. */
  39439. getClassName(): string;
  39440. }
  39441. }
  39442. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39443. import { Behavior } from "babylonjs/Behaviors/behavior";
  39444. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39445. /**
  39446. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39447. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39448. */
  39449. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39450. /**
  39451. * Gets the name of the behavior.
  39452. */
  39453. readonly name: string;
  39454. private _zoomStopsAnimation;
  39455. private _idleRotationSpeed;
  39456. private _idleRotationWaitTime;
  39457. private _idleRotationSpinupTime;
  39458. /**
  39459. * Sets the flag that indicates if user zooming should stop animation.
  39460. */
  39461. /**
  39462. * Gets the flag that indicates if user zooming should stop animation.
  39463. */
  39464. zoomStopsAnimation: boolean;
  39465. /**
  39466. * Sets the default speed at which the camera rotates around the model.
  39467. */
  39468. /**
  39469. * Gets the default speed at which the camera rotates around the model.
  39470. */
  39471. idleRotationSpeed: number;
  39472. /**
  39473. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39474. */
  39475. /**
  39476. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39477. */
  39478. idleRotationWaitTime: number;
  39479. /**
  39480. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39481. */
  39482. /**
  39483. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39484. */
  39485. idleRotationSpinupTime: number;
  39486. /**
  39487. * Gets a value indicating if the camera is currently rotating because of this behavior
  39488. */
  39489. readonly rotationInProgress: boolean;
  39490. private _onPrePointerObservableObserver;
  39491. private _onAfterCheckInputsObserver;
  39492. private _attachedCamera;
  39493. private _isPointerDown;
  39494. private _lastFrameTime;
  39495. private _lastInteractionTime;
  39496. private _cameraRotationSpeed;
  39497. /**
  39498. * Initializes the behavior.
  39499. */
  39500. init(): void;
  39501. /**
  39502. * Attaches the behavior to its arc rotate camera.
  39503. * @param camera Defines the camera to attach the behavior to
  39504. */
  39505. attach(camera: ArcRotateCamera): void;
  39506. /**
  39507. * Detaches the behavior from its current arc rotate camera.
  39508. */
  39509. detach(): void;
  39510. /**
  39511. * Returns true if user is scrolling.
  39512. * @return true if user is scrolling.
  39513. */
  39514. private _userIsZooming;
  39515. private _lastFrameRadius;
  39516. private _shouldAnimationStopForInteraction;
  39517. /**
  39518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39519. */
  39520. private _applyUserInteraction;
  39521. private _userIsMoving;
  39522. }
  39523. }
  39524. declare module "babylonjs/Behaviors/Cameras/index" {
  39525. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39526. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39527. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39528. }
  39529. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39530. import { Mesh } from "babylonjs/Meshes/mesh";
  39531. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39532. import { Behavior } from "babylonjs/Behaviors/behavior";
  39533. /**
  39534. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39535. */
  39536. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39537. private ui;
  39538. /**
  39539. * The name of the behavior
  39540. */
  39541. name: string;
  39542. /**
  39543. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39544. */
  39545. distanceAwayFromFace: number;
  39546. /**
  39547. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39548. */
  39549. distanceAwayFromBottomOfFace: number;
  39550. private _faceVectors;
  39551. private _target;
  39552. private _scene;
  39553. private _onRenderObserver;
  39554. private _tmpMatrix;
  39555. private _tmpVector;
  39556. /**
  39557. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39558. * @param ui The transform node that should be attched to the mesh
  39559. */
  39560. constructor(ui: TransformNode);
  39561. /**
  39562. * Initializes the behavior
  39563. */
  39564. init(): void;
  39565. private _closestFace;
  39566. private _zeroVector;
  39567. private _lookAtTmpMatrix;
  39568. private _lookAtToRef;
  39569. /**
  39570. * Attaches the AttachToBoxBehavior to the passed in mesh
  39571. * @param target The mesh that the specified node will be attached to
  39572. */
  39573. attach(target: Mesh): void;
  39574. /**
  39575. * Detaches the behavior from the mesh
  39576. */
  39577. detach(): void;
  39578. }
  39579. }
  39580. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39581. import { Behavior } from "babylonjs/Behaviors/behavior";
  39582. import { Mesh } from "babylonjs/Meshes/mesh";
  39583. /**
  39584. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39585. */
  39586. export class FadeInOutBehavior implements Behavior<Mesh> {
  39587. /**
  39588. * Time in milliseconds to delay before fading in (Default: 0)
  39589. */
  39590. delay: number;
  39591. /**
  39592. * Time in milliseconds for the mesh to fade in (Default: 300)
  39593. */
  39594. fadeInTime: number;
  39595. private _millisecondsPerFrame;
  39596. private _hovered;
  39597. private _hoverValue;
  39598. private _ownerNode;
  39599. /**
  39600. * Instatiates the FadeInOutBehavior
  39601. */
  39602. constructor();
  39603. /**
  39604. * The name of the behavior
  39605. */
  39606. readonly name: string;
  39607. /**
  39608. * Initializes the behavior
  39609. */
  39610. init(): void;
  39611. /**
  39612. * Attaches the fade behavior on the passed in mesh
  39613. * @param ownerNode The mesh that will be faded in/out once attached
  39614. */
  39615. attach(ownerNode: Mesh): void;
  39616. /**
  39617. * Detaches the behavior from the mesh
  39618. */
  39619. detach(): void;
  39620. /**
  39621. * Triggers the mesh to begin fading in or out
  39622. * @param value if the object should fade in or out (true to fade in)
  39623. */
  39624. fadeIn(value: boolean): void;
  39625. private _update;
  39626. private _setAllVisibility;
  39627. }
  39628. }
  39629. declare module "babylonjs/Misc/pivotTools" {
  39630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39631. /**
  39632. * Class containing a set of static utilities functions for managing Pivots
  39633. * @hidden
  39634. */
  39635. export class PivotTools {
  39636. private static _PivotCached;
  39637. private static _OldPivotPoint;
  39638. private static _PivotTranslation;
  39639. private static _PivotTmpVector;
  39640. /** @hidden */
  39641. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39642. /** @hidden */
  39643. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39644. }
  39645. }
  39646. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  39647. import { Scene } from "babylonjs/scene";
  39648. import { Vector4 } from "babylonjs/Maths/math.vector";
  39649. import { Mesh } from "babylonjs/Meshes/mesh";
  39650. import { Nullable } from "babylonjs/types";
  39651. import { Plane } from "babylonjs/Maths/math.plane";
  39652. /**
  39653. * Class containing static functions to help procedurally build meshes
  39654. */
  39655. export class PlaneBuilder {
  39656. /**
  39657. * Creates a plane mesh
  39658. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39659. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39660. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39664. * @param name defines the name of the mesh
  39665. * @param options defines the options used to create the mesh
  39666. * @param scene defines the hosting scene
  39667. * @returns the plane mesh
  39668. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39669. */
  39670. static CreatePlane(name: string, options: {
  39671. size?: number;
  39672. width?: number;
  39673. height?: number;
  39674. sideOrientation?: number;
  39675. frontUVs?: Vector4;
  39676. backUVs?: Vector4;
  39677. updatable?: boolean;
  39678. sourcePlane?: Plane;
  39679. }, scene?: Nullable<Scene>): Mesh;
  39680. }
  39681. }
  39682. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  39683. import { Behavior } from "babylonjs/Behaviors/behavior";
  39684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39685. import { Observable } from "babylonjs/Misc/observable";
  39686. import { Vector3 } from "babylonjs/Maths/math.vector";
  39687. import { Ray } from "babylonjs/Culling/ray";
  39688. import "babylonjs/Meshes/Builders/planeBuilder";
  39689. /**
  39690. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39691. */
  39692. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39693. private static _AnyMouseID;
  39694. /**
  39695. * Abstract mesh the behavior is set on
  39696. */
  39697. attachedNode: AbstractMesh;
  39698. private _dragPlane;
  39699. private _scene;
  39700. private _pointerObserver;
  39701. private _beforeRenderObserver;
  39702. private static _planeScene;
  39703. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39704. /**
  39705. * 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)
  39706. */
  39707. maxDragAngle: number;
  39708. /**
  39709. * @hidden
  39710. */
  39711. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39712. /**
  39713. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39714. */
  39715. currentDraggingPointerID: number;
  39716. /**
  39717. * The last position where the pointer hit the drag plane in world space
  39718. */
  39719. lastDragPosition: Vector3;
  39720. /**
  39721. * If the behavior is currently in a dragging state
  39722. */
  39723. dragging: boolean;
  39724. /**
  39725. * 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)
  39726. */
  39727. dragDeltaRatio: number;
  39728. /**
  39729. * If the drag plane orientation should be updated during the dragging (Default: true)
  39730. */
  39731. updateDragPlane: boolean;
  39732. private _debugMode;
  39733. private _moving;
  39734. /**
  39735. * Fires each time the attached mesh is dragged with the pointer
  39736. * * delta between last drag position and current drag position in world space
  39737. * * dragDistance along the drag axis
  39738. * * dragPlaneNormal normal of the current drag plane used during the drag
  39739. * * dragPlanePoint in world space where the drag intersects the drag plane
  39740. */
  39741. onDragObservable: Observable<{
  39742. delta: Vector3;
  39743. dragPlanePoint: Vector3;
  39744. dragPlaneNormal: Vector3;
  39745. dragDistance: number;
  39746. pointerId: number;
  39747. }>;
  39748. /**
  39749. * Fires each time a drag begins (eg. mouse down on mesh)
  39750. */
  39751. onDragStartObservable: Observable<{
  39752. dragPlanePoint: Vector3;
  39753. pointerId: number;
  39754. }>;
  39755. /**
  39756. * Fires each time a drag ends (eg. mouse release after drag)
  39757. */
  39758. onDragEndObservable: Observable<{
  39759. dragPlanePoint: Vector3;
  39760. pointerId: number;
  39761. }>;
  39762. /**
  39763. * If the attached mesh should be moved when dragged
  39764. */
  39765. moveAttached: boolean;
  39766. /**
  39767. * If the drag behavior will react to drag events (Default: true)
  39768. */
  39769. enabled: boolean;
  39770. /**
  39771. * If pointer events should start and release the drag (Default: true)
  39772. */
  39773. startAndReleaseDragOnPointerEvents: boolean;
  39774. /**
  39775. * If camera controls should be detached during the drag
  39776. */
  39777. detachCameraControls: boolean;
  39778. /**
  39779. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39780. */
  39781. useObjectOrienationForDragging: boolean;
  39782. private _options;
  39783. /**
  39784. * Gets the options used by the behavior
  39785. */
  39786. /**
  39787. * Sets the options used by the behavior
  39788. */
  39789. options: {
  39790. dragAxis?: Vector3;
  39791. dragPlaneNormal?: Vector3;
  39792. };
  39793. /**
  39794. * Creates a pointer drag behavior that can be attached to a mesh
  39795. * @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)
  39796. */
  39797. constructor(options?: {
  39798. dragAxis?: Vector3;
  39799. dragPlaneNormal?: Vector3;
  39800. });
  39801. /**
  39802. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39803. */
  39804. validateDrag: (targetPosition: Vector3) => boolean;
  39805. /**
  39806. * The name of the behavior
  39807. */
  39808. readonly name: string;
  39809. /**
  39810. * Initializes the behavior
  39811. */
  39812. init(): void;
  39813. private _tmpVector;
  39814. private _alternatePickedPoint;
  39815. private _worldDragAxis;
  39816. private _targetPosition;
  39817. private _attachedElement;
  39818. /**
  39819. * Attaches the drag behavior the passed in mesh
  39820. * @param ownerNode The mesh that will be dragged around once attached
  39821. * @param predicate Predicate to use for pick filtering
  39822. */
  39823. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39824. /**
  39825. * Force relase the drag action by code.
  39826. */
  39827. releaseDrag(): void;
  39828. private _startDragRay;
  39829. private _lastPointerRay;
  39830. /**
  39831. * Simulates the start of a pointer drag event on the behavior
  39832. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39833. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39834. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39835. */
  39836. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39837. private _startDrag;
  39838. private _dragDelta;
  39839. private _moveDrag;
  39840. private _pickWithRayOnDragPlane;
  39841. private _pointA;
  39842. private _pointB;
  39843. private _pointC;
  39844. private _lineA;
  39845. private _lineB;
  39846. private _localAxis;
  39847. private _lookAt;
  39848. private _updateDragPlanePosition;
  39849. /**
  39850. * Detaches the behavior from the mesh
  39851. */
  39852. detach(): void;
  39853. }
  39854. }
  39855. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  39856. import { Mesh } from "babylonjs/Meshes/mesh";
  39857. import { Behavior } from "babylonjs/Behaviors/behavior";
  39858. /**
  39859. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39860. */
  39861. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39862. private _dragBehaviorA;
  39863. private _dragBehaviorB;
  39864. private _startDistance;
  39865. private _initialScale;
  39866. private _targetScale;
  39867. private _ownerNode;
  39868. private _sceneRenderObserver;
  39869. /**
  39870. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39871. */
  39872. constructor();
  39873. /**
  39874. * The name of the behavior
  39875. */
  39876. readonly name: string;
  39877. /**
  39878. * Initializes the behavior
  39879. */
  39880. init(): void;
  39881. private _getCurrentDistance;
  39882. /**
  39883. * Attaches the scale behavior the passed in mesh
  39884. * @param ownerNode The mesh that will be scaled around once attached
  39885. */
  39886. attach(ownerNode: Mesh): void;
  39887. /**
  39888. * Detaches the behavior from the mesh
  39889. */
  39890. detach(): void;
  39891. }
  39892. }
  39893. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  39894. import { Behavior } from "babylonjs/Behaviors/behavior";
  39895. import { Mesh } from "babylonjs/Meshes/mesh";
  39896. import { Observable } from "babylonjs/Misc/observable";
  39897. /**
  39898. * 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
  39899. */
  39900. export class SixDofDragBehavior implements Behavior<Mesh> {
  39901. private static _virtualScene;
  39902. private _ownerNode;
  39903. private _sceneRenderObserver;
  39904. private _scene;
  39905. private _targetPosition;
  39906. private _virtualOriginMesh;
  39907. private _virtualDragMesh;
  39908. private _pointerObserver;
  39909. private _moving;
  39910. private _startingOrientation;
  39911. /**
  39912. * 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)
  39913. */
  39914. private zDragFactor;
  39915. /**
  39916. * If the object should rotate to face the drag origin
  39917. */
  39918. rotateDraggedObject: boolean;
  39919. /**
  39920. * If the behavior is currently in a dragging state
  39921. */
  39922. dragging: boolean;
  39923. /**
  39924. * 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)
  39925. */
  39926. dragDeltaRatio: number;
  39927. /**
  39928. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39929. */
  39930. currentDraggingPointerID: number;
  39931. /**
  39932. * If camera controls should be detached during the drag
  39933. */
  39934. detachCameraControls: boolean;
  39935. /**
  39936. * Fires each time a drag starts
  39937. */
  39938. onDragStartObservable: Observable<{}>;
  39939. /**
  39940. * Fires each time a drag ends (eg. mouse release after drag)
  39941. */
  39942. onDragEndObservable: Observable<{}>;
  39943. /**
  39944. * 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
  39945. */
  39946. constructor();
  39947. /**
  39948. * The name of the behavior
  39949. */
  39950. readonly name: string;
  39951. /**
  39952. * Initializes the behavior
  39953. */
  39954. init(): void;
  39955. /**
  39956. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39957. */
  39958. private readonly _pointerCamera;
  39959. /**
  39960. * Attaches the scale behavior the passed in mesh
  39961. * @param ownerNode The mesh that will be scaled around once attached
  39962. */
  39963. attach(ownerNode: Mesh): void;
  39964. /**
  39965. * Detaches the behavior from the mesh
  39966. */
  39967. detach(): void;
  39968. }
  39969. }
  39970. declare module "babylonjs/Behaviors/Meshes/index" {
  39971. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  39972. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  39973. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  39974. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  39975. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  39976. }
  39977. declare module "babylonjs/Behaviors/index" {
  39978. export * from "babylonjs/Behaviors/behavior";
  39979. export * from "babylonjs/Behaviors/Cameras/index";
  39980. export * from "babylonjs/Behaviors/Meshes/index";
  39981. }
  39982. declare module "babylonjs/Bones/boneIKController" {
  39983. import { Bone } from "babylonjs/Bones/bone";
  39984. import { Vector3 } from "babylonjs/Maths/math.vector";
  39985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39986. import { Nullable } from "babylonjs/types";
  39987. /**
  39988. * Class used to apply inverse kinematics to bones
  39989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39990. */
  39991. export class BoneIKController {
  39992. private static _tmpVecs;
  39993. private static _tmpQuat;
  39994. private static _tmpMats;
  39995. /**
  39996. * Gets or sets the target mesh
  39997. */
  39998. targetMesh: AbstractMesh;
  39999. /** Gets or sets the mesh used as pole */
  40000. poleTargetMesh: AbstractMesh;
  40001. /**
  40002. * Gets or sets the bone used as pole
  40003. */
  40004. poleTargetBone: Nullable<Bone>;
  40005. /**
  40006. * Gets or sets the target position
  40007. */
  40008. targetPosition: Vector3;
  40009. /**
  40010. * Gets or sets the pole target position
  40011. */
  40012. poleTargetPosition: Vector3;
  40013. /**
  40014. * Gets or sets the pole target local offset
  40015. */
  40016. poleTargetLocalOffset: Vector3;
  40017. /**
  40018. * Gets or sets the pole angle
  40019. */
  40020. poleAngle: number;
  40021. /**
  40022. * Gets or sets the mesh associated with the controller
  40023. */
  40024. mesh: AbstractMesh;
  40025. /**
  40026. * 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)
  40027. */
  40028. slerpAmount: number;
  40029. private _bone1Quat;
  40030. private _bone1Mat;
  40031. private _bone2Ang;
  40032. private _bone1;
  40033. private _bone2;
  40034. private _bone1Length;
  40035. private _bone2Length;
  40036. private _maxAngle;
  40037. private _maxReach;
  40038. private _rightHandedSystem;
  40039. private _bendAxis;
  40040. private _slerping;
  40041. private _adjustRoll;
  40042. /**
  40043. * Gets or sets maximum allowed angle
  40044. */
  40045. maxAngle: number;
  40046. /**
  40047. * Creates a new BoneIKController
  40048. * @param mesh defines the mesh to control
  40049. * @param bone defines the bone to control
  40050. * @param options defines options to set up the controller
  40051. */
  40052. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40053. targetMesh?: AbstractMesh;
  40054. poleTargetMesh?: AbstractMesh;
  40055. poleTargetBone?: Bone;
  40056. poleTargetLocalOffset?: Vector3;
  40057. poleAngle?: number;
  40058. bendAxis?: Vector3;
  40059. maxAngle?: number;
  40060. slerpAmount?: number;
  40061. });
  40062. private _setMaxAngle;
  40063. /**
  40064. * Force the controller to update the bones
  40065. */
  40066. update(): void;
  40067. }
  40068. }
  40069. declare module "babylonjs/Bones/boneLookController" {
  40070. import { Vector3 } from "babylonjs/Maths/math.vector";
  40071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40072. import { Bone } from "babylonjs/Bones/bone";
  40073. import { Space } from "babylonjs/Maths/math.axis";
  40074. /**
  40075. * Class used to make a bone look toward a point in space
  40076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40077. */
  40078. export class BoneLookController {
  40079. private static _tmpVecs;
  40080. private static _tmpQuat;
  40081. private static _tmpMats;
  40082. /**
  40083. * The target Vector3 that the bone will look at
  40084. */
  40085. target: Vector3;
  40086. /**
  40087. * The mesh that the bone is attached to
  40088. */
  40089. mesh: AbstractMesh;
  40090. /**
  40091. * The bone that will be looking to the target
  40092. */
  40093. bone: Bone;
  40094. /**
  40095. * The up axis of the coordinate system that is used when the bone is rotated
  40096. */
  40097. upAxis: Vector3;
  40098. /**
  40099. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40100. */
  40101. upAxisSpace: Space;
  40102. /**
  40103. * Used to make an adjustment to the yaw of the bone
  40104. */
  40105. adjustYaw: number;
  40106. /**
  40107. * Used to make an adjustment to the pitch of the bone
  40108. */
  40109. adjustPitch: number;
  40110. /**
  40111. * Used to make an adjustment to the roll of the bone
  40112. */
  40113. adjustRoll: number;
  40114. /**
  40115. * 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)
  40116. */
  40117. slerpAmount: number;
  40118. private _minYaw;
  40119. private _maxYaw;
  40120. private _minPitch;
  40121. private _maxPitch;
  40122. private _minYawSin;
  40123. private _minYawCos;
  40124. private _maxYawSin;
  40125. private _maxYawCos;
  40126. private _midYawConstraint;
  40127. private _minPitchTan;
  40128. private _maxPitchTan;
  40129. private _boneQuat;
  40130. private _slerping;
  40131. private _transformYawPitch;
  40132. private _transformYawPitchInv;
  40133. private _firstFrameSkipped;
  40134. private _yawRange;
  40135. private _fowardAxis;
  40136. /**
  40137. * Gets or sets the minimum yaw angle that the bone can look to
  40138. */
  40139. minYaw: number;
  40140. /**
  40141. * Gets or sets the maximum yaw angle that the bone can look to
  40142. */
  40143. maxYaw: number;
  40144. /**
  40145. * Gets or sets the minimum pitch angle that the bone can look to
  40146. */
  40147. minPitch: number;
  40148. /**
  40149. * Gets or sets the maximum pitch angle that the bone can look to
  40150. */
  40151. maxPitch: number;
  40152. /**
  40153. * Create a BoneLookController
  40154. * @param mesh the mesh that the bone belongs to
  40155. * @param bone the bone that will be looking to the target
  40156. * @param target the target Vector3 to look at
  40157. * @param options optional settings:
  40158. * * maxYaw: the maximum angle the bone will yaw to
  40159. * * minYaw: the minimum angle the bone will yaw to
  40160. * * maxPitch: the maximum angle the bone will pitch to
  40161. * * minPitch: the minimum angle the bone will yaw to
  40162. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40163. * * upAxis: the up axis of the coordinate system
  40164. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40165. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40166. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40167. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40168. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40169. * * adjustRoll: used to make an adjustment to the roll of the bone
  40170. **/
  40171. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40172. maxYaw?: number;
  40173. minYaw?: number;
  40174. maxPitch?: number;
  40175. minPitch?: number;
  40176. slerpAmount?: number;
  40177. upAxis?: Vector3;
  40178. upAxisSpace?: Space;
  40179. yawAxis?: Vector3;
  40180. pitchAxis?: Vector3;
  40181. adjustYaw?: number;
  40182. adjustPitch?: number;
  40183. adjustRoll?: number;
  40184. });
  40185. /**
  40186. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40187. */
  40188. update(): void;
  40189. private _getAngleDiff;
  40190. private _getAngleBetween;
  40191. private _isAngleBetween;
  40192. }
  40193. }
  40194. declare module "babylonjs/Bones/index" {
  40195. export * from "babylonjs/Bones/bone";
  40196. export * from "babylonjs/Bones/boneIKController";
  40197. export * from "babylonjs/Bones/boneLookController";
  40198. export * from "babylonjs/Bones/skeleton";
  40199. }
  40200. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40201. import { Nullable } from "babylonjs/types";
  40202. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40204. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40205. /**
  40206. * Manage the gamepad inputs to control an arc rotate camera.
  40207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40208. */
  40209. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40210. /**
  40211. * Defines the camera the input is attached to.
  40212. */
  40213. camera: ArcRotateCamera;
  40214. /**
  40215. * Defines the gamepad the input is gathering event from.
  40216. */
  40217. gamepad: Nullable<Gamepad>;
  40218. /**
  40219. * Defines the gamepad rotation sensiblity.
  40220. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40221. */
  40222. gamepadRotationSensibility: number;
  40223. /**
  40224. * Defines the gamepad move sensiblity.
  40225. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40226. */
  40227. gamepadMoveSensibility: number;
  40228. private _yAxisScale;
  40229. /**
  40230. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40231. */
  40232. invertYAxis: boolean;
  40233. private _onGamepadConnectedObserver;
  40234. private _onGamepadDisconnectedObserver;
  40235. /**
  40236. * Attach the input controls to a specific dom element to get the input from.
  40237. * @param element Defines the element the controls should be listened from
  40238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40239. */
  40240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40241. /**
  40242. * Detach the current controls from the specified dom element.
  40243. * @param element Defines the element to stop listening the inputs from
  40244. */
  40245. detachControl(element: Nullable<HTMLElement>): void;
  40246. /**
  40247. * Update the current camera state depending on the inputs that have been used this frame.
  40248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40249. */
  40250. checkInputs(): void;
  40251. /**
  40252. * Gets the class name of the current intput.
  40253. * @returns the class name
  40254. */
  40255. getClassName(): string;
  40256. /**
  40257. * Get the friendly name associated with the input class.
  40258. * @returns the input friendly name
  40259. */
  40260. getSimpleName(): string;
  40261. }
  40262. }
  40263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40264. import { Nullable } from "babylonjs/types";
  40265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40267. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40268. interface ArcRotateCameraInputsManager {
  40269. /**
  40270. * Add orientation input support to the input manager.
  40271. * @returns the current input manager
  40272. */
  40273. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40274. }
  40275. }
  40276. /**
  40277. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40279. */
  40280. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40281. /**
  40282. * Defines the camera the input is attached to.
  40283. */
  40284. camera: ArcRotateCamera;
  40285. /**
  40286. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40287. */
  40288. alphaCorrection: number;
  40289. /**
  40290. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40291. */
  40292. gammaCorrection: number;
  40293. private _alpha;
  40294. private _gamma;
  40295. private _dirty;
  40296. private _deviceOrientationHandler;
  40297. /**
  40298. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40299. */
  40300. constructor();
  40301. /**
  40302. * Attach the input controls to a specific dom element to get the input from.
  40303. * @param element Defines the element the controls should be listened from
  40304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40305. */
  40306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40307. /** @hidden */
  40308. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40309. /**
  40310. * Update the current camera state depending on the inputs that have been used this frame.
  40311. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40312. */
  40313. checkInputs(): void;
  40314. /**
  40315. * Detach the current controls from the specified dom element.
  40316. * @param element Defines the element to stop listening the inputs from
  40317. */
  40318. detachControl(element: Nullable<HTMLElement>): void;
  40319. /**
  40320. * Gets the class name of the current intput.
  40321. * @returns the class name
  40322. */
  40323. getClassName(): string;
  40324. /**
  40325. * Get the friendly name associated with the input class.
  40326. * @returns the input friendly name
  40327. */
  40328. getSimpleName(): string;
  40329. }
  40330. }
  40331. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40332. import { Nullable } from "babylonjs/types";
  40333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40334. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40335. /**
  40336. * Listen to mouse events to control the camera.
  40337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40338. */
  40339. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40340. /**
  40341. * Defines the camera the input is attached to.
  40342. */
  40343. camera: FlyCamera;
  40344. /**
  40345. * Defines if touch is enabled. (Default is true.)
  40346. */
  40347. touchEnabled: boolean;
  40348. /**
  40349. * Defines the buttons associated with the input to handle camera rotation.
  40350. */
  40351. buttons: number[];
  40352. /**
  40353. * Assign buttons for Yaw control.
  40354. */
  40355. buttonsYaw: number[];
  40356. /**
  40357. * Assign buttons for Pitch control.
  40358. */
  40359. buttonsPitch: number[];
  40360. /**
  40361. * Assign buttons for Roll control.
  40362. */
  40363. buttonsRoll: number[];
  40364. /**
  40365. * Detect if any button is being pressed while mouse is moved.
  40366. * -1 = Mouse locked.
  40367. * 0 = Left button.
  40368. * 1 = Middle Button.
  40369. * 2 = Right Button.
  40370. */
  40371. activeButton: number;
  40372. /**
  40373. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40374. * Higher values reduce its sensitivity.
  40375. */
  40376. angularSensibility: number;
  40377. private _mousemoveCallback;
  40378. private _observer;
  40379. private _rollObserver;
  40380. private previousPosition;
  40381. private noPreventDefault;
  40382. private element;
  40383. /**
  40384. * Listen to mouse events to control the camera.
  40385. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40387. */
  40388. constructor(touchEnabled?: boolean);
  40389. /**
  40390. * Attach the mouse control to the HTML DOM element.
  40391. * @param element Defines the element that listens to the input events.
  40392. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40393. */
  40394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40395. /**
  40396. * Detach the current controls from the specified dom element.
  40397. * @param element Defines the element to stop listening the inputs from
  40398. */
  40399. detachControl(element: Nullable<HTMLElement>): void;
  40400. /**
  40401. * Gets the class name of the current input.
  40402. * @returns the class name.
  40403. */
  40404. getClassName(): string;
  40405. /**
  40406. * Get the friendly name associated with the input class.
  40407. * @returns the input's friendly name.
  40408. */
  40409. getSimpleName(): string;
  40410. private _pointerInput;
  40411. private _onMouseMove;
  40412. /**
  40413. * Rotate camera by mouse offset.
  40414. */
  40415. private rotateCamera;
  40416. }
  40417. }
  40418. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40419. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40420. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40421. /**
  40422. * Default Inputs manager for the FlyCamera.
  40423. * It groups all the default supported inputs for ease of use.
  40424. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40425. */
  40426. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40427. /**
  40428. * Instantiates a new FlyCameraInputsManager.
  40429. * @param camera Defines the camera the inputs belong to.
  40430. */
  40431. constructor(camera: FlyCamera);
  40432. /**
  40433. * Add keyboard input support to the input manager.
  40434. * @returns the new FlyCameraKeyboardMoveInput().
  40435. */
  40436. addKeyboard(): FlyCameraInputsManager;
  40437. /**
  40438. * Add mouse input support to the input manager.
  40439. * @param touchEnabled Enable touch screen support.
  40440. * @returns the new FlyCameraMouseInput().
  40441. */
  40442. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40443. }
  40444. }
  40445. declare module "babylonjs/Cameras/flyCamera" {
  40446. import { Scene } from "babylonjs/scene";
  40447. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40449. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40450. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40451. /**
  40452. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40453. * such as in a 3D Space Shooter or a Flight Simulator.
  40454. */
  40455. export class FlyCamera extends TargetCamera {
  40456. /**
  40457. * Define the collision ellipsoid of the camera.
  40458. * This is helpful for simulating a camera body, like a player's body.
  40459. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40460. */
  40461. ellipsoid: Vector3;
  40462. /**
  40463. * Define an offset for the position of the ellipsoid around the camera.
  40464. * This can be helpful if the camera is attached away from the player's body center,
  40465. * such as at its head.
  40466. */
  40467. ellipsoidOffset: Vector3;
  40468. /**
  40469. * Enable or disable collisions of the camera with the rest of the scene objects.
  40470. */
  40471. checkCollisions: boolean;
  40472. /**
  40473. * Enable or disable gravity on the camera.
  40474. */
  40475. applyGravity: boolean;
  40476. /**
  40477. * Define the current direction the camera is moving to.
  40478. */
  40479. cameraDirection: Vector3;
  40480. /**
  40481. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40482. * This overrides and empties cameraRotation.
  40483. */
  40484. rotationQuaternion: Quaternion;
  40485. /**
  40486. * Track Roll to maintain the wanted Rolling when looking around.
  40487. */
  40488. _trackRoll: number;
  40489. /**
  40490. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40491. */
  40492. rollCorrect: number;
  40493. /**
  40494. * Mimic a banked turn, Rolling the camera when Yawing.
  40495. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40496. */
  40497. bankedTurn: boolean;
  40498. /**
  40499. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40500. */
  40501. bankedTurnLimit: number;
  40502. /**
  40503. * Value of 0 disables the banked Roll.
  40504. * Value of 1 is equal to the Yaw angle in radians.
  40505. */
  40506. bankedTurnMultiplier: number;
  40507. /**
  40508. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40509. */
  40510. inputs: FlyCameraInputsManager;
  40511. /**
  40512. * Gets the input sensibility for mouse input.
  40513. * Higher values reduce sensitivity.
  40514. */
  40515. /**
  40516. * Sets the input sensibility for a mouse input.
  40517. * Higher values reduce sensitivity.
  40518. */
  40519. angularSensibility: number;
  40520. /**
  40521. * Get the keys for camera movement forward.
  40522. */
  40523. /**
  40524. * Set the keys for camera movement forward.
  40525. */
  40526. keysForward: number[];
  40527. /**
  40528. * Get the keys for camera movement backward.
  40529. */
  40530. keysBackward: number[];
  40531. /**
  40532. * Get the keys for camera movement up.
  40533. */
  40534. /**
  40535. * Set the keys for camera movement up.
  40536. */
  40537. keysUp: number[];
  40538. /**
  40539. * Get the keys for camera movement down.
  40540. */
  40541. /**
  40542. * Set the keys for camera movement down.
  40543. */
  40544. keysDown: number[];
  40545. /**
  40546. * Get the keys for camera movement left.
  40547. */
  40548. /**
  40549. * Set the keys for camera movement left.
  40550. */
  40551. keysLeft: number[];
  40552. /**
  40553. * Set the keys for camera movement right.
  40554. */
  40555. /**
  40556. * Set the keys for camera movement right.
  40557. */
  40558. keysRight: number[];
  40559. /**
  40560. * Event raised when the camera collides with a mesh in the scene.
  40561. */
  40562. onCollide: (collidedMesh: AbstractMesh) => void;
  40563. private _collider;
  40564. private _needMoveForGravity;
  40565. private _oldPosition;
  40566. private _diffPosition;
  40567. private _newPosition;
  40568. /** @hidden */
  40569. _localDirection: Vector3;
  40570. /** @hidden */
  40571. _transformedDirection: Vector3;
  40572. /**
  40573. * Instantiates a FlyCamera.
  40574. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40575. * such as in a 3D Space Shooter or a Flight Simulator.
  40576. * @param name Define the name of the camera in the scene.
  40577. * @param position Define the starting position of the camera in the scene.
  40578. * @param scene Define the scene the camera belongs to.
  40579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40580. */
  40581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40582. /**
  40583. * Attach a control to the HTML DOM element.
  40584. * @param element Defines the element that listens to the input events.
  40585. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40586. */
  40587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40588. /**
  40589. * Detach a control from the HTML DOM element.
  40590. * The camera will stop reacting to that input.
  40591. * @param element Defines the element that listens to the input events.
  40592. */
  40593. detachControl(element: HTMLElement): void;
  40594. private _collisionMask;
  40595. /**
  40596. * Get the mask that the camera ignores in collision events.
  40597. */
  40598. /**
  40599. * Set the mask that the camera ignores in collision events.
  40600. */
  40601. collisionMask: number;
  40602. /** @hidden */
  40603. _collideWithWorld(displacement: Vector3): void;
  40604. /** @hidden */
  40605. private _onCollisionPositionChange;
  40606. /** @hidden */
  40607. _checkInputs(): void;
  40608. /** @hidden */
  40609. _decideIfNeedsToMove(): boolean;
  40610. /** @hidden */
  40611. _updatePosition(): void;
  40612. /**
  40613. * Restore the Roll to its target value at the rate specified.
  40614. * @param rate - Higher means slower restoring.
  40615. * @hidden
  40616. */
  40617. restoreRoll(rate: number): void;
  40618. /**
  40619. * Destroy the camera and release the current resources held by it.
  40620. */
  40621. dispose(): void;
  40622. /**
  40623. * Get the current object class name.
  40624. * @returns the class name.
  40625. */
  40626. getClassName(): string;
  40627. }
  40628. }
  40629. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  40630. import { Nullable } from "babylonjs/types";
  40631. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40632. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40633. /**
  40634. * Listen to keyboard events to control the camera.
  40635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40636. */
  40637. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40638. /**
  40639. * Defines the camera the input is attached to.
  40640. */
  40641. camera: FlyCamera;
  40642. /**
  40643. * The list of keyboard keys used to control the forward move of the camera.
  40644. */
  40645. keysForward: number[];
  40646. /**
  40647. * The list of keyboard keys used to control the backward move of the camera.
  40648. */
  40649. keysBackward: number[];
  40650. /**
  40651. * The list of keyboard keys used to control the forward move of the camera.
  40652. */
  40653. keysUp: number[];
  40654. /**
  40655. * The list of keyboard keys used to control the backward move of the camera.
  40656. */
  40657. keysDown: number[];
  40658. /**
  40659. * The list of keyboard keys used to control the right strafe move of the camera.
  40660. */
  40661. keysRight: number[];
  40662. /**
  40663. * The list of keyboard keys used to control the left strafe move of the camera.
  40664. */
  40665. keysLeft: number[];
  40666. private _keys;
  40667. private _onCanvasBlurObserver;
  40668. private _onKeyboardObserver;
  40669. private _engine;
  40670. private _scene;
  40671. /**
  40672. * Attach the input controls to a specific dom element to get the input from.
  40673. * @param element Defines the element the controls should be listened from
  40674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40675. */
  40676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40677. /**
  40678. * Detach the current controls from the specified dom element.
  40679. * @param element Defines the element to stop listening the inputs from
  40680. */
  40681. detachControl(element: Nullable<HTMLElement>): void;
  40682. /**
  40683. * Gets the class name of the current intput.
  40684. * @returns the class name
  40685. */
  40686. getClassName(): string;
  40687. /** @hidden */
  40688. _onLostFocus(e: FocusEvent): void;
  40689. /**
  40690. * Get the friendly name associated with the input class.
  40691. * @returns the input friendly name
  40692. */
  40693. getSimpleName(): string;
  40694. /**
  40695. * Update the current camera state depending on the inputs that have been used this frame.
  40696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40697. */
  40698. checkInputs(): void;
  40699. }
  40700. }
  40701. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  40702. import { Nullable } from "babylonjs/types";
  40703. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40704. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40705. /**
  40706. * Manage the mouse wheel inputs to control a follow camera.
  40707. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40708. */
  40709. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40710. /**
  40711. * Defines the camera the input is attached to.
  40712. */
  40713. camera: FollowCamera;
  40714. /**
  40715. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40716. */
  40717. axisControlRadius: boolean;
  40718. /**
  40719. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40720. */
  40721. axisControlHeight: boolean;
  40722. /**
  40723. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40724. */
  40725. axisControlRotation: boolean;
  40726. /**
  40727. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40728. * relation to mouseWheel events.
  40729. */
  40730. wheelPrecision: number;
  40731. /**
  40732. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40733. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40734. */
  40735. wheelDeltaPercentage: number;
  40736. private _wheel;
  40737. private _observer;
  40738. /**
  40739. * Attach the input controls to a specific dom element to get the input from.
  40740. * @param element Defines the element the controls should be listened from
  40741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40742. */
  40743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40744. /**
  40745. * Detach the current controls from the specified dom element.
  40746. * @param element Defines the element to stop listening the inputs from
  40747. */
  40748. detachControl(element: Nullable<HTMLElement>): void;
  40749. /**
  40750. * Gets the class name of the current intput.
  40751. * @returns the class name
  40752. */
  40753. getClassName(): string;
  40754. /**
  40755. * Get the friendly name associated with the input class.
  40756. * @returns the input friendly name
  40757. */
  40758. getSimpleName(): string;
  40759. }
  40760. }
  40761. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  40762. import { Nullable } from "babylonjs/types";
  40763. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40764. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  40765. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  40766. /**
  40767. * Manage the pointers inputs to control an follow camera.
  40768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40769. */
  40770. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40771. /**
  40772. * Defines the camera the input is attached to.
  40773. */
  40774. camera: FollowCamera;
  40775. /**
  40776. * Gets the class name of the current input.
  40777. * @returns the class name
  40778. */
  40779. getClassName(): string;
  40780. /**
  40781. * Defines the pointer angular sensibility along the X axis or how fast is
  40782. * the camera rotating.
  40783. * A negative number will reverse the axis direction.
  40784. */
  40785. angularSensibilityX: number;
  40786. /**
  40787. * Defines the pointer angular sensibility along the Y axis or how fast is
  40788. * the camera rotating.
  40789. * A negative number will reverse the axis direction.
  40790. */
  40791. angularSensibilityY: number;
  40792. /**
  40793. * Defines the pointer pinch precision or how fast is the camera zooming.
  40794. * A negative number will reverse the axis direction.
  40795. */
  40796. pinchPrecision: number;
  40797. /**
  40798. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40799. * from 0.
  40800. * It defines the percentage of current camera.radius to use as delta when
  40801. * pinch zoom is used.
  40802. */
  40803. pinchDeltaPercentage: number;
  40804. /**
  40805. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40806. */
  40807. axisXControlRadius: boolean;
  40808. /**
  40809. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40810. */
  40811. axisXControlHeight: boolean;
  40812. /**
  40813. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40814. */
  40815. axisXControlRotation: boolean;
  40816. /**
  40817. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40818. */
  40819. axisYControlRadius: boolean;
  40820. /**
  40821. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40822. */
  40823. axisYControlHeight: boolean;
  40824. /**
  40825. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40826. */
  40827. axisYControlRotation: boolean;
  40828. /**
  40829. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40830. */
  40831. axisPinchControlRadius: boolean;
  40832. /**
  40833. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40834. */
  40835. axisPinchControlHeight: boolean;
  40836. /**
  40837. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40838. */
  40839. axisPinchControlRotation: boolean;
  40840. /**
  40841. * Log error messages if basic misconfiguration has occurred.
  40842. */
  40843. warningEnable: boolean;
  40844. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40845. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40846. private _warningCounter;
  40847. private _warning;
  40848. }
  40849. }
  40850. declare module "babylonjs/Cameras/followCameraInputsManager" {
  40851. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40852. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  40853. /**
  40854. * Default Inputs manager for the FollowCamera.
  40855. * It groups all the default supported inputs for ease of use.
  40856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40857. */
  40858. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40859. /**
  40860. * Instantiates a new FollowCameraInputsManager.
  40861. * @param camera Defines the camera the inputs belong to
  40862. */
  40863. constructor(camera: FollowCamera);
  40864. /**
  40865. * Add keyboard input support to the input manager.
  40866. * @returns the current input manager
  40867. */
  40868. addKeyboard(): FollowCameraInputsManager;
  40869. /**
  40870. * Add mouse wheel input support to the input manager.
  40871. * @returns the current input manager
  40872. */
  40873. addMouseWheel(): FollowCameraInputsManager;
  40874. /**
  40875. * Add pointers input support to the input manager.
  40876. * @returns the current input manager
  40877. */
  40878. addPointers(): FollowCameraInputsManager;
  40879. /**
  40880. * Add orientation input support to the input manager.
  40881. * @returns the current input manager
  40882. */
  40883. addVRDeviceOrientation(): FollowCameraInputsManager;
  40884. }
  40885. }
  40886. declare module "babylonjs/Cameras/followCamera" {
  40887. import { Nullable } from "babylonjs/types";
  40888. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40889. import { Scene } from "babylonjs/scene";
  40890. import { Vector3 } from "babylonjs/Maths/math.vector";
  40891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40892. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  40893. /**
  40894. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40895. * an arc rotate version arcFollowCamera are available.
  40896. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40897. */
  40898. export class FollowCamera extends TargetCamera {
  40899. /**
  40900. * Distance the follow camera should follow an object at
  40901. */
  40902. radius: number;
  40903. /**
  40904. * Minimum allowed distance of the camera to the axis of rotation
  40905. * (The camera can not get closer).
  40906. * This can help limiting how the Camera is able to move in the scene.
  40907. */
  40908. lowerRadiusLimit: Nullable<number>;
  40909. /**
  40910. * Maximum allowed distance of the camera to the axis of rotation
  40911. * (The camera can not get further).
  40912. * This can help limiting how the Camera is able to move in the scene.
  40913. */
  40914. upperRadiusLimit: Nullable<number>;
  40915. /**
  40916. * Define a rotation offset between the camera and the object it follows
  40917. */
  40918. rotationOffset: number;
  40919. /**
  40920. * Minimum allowed angle to camera position relative to target object.
  40921. * This can help limiting how the Camera is able to move in the scene.
  40922. */
  40923. lowerRotationOffsetLimit: Nullable<number>;
  40924. /**
  40925. * Maximum allowed angle to camera position relative to target object.
  40926. * This can help limiting how the Camera is able to move in the scene.
  40927. */
  40928. upperRotationOffsetLimit: Nullable<number>;
  40929. /**
  40930. * Define a height offset between the camera and the object it follows.
  40931. * It can help following an object from the top (like a car chaing a plane)
  40932. */
  40933. heightOffset: number;
  40934. /**
  40935. * Minimum allowed height of camera position relative to target object.
  40936. * This can help limiting how the Camera is able to move in the scene.
  40937. */
  40938. lowerHeightOffsetLimit: Nullable<number>;
  40939. /**
  40940. * Maximum allowed height of camera position relative to target object.
  40941. * This can help limiting how the Camera is able to move in the scene.
  40942. */
  40943. upperHeightOffsetLimit: Nullable<number>;
  40944. /**
  40945. * Define how fast the camera can accelerate to follow it s target.
  40946. */
  40947. cameraAcceleration: number;
  40948. /**
  40949. * Define the speed limit of the camera following an object.
  40950. */
  40951. maxCameraSpeed: number;
  40952. /**
  40953. * Define the target of the camera.
  40954. */
  40955. lockedTarget: Nullable<AbstractMesh>;
  40956. /**
  40957. * Defines the input associated with the camera.
  40958. */
  40959. inputs: FollowCameraInputsManager;
  40960. /**
  40961. * Instantiates the follow camera.
  40962. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40963. * @param name Define the name of the camera in the scene
  40964. * @param position Define the position of the camera
  40965. * @param scene Define the scene the camera belong to
  40966. * @param lockedTarget Define the target of the camera
  40967. */
  40968. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40969. private _follow;
  40970. /**
  40971. * Attached controls to the current camera.
  40972. * @param element Defines the element the controls should be listened from
  40973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40974. */
  40975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40976. /**
  40977. * Detach the current controls from the camera.
  40978. * The camera will stop reacting to inputs.
  40979. * @param element Defines the element to stop listening the inputs from
  40980. */
  40981. detachControl(element: HTMLElement): void;
  40982. /** @hidden */
  40983. _checkInputs(): void;
  40984. private _checkLimits;
  40985. /**
  40986. * Gets the camera class name.
  40987. * @returns the class name
  40988. */
  40989. getClassName(): string;
  40990. }
  40991. /**
  40992. * Arc Rotate version of the follow camera.
  40993. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40994. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40995. */
  40996. export class ArcFollowCamera extends TargetCamera {
  40997. /** The longitudinal angle of the camera */
  40998. alpha: number;
  40999. /** The latitudinal angle of the camera */
  41000. beta: number;
  41001. /** The radius of the camera from its target */
  41002. radius: number;
  41003. /** Define the camera target (the messh it should follow) */
  41004. target: Nullable<AbstractMesh>;
  41005. private _cartesianCoordinates;
  41006. /**
  41007. * Instantiates a new ArcFollowCamera
  41008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41009. * @param name Define the name of the camera
  41010. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41011. * @param beta Define the rotation angle of the camera around the elevation axis
  41012. * @param radius Define the radius of the camera from its target point
  41013. * @param target Define the target of the camera
  41014. * @param scene Define the scene the camera belongs to
  41015. */
  41016. constructor(name: string,
  41017. /** The longitudinal angle of the camera */
  41018. alpha: number,
  41019. /** The latitudinal angle of the camera */
  41020. beta: number,
  41021. /** The radius of the camera from its target */
  41022. radius: number,
  41023. /** Define the camera target (the messh it should follow) */
  41024. target: Nullable<AbstractMesh>, scene: Scene);
  41025. private _follow;
  41026. /** @hidden */
  41027. _checkInputs(): void;
  41028. /**
  41029. * Returns the class name of the object.
  41030. * It is mostly used internally for serialization purposes.
  41031. */
  41032. getClassName(): string;
  41033. }
  41034. }
  41035. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41036. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41037. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41038. import { Nullable } from "babylonjs/types";
  41039. /**
  41040. * Manage the keyboard inputs to control the movement of a follow camera.
  41041. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41042. */
  41043. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41044. /**
  41045. * Defines the camera the input is attached to.
  41046. */
  41047. camera: FollowCamera;
  41048. /**
  41049. * Defines the list of key codes associated with the up action (increase heightOffset)
  41050. */
  41051. keysHeightOffsetIncr: number[];
  41052. /**
  41053. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41054. */
  41055. keysHeightOffsetDecr: number[];
  41056. /**
  41057. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41058. */
  41059. keysHeightOffsetModifierAlt: boolean;
  41060. /**
  41061. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41062. */
  41063. keysHeightOffsetModifierCtrl: boolean;
  41064. /**
  41065. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41066. */
  41067. keysHeightOffsetModifierShift: boolean;
  41068. /**
  41069. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41070. */
  41071. keysRotationOffsetIncr: number[];
  41072. /**
  41073. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41074. */
  41075. keysRotationOffsetDecr: number[];
  41076. /**
  41077. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41078. */
  41079. keysRotationOffsetModifierAlt: boolean;
  41080. /**
  41081. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41082. */
  41083. keysRotationOffsetModifierCtrl: boolean;
  41084. /**
  41085. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41086. */
  41087. keysRotationOffsetModifierShift: boolean;
  41088. /**
  41089. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41090. */
  41091. keysRadiusIncr: number[];
  41092. /**
  41093. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41094. */
  41095. keysRadiusDecr: number[];
  41096. /**
  41097. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41098. */
  41099. keysRadiusModifierAlt: boolean;
  41100. /**
  41101. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41102. */
  41103. keysRadiusModifierCtrl: boolean;
  41104. /**
  41105. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41106. */
  41107. keysRadiusModifierShift: boolean;
  41108. /**
  41109. * Defines the rate of change of heightOffset.
  41110. */
  41111. heightSensibility: number;
  41112. /**
  41113. * Defines the rate of change of rotationOffset.
  41114. */
  41115. rotationSensibility: number;
  41116. /**
  41117. * Defines the rate of change of radius.
  41118. */
  41119. radiusSensibility: number;
  41120. private _keys;
  41121. private _ctrlPressed;
  41122. private _altPressed;
  41123. private _shiftPressed;
  41124. private _onCanvasBlurObserver;
  41125. private _onKeyboardObserver;
  41126. private _engine;
  41127. private _scene;
  41128. /**
  41129. * Attach the input controls to a specific dom element to get the input from.
  41130. * @param element Defines the element the controls should be listened from
  41131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41132. */
  41133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41134. /**
  41135. * Detach the current controls from the specified dom element.
  41136. * @param element Defines the element to stop listening the inputs from
  41137. */
  41138. detachControl(element: Nullable<HTMLElement>): void;
  41139. /**
  41140. * Update the current camera state depending on the inputs that have been used this frame.
  41141. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41142. */
  41143. checkInputs(): void;
  41144. /**
  41145. * Gets the class name of the current input.
  41146. * @returns the class name
  41147. */
  41148. getClassName(): string;
  41149. /**
  41150. * Get the friendly name associated with the input class.
  41151. * @returns the input friendly name
  41152. */
  41153. getSimpleName(): string;
  41154. /**
  41155. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41156. * allow modification of the heightOffset value.
  41157. */
  41158. private _modifierHeightOffset;
  41159. /**
  41160. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41161. * allow modification of the rotationOffset value.
  41162. */
  41163. private _modifierRotationOffset;
  41164. /**
  41165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41166. * allow modification of the radius value.
  41167. */
  41168. private _modifierRadius;
  41169. }
  41170. }
  41171. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41172. import { Nullable } from "babylonjs/types";
  41173. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41174. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41175. import { Observable } from "babylonjs/Misc/observable";
  41176. module "babylonjs/Cameras/freeCameraInputsManager" {
  41177. interface FreeCameraInputsManager {
  41178. /**
  41179. * @hidden
  41180. */
  41181. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41182. /**
  41183. * Add orientation input support to the input manager.
  41184. * @returns the current input manager
  41185. */
  41186. addDeviceOrientation(): FreeCameraInputsManager;
  41187. }
  41188. }
  41189. /**
  41190. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41191. * Screen rotation is taken into account.
  41192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41193. */
  41194. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41195. private _camera;
  41196. private _screenOrientationAngle;
  41197. private _constantTranform;
  41198. private _screenQuaternion;
  41199. private _alpha;
  41200. private _beta;
  41201. private _gamma;
  41202. /**
  41203. * Can be used to detect if a device orientation sensor is available on a device
  41204. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41205. * @returns a promise that will resolve on orientation change
  41206. */
  41207. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41208. /**
  41209. * @hidden
  41210. */
  41211. _onDeviceOrientationChangedObservable: Observable<void>;
  41212. /**
  41213. * Instantiates a new input
  41214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41215. */
  41216. constructor();
  41217. /**
  41218. * Define the camera controlled by the input.
  41219. */
  41220. camera: FreeCamera;
  41221. /**
  41222. * Attach the input controls to a specific dom element to get the input from.
  41223. * @param element Defines the element the controls should be listened from
  41224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41225. */
  41226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41227. private _orientationChanged;
  41228. private _deviceOrientation;
  41229. /**
  41230. * Detach the current controls from the specified dom element.
  41231. * @param element Defines the element to stop listening the inputs from
  41232. */
  41233. detachControl(element: Nullable<HTMLElement>): void;
  41234. /**
  41235. * Update the current camera state depending on the inputs that have been used this frame.
  41236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41237. */
  41238. checkInputs(): void;
  41239. /**
  41240. * Gets the class name of the current intput.
  41241. * @returns the class name
  41242. */
  41243. getClassName(): string;
  41244. /**
  41245. * Get the friendly name associated with the input class.
  41246. * @returns the input friendly name
  41247. */
  41248. getSimpleName(): string;
  41249. }
  41250. }
  41251. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41252. import { Nullable } from "babylonjs/types";
  41253. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41254. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41255. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41256. /**
  41257. * Manage the gamepad inputs to control a free camera.
  41258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41259. */
  41260. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41261. /**
  41262. * Define the camera the input is attached to.
  41263. */
  41264. camera: FreeCamera;
  41265. /**
  41266. * Define the Gamepad controlling the input
  41267. */
  41268. gamepad: Nullable<Gamepad>;
  41269. /**
  41270. * Defines the gamepad rotation sensiblity.
  41271. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41272. */
  41273. gamepadAngularSensibility: number;
  41274. /**
  41275. * Defines the gamepad move sensiblity.
  41276. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41277. */
  41278. gamepadMoveSensibility: number;
  41279. private _yAxisScale;
  41280. /**
  41281. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41282. */
  41283. invertYAxis: boolean;
  41284. private _onGamepadConnectedObserver;
  41285. private _onGamepadDisconnectedObserver;
  41286. private _cameraTransform;
  41287. private _deltaTransform;
  41288. private _vector3;
  41289. private _vector2;
  41290. /**
  41291. * Attach the input controls to a specific dom element to get the input from.
  41292. * @param element Defines the element the controls should be listened from
  41293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41294. */
  41295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41296. /**
  41297. * Detach the current controls from the specified dom element.
  41298. * @param element Defines the element to stop listening the inputs from
  41299. */
  41300. detachControl(element: Nullable<HTMLElement>): void;
  41301. /**
  41302. * Update the current camera state depending on the inputs that have been used this frame.
  41303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41304. */
  41305. checkInputs(): void;
  41306. /**
  41307. * Gets the class name of the current intput.
  41308. * @returns the class name
  41309. */
  41310. getClassName(): string;
  41311. /**
  41312. * Get the friendly name associated with the input class.
  41313. * @returns the input friendly name
  41314. */
  41315. getSimpleName(): string;
  41316. }
  41317. }
  41318. declare module "babylonjs/Misc/virtualJoystick" {
  41319. import { Nullable } from "babylonjs/types";
  41320. import { Vector3 } from "babylonjs/Maths/math.vector";
  41321. /**
  41322. * Defines the potential axis of a Joystick
  41323. */
  41324. export enum JoystickAxis {
  41325. /** X axis */
  41326. X = 0,
  41327. /** Y axis */
  41328. Y = 1,
  41329. /** Z axis */
  41330. Z = 2
  41331. }
  41332. /**
  41333. * Class used to define virtual joystick (used in touch mode)
  41334. */
  41335. export class VirtualJoystick {
  41336. /**
  41337. * Gets or sets a boolean indicating that left and right values must be inverted
  41338. */
  41339. reverseLeftRight: boolean;
  41340. /**
  41341. * Gets or sets a boolean indicating that up and down values must be inverted
  41342. */
  41343. reverseUpDown: boolean;
  41344. /**
  41345. * Gets the offset value for the position (ie. the change of the position value)
  41346. */
  41347. deltaPosition: Vector3;
  41348. /**
  41349. * Gets a boolean indicating if the virtual joystick was pressed
  41350. */
  41351. pressed: boolean;
  41352. /**
  41353. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41354. */
  41355. static Canvas: Nullable<HTMLCanvasElement>;
  41356. private static _globalJoystickIndex;
  41357. private static vjCanvasContext;
  41358. private static vjCanvasWidth;
  41359. private static vjCanvasHeight;
  41360. private static halfWidth;
  41361. private _action;
  41362. private _axisTargetedByLeftAndRight;
  41363. private _axisTargetedByUpAndDown;
  41364. private _joystickSensibility;
  41365. private _inversedSensibility;
  41366. private _joystickPointerID;
  41367. private _joystickColor;
  41368. private _joystickPointerPos;
  41369. private _joystickPreviousPointerPos;
  41370. private _joystickPointerStartPos;
  41371. private _deltaJoystickVector;
  41372. private _leftJoystick;
  41373. private _touches;
  41374. private _onPointerDownHandlerRef;
  41375. private _onPointerMoveHandlerRef;
  41376. private _onPointerUpHandlerRef;
  41377. private _onResize;
  41378. /**
  41379. * Creates a new virtual joystick
  41380. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41381. */
  41382. constructor(leftJoystick?: boolean);
  41383. /**
  41384. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41385. * @param newJoystickSensibility defines the new sensibility
  41386. */
  41387. setJoystickSensibility(newJoystickSensibility: number): void;
  41388. private _onPointerDown;
  41389. private _onPointerMove;
  41390. private _onPointerUp;
  41391. /**
  41392. * Change the color of the virtual joystick
  41393. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41394. */
  41395. setJoystickColor(newColor: string): void;
  41396. /**
  41397. * Defines a callback to call when the joystick is touched
  41398. * @param action defines the callback
  41399. */
  41400. setActionOnTouch(action: () => any): void;
  41401. /**
  41402. * Defines which axis you'd like to control for left & right
  41403. * @param axis defines the axis to use
  41404. */
  41405. setAxisForLeftRight(axis: JoystickAxis): void;
  41406. /**
  41407. * Defines which axis you'd like to control for up & down
  41408. * @param axis defines the axis to use
  41409. */
  41410. setAxisForUpDown(axis: JoystickAxis): void;
  41411. private _drawVirtualJoystick;
  41412. /**
  41413. * Release internal HTML canvas
  41414. */
  41415. releaseCanvas(): void;
  41416. }
  41417. }
  41418. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41419. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41420. import { Nullable } from "babylonjs/types";
  41421. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41422. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41423. module "babylonjs/Cameras/freeCameraInputsManager" {
  41424. interface FreeCameraInputsManager {
  41425. /**
  41426. * Add virtual joystick input support to the input manager.
  41427. * @returns the current input manager
  41428. */
  41429. addVirtualJoystick(): FreeCameraInputsManager;
  41430. }
  41431. }
  41432. /**
  41433. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41435. */
  41436. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41437. /**
  41438. * Defines the camera the input is attached to.
  41439. */
  41440. camera: FreeCamera;
  41441. private _leftjoystick;
  41442. private _rightjoystick;
  41443. /**
  41444. * Gets the left stick of the virtual joystick.
  41445. * @returns The virtual Joystick
  41446. */
  41447. getLeftJoystick(): VirtualJoystick;
  41448. /**
  41449. * Gets the right stick of the virtual joystick.
  41450. * @returns The virtual Joystick
  41451. */
  41452. getRightJoystick(): VirtualJoystick;
  41453. /**
  41454. * Update the current camera state depending on the inputs that have been used this frame.
  41455. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41456. */
  41457. checkInputs(): void;
  41458. /**
  41459. * Attach the input controls to a specific dom element to get the input from.
  41460. * @param element Defines the element the controls should be listened from
  41461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41462. */
  41463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41464. /**
  41465. * Detach the current controls from the specified dom element.
  41466. * @param element Defines the element to stop listening the inputs from
  41467. */
  41468. detachControl(element: Nullable<HTMLElement>): void;
  41469. /**
  41470. * Gets the class name of the current intput.
  41471. * @returns the class name
  41472. */
  41473. getClassName(): string;
  41474. /**
  41475. * Get the friendly name associated with the input class.
  41476. * @returns the input friendly name
  41477. */
  41478. getSimpleName(): string;
  41479. }
  41480. }
  41481. declare module "babylonjs/Cameras/Inputs/index" {
  41482. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41483. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41484. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41485. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41486. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41487. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41488. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41489. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41490. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41491. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41492. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41493. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41494. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41495. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41496. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41497. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41498. }
  41499. declare module "babylonjs/Cameras/touchCamera" {
  41500. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41501. import { Scene } from "babylonjs/scene";
  41502. import { Vector3 } from "babylonjs/Maths/math.vector";
  41503. /**
  41504. * This represents a FPS type of camera controlled by touch.
  41505. * This is like a universal camera minus the Gamepad controls.
  41506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41507. */
  41508. export class TouchCamera extends FreeCamera {
  41509. /**
  41510. * Defines the touch sensibility for rotation.
  41511. * The higher the faster.
  41512. */
  41513. touchAngularSensibility: number;
  41514. /**
  41515. * Defines the touch sensibility for move.
  41516. * The higher the faster.
  41517. */
  41518. touchMoveSensibility: number;
  41519. /**
  41520. * Instantiates a new touch camera.
  41521. * This represents a FPS type of camera controlled by touch.
  41522. * This is like a universal camera minus the Gamepad controls.
  41523. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41524. * @param name Define the name of the camera in the scene
  41525. * @param position Define the start position of the camera in the scene
  41526. * @param scene Define the scene the camera belongs to
  41527. */
  41528. constructor(name: string, position: Vector3, scene: Scene);
  41529. /**
  41530. * Gets the current object class name.
  41531. * @return the class name
  41532. */
  41533. getClassName(): string;
  41534. /** @hidden */
  41535. _setupInputs(): void;
  41536. }
  41537. }
  41538. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41539. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41540. import { Scene } from "babylonjs/scene";
  41541. import { Vector3 } from "babylonjs/Maths/math.vector";
  41542. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41543. import { Axis } from "babylonjs/Maths/math.axis";
  41544. /**
  41545. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41546. * being tilted forward or back and left or right.
  41547. */
  41548. export class DeviceOrientationCamera extends FreeCamera {
  41549. private _initialQuaternion;
  41550. private _quaternionCache;
  41551. private _tmpDragQuaternion;
  41552. private _disablePointerInputWhenUsingDeviceOrientation;
  41553. /**
  41554. * Creates a new device orientation camera
  41555. * @param name The name of the camera
  41556. * @param position The start position camera
  41557. * @param scene The scene the camera belongs to
  41558. */
  41559. constructor(name: string, position: Vector3, scene: Scene);
  41560. /**
  41561. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41562. */
  41563. disablePointerInputWhenUsingDeviceOrientation: boolean;
  41564. private _dragFactor;
  41565. /**
  41566. * Enabled turning on the y axis when the orientation sensor is active
  41567. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41568. */
  41569. enableHorizontalDragging(dragFactor?: number): void;
  41570. /**
  41571. * Gets the current instance class name ("DeviceOrientationCamera").
  41572. * This helps avoiding instanceof at run time.
  41573. * @returns the class name
  41574. */
  41575. getClassName(): string;
  41576. /**
  41577. * @hidden
  41578. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41579. */
  41580. _checkInputs(): void;
  41581. /**
  41582. * Reset the camera to its default orientation on the specified axis only.
  41583. * @param axis The axis to reset
  41584. */
  41585. resetToCurrentRotation(axis?: Axis): void;
  41586. }
  41587. }
  41588. declare module "babylonjs/Gamepads/xboxGamepad" {
  41589. import { Observable } from "babylonjs/Misc/observable";
  41590. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41591. /**
  41592. * Defines supported buttons for XBox360 compatible gamepads
  41593. */
  41594. export enum Xbox360Button {
  41595. /** A */
  41596. A = 0,
  41597. /** B */
  41598. B = 1,
  41599. /** X */
  41600. X = 2,
  41601. /** Y */
  41602. Y = 3,
  41603. /** Start */
  41604. Start = 4,
  41605. /** Back */
  41606. Back = 5,
  41607. /** Left button */
  41608. LB = 6,
  41609. /** Right button */
  41610. RB = 7,
  41611. /** Left stick */
  41612. LeftStick = 8,
  41613. /** Right stick */
  41614. RightStick = 9
  41615. }
  41616. /** Defines values for XBox360 DPad */
  41617. export enum Xbox360Dpad {
  41618. /** Up */
  41619. Up = 0,
  41620. /** Down */
  41621. Down = 1,
  41622. /** Left */
  41623. Left = 2,
  41624. /** Right */
  41625. Right = 3
  41626. }
  41627. /**
  41628. * Defines a XBox360 gamepad
  41629. */
  41630. export class Xbox360Pad extends Gamepad {
  41631. private _leftTrigger;
  41632. private _rightTrigger;
  41633. private _onlefttriggerchanged;
  41634. private _onrighttriggerchanged;
  41635. private _onbuttondown;
  41636. private _onbuttonup;
  41637. private _ondpaddown;
  41638. private _ondpadup;
  41639. /** Observable raised when a button is pressed */
  41640. onButtonDownObservable: Observable<Xbox360Button>;
  41641. /** Observable raised when a button is released */
  41642. onButtonUpObservable: Observable<Xbox360Button>;
  41643. /** Observable raised when a pad is pressed */
  41644. onPadDownObservable: Observable<Xbox360Dpad>;
  41645. /** Observable raised when a pad is released */
  41646. onPadUpObservable: Observable<Xbox360Dpad>;
  41647. private _buttonA;
  41648. private _buttonB;
  41649. private _buttonX;
  41650. private _buttonY;
  41651. private _buttonBack;
  41652. private _buttonStart;
  41653. private _buttonLB;
  41654. private _buttonRB;
  41655. private _buttonLeftStick;
  41656. private _buttonRightStick;
  41657. private _dPadUp;
  41658. private _dPadDown;
  41659. private _dPadLeft;
  41660. private _dPadRight;
  41661. private _isXboxOnePad;
  41662. /**
  41663. * Creates a new XBox360 gamepad object
  41664. * @param id defines the id of this gamepad
  41665. * @param index defines its index
  41666. * @param gamepad defines the internal HTML gamepad object
  41667. * @param xboxOne defines if it is a XBox One gamepad
  41668. */
  41669. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41670. /**
  41671. * Defines the callback to call when left trigger is pressed
  41672. * @param callback defines the callback to use
  41673. */
  41674. onlefttriggerchanged(callback: (value: number) => void): void;
  41675. /**
  41676. * Defines the callback to call when right trigger is pressed
  41677. * @param callback defines the callback to use
  41678. */
  41679. onrighttriggerchanged(callback: (value: number) => void): void;
  41680. /**
  41681. * Gets the left trigger value
  41682. */
  41683. /**
  41684. * Sets the left trigger value
  41685. */
  41686. leftTrigger: number;
  41687. /**
  41688. * Gets the right trigger value
  41689. */
  41690. /**
  41691. * Sets the right trigger value
  41692. */
  41693. rightTrigger: number;
  41694. /**
  41695. * Defines the callback to call when a button is pressed
  41696. * @param callback defines the callback to use
  41697. */
  41698. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41699. /**
  41700. * Defines the callback to call when a button is released
  41701. * @param callback defines the callback to use
  41702. */
  41703. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41704. /**
  41705. * Defines the callback to call when a pad is pressed
  41706. * @param callback defines the callback to use
  41707. */
  41708. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41709. /**
  41710. * Defines the callback to call when a pad is released
  41711. * @param callback defines the callback to use
  41712. */
  41713. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41714. private _setButtonValue;
  41715. private _setDPadValue;
  41716. /**
  41717. * Gets the value of the `A` button
  41718. */
  41719. /**
  41720. * Sets the value of the `A` button
  41721. */
  41722. buttonA: number;
  41723. /**
  41724. * Gets the value of the `B` button
  41725. */
  41726. /**
  41727. * Sets the value of the `B` button
  41728. */
  41729. buttonB: number;
  41730. /**
  41731. * Gets the value of the `X` button
  41732. */
  41733. /**
  41734. * Sets the value of the `X` button
  41735. */
  41736. buttonX: number;
  41737. /**
  41738. * Gets the value of the `Y` button
  41739. */
  41740. /**
  41741. * Sets the value of the `Y` button
  41742. */
  41743. buttonY: number;
  41744. /**
  41745. * Gets the value of the `Start` button
  41746. */
  41747. /**
  41748. * Sets the value of the `Start` button
  41749. */
  41750. buttonStart: number;
  41751. /**
  41752. * Gets the value of the `Back` button
  41753. */
  41754. /**
  41755. * Sets the value of the `Back` button
  41756. */
  41757. buttonBack: number;
  41758. /**
  41759. * Gets the value of the `Left` button
  41760. */
  41761. /**
  41762. * Sets the value of the `Left` button
  41763. */
  41764. buttonLB: number;
  41765. /**
  41766. * Gets the value of the `Right` button
  41767. */
  41768. /**
  41769. * Sets the value of the `Right` button
  41770. */
  41771. buttonRB: number;
  41772. /**
  41773. * Gets the value of the Left joystick
  41774. */
  41775. /**
  41776. * Sets the value of the Left joystick
  41777. */
  41778. buttonLeftStick: number;
  41779. /**
  41780. * Gets the value of the Right joystick
  41781. */
  41782. /**
  41783. * Sets the value of the Right joystick
  41784. */
  41785. buttonRightStick: number;
  41786. /**
  41787. * Gets the value of D-pad up
  41788. */
  41789. /**
  41790. * Sets the value of D-pad up
  41791. */
  41792. dPadUp: number;
  41793. /**
  41794. * Gets the value of D-pad down
  41795. */
  41796. /**
  41797. * Sets the value of D-pad down
  41798. */
  41799. dPadDown: number;
  41800. /**
  41801. * Gets the value of D-pad left
  41802. */
  41803. /**
  41804. * Sets the value of D-pad left
  41805. */
  41806. dPadLeft: number;
  41807. /**
  41808. * Gets the value of D-pad right
  41809. */
  41810. /**
  41811. * Sets the value of D-pad right
  41812. */
  41813. dPadRight: number;
  41814. /**
  41815. * Force the gamepad to synchronize with device values
  41816. */
  41817. update(): void;
  41818. /**
  41819. * Disposes the gamepad
  41820. */
  41821. dispose(): void;
  41822. }
  41823. }
  41824. declare module "babylonjs/Gamepads/dualShockGamepad" {
  41825. import { Observable } from "babylonjs/Misc/observable";
  41826. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41827. /**
  41828. * Defines supported buttons for DualShock compatible gamepads
  41829. */
  41830. export enum DualShockButton {
  41831. /** Cross */
  41832. Cross = 0,
  41833. /** Circle */
  41834. Circle = 1,
  41835. /** Square */
  41836. Square = 2,
  41837. /** Triangle */
  41838. Triangle = 3,
  41839. /** Options */
  41840. Options = 4,
  41841. /** Share */
  41842. Share = 5,
  41843. /** L1 */
  41844. L1 = 6,
  41845. /** R1 */
  41846. R1 = 7,
  41847. /** Left stick */
  41848. LeftStick = 8,
  41849. /** Right stick */
  41850. RightStick = 9
  41851. }
  41852. /** Defines values for DualShock DPad */
  41853. export enum DualShockDpad {
  41854. /** Up */
  41855. Up = 0,
  41856. /** Down */
  41857. Down = 1,
  41858. /** Left */
  41859. Left = 2,
  41860. /** Right */
  41861. Right = 3
  41862. }
  41863. /**
  41864. * Defines a DualShock gamepad
  41865. */
  41866. export class DualShockPad extends Gamepad {
  41867. private _leftTrigger;
  41868. private _rightTrigger;
  41869. private _onlefttriggerchanged;
  41870. private _onrighttriggerchanged;
  41871. private _onbuttondown;
  41872. private _onbuttonup;
  41873. private _ondpaddown;
  41874. private _ondpadup;
  41875. /** Observable raised when a button is pressed */
  41876. onButtonDownObservable: Observable<DualShockButton>;
  41877. /** Observable raised when a button is released */
  41878. onButtonUpObservable: Observable<DualShockButton>;
  41879. /** Observable raised when a pad is pressed */
  41880. onPadDownObservable: Observable<DualShockDpad>;
  41881. /** Observable raised when a pad is released */
  41882. onPadUpObservable: Observable<DualShockDpad>;
  41883. private _buttonCross;
  41884. private _buttonCircle;
  41885. private _buttonSquare;
  41886. private _buttonTriangle;
  41887. private _buttonShare;
  41888. private _buttonOptions;
  41889. private _buttonL1;
  41890. private _buttonR1;
  41891. private _buttonLeftStick;
  41892. private _buttonRightStick;
  41893. private _dPadUp;
  41894. private _dPadDown;
  41895. private _dPadLeft;
  41896. private _dPadRight;
  41897. /**
  41898. * Creates a new DualShock gamepad object
  41899. * @param id defines the id of this gamepad
  41900. * @param index defines its index
  41901. * @param gamepad defines the internal HTML gamepad object
  41902. */
  41903. constructor(id: string, index: number, gamepad: any);
  41904. /**
  41905. * Defines the callback to call when left trigger is pressed
  41906. * @param callback defines the callback to use
  41907. */
  41908. onlefttriggerchanged(callback: (value: number) => void): void;
  41909. /**
  41910. * Defines the callback to call when right trigger is pressed
  41911. * @param callback defines the callback to use
  41912. */
  41913. onrighttriggerchanged(callback: (value: number) => void): void;
  41914. /**
  41915. * Gets the left trigger value
  41916. */
  41917. /**
  41918. * Sets the left trigger value
  41919. */
  41920. leftTrigger: number;
  41921. /**
  41922. * Gets the right trigger value
  41923. */
  41924. /**
  41925. * Sets the right trigger value
  41926. */
  41927. rightTrigger: number;
  41928. /**
  41929. * Defines the callback to call when a button is pressed
  41930. * @param callback defines the callback to use
  41931. */
  41932. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41933. /**
  41934. * Defines the callback to call when a button is released
  41935. * @param callback defines the callback to use
  41936. */
  41937. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41938. /**
  41939. * Defines the callback to call when a pad is pressed
  41940. * @param callback defines the callback to use
  41941. */
  41942. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41943. /**
  41944. * Defines the callback to call when a pad is released
  41945. * @param callback defines the callback to use
  41946. */
  41947. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41948. private _setButtonValue;
  41949. private _setDPadValue;
  41950. /**
  41951. * Gets the value of the `Cross` button
  41952. */
  41953. /**
  41954. * Sets the value of the `Cross` button
  41955. */
  41956. buttonCross: number;
  41957. /**
  41958. * Gets the value of the `Circle` button
  41959. */
  41960. /**
  41961. * Sets the value of the `Circle` button
  41962. */
  41963. buttonCircle: number;
  41964. /**
  41965. * Gets the value of the `Square` button
  41966. */
  41967. /**
  41968. * Sets the value of the `Square` button
  41969. */
  41970. buttonSquare: number;
  41971. /**
  41972. * Gets the value of the `Triangle` button
  41973. */
  41974. /**
  41975. * Sets the value of the `Triangle` button
  41976. */
  41977. buttonTriangle: number;
  41978. /**
  41979. * Gets the value of the `Options` button
  41980. */
  41981. /**
  41982. * Sets the value of the `Options` button
  41983. */
  41984. buttonOptions: number;
  41985. /**
  41986. * Gets the value of the `Share` button
  41987. */
  41988. /**
  41989. * Sets the value of the `Share` button
  41990. */
  41991. buttonShare: number;
  41992. /**
  41993. * Gets the value of the `L1` button
  41994. */
  41995. /**
  41996. * Sets the value of the `L1` button
  41997. */
  41998. buttonL1: number;
  41999. /**
  42000. * Gets the value of the `R1` button
  42001. */
  42002. /**
  42003. * Sets the value of the `R1` button
  42004. */
  42005. buttonR1: number;
  42006. /**
  42007. * Gets the value of the Left joystick
  42008. */
  42009. /**
  42010. * Sets the value of the Left joystick
  42011. */
  42012. buttonLeftStick: number;
  42013. /**
  42014. * Gets the value of the Right joystick
  42015. */
  42016. /**
  42017. * Sets the value of the Right joystick
  42018. */
  42019. buttonRightStick: number;
  42020. /**
  42021. * Gets the value of D-pad up
  42022. */
  42023. /**
  42024. * Sets the value of D-pad up
  42025. */
  42026. dPadUp: number;
  42027. /**
  42028. * Gets the value of D-pad down
  42029. */
  42030. /**
  42031. * Sets the value of D-pad down
  42032. */
  42033. dPadDown: number;
  42034. /**
  42035. * Gets the value of D-pad left
  42036. */
  42037. /**
  42038. * Sets the value of D-pad left
  42039. */
  42040. dPadLeft: number;
  42041. /**
  42042. * Gets the value of D-pad right
  42043. */
  42044. /**
  42045. * Sets the value of D-pad right
  42046. */
  42047. dPadRight: number;
  42048. /**
  42049. * Force the gamepad to synchronize with device values
  42050. */
  42051. update(): void;
  42052. /**
  42053. * Disposes the gamepad
  42054. */
  42055. dispose(): void;
  42056. }
  42057. }
  42058. declare module "babylonjs/Gamepads/gamepadManager" {
  42059. import { Observable } from "babylonjs/Misc/observable";
  42060. import { Nullable } from "babylonjs/types";
  42061. import { Scene } from "babylonjs/scene";
  42062. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42063. /**
  42064. * Manager for handling gamepads
  42065. */
  42066. export class GamepadManager {
  42067. private _scene?;
  42068. private _babylonGamepads;
  42069. private _oneGamepadConnected;
  42070. /** @hidden */
  42071. _isMonitoring: boolean;
  42072. private _gamepadEventSupported;
  42073. private _gamepadSupport;
  42074. /**
  42075. * observable to be triggered when the gamepad controller has been connected
  42076. */
  42077. onGamepadConnectedObservable: Observable<Gamepad>;
  42078. /**
  42079. * observable to be triggered when the gamepad controller has been disconnected
  42080. */
  42081. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42082. private _onGamepadConnectedEvent;
  42083. private _onGamepadDisconnectedEvent;
  42084. /**
  42085. * Initializes the gamepad manager
  42086. * @param _scene BabylonJS scene
  42087. */
  42088. constructor(_scene?: Scene | undefined);
  42089. /**
  42090. * The gamepads in the game pad manager
  42091. */
  42092. readonly gamepads: Gamepad[];
  42093. /**
  42094. * Get the gamepad controllers based on type
  42095. * @param type The type of gamepad controller
  42096. * @returns Nullable gamepad
  42097. */
  42098. getGamepadByType(type?: number): Nullable<Gamepad>;
  42099. /**
  42100. * Disposes the gamepad manager
  42101. */
  42102. dispose(): void;
  42103. private _addNewGamepad;
  42104. private _startMonitoringGamepads;
  42105. private _stopMonitoringGamepads;
  42106. /** @hidden */
  42107. _checkGamepadsStatus(): void;
  42108. private _updateGamepadObjects;
  42109. }
  42110. }
  42111. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42112. import { Nullable } from "babylonjs/types";
  42113. import { Scene } from "babylonjs/scene";
  42114. import { ISceneComponent } from "babylonjs/sceneComponent";
  42115. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42116. module "babylonjs/scene" {
  42117. interface Scene {
  42118. /** @hidden */
  42119. _gamepadManager: Nullable<GamepadManager>;
  42120. /**
  42121. * Gets the gamepad manager associated with the scene
  42122. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42123. */
  42124. gamepadManager: GamepadManager;
  42125. }
  42126. }
  42127. module "babylonjs/Cameras/freeCameraInputsManager" {
  42128. /**
  42129. * Interface representing a free camera inputs manager
  42130. */
  42131. interface FreeCameraInputsManager {
  42132. /**
  42133. * Adds gamepad input support to the FreeCameraInputsManager.
  42134. * @returns the FreeCameraInputsManager
  42135. */
  42136. addGamepad(): FreeCameraInputsManager;
  42137. }
  42138. }
  42139. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42140. /**
  42141. * Interface representing an arc rotate camera inputs manager
  42142. */
  42143. interface ArcRotateCameraInputsManager {
  42144. /**
  42145. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42146. * @returns the camera inputs manager
  42147. */
  42148. addGamepad(): ArcRotateCameraInputsManager;
  42149. }
  42150. }
  42151. /**
  42152. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42153. */
  42154. export class GamepadSystemSceneComponent implements ISceneComponent {
  42155. /**
  42156. * The component name helpfull to identify the component in the list of scene components.
  42157. */
  42158. readonly name: string;
  42159. /**
  42160. * The scene the component belongs to.
  42161. */
  42162. scene: Scene;
  42163. /**
  42164. * Creates a new instance of the component for the given scene
  42165. * @param scene Defines the scene to register the component in
  42166. */
  42167. constructor(scene: Scene);
  42168. /**
  42169. * Registers the component in a given scene
  42170. */
  42171. register(): void;
  42172. /**
  42173. * Rebuilds the elements related to this component in case of
  42174. * context lost for instance.
  42175. */
  42176. rebuild(): void;
  42177. /**
  42178. * Disposes the component and the associated ressources
  42179. */
  42180. dispose(): void;
  42181. private _beforeCameraUpdate;
  42182. }
  42183. }
  42184. declare module "babylonjs/Cameras/universalCamera" {
  42185. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42186. import { Scene } from "babylonjs/scene";
  42187. import { Vector3 } from "babylonjs/Maths/math.vector";
  42188. import "babylonjs/Gamepads/gamepadSceneComponent";
  42189. /**
  42190. * 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,
  42191. * which still works and will still be found in many Playgrounds.
  42192. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42193. */
  42194. export class UniversalCamera extends TouchCamera {
  42195. /**
  42196. * Defines the gamepad rotation sensiblity.
  42197. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42198. */
  42199. gamepadAngularSensibility: number;
  42200. /**
  42201. * Defines the gamepad move sensiblity.
  42202. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42203. */
  42204. gamepadMoveSensibility: number;
  42205. /**
  42206. * 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,
  42207. * which still works and will still be found in many Playgrounds.
  42208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42209. * @param name Define the name of the camera in the scene
  42210. * @param position Define the start position of the camera in the scene
  42211. * @param scene Define the scene the camera belongs to
  42212. */
  42213. constructor(name: string, position: Vector3, scene: Scene);
  42214. /**
  42215. * Gets the current object class name.
  42216. * @return the class name
  42217. */
  42218. getClassName(): string;
  42219. }
  42220. }
  42221. declare module "babylonjs/Cameras/gamepadCamera" {
  42222. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42223. import { Scene } from "babylonjs/scene";
  42224. import { Vector3 } from "babylonjs/Maths/math.vector";
  42225. /**
  42226. * This represents a FPS type of camera. This is only here for back compat purpose.
  42227. * Please use the UniversalCamera instead as both are identical.
  42228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42229. */
  42230. export class GamepadCamera extends UniversalCamera {
  42231. /**
  42232. * Instantiates a new Gamepad Camera
  42233. * This represents a FPS type of camera. This is only here for back compat purpose.
  42234. * Please use the UniversalCamera instead as both are identical.
  42235. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42236. * @param name Define the name of the camera in the scene
  42237. * @param position Define the start position of the camera in the scene
  42238. * @param scene Define the scene the camera belongs to
  42239. */
  42240. constructor(name: string, position: Vector3, scene: Scene);
  42241. /**
  42242. * Gets the current object class name.
  42243. * @return the class name
  42244. */
  42245. getClassName(): string;
  42246. }
  42247. }
  42248. declare module "babylonjs/Shaders/pass.fragment" {
  42249. /** @hidden */
  42250. export var passPixelShader: {
  42251. name: string;
  42252. shader: string;
  42253. };
  42254. }
  42255. declare module "babylonjs/Shaders/passCube.fragment" {
  42256. /** @hidden */
  42257. export var passCubePixelShader: {
  42258. name: string;
  42259. shader: string;
  42260. };
  42261. }
  42262. declare module "babylonjs/PostProcesses/passPostProcess" {
  42263. import { Nullable } from "babylonjs/types";
  42264. import { Camera } from "babylonjs/Cameras/camera";
  42265. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42266. import { Engine } from "babylonjs/Engines/engine";
  42267. import "babylonjs/Shaders/pass.fragment";
  42268. import "babylonjs/Shaders/passCube.fragment";
  42269. /**
  42270. * PassPostProcess which produces an output the same as it's input
  42271. */
  42272. export class PassPostProcess extends PostProcess {
  42273. /**
  42274. * Creates the PassPostProcess
  42275. * @param name The name of the effect.
  42276. * @param options The required width/height ratio to downsize to before computing the render pass.
  42277. * @param camera The camera to apply the render pass to.
  42278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42279. * @param engine The engine which the post process will be applied. (default: current engine)
  42280. * @param reusable If the post process can be reused on the same frame. (default: false)
  42281. * @param textureType The type of texture to be used when performing the post processing.
  42282. * @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)
  42283. */
  42284. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42285. }
  42286. /**
  42287. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42288. */
  42289. export class PassCubePostProcess extends PostProcess {
  42290. private _face;
  42291. /**
  42292. * Gets or sets the cube face to display.
  42293. * * 0 is +X
  42294. * * 1 is -X
  42295. * * 2 is +Y
  42296. * * 3 is -Y
  42297. * * 4 is +Z
  42298. * * 5 is -Z
  42299. */
  42300. face: number;
  42301. /**
  42302. * Creates the PassCubePostProcess
  42303. * @param name The name of the effect.
  42304. * @param options The required width/height ratio to downsize to before computing the render pass.
  42305. * @param camera The camera to apply the render pass to.
  42306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42307. * @param engine The engine which the post process will be applied. (default: current engine)
  42308. * @param reusable If the post process can be reused on the same frame. (default: false)
  42309. * @param textureType The type of texture to be used when performing the post processing.
  42310. * @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)
  42311. */
  42312. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42313. }
  42314. }
  42315. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42316. /** @hidden */
  42317. export var anaglyphPixelShader: {
  42318. name: string;
  42319. shader: string;
  42320. };
  42321. }
  42322. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42323. import { Engine } from "babylonjs/Engines/engine";
  42324. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42325. import { Camera } from "babylonjs/Cameras/camera";
  42326. import "babylonjs/Shaders/anaglyph.fragment";
  42327. /**
  42328. * Postprocess used to generate anaglyphic rendering
  42329. */
  42330. export class AnaglyphPostProcess extends PostProcess {
  42331. private _passedProcess;
  42332. /**
  42333. * Creates a new AnaglyphPostProcess
  42334. * @param name defines postprocess name
  42335. * @param options defines creation options or target ratio scale
  42336. * @param rigCameras defines cameras using this postprocess
  42337. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42338. * @param engine defines hosting engine
  42339. * @param reusable defines if the postprocess will be reused multiple times per frame
  42340. */
  42341. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42342. }
  42343. }
  42344. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42345. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42346. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42347. import { Scene } from "babylonjs/scene";
  42348. import { Vector3 } from "babylonjs/Maths/math.vector";
  42349. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42350. /**
  42351. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42352. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42353. */
  42354. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42355. /**
  42356. * Creates a new AnaglyphArcRotateCamera
  42357. * @param name defines camera name
  42358. * @param alpha defines alpha angle (in radians)
  42359. * @param beta defines beta angle (in radians)
  42360. * @param radius defines radius
  42361. * @param target defines camera target
  42362. * @param interaxialDistance defines distance between each color axis
  42363. * @param scene defines the hosting scene
  42364. */
  42365. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42366. /**
  42367. * Gets camera class name
  42368. * @returns AnaglyphArcRotateCamera
  42369. */
  42370. getClassName(): string;
  42371. }
  42372. }
  42373. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42374. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42375. import { Scene } from "babylonjs/scene";
  42376. import { Vector3 } from "babylonjs/Maths/math.vector";
  42377. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42378. /**
  42379. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42380. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42381. */
  42382. export class AnaglyphFreeCamera extends FreeCamera {
  42383. /**
  42384. * Creates a new AnaglyphFreeCamera
  42385. * @param name defines camera name
  42386. * @param position defines initial position
  42387. * @param interaxialDistance defines distance between each color axis
  42388. * @param scene defines the hosting scene
  42389. */
  42390. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42391. /**
  42392. * Gets camera class name
  42393. * @returns AnaglyphFreeCamera
  42394. */
  42395. getClassName(): string;
  42396. }
  42397. }
  42398. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42399. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42400. import { Scene } from "babylonjs/scene";
  42401. import { Vector3 } from "babylonjs/Maths/math.vector";
  42402. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42403. /**
  42404. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42405. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42406. */
  42407. export class AnaglyphGamepadCamera extends GamepadCamera {
  42408. /**
  42409. * Creates a new AnaglyphGamepadCamera
  42410. * @param name defines camera name
  42411. * @param position defines initial position
  42412. * @param interaxialDistance defines distance between each color axis
  42413. * @param scene defines the hosting scene
  42414. */
  42415. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42416. /**
  42417. * Gets camera class name
  42418. * @returns AnaglyphGamepadCamera
  42419. */
  42420. getClassName(): string;
  42421. }
  42422. }
  42423. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42424. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42425. import { Scene } from "babylonjs/scene";
  42426. import { Vector3 } from "babylonjs/Maths/math.vector";
  42427. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42428. /**
  42429. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42430. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42431. */
  42432. export class AnaglyphUniversalCamera extends UniversalCamera {
  42433. /**
  42434. * Creates a new AnaglyphUniversalCamera
  42435. * @param name defines camera name
  42436. * @param position defines initial position
  42437. * @param interaxialDistance defines distance between each color axis
  42438. * @param scene defines the hosting scene
  42439. */
  42440. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42441. /**
  42442. * Gets camera class name
  42443. * @returns AnaglyphUniversalCamera
  42444. */
  42445. getClassName(): string;
  42446. }
  42447. }
  42448. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42449. /** @hidden */
  42450. export var stereoscopicInterlacePixelShader: {
  42451. name: string;
  42452. shader: string;
  42453. };
  42454. }
  42455. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42456. import { Camera } from "babylonjs/Cameras/camera";
  42457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42458. import { Engine } from "babylonjs/Engines/engine";
  42459. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42460. /**
  42461. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42462. */
  42463. export class StereoscopicInterlacePostProcess extends PostProcess {
  42464. private _stepSize;
  42465. private _passedProcess;
  42466. /**
  42467. * Initializes a StereoscopicInterlacePostProcess
  42468. * @param name The name of the effect.
  42469. * @param rigCameras The rig cameras to be appled to the post process
  42470. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42472. * @param engine The engine which the post process will be applied. (default: current engine)
  42473. * @param reusable If the post process can be reused on the same frame. (default: false)
  42474. */
  42475. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42476. }
  42477. }
  42478. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42479. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42480. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42481. import { Scene } from "babylonjs/scene";
  42482. import { Vector3 } from "babylonjs/Maths/math.vector";
  42483. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42484. /**
  42485. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42486. * @see http://doc.babylonjs.com/features/cameras
  42487. */
  42488. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42489. /**
  42490. * Creates a new StereoscopicArcRotateCamera
  42491. * @param name defines camera name
  42492. * @param alpha defines alpha angle (in radians)
  42493. * @param beta defines beta angle (in radians)
  42494. * @param radius defines radius
  42495. * @param target defines camera target
  42496. * @param interaxialDistance defines distance between each color axis
  42497. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42498. * @param scene defines the hosting scene
  42499. */
  42500. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42501. /**
  42502. * Gets camera class name
  42503. * @returns StereoscopicArcRotateCamera
  42504. */
  42505. getClassName(): string;
  42506. }
  42507. }
  42508. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42510. import { Scene } from "babylonjs/scene";
  42511. import { Vector3 } from "babylonjs/Maths/math.vector";
  42512. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42513. /**
  42514. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42515. * @see http://doc.babylonjs.com/features/cameras
  42516. */
  42517. export class StereoscopicFreeCamera extends FreeCamera {
  42518. /**
  42519. * Creates a new StereoscopicFreeCamera
  42520. * @param name defines camera name
  42521. * @param position defines initial position
  42522. * @param interaxialDistance defines distance between each color axis
  42523. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42524. * @param scene defines the hosting scene
  42525. */
  42526. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42527. /**
  42528. * Gets camera class name
  42529. * @returns StereoscopicFreeCamera
  42530. */
  42531. getClassName(): string;
  42532. }
  42533. }
  42534. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42535. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42536. import { Scene } from "babylonjs/scene";
  42537. import { Vector3 } from "babylonjs/Maths/math.vector";
  42538. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42539. /**
  42540. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42541. * @see http://doc.babylonjs.com/features/cameras
  42542. */
  42543. export class StereoscopicGamepadCamera extends GamepadCamera {
  42544. /**
  42545. * Creates a new StereoscopicGamepadCamera
  42546. * @param name defines camera name
  42547. * @param position defines initial position
  42548. * @param interaxialDistance defines distance between each color axis
  42549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42550. * @param scene defines the hosting scene
  42551. */
  42552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42553. /**
  42554. * Gets camera class name
  42555. * @returns StereoscopicGamepadCamera
  42556. */
  42557. getClassName(): string;
  42558. }
  42559. }
  42560. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  42561. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42562. import { Scene } from "babylonjs/scene";
  42563. import { Vector3 } from "babylonjs/Maths/math.vector";
  42564. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42565. /**
  42566. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42567. * @see http://doc.babylonjs.com/features/cameras
  42568. */
  42569. export class StereoscopicUniversalCamera extends UniversalCamera {
  42570. /**
  42571. * Creates a new StereoscopicUniversalCamera
  42572. * @param name defines camera name
  42573. * @param position defines initial position
  42574. * @param interaxialDistance defines distance between each color axis
  42575. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42576. * @param scene defines the hosting scene
  42577. */
  42578. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42579. /**
  42580. * Gets camera class name
  42581. * @returns StereoscopicUniversalCamera
  42582. */
  42583. getClassName(): string;
  42584. }
  42585. }
  42586. declare module "babylonjs/Cameras/Stereoscopic/index" {
  42587. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  42588. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  42589. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  42590. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  42591. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  42592. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  42593. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  42594. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  42595. }
  42596. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  42597. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42598. import { Scene } from "babylonjs/scene";
  42599. import { Vector3 } from "babylonjs/Maths/math.vector";
  42600. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42601. /**
  42602. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42603. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42604. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42605. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42606. */
  42607. export class VirtualJoysticksCamera extends FreeCamera {
  42608. /**
  42609. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42610. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42611. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42612. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42613. * @param name Define the name of the camera in the scene
  42614. * @param position Define the start position of the camera in the scene
  42615. * @param scene Define the scene the camera belongs to
  42616. */
  42617. constructor(name: string, position: Vector3, scene: Scene);
  42618. /**
  42619. * Gets the current object class name.
  42620. * @return the class name
  42621. */
  42622. getClassName(): string;
  42623. }
  42624. }
  42625. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  42626. import { Matrix } from "babylonjs/Maths/math.vector";
  42627. /**
  42628. * This represents all the required metrics to create a VR camera.
  42629. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42630. */
  42631. export class VRCameraMetrics {
  42632. /**
  42633. * Define the horizontal resolution off the screen.
  42634. */
  42635. hResolution: number;
  42636. /**
  42637. * Define the vertical resolution off the screen.
  42638. */
  42639. vResolution: number;
  42640. /**
  42641. * Define the horizontal screen size.
  42642. */
  42643. hScreenSize: number;
  42644. /**
  42645. * Define the vertical screen size.
  42646. */
  42647. vScreenSize: number;
  42648. /**
  42649. * Define the vertical screen center position.
  42650. */
  42651. vScreenCenter: number;
  42652. /**
  42653. * Define the distance of the eyes to the screen.
  42654. */
  42655. eyeToScreenDistance: number;
  42656. /**
  42657. * Define the distance between both lenses
  42658. */
  42659. lensSeparationDistance: number;
  42660. /**
  42661. * Define the distance between both viewer's eyes.
  42662. */
  42663. interpupillaryDistance: number;
  42664. /**
  42665. * Define the distortion factor of the VR postprocess.
  42666. * Please, touch with care.
  42667. */
  42668. distortionK: number[];
  42669. /**
  42670. * Define the chromatic aberration correction factors for the VR post process.
  42671. */
  42672. chromaAbCorrection: number[];
  42673. /**
  42674. * Define the scale factor of the post process.
  42675. * The smaller the better but the slower.
  42676. */
  42677. postProcessScaleFactor: number;
  42678. /**
  42679. * Define an offset for the lens center.
  42680. */
  42681. lensCenterOffset: number;
  42682. /**
  42683. * Define if the current vr camera should compensate the distortion of the lense or not.
  42684. */
  42685. compensateDistortion: boolean;
  42686. /**
  42687. * Defines if multiview should be enabled when rendering (Default: false)
  42688. */
  42689. multiviewEnabled: boolean;
  42690. /**
  42691. * Gets the rendering aspect ratio based on the provided resolutions.
  42692. */
  42693. readonly aspectRatio: number;
  42694. /**
  42695. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42696. */
  42697. readonly aspectRatioFov: number;
  42698. /**
  42699. * @hidden
  42700. */
  42701. readonly leftHMatrix: Matrix;
  42702. /**
  42703. * @hidden
  42704. */
  42705. readonly rightHMatrix: Matrix;
  42706. /**
  42707. * @hidden
  42708. */
  42709. readonly leftPreViewMatrix: Matrix;
  42710. /**
  42711. * @hidden
  42712. */
  42713. readonly rightPreViewMatrix: Matrix;
  42714. /**
  42715. * Get the default VRMetrics based on the most generic setup.
  42716. * @returns the default vr metrics
  42717. */
  42718. static GetDefault(): VRCameraMetrics;
  42719. }
  42720. }
  42721. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  42722. /** @hidden */
  42723. export var vrDistortionCorrectionPixelShader: {
  42724. name: string;
  42725. shader: string;
  42726. };
  42727. }
  42728. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  42729. import { Camera } from "babylonjs/Cameras/camera";
  42730. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42731. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42732. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  42733. /**
  42734. * VRDistortionCorrectionPostProcess used for mobile VR
  42735. */
  42736. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42737. private _isRightEye;
  42738. private _distortionFactors;
  42739. private _postProcessScaleFactor;
  42740. private _lensCenterOffset;
  42741. private _scaleIn;
  42742. private _scaleFactor;
  42743. private _lensCenter;
  42744. /**
  42745. * Initializes the VRDistortionCorrectionPostProcess
  42746. * @param name The name of the effect.
  42747. * @param camera The camera to apply the render pass to.
  42748. * @param isRightEye If this is for the right eye distortion
  42749. * @param vrMetrics All the required metrics for the VR camera
  42750. */
  42751. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42752. }
  42753. }
  42754. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  42755. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  42756. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42757. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42758. import { Scene } from "babylonjs/scene";
  42759. import { Vector3 } from "babylonjs/Maths/math.vector";
  42760. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42761. import "babylonjs/Cameras/RigModes/vrRigMode";
  42762. /**
  42763. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42764. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42765. */
  42766. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42767. /**
  42768. * Creates a new VRDeviceOrientationArcRotateCamera
  42769. * @param name defines camera name
  42770. * @param alpha defines the camera rotation along the logitudinal axis
  42771. * @param beta defines the camera rotation along the latitudinal axis
  42772. * @param radius defines the camera distance from its target
  42773. * @param target defines the camera target
  42774. * @param scene defines the scene the camera belongs to
  42775. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42776. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42777. */
  42778. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42779. /**
  42780. * Gets camera class name
  42781. * @returns VRDeviceOrientationArcRotateCamera
  42782. */
  42783. getClassName(): string;
  42784. }
  42785. }
  42786. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  42787. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42788. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42789. import { Scene } from "babylonjs/scene";
  42790. import { Vector3 } from "babylonjs/Maths/math.vector";
  42791. import "babylonjs/Cameras/RigModes/vrRigMode";
  42792. /**
  42793. * Camera used to simulate VR rendering (based on FreeCamera)
  42794. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42795. */
  42796. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42797. /**
  42798. * Creates a new VRDeviceOrientationFreeCamera
  42799. * @param name defines camera name
  42800. * @param position defines the start position of the camera
  42801. * @param scene defines the scene the camera belongs to
  42802. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42803. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42804. */
  42805. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42806. /**
  42807. * Gets camera class name
  42808. * @returns VRDeviceOrientationFreeCamera
  42809. */
  42810. getClassName(): string;
  42811. }
  42812. }
  42813. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  42814. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42815. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42816. import { Scene } from "babylonjs/scene";
  42817. import { Vector3 } from "babylonjs/Maths/math.vector";
  42818. import "babylonjs/Gamepads/gamepadSceneComponent";
  42819. /**
  42820. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42821. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42822. */
  42823. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42824. /**
  42825. * Creates a new VRDeviceOrientationGamepadCamera
  42826. * @param name defines camera name
  42827. * @param position defines the start position of the camera
  42828. * @param scene defines the scene the camera belongs to
  42829. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42830. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42831. */
  42832. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42833. /**
  42834. * Gets camera class name
  42835. * @returns VRDeviceOrientationGamepadCamera
  42836. */
  42837. getClassName(): string;
  42838. }
  42839. }
  42840. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42841. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42842. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42843. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42844. /** @hidden */
  42845. export var imageProcessingPixelShader: {
  42846. name: string;
  42847. shader: string;
  42848. };
  42849. }
  42850. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42851. import { Nullable } from "babylonjs/types";
  42852. import { Color4 } from "babylonjs/Maths/math.color";
  42853. import { Camera } from "babylonjs/Cameras/camera";
  42854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42855. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42856. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42857. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42858. import { Engine } from "babylonjs/Engines/engine";
  42859. import "babylonjs/Shaders/imageProcessing.fragment";
  42860. import "babylonjs/Shaders/postprocess.vertex";
  42861. /**
  42862. * ImageProcessingPostProcess
  42863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42864. */
  42865. export class ImageProcessingPostProcess extends PostProcess {
  42866. /**
  42867. * Default configuration related to image processing available in the PBR Material.
  42868. */
  42869. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42870. /**
  42871. * Gets the image processing configuration used either in this material.
  42872. */
  42873. /**
  42874. * Sets the Default image processing configuration used either in the this material.
  42875. *
  42876. * If sets to null, the scene one is in use.
  42877. */
  42878. imageProcessingConfiguration: ImageProcessingConfiguration;
  42879. /**
  42880. * Keep track of the image processing observer to allow dispose and replace.
  42881. */
  42882. private _imageProcessingObserver;
  42883. /**
  42884. * Attaches a new image processing configuration to the PBR Material.
  42885. * @param configuration
  42886. */
  42887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42888. /**
  42889. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42890. */
  42891. /**
  42892. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42893. */
  42894. colorCurves: Nullable<ColorCurves>;
  42895. /**
  42896. * Gets wether the color curves effect is enabled.
  42897. */
  42898. /**
  42899. * Sets wether the color curves effect is enabled.
  42900. */
  42901. colorCurvesEnabled: boolean;
  42902. /**
  42903. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42904. */
  42905. /**
  42906. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42907. */
  42908. colorGradingTexture: Nullable<BaseTexture>;
  42909. /**
  42910. * Gets wether the color grading effect is enabled.
  42911. */
  42912. /**
  42913. * Gets wether the color grading effect is enabled.
  42914. */
  42915. colorGradingEnabled: boolean;
  42916. /**
  42917. * Gets exposure used in the effect.
  42918. */
  42919. /**
  42920. * Sets exposure used in the effect.
  42921. */
  42922. exposure: number;
  42923. /**
  42924. * Gets wether tonemapping is enabled or not.
  42925. */
  42926. /**
  42927. * Sets wether tonemapping is enabled or not
  42928. */
  42929. toneMappingEnabled: boolean;
  42930. /**
  42931. * Gets the type of tone mapping effect.
  42932. */
  42933. /**
  42934. * Sets the type of tone mapping effect.
  42935. */
  42936. toneMappingType: number;
  42937. /**
  42938. * Gets contrast used in the effect.
  42939. */
  42940. /**
  42941. * Sets contrast used in the effect.
  42942. */
  42943. contrast: number;
  42944. /**
  42945. * Gets Vignette stretch size.
  42946. */
  42947. /**
  42948. * Sets Vignette stretch size.
  42949. */
  42950. vignetteStretch: number;
  42951. /**
  42952. * Gets Vignette centre X Offset.
  42953. */
  42954. /**
  42955. * Sets Vignette centre X Offset.
  42956. */
  42957. vignetteCentreX: number;
  42958. /**
  42959. * Gets Vignette centre Y Offset.
  42960. */
  42961. /**
  42962. * Sets Vignette centre Y Offset.
  42963. */
  42964. vignetteCentreY: number;
  42965. /**
  42966. * Gets Vignette weight or intensity of the vignette effect.
  42967. */
  42968. /**
  42969. * Sets Vignette weight or intensity of the vignette effect.
  42970. */
  42971. vignetteWeight: number;
  42972. /**
  42973. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42974. * if vignetteEnabled is set to true.
  42975. */
  42976. /**
  42977. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42978. * if vignetteEnabled is set to true.
  42979. */
  42980. vignetteColor: Color4;
  42981. /**
  42982. * Gets Camera field of view used by the Vignette effect.
  42983. */
  42984. /**
  42985. * Sets Camera field of view used by the Vignette effect.
  42986. */
  42987. vignetteCameraFov: number;
  42988. /**
  42989. * Gets the vignette blend mode allowing different kind of effect.
  42990. */
  42991. /**
  42992. * Sets the vignette blend mode allowing different kind of effect.
  42993. */
  42994. vignetteBlendMode: number;
  42995. /**
  42996. * Gets wether the vignette effect is enabled.
  42997. */
  42998. /**
  42999. * Sets wether the vignette effect is enabled.
  43000. */
  43001. vignetteEnabled: boolean;
  43002. private _fromLinearSpace;
  43003. /**
  43004. * Gets wether the input of the processing is in Gamma or Linear Space.
  43005. */
  43006. /**
  43007. * Sets wether the input of the processing is in Gamma or Linear Space.
  43008. */
  43009. fromLinearSpace: boolean;
  43010. /**
  43011. * Defines cache preventing GC.
  43012. */
  43013. private _defines;
  43014. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43015. /**
  43016. * "ImageProcessingPostProcess"
  43017. * @returns "ImageProcessingPostProcess"
  43018. */
  43019. getClassName(): string;
  43020. protected _updateParameters(): void;
  43021. dispose(camera?: Camera): void;
  43022. }
  43023. }
  43024. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43025. import { Scene } from "babylonjs/scene";
  43026. import { Color3 } from "babylonjs/Maths/math.color";
  43027. import { Mesh } from "babylonjs/Meshes/mesh";
  43028. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43029. import { Nullable } from "babylonjs/types";
  43030. /**
  43031. * Class containing static functions to help procedurally build meshes
  43032. */
  43033. export class GroundBuilder {
  43034. /**
  43035. * Creates a ground mesh
  43036. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43037. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43039. * @param name defines the name of the mesh
  43040. * @param options defines the options used to create the mesh
  43041. * @param scene defines the hosting scene
  43042. * @returns the ground mesh
  43043. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43044. */
  43045. static CreateGround(name: string, options: {
  43046. width?: number;
  43047. height?: number;
  43048. subdivisions?: number;
  43049. subdivisionsX?: number;
  43050. subdivisionsY?: number;
  43051. updatable?: boolean;
  43052. }, scene: any): Mesh;
  43053. /**
  43054. * Creates a tiled ground mesh
  43055. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43056. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43057. * * 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
  43058. * * 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
  43059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43060. * @param name defines the name of the mesh
  43061. * @param options defines the options used to create the mesh
  43062. * @param scene defines the hosting scene
  43063. * @returns the tiled ground mesh
  43064. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43065. */
  43066. static CreateTiledGround(name: string, options: {
  43067. xmin: number;
  43068. zmin: number;
  43069. xmax: number;
  43070. zmax: number;
  43071. subdivisions?: {
  43072. w: number;
  43073. h: number;
  43074. };
  43075. precision?: {
  43076. w: number;
  43077. h: number;
  43078. };
  43079. updatable?: boolean;
  43080. }, scene?: Nullable<Scene>): Mesh;
  43081. /**
  43082. * Creates a ground mesh from a height map
  43083. * * The parameter `url` sets the URL of the height map image resource.
  43084. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43085. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43086. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43087. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43088. * * 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.
  43089. * * 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).
  43090. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43092. * @param name defines the name of the mesh
  43093. * @param url defines the url to the height map
  43094. * @param options defines the options used to create the mesh
  43095. * @param scene defines the hosting scene
  43096. * @returns the ground mesh
  43097. * @see https://doc.babylonjs.com/babylon101/height_map
  43098. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43099. */
  43100. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43101. width?: number;
  43102. height?: number;
  43103. subdivisions?: number;
  43104. minHeight?: number;
  43105. maxHeight?: number;
  43106. colorFilter?: Color3;
  43107. alphaFilter?: number;
  43108. updatable?: boolean;
  43109. onReady?: (mesh: GroundMesh) => void;
  43110. }, scene?: Nullable<Scene>): GroundMesh;
  43111. }
  43112. }
  43113. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43114. import { Vector4 } from "babylonjs/Maths/math.vector";
  43115. import { Mesh } from "babylonjs/Meshes/mesh";
  43116. /**
  43117. * Class containing static functions to help procedurally build meshes
  43118. */
  43119. export class TorusBuilder {
  43120. /**
  43121. * Creates a torus mesh
  43122. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43123. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43124. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43128. * @param name defines the name of the mesh
  43129. * @param options defines the options used to create the mesh
  43130. * @param scene defines the hosting scene
  43131. * @returns the torus mesh
  43132. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43133. */
  43134. static CreateTorus(name: string, options: {
  43135. diameter?: number;
  43136. thickness?: number;
  43137. tessellation?: number;
  43138. updatable?: boolean;
  43139. sideOrientation?: number;
  43140. frontUVs?: Vector4;
  43141. backUVs?: Vector4;
  43142. }, scene: any): Mesh;
  43143. }
  43144. }
  43145. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43146. import { Vector4 } from "babylonjs/Maths/math.vector";
  43147. import { Color4 } from "babylonjs/Maths/math.color";
  43148. import { Mesh } from "babylonjs/Meshes/mesh";
  43149. /**
  43150. * Class containing static functions to help procedurally build meshes
  43151. */
  43152. export class CylinderBuilder {
  43153. /**
  43154. * Creates a cylinder or a cone mesh
  43155. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43156. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43157. * * 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.
  43158. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43159. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43160. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43161. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43162. * * 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).
  43163. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43164. * * 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).
  43165. * * 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
  43166. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43167. * * 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
  43168. * * 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.
  43169. * * If `enclose` is false, a ring surface is one element.
  43170. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43171. * * 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
  43172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43175. * @param name defines the name of the mesh
  43176. * @param options defines the options used to create the mesh
  43177. * @param scene defines the hosting scene
  43178. * @returns the cylinder mesh
  43179. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43180. */
  43181. static CreateCylinder(name: string, options: {
  43182. height?: number;
  43183. diameterTop?: number;
  43184. diameterBottom?: number;
  43185. diameter?: number;
  43186. tessellation?: number;
  43187. subdivisions?: number;
  43188. arc?: number;
  43189. faceColors?: Color4[];
  43190. faceUV?: Vector4[];
  43191. updatable?: boolean;
  43192. hasRings?: boolean;
  43193. enclose?: boolean;
  43194. cap?: number;
  43195. sideOrientation?: number;
  43196. frontUVs?: Vector4;
  43197. backUVs?: Vector4;
  43198. }, scene: any): Mesh;
  43199. }
  43200. }
  43201. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43202. import { Nullable } from "babylonjs/types";
  43203. import { IDisposable } from "babylonjs/scene";
  43204. /**
  43205. * States of the webXR experience
  43206. */
  43207. export enum WebXRState {
  43208. /**
  43209. * Transitioning to being in XR mode
  43210. */
  43211. ENTERING_XR = 0,
  43212. /**
  43213. * Transitioning to non XR mode
  43214. */
  43215. EXITING_XR = 1,
  43216. /**
  43217. * In XR mode and presenting
  43218. */
  43219. IN_XR = 2,
  43220. /**
  43221. * Not entered XR mode
  43222. */
  43223. NOT_IN_XR = 3
  43224. }
  43225. /**
  43226. * Abstraction of the XR render target
  43227. */
  43228. export interface WebXRRenderTarget extends IDisposable {
  43229. /**
  43230. * xrpresent context of the canvas which can be used to display/mirror xr content
  43231. */
  43232. canvasContext: WebGLRenderingContext;
  43233. /**
  43234. * xr layer for the canvas
  43235. */
  43236. xrLayer: Nullable<XRWebGLLayer>;
  43237. /**
  43238. * Initializes the xr layer for the session
  43239. * @param xrSession xr session
  43240. * @returns a promise that will resolve once the XR Layer has been created
  43241. */
  43242. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43243. }
  43244. }
  43245. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43246. import { Nullable } from "babylonjs/types";
  43247. import { Observable } from "babylonjs/Misc/observable";
  43248. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43249. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43250. /**
  43251. * COnfiguration object for WebXR output canvas
  43252. */
  43253. export class WebXRManagedOutputCanvasOptions {
  43254. /**
  43255. * Options for this XR Layer output
  43256. */
  43257. canvasOptions: XRWebGLLayerOptions;
  43258. /**
  43259. * CSS styling for a newly created canvas (if not provided)
  43260. */
  43261. newCanvasCssStyle?: string;
  43262. /**
  43263. * Get the default values of the configuration object
  43264. * @returns default values of this configuration object
  43265. */
  43266. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43267. }
  43268. /**
  43269. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43270. */
  43271. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43272. private configuration;
  43273. private _engine;
  43274. private _canvas;
  43275. /**
  43276. * xrpresent context of the canvas which can be used to display/mirror xr content
  43277. */
  43278. canvasContext: WebGLRenderingContext;
  43279. /**
  43280. * xr layer for the canvas
  43281. */
  43282. xrLayer: Nullable<XRWebGLLayer>;
  43283. /**
  43284. * Initializes the xr layer for the session
  43285. * @param xrSession xr session
  43286. * @returns a promise that will resolve once the XR Layer has been created
  43287. */
  43288. initializeXRLayerAsync(xrSession: any): any;
  43289. /**
  43290. * Initializes the canvas to be added/removed upon entering/exiting xr
  43291. * @param engine the Babylon engine
  43292. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43293. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43294. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43295. */
  43296. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43297. /**
  43298. * Disposes of the object
  43299. */
  43300. dispose(): void;
  43301. private _setManagedOutputCanvas;
  43302. private _addCanvas;
  43303. private _removeCanvas;
  43304. }
  43305. }
  43306. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43307. import { Observable } from "babylonjs/Misc/observable";
  43308. import { Nullable } from "babylonjs/types";
  43309. import { IDisposable, Scene } from "babylonjs/scene";
  43310. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43311. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43312. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43313. /**
  43314. * Manages an XRSession to work with Babylon's engine
  43315. * @see https://doc.babylonjs.com/how_to/webxr
  43316. */
  43317. export class WebXRSessionManager implements IDisposable {
  43318. /** The scene which the session should be created for */
  43319. scene: Scene;
  43320. /**
  43321. * Fires every time a new xrFrame arrives which can be used to update the camera
  43322. */
  43323. onXRFrameObservable: Observable<XRFrame>;
  43324. /**
  43325. * Fires when the xr session is ended either by the device or manually done
  43326. */
  43327. onXRSessionEnded: Observable<any>;
  43328. /**
  43329. * Fires when the xr session is ended either by the device or manually done
  43330. */
  43331. onXRSessionInit: Observable<XRSession>;
  43332. /**
  43333. * Underlying xr session
  43334. */
  43335. session: XRSession;
  43336. /**
  43337. * Type of reference space used when creating the session
  43338. */
  43339. referenceSpace: XRReferenceSpace;
  43340. /**
  43341. * Current XR frame
  43342. */
  43343. currentFrame: Nullable<XRFrame>;
  43344. private _xrNavigator;
  43345. private baseLayer;
  43346. private _rttProvider;
  43347. private _sessionEnded;
  43348. /**
  43349. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43350. * @param scene The scene which the session should be created for
  43351. */
  43352. constructor(
  43353. /** The scene which the session should be created for */
  43354. scene: Scene);
  43355. /**
  43356. * Initializes the manager
  43357. * After initialization enterXR can be called to start an XR session
  43358. * @returns Promise which resolves after it is initialized
  43359. */
  43360. initializeAsync(): Promise<void>;
  43361. /**
  43362. * Initializes an xr session
  43363. * @param xrSessionMode mode to initialize
  43364. * @param optionalFeatures defines optional values to pass to the session builder
  43365. * @returns a promise which will resolve once the session has been initialized
  43366. */
  43367. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43368. /**
  43369. * Sets the reference space on the xr session
  43370. * @param referenceSpace space to set
  43371. * @returns a promise that will resolve once the reference space has been set
  43372. */
  43373. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43374. /**
  43375. * Updates the render state of the session
  43376. * @param state state to set
  43377. * @returns a promise that resolves once the render state has been updated
  43378. */
  43379. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43380. /**
  43381. * Starts rendering to the xr layer
  43382. * @returns a promise that will resolve once rendering has started
  43383. */
  43384. startRenderingToXRAsync(): Promise<void>;
  43385. /**
  43386. * Gets the correct render target texture to be rendered this frame for this eye
  43387. * @param eye the eye for which to get the render target
  43388. * @returns the render target for the specified eye
  43389. */
  43390. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43391. /**
  43392. * Stops the xrSession and restores the renderloop
  43393. * @returns Promise which resolves after it exits XR
  43394. */
  43395. exitXRAsync(): Promise<void>;
  43396. /**
  43397. * Checks if a session would be supported for the creation options specified
  43398. * @param sessionMode session mode to check if supported eg. immersive-vr
  43399. * @returns true if supported
  43400. */
  43401. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43402. /**
  43403. * Creates a WebXRRenderTarget object for the XR session
  43404. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43405. * @param options optional options to provide when creating a new render target
  43406. * @returns a WebXR render target to which the session can render
  43407. */
  43408. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43409. /**
  43410. * @hidden
  43411. * Converts the render layer of xrSession to a render target
  43412. * @param session session to create render target for
  43413. * @param scene scene the new render target should be created for
  43414. * @param baseLayer the webgl layer to create the render target for
  43415. */
  43416. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43417. /**
  43418. * Disposes of the session manager
  43419. */
  43420. dispose(): void;
  43421. /**
  43422. * Gets a promise returning true when fullfiled if the given session mode is supported
  43423. * @param sessionMode defines the session to test
  43424. * @returns a promise
  43425. */
  43426. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43427. }
  43428. }
  43429. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43430. import { Scene } from "babylonjs/scene";
  43431. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43432. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43433. /**
  43434. * WebXR Camera which holds the views for the xrSession
  43435. * @see https://doc.babylonjs.com/how_to/webxr
  43436. */
  43437. export class WebXRCamera extends FreeCamera {
  43438. /**
  43439. * Is the camera in debug mode. Used when using an emulator
  43440. */
  43441. debugMode: boolean;
  43442. /**
  43443. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43444. * @param name the name of the camera
  43445. * @param scene the scene to add the camera to
  43446. */
  43447. constructor(name: string, scene: Scene);
  43448. private _updateNumberOfRigCameras;
  43449. /** @hidden */
  43450. _updateForDualEyeDebugging(): void;
  43451. /**
  43452. * Updates the cameras position from the current pose information of the XR session
  43453. * @param xrSessionManager the session containing pose information
  43454. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43455. */
  43456. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43457. }
  43458. }
  43459. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43460. import { Observable } from "babylonjs/Misc/observable";
  43461. import { IDisposable, Scene } from "babylonjs/scene";
  43462. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43464. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43465. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43466. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43467. /**
  43468. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43469. * @see https://doc.babylonjs.com/how_to/webxr
  43470. */
  43471. export class WebXRExperienceHelper implements IDisposable {
  43472. private scene;
  43473. /**
  43474. * 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
  43475. */
  43476. container: AbstractMesh;
  43477. /**
  43478. * Camera used to render xr content
  43479. */
  43480. camera: WebXRCamera;
  43481. /**
  43482. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43483. */
  43484. state: WebXRState;
  43485. private _setState;
  43486. private static _TmpVector;
  43487. /**
  43488. * Fires when the state of the experience helper has changed
  43489. */
  43490. onStateChangedObservable: Observable<WebXRState>;
  43491. /** Session manager used to keep track of xr session */
  43492. sessionManager: WebXRSessionManager;
  43493. private _nonVRCamera;
  43494. private _originalSceneAutoClear;
  43495. private _supported;
  43496. /**
  43497. * Creates the experience helper
  43498. * @param scene the scene to attach the experience helper to
  43499. * @returns a promise for the experience helper
  43500. */
  43501. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43502. /**
  43503. * Creates a WebXRExperienceHelper
  43504. * @param scene The scene the helper should be created in
  43505. */
  43506. private constructor();
  43507. /**
  43508. * Exits XR mode and returns the scene to its original state
  43509. * @returns promise that resolves after xr mode has exited
  43510. */
  43511. exitXRAsync(): Promise<void>;
  43512. /**
  43513. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43514. * @param sessionMode options for the XR session
  43515. * @param referenceSpaceType frame of reference of the XR session
  43516. * @param renderTarget the output canvas that will be used to enter XR mode
  43517. * @returns promise that resolves after xr mode has entered
  43518. */
  43519. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43520. /**
  43521. * Updates the global position of the camera by moving the camera's container
  43522. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43523. * @param position The desired global position of the camera
  43524. */
  43525. setPositionOfCameraUsingContainer(position: Vector3): void;
  43526. /**
  43527. * Rotates the xr camera by rotating the camera's container around the camera's position
  43528. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43529. * @param rotation the desired quaternion rotation to apply to the camera
  43530. */
  43531. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43532. /**
  43533. * Disposes of the experience helper
  43534. */
  43535. dispose(): void;
  43536. }
  43537. }
  43538. declare module "babylonjs/Cameras/XR/webXRController" {
  43539. import { Nullable } from "babylonjs/types";
  43540. import { Observable } from "babylonjs/Misc/observable";
  43541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43542. import { Ray } from "babylonjs/Culling/ray";
  43543. import { Scene } from "babylonjs/scene";
  43544. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43545. /**
  43546. * Represents an XR input
  43547. */
  43548. export class WebXRController {
  43549. private scene;
  43550. /** The underlying input source for the controller */
  43551. inputSource: XRInputSource;
  43552. private parentContainer;
  43553. /**
  43554. * 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
  43555. */
  43556. grip?: AbstractMesh;
  43557. /**
  43558. * Pointer which can be used to select objects or attach a visible laser to
  43559. */
  43560. pointer: AbstractMesh;
  43561. private _gamepadMode;
  43562. /**
  43563. * If available, this is the gamepad object related to this controller.
  43564. * Using this object it is possible to get click events and trackpad changes of the
  43565. * webxr controller that is currently being used.
  43566. */
  43567. gamepadController?: WebVRController;
  43568. /**
  43569. * Event that fires when the controller is removed/disposed
  43570. */
  43571. onDisposeObservable: Observable<{}>;
  43572. private _tmpQuaternion;
  43573. private _tmpVector;
  43574. /**
  43575. * Creates the controller
  43576. * @see https://doc.babylonjs.com/how_to/webxr
  43577. * @param scene the scene which the controller should be associated to
  43578. * @param inputSource the underlying input source for the controller
  43579. * @param parentContainer parent that the controller meshes should be children of
  43580. */
  43581. constructor(scene: Scene,
  43582. /** The underlying input source for the controller */
  43583. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43584. /**
  43585. * Updates the controller pose based on the given XRFrame
  43586. * @param xrFrame xr frame to update the pose with
  43587. * @param referenceSpace reference space to use
  43588. */
  43589. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43590. /**
  43591. * Gets a world space ray coming from the controller
  43592. * @param result the resulting ray
  43593. */
  43594. getWorldPointerRayToRef(result: Ray): void;
  43595. /**
  43596. * Get the scene associated with this controller
  43597. * @returns the scene object
  43598. */
  43599. getScene(): Scene;
  43600. /**
  43601. * Disposes of the object
  43602. */
  43603. dispose(): void;
  43604. }
  43605. }
  43606. declare module "babylonjs/Cameras/XR/webXRInput" {
  43607. import { Observable } from "babylonjs/Misc/observable";
  43608. import { IDisposable } from "babylonjs/scene";
  43609. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43610. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43611. /**
  43612. * XR input used to track XR inputs such as controllers/rays
  43613. */
  43614. export class WebXRInput implements IDisposable {
  43615. /**
  43616. * Base experience the input listens to
  43617. */
  43618. baseExperience: WebXRExperienceHelper;
  43619. /**
  43620. * XR controllers being tracked
  43621. */
  43622. controllers: Array<WebXRController>;
  43623. private _frameObserver;
  43624. private _stateObserver;
  43625. /**
  43626. * Event when a controller has been connected/added
  43627. */
  43628. onControllerAddedObservable: Observable<WebXRController>;
  43629. /**
  43630. * Event when a controller has been removed/disconnected
  43631. */
  43632. onControllerRemovedObservable: Observable<WebXRController>;
  43633. /**
  43634. * Initializes the WebXRInput
  43635. * @param baseExperience experience helper which the input should be created for
  43636. */
  43637. constructor(
  43638. /**
  43639. * Base experience the input listens to
  43640. */
  43641. baseExperience: WebXRExperienceHelper);
  43642. private _onInputSourcesChange;
  43643. private _addAndRemoveControllers;
  43644. /**
  43645. * Disposes of the object
  43646. */
  43647. dispose(): void;
  43648. }
  43649. }
  43650. declare module "babylonjs/Loading/sceneLoader" {
  43651. import { Observable } from "babylonjs/Misc/observable";
  43652. import { Nullable } from "babylonjs/types";
  43653. import { Scene } from "babylonjs/scene";
  43654. import { Engine } from "babylonjs/Engines/engine";
  43655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43656. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43657. import { AssetContainer } from "babylonjs/assetContainer";
  43658. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43659. import { Skeleton } from "babylonjs/Bones/skeleton";
  43660. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43661. import { WebRequest } from "babylonjs/Misc/webRequest";
  43662. /**
  43663. * Class used to represent data loading progression
  43664. */
  43665. export class SceneLoaderProgressEvent {
  43666. /** defines if data length to load can be evaluated */
  43667. readonly lengthComputable: boolean;
  43668. /** defines the loaded data length */
  43669. readonly loaded: number;
  43670. /** defines the data length to load */
  43671. readonly total: number;
  43672. /**
  43673. * Create a new progress event
  43674. * @param lengthComputable defines if data length to load can be evaluated
  43675. * @param loaded defines the loaded data length
  43676. * @param total defines the data length to load
  43677. */
  43678. constructor(
  43679. /** defines if data length to load can be evaluated */
  43680. lengthComputable: boolean,
  43681. /** defines the loaded data length */
  43682. loaded: number,
  43683. /** defines the data length to load */
  43684. total: number);
  43685. /**
  43686. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43687. * @param event defines the source event
  43688. * @returns a new SceneLoaderProgressEvent
  43689. */
  43690. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43691. }
  43692. /**
  43693. * Interface used by SceneLoader plugins to define supported file extensions
  43694. */
  43695. export interface ISceneLoaderPluginExtensions {
  43696. /**
  43697. * Defines the list of supported extensions
  43698. */
  43699. [extension: string]: {
  43700. isBinary: boolean;
  43701. };
  43702. }
  43703. /**
  43704. * Interface used by SceneLoader plugin factory
  43705. */
  43706. export interface ISceneLoaderPluginFactory {
  43707. /**
  43708. * Defines the name of the factory
  43709. */
  43710. name: string;
  43711. /**
  43712. * Function called to create a new plugin
  43713. * @return the new plugin
  43714. */
  43715. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43716. /**
  43717. * The callback that returns true if the data can be directly loaded.
  43718. * @param data string containing the file data
  43719. * @returns if the data can be loaded directly
  43720. */
  43721. canDirectLoad?(data: string): boolean;
  43722. }
  43723. /**
  43724. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43725. */
  43726. export interface ISceneLoaderPluginBase {
  43727. /**
  43728. * The friendly name of this plugin.
  43729. */
  43730. name: string;
  43731. /**
  43732. * The file extensions supported by this plugin.
  43733. */
  43734. extensions: string | ISceneLoaderPluginExtensions;
  43735. /**
  43736. * The callback called when loading from a url.
  43737. * @param scene scene loading this url
  43738. * @param url url to load
  43739. * @param onSuccess callback called when the file successfully loads
  43740. * @param onProgress callback called while file is loading (if the server supports this mode)
  43741. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43742. * @param onError callback called when the file fails to load
  43743. * @returns a file request object
  43744. */
  43745. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43746. /**
  43747. * The callback called when loading from a file object.
  43748. * @param scene scene loading this file
  43749. * @param file defines the file to load
  43750. * @param onSuccess defines the callback to call when data is loaded
  43751. * @param onProgress defines the callback to call during loading process
  43752. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43753. * @param onError defines the callback to call when an error occurs
  43754. * @returns a file request object
  43755. */
  43756. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43757. /**
  43758. * The callback that returns true if the data can be directly loaded.
  43759. * @param data string containing the file data
  43760. * @returns if the data can be loaded directly
  43761. */
  43762. canDirectLoad?(data: string): boolean;
  43763. /**
  43764. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43765. * @param scene scene loading this data
  43766. * @param data string containing the data
  43767. * @returns data to pass to the plugin
  43768. */
  43769. directLoad?(scene: Scene, data: string): any;
  43770. /**
  43771. * The callback that allows custom handling of the root url based on the response url.
  43772. * @param rootUrl the original root url
  43773. * @param responseURL the response url if available
  43774. * @returns the new root url
  43775. */
  43776. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43777. }
  43778. /**
  43779. * Interface used to define a SceneLoader plugin
  43780. */
  43781. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43782. /**
  43783. * Import meshes into a scene.
  43784. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43785. * @param scene The scene to import into
  43786. * @param data The data to import
  43787. * @param rootUrl The root url for scene and resources
  43788. * @param meshes The meshes array to import into
  43789. * @param particleSystems The particle systems array to import into
  43790. * @param skeletons The skeletons array to import into
  43791. * @param onError The callback when import fails
  43792. * @returns True if successful or false otherwise
  43793. */
  43794. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43795. /**
  43796. * Load into a scene.
  43797. * @param scene The scene to load into
  43798. * @param data The data to import
  43799. * @param rootUrl The root url for scene and resources
  43800. * @param onError The callback when import fails
  43801. * @returns True if successful or false otherwise
  43802. */
  43803. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43804. /**
  43805. * Load into an asset container.
  43806. * @param scene The scene to load into
  43807. * @param data The data to import
  43808. * @param rootUrl The root url for scene and resources
  43809. * @param onError The callback when import fails
  43810. * @returns The loaded asset container
  43811. */
  43812. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43813. }
  43814. /**
  43815. * Interface used to define an async SceneLoader plugin
  43816. */
  43817. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43818. /**
  43819. * Import meshes into a scene.
  43820. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43821. * @param scene The scene to import into
  43822. * @param data The data to import
  43823. * @param rootUrl The root url for scene and resources
  43824. * @param onProgress The callback when the load progresses
  43825. * @param fileName Defines the name of the file to load
  43826. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43827. */
  43828. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43829. meshes: AbstractMesh[];
  43830. particleSystems: IParticleSystem[];
  43831. skeletons: Skeleton[];
  43832. animationGroups: AnimationGroup[];
  43833. }>;
  43834. /**
  43835. * Load into a scene.
  43836. * @param scene The scene to load into
  43837. * @param data The data to import
  43838. * @param rootUrl The root url for scene and resources
  43839. * @param onProgress The callback when the load progresses
  43840. * @param fileName Defines the name of the file to load
  43841. * @returns Nothing
  43842. */
  43843. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43844. /**
  43845. * Load into an asset container.
  43846. * @param scene The scene to load into
  43847. * @param data The data to import
  43848. * @param rootUrl The root url for scene and resources
  43849. * @param onProgress The callback when the load progresses
  43850. * @param fileName Defines the name of the file to load
  43851. * @returns The loaded asset container
  43852. */
  43853. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43854. }
  43855. /**
  43856. * Mode that determines how to handle old animation groups before loading new ones.
  43857. */
  43858. export enum SceneLoaderAnimationGroupLoadingMode {
  43859. /**
  43860. * Reset all old animations to initial state then dispose them.
  43861. */
  43862. Clean = 0,
  43863. /**
  43864. * Stop all old animations.
  43865. */
  43866. Stop = 1,
  43867. /**
  43868. * Restart old animations from first frame.
  43869. */
  43870. Sync = 2,
  43871. /**
  43872. * Old animations remains untouched.
  43873. */
  43874. NoSync = 3
  43875. }
  43876. /**
  43877. * Class used to load scene from various file formats using registered plugins
  43878. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43879. */
  43880. export class SceneLoader {
  43881. /**
  43882. * No logging while loading
  43883. */
  43884. static readonly NO_LOGGING: number;
  43885. /**
  43886. * Minimal logging while loading
  43887. */
  43888. static readonly MINIMAL_LOGGING: number;
  43889. /**
  43890. * Summary logging while loading
  43891. */
  43892. static readonly SUMMARY_LOGGING: number;
  43893. /**
  43894. * Detailled logging while loading
  43895. */
  43896. static readonly DETAILED_LOGGING: number;
  43897. /**
  43898. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43899. */
  43900. static ForceFullSceneLoadingForIncremental: boolean;
  43901. /**
  43902. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43903. */
  43904. static ShowLoadingScreen: boolean;
  43905. /**
  43906. * Defines the current logging level (while loading the scene)
  43907. * @ignorenaming
  43908. */
  43909. static loggingLevel: number;
  43910. /**
  43911. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43912. */
  43913. static CleanBoneMatrixWeights: boolean;
  43914. /**
  43915. * Event raised when a plugin is used to load a scene
  43916. */
  43917. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43918. private static _registeredPlugins;
  43919. private static _getDefaultPlugin;
  43920. private static _getPluginForExtension;
  43921. private static _getPluginForDirectLoad;
  43922. private static _getPluginForFilename;
  43923. private static _getDirectLoad;
  43924. private static _loadData;
  43925. private static _getFileInfo;
  43926. /**
  43927. * Gets a plugin that can load the given extension
  43928. * @param extension defines the extension to load
  43929. * @returns a plugin or null if none works
  43930. */
  43931. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43932. /**
  43933. * Gets a boolean indicating that the given extension can be loaded
  43934. * @param extension defines the extension to load
  43935. * @returns true if the extension is supported
  43936. */
  43937. static IsPluginForExtensionAvailable(extension: string): boolean;
  43938. /**
  43939. * Adds a new plugin to the list of registered plugins
  43940. * @param plugin defines the plugin to add
  43941. */
  43942. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43943. /**
  43944. * Import meshes into a scene
  43945. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43946. * @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)
  43947. * @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)
  43948. * @param scene the instance of BABYLON.Scene to append to
  43949. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43950. * @param onProgress a callback with a progress event for each file being loaded
  43951. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43952. * @param pluginExtension the extension used to determine the plugin
  43953. * @returns The loaded plugin
  43954. */
  43955. 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>;
  43956. /**
  43957. * Import meshes into a scene
  43958. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43959. * @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)
  43960. * @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)
  43961. * @param scene the instance of BABYLON.Scene to append to
  43962. * @param onProgress a callback with a progress event for each file being loaded
  43963. * @param pluginExtension the extension used to determine the plugin
  43964. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43965. */
  43966. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43967. meshes: AbstractMesh[];
  43968. particleSystems: IParticleSystem[];
  43969. skeletons: Skeleton[];
  43970. animationGroups: AnimationGroup[];
  43971. }>;
  43972. /**
  43973. * Load a scene
  43974. * @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)
  43975. * @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)
  43976. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43977. * @param onSuccess a callback with the scene when import succeeds
  43978. * @param onProgress a callback with a progress event for each file being loaded
  43979. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43980. * @param pluginExtension the extension used to determine the plugin
  43981. * @returns The loaded plugin
  43982. */
  43983. 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>;
  43984. /**
  43985. * Load a scene
  43986. * @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)
  43987. * @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)
  43988. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43989. * @param onProgress a callback with a progress event for each file being loaded
  43990. * @param pluginExtension the extension used to determine the plugin
  43991. * @returns The loaded scene
  43992. */
  43993. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43994. /**
  43995. * Append a scene
  43996. * @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)
  43997. * @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)
  43998. * @param scene is the instance of BABYLON.Scene to append to
  43999. * @param onSuccess a callback with the scene when import succeeds
  44000. * @param onProgress a callback with a progress event for each file being loaded
  44001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44002. * @param pluginExtension the extension used to determine the plugin
  44003. * @returns The loaded plugin
  44004. */
  44005. 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>;
  44006. /**
  44007. * Append a scene
  44008. * @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)
  44009. * @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)
  44010. * @param scene is the instance of BABYLON.Scene to append to
  44011. * @param onProgress a callback with a progress event for each file being loaded
  44012. * @param pluginExtension the extension used to determine the plugin
  44013. * @returns The given scene
  44014. */
  44015. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44016. /**
  44017. * Load a scene into an asset container
  44018. * @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)
  44019. * @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)
  44020. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44021. * @param onSuccess a callback with the scene when import succeeds
  44022. * @param onProgress a callback with a progress event for each file being loaded
  44023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44024. * @param pluginExtension the extension used to determine the plugin
  44025. * @returns The loaded plugin
  44026. */
  44027. 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>;
  44028. /**
  44029. * Load a scene into an asset container
  44030. * @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)
  44031. * @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)
  44032. * @param scene is the instance of Scene to append to
  44033. * @param onProgress a callback with a progress event for each file being loaded
  44034. * @param pluginExtension the extension used to determine the plugin
  44035. * @returns The loaded asset container
  44036. */
  44037. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44038. /**
  44039. * Import animations from a file into a scene
  44040. * @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)
  44041. * @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)
  44042. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44043. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44044. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44045. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44046. * @param onSuccess a callback with the scene when import succeeds
  44047. * @param onProgress a callback with a progress event for each file being loaded
  44048. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44049. */
  44050. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44051. /**
  44052. * Import animations from a file into a scene
  44053. * @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)
  44054. * @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)
  44055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44056. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44057. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44058. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44059. * @param onSuccess a callback with the scene when import succeeds
  44060. * @param onProgress a callback with a progress event for each file being loaded
  44061. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44062. * @returns the updated scene with imported animations
  44063. */
  44064. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44065. }
  44066. }
  44067. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44068. import { Scene } from "babylonjs/scene";
  44069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44070. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44071. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44072. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44073. /**
  44074. * Generic Controller
  44075. */
  44076. export class GenericController extends WebVRController {
  44077. /**
  44078. * Base Url for the controller model.
  44079. */
  44080. static readonly MODEL_BASE_URL: string;
  44081. /**
  44082. * File name for the controller model.
  44083. */
  44084. static readonly MODEL_FILENAME: string;
  44085. /**
  44086. * Creates a new GenericController from a gamepad
  44087. * @param vrGamepad the gamepad that the controller should be created from
  44088. */
  44089. constructor(vrGamepad: any);
  44090. /**
  44091. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44092. * @param scene scene in which to add meshes
  44093. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44094. */
  44095. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44096. /**
  44097. * Called once for each button that changed state since the last frame
  44098. * @param buttonIdx Which button index changed
  44099. * @param state New state of the button
  44100. * @param changes Which properties on the state changed since last frame
  44101. */
  44102. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44103. }
  44104. }
  44105. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44106. import { Observable } from "babylonjs/Misc/observable";
  44107. import { Scene } from "babylonjs/scene";
  44108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44109. import { Ray } from "babylonjs/Culling/ray";
  44110. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44111. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44112. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44113. /**
  44114. * Defines the WindowsMotionController object that the state of the windows motion controller
  44115. */
  44116. export class WindowsMotionController extends WebVRController {
  44117. /**
  44118. * The base url used to load the left and right controller models
  44119. */
  44120. static MODEL_BASE_URL: string;
  44121. /**
  44122. * The name of the left controller model file
  44123. */
  44124. static MODEL_LEFT_FILENAME: string;
  44125. /**
  44126. * The name of the right controller model file
  44127. */
  44128. static MODEL_RIGHT_FILENAME: string;
  44129. /**
  44130. * The controller name prefix for this controller type
  44131. */
  44132. static readonly GAMEPAD_ID_PREFIX: string;
  44133. /**
  44134. * The controller id pattern for this controller type
  44135. */
  44136. private static readonly GAMEPAD_ID_PATTERN;
  44137. private _loadedMeshInfo;
  44138. protected readonly _mapping: {
  44139. buttons: string[];
  44140. buttonMeshNames: {
  44141. 'trigger': string;
  44142. 'menu': string;
  44143. 'grip': string;
  44144. 'thumbstick': string;
  44145. 'trackpad': string;
  44146. };
  44147. buttonObservableNames: {
  44148. 'trigger': string;
  44149. 'menu': string;
  44150. 'grip': string;
  44151. 'thumbstick': string;
  44152. 'trackpad': string;
  44153. };
  44154. axisMeshNames: string[];
  44155. pointingPoseMeshName: string;
  44156. };
  44157. /**
  44158. * Fired when the trackpad on this controller is clicked
  44159. */
  44160. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44161. /**
  44162. * Fired when the trackpad on this controller is modified
  44163. */
  44164. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44165. /**
  44166. * The current x and y values of this controller's trackpad
  44167. */
  44168. trackpad: StickValues;
  44169. /**
  44170. * Creates a new WindowsMotionController from a gamepad
  44171. * @param vrGamepad the gamepad that the controller should be created from
  44172. */
  44173. constructor(vrGamepad: any);
  44174. /**
  44175. * Fired when the trigger on this controller is modified
  44176. */
  44177. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44178. /**
  44179. * Fired when the menu button on this controller is modified
  44180. */
  44181. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44182. /**
  44183. * Fired when the grip button on this controller is modified
  44184. */
  44185. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44186. /**
  44187. * Fired when the thumbstick button on this controller is modified
  44188. */
  44189. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44190. /**
  44191. * Fired when the touchpad button on this controller is modified
  44192. */
  44193. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44194. /**
  44195. * Fired when the touchpad values on this controller are modified
  44196. */
  44197. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44198. protected _updateTrackpad(): void;
  44199. /**
  44200. * Called once per frame by the engine.
  44201. */
  44202. update(): void;
  44203. /**
  44204. * Called once for each button that changed state since the last frame
  44205. * @param buttonIdx Which button index changed
  44206. * @param state New state of the button
  44207. * @param changes Which properties on the state changed since last frame
  44208. */
  44209. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44210. /**
  44211. * Moves the buttons on the controller mesh based on their current state
  44212. * @param buttonName the name of the button to move
  44213. * @param buttonValue the value of the button which determines the buttons new position
  44214. */
  44215. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44216. /**
  44217. * Moves the axis on the controller mesh based on its current state
  44218. * @param axis the index of the axis
  44219. * @param axisValue the value of the axis which determines the meshes new position
  44220. * @hidden
  44221. */
  44222. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44223. /**
  44224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44225. * @param scene scene in which to add meshes
  44226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44227. */
  44228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44229. /**
  44230. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44231. * can be transformed by button presses and axes values, based on this._mapping.
  44232. *
  44233. * @param scene scene in which the meshes exist
  44234. * @param meshes list of meshes that make up the controller model to process
  44235. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44236. */
  44237. private processModel;
  44238. private createMeshInfo;
  44239. /**
  44240. * Gets the ray of the controller in the direction the controller is pointing
  44241. * @param length the length the resulting ray should be
  44242. * @returns a ray in the direction the controller is pointing
  44243. */
  44244. getForwardRay(length?: number): Ray;
  44245. /**
  44246. * Disposes of the controller
  44247. */
  44248. dispose(): void;
  44249. }
  44250. /**
  44251. * This class represents a new windows motion controller in XR.
  44252. */
  44253. export class XRWindowsMotionController extends WindowsMotionController {
  44254. /**
  44255. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44256. */
  44257. protected readonly _mapping: {
  44258. buttons: string[];
  44259. buttonMeshNames: {
  44260. 'trigger': string;
  44261. 'menu': string;
  44262. 'grip': string;
  44263. 'thumbstick': string;
  44264. 'trackpad': string;
  44265. };
  44266. buttonObservableNames: {
  44267. 'trigger': string;
  44268. 'menu': string;
  44269. 'grip': string;
  44270. 'thumbstick': string;
  44271. 'trackpad': string;
  44272. };
  44273. axisMeshNames: string[];
  44274. pointingPoseMeshName: string;
  44275. };
  44276. /**
  44277. * Construct a new XR-Based windows motion controller
  44278. *
  44279. * @param gamepadInfo the gamepad object from the browser
  44280. */
  44281. constructor(gamepadInfo: any);
  44282. /**
  44283. * holds the thumbstick values (X,Y)
  44284. */
  44285. thumbstickValues: StickValues;
  44286. /**
  44287. * Fired when the thumbstick on this controller is clicked
  44288. */
  44289. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44290. /**
  44291. * Fired when the thumbstick on this controller is modified
  44292. */
  44293. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44294. /**
  44295. * Fired when the touchpad button on this controller is modified
  44296. */
  44297. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44298. /**
  44299. * Fired when the touchpad values on this controller are modified
  44300. */
  44301. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44302. /**
  44303. * Fired when the thumbstick button on this controller is modified
  44304. * here to prevent breaking changes
  44305. */
  44306. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44307. /**
  44308. * updating the thumbstick(!) and not the trackpad.
  44309. * This is named this way due to the difference between WebVR and XR and to avoid
  44310. * changing the parent class.
  44311. */
  44312. protected _updateTrackpad(): void;
  44313. /**
  44314. * Disposes the class with joy
  44315. */
  44316. dispose(): void;
  44317. }
  44318. }
  44319. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44320. import { Observable } from "babylonjs/Misc/observable";
  44321. import { Scene } from "babylonjs/scene";
  44322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44323. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44324. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44325. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44326. /**
  44327. * Oculus Touch Controller
  44328. */
  44329. export class OculusTouchController extends WebVRController {
  44330. /**
  44331. * Base Url for the controller model.
  44332. */
  44333. static MODEL_BASE_URL: string;
  44334. /**
  44335. * File name for the left controller model.
  44336. */
  44337. static MODEL_LEFT_FILENAME: string;
  44338. /**
  44339. * File name for the right controller model.
  44340. */
  44341. static MODEL_RIGHT_FILENAME: string;
  44342. /**
  44343. * Base Url for the Quest controller model.
  44344. */
  44345. static QUEST_MODEL_BASE_URL: string;
  44346. /**
  44347. * @hidden
  44348. * If the controllers are running on a device that needs the updated Quest controller models
  44349. */
  44350. static _IsQuest: boolean;
  44351. /**
  44352. * Fired when the secondary trigger on this controller is modified
  44353. */
  44354. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44355. /**
  44356. * Fired when the thumb rest on this controller is modified
  44357. */
  44358. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44359. /**
  44360. * Creates a new OculusTouchController from a gamepad
  44361. * @param vrGamepad the gamepad that the controller should be created from
  44362. */
  44363. constructor(vrGamepad: any);
  44364. /**
  44365. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44366. * @param scene scene in which to add meshes
  44367. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44368. */
  44369. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44370. /**
  44371. * Fired when the A button on this controller is modified
  44372. */
  44373. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44374. /**
  44375. * Fired when the B button on this controller is modified
  44376. */
  44377. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44378. /**
  44379. * Fired when the X button on this controller is modified
  44380. */
  44381. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44382. /**
  44383. * Fired when the Y button on this controller is modified
  44384. */
  44385. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44386. /**
  44387. * Called once for each button that changed state since the last frame
  44388. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44389. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44390. * 2) secondary trigger (same)
  44391. * 3) A (right) X (left), touch, pressed = value
  44392. * 4) B / Y
  44393. * 5) thumb rest
  44394. * @param buttonIdx Which button index changed
  44395. * @param state New state of the button
  44396. * @param changes Which properties on the state changed since last frame
  44397. */
  44398. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44399. }
  44400. }
  44401. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44402. import { Scene } from "babylonjs/scene";
  44403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44404. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44405. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44406. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44407. import { Observable } from "babylonjs/Misc/observable";
  44408. /**
  44409. * Vive Controller
  44410. */
  44411. export class ViveController extends WebVRController {
  44412. /**
  44413. * Base Url for the controller model.
  44414. */
  44415. static MODEL_BASE_URL: string;
  44416. /**
  44417. * File name for the controller model.
  44418. */
  44419. static MODEL_FILENAME: string;
  44420. /**
  44421. * Creates a new ViveController from a gamepad
  44422. * @param vrGamepad the gamepad that the controller should be created from
  44423. */
  44424. constructor(vrGamepad: any);
  44425. /**
  44426. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44427. * @param scene scene in which to add meshes
  44428. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44429. */
  44430. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44431. /**
  44432. * Fired when the left button on this controller is modified
  44433. */
  44434. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44435. /**
  44436. * Fired when the right button on this controller is modified
  44437. */
  44438. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44439. /**
  44440. * Fired when the menu button on this controller is modified
  44441. */
  44442. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44443. /**
  44444. * Called once for each button that changed state since the last frame
  44445. * Vive mapping:
  44446. * 0: touchpad
  44447. * 1: trigger
  44448. * 2: left AND right buttons
  44449. * 3: menu button
  44450. * @param buttonIdx Which button index changed
  44451. * @param state New state of the button
  44452. * @param changes Which properties on the state changed since last frame
  44453. */
  44454. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44455. }
  44456. }
  44457. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44458. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44459. import { Observable } from "babylonjs/Misc/observable";
  44460. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44461. /**
  44462. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44463. */
  44464. export class WebXRControllerModelLoader {
  44465. /**
  44466. * an observable that triggers when a new model (the mesh itself) was initialized.
  44467. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44468. */
  44469. onControllerModelLoaded: Observable<WebXRController>;
  44470. /**
  44471. * Creates the WebXRControllerModelLoader
  44472. * @param input xr input that creates the controllers
  44473. */
  44474. constructor(input: WebXRInput);
  44475. }
  44476. }
  44477. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  44478. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44479. /**
  44480. * Handles pointer input automatically for the pointer of XR controllers
  44481. */
  44482. export class WebXRControllerPointerSelection {
  44483. private static _idCounter;
  44484. private _tmpRay;
  44485. /**
  44486. * Creates a WebXRControllerPointerSelection
  44487. * @param input input manager to setup pointer selection
  44488. */
  44489. constructor(input: WebXRInput);
  44490. private _convertNormalToDirectionOfRay;
  44491. private _updatePointerDistance;
  44492. }
  44493. }
  44494. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  44495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44496. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44497. /**
  44498. * Enables teleportation
  44499. */
  44500. export class WebXRControllerTeleportation {
  44501. private _teleportationFillColor;
  44502. private _teleportationBorderColor;
  44503. private _tmpRay;
  44504. private _tmpVector;
  44505. /**
  44506. * when set to true (default) teleportation will wait for thumbstick changes.
  44507. * When set to false teleportation will be disabled.
  44508. *
  44509. * If set to false while teleporting results can be unexpected.
  44510. */
  44511. enabled: boolean;
  44512. /**
  44513. * Creates a WebXRControllerTeleportation
  44514. * @param input input manager to add teleportation to
  44515. * @param floorMeshes floormeshes which can be teleported to
  44516. */
  44517. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  44518. }
  44519. }
  44520. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  44521. import { Nullable } from "babylonjs/types";
  44522. import { Observable } from "babylonjs/Misc/observable";
  44523. import { IDisposable, Scene } from "babylonjs/scene";
  44524. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44525. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44526. /**
  44527. * Button which can be used to enter a different mode of XR
  44528. */
  44529. export class WebXREnterExitUIButton {
  44530. /** button element */
  44531. element: HTMLElement;
  44532. /** XR initialization options for the button */
  44533. sessionMode: XRSessionMode;
  44534. /** Reference space type */
  44535. referenceSpaceType: XRReferenceSpaceType;
  44536. /**
  44537. * Creates a WebXREnterExitUIButton
  44538. * @param element button element
  44539. * @param sessionMode XR initialization session mode
  44540. * @param referenceSpaceType the type of reference space to be used
  44541. */
  44542. constructor(
  44543. /** button element */
  44544. element: HTMLElement,
  44545. /** XR initialization options for the button */
  44546. sessionMode: XRSessionMode,
  44547. /** Reference space type */
  44548. referenceSpaceType: XRReferenceSpaceType);
  44549. /**
  44550. * Overwritable function which can be used to update the button's visuals when the state changes
  44551. * @param activeButton the current active button in the UI
  44552. */
  44553. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44554. }
  44555. /**
  44556. * Options to create the webXR UI
  44557. */
  44558. export class WebXREnterExitUIOptions {
  44559. /**
  44560. * Context to enter xr with
  44561. */
  44562. renderTarget?: Nullable<WebXRRenderTarget>;
  44563. /**
  44564. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44565. */
  44566. customButtons?: Array<WebXREnterExitUIButton>;
  44567. /**
  44568. * A session mode to use when creating the default button.
  44569. * Default is immersive-vr
  44570. */
  44571. sessionMode?: XRSessionMode;
  44572. /**
  44573. * A reference space type to use when creating the default button.
  44574. * Default is local-floor
  44575. */
  44576. referenceSpaceType?: XRReferenceSpaceType;
  44577. }
  44578. /**
  44579. * UI to allow the user to enter/exit XR mode
  44580. */
  44581. export class WebXREnterExitUI implements IDisposable {
  44582. private scene;
  44583. /** version of the options passed to this UI */
  44584. options: WebXREnterExitUIOptions;
  44585. private _overlay;
  44586. private _buttons;
  44587. private _activeButton;
  44588. /**
  44589. * Fired every time the active button is changed.
  44590. *
  44591. * When xr is entered via a button that launches xr that button will be the callback parameter
  44592. *
  44593. * When exiting xr the callback parameter will be null)
  44594. */
  44595. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44596. /**
  44597. * Creates UI to allow the user to enter/exit XR mode
  44598. * @param scene the scene to add the ui to
  44599. * @param helper the xr experience helper to enter/exit xr with
  44600. * @param options options to configure the UI
  44601. * @returns the created ui
  44602. */
  44603. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44604. /**
  44605. *
  44606. * @param scene babylon scene object to use
  44607. * @param options (read-only) version of the options passed to this UI
  44608. */
  44609. private constructor();
  44610. private _updateButtons;
  44611. /**
  44612. * Disposes of the object
  44613. */
  44614. dispose(): void;
  44615. }
  44616. }
  44617. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44618. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44619. import { Scene } from "babylonjs/scene";
  44620. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44621. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44622. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44623. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44624. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44625. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44627. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44628. /**
  44629. * Options for the default xr helper
  44630. */
  44631. export class WebXRDefaultExperienceOptions {
  44632. /**
  44633. * Floor meshes that should be used for teleporting
  44634. */
  44635. floorMeshes: Array<AbstractMesh>;
  44636. /**
  44637. * Enable or disable default UI to enter XR
  44638. */
  44639. disableDefaultUI?: boolean;
  44640. /**
  44641. * optional configuration for the output canvas
  44642. */
  44643. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44644. /**
  44645. * optional UI options. This can be used among other to change session mode and reference space type
  44646. */
  44647. uiOptions?: WebXREnterExitUIOptions;
  44648. }
  44649. /**
  44650. * Default experience which provides a similar setup to the previous webVRExperience
  44651. */
  44652. export class WebXRDefaultExperience {
  44653. /**
  44654. * Base experience
  44655. */
  44656. baseExperience: WebXRExperienceHelper;
  44657. /**
  44658. * Input experience extension
  44659. */
  44660. input: WebXRInput;
  44661. /**
  44662. * Loads the controller models
  44663. */
  44664. controllerModelLoader: WebXRControllerModelLoader;
  44665. /**
  44666. * Enables laser pointer and selection
  44667. */
  44668. pointerSelection: WebXRControllerPointerSelection;
  44669. /**
  44670. * Enables teleportation
  44671. */
  44672. teleportation: WebXRControllerTeleportation;
  44673. /**
  44674. * Enables ui for entering/exiting xr
  44675. */
  44676. enterExitUI: WebXREnterExitUI;
  44677. /**
  44678. * Default target xr should render to
  44679. */
  44680. renderTarget: WebXRRenderTarget;
  44681. /**
  44682. * Creates the default xr experience
  44683. * @param scene scene
  44684. * @param options options for basic configuration
  44685. * @returns resulting WebXRDefaultExperience
  44686. */
  44687. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44688. private constructor();
  44689. /**
  44690. * DIsposes of the experience helper
  44691. */
  44692. dispose(): void;
  44693. }
  44694. }
  44695. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  44696. import { Observable } from "babylonjs/Misc/observable";
  44697. import { Nullable } from "babylonjs/types";
  44698. import { Camera } from "babylonjs/Cameras/camera";
  44699. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  44700. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  44701. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  44702. import { Scene } from "babylonjs/scene";
  44703. import { Vector3 } from "babylonjs/Maths/math.vector";
  44704. import { Color3 } from "babylonjs/Maths/math.color";
  44705. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44707. import { Mesh } from "babylonjs/Meshes/mesh";
  44708. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44709. import { EasingFunction } from "babylonjs/Animations/easing";
  44710. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  44711. import "babylonjs/Meshes/Builders/groundBuilder";
  44712. import "babylonjs/Meshes/Builders/torusBuilder";
  44713. import "babylonjs/Meshes/Builders/cylinderBuilder";
  44714. import "babylonjs/Gamepads/gamepadSceneComponent";
  44715. import "babylonjs/Animations/animatable";
  44716. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44717. /**
  44718. * Options to modify the vr teleportation behavior.
  44719. */
  44720. export interface VRTeleportationOptions {
  44721. /**
  44722. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44723. */
  44724. floorMeshName?: string;
  44725. /**
  44726. * A list of meshes to be used as the teleportation floor. (default: empty)
  44727. */
  44728. floorMeshes?: Mesh[];
  44729. /**
  44730. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44731. */
  44732. teleportationMode?: number;
  44733. /**
  44734. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44735. */
  44736. teleportationTime?: number;
  44737. /**
  44738. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44739. */
  44740. teleportationSpeed?: number;
  44741. /**
  44742. * The easing function used in the animation or null for Linear. (default CircleEase)
  44743. */
  44744. easingFunction?: EasingFunction;
  44745. }
  44746. /**
  44747. * Options to modify the vr experience helper's behavior.
  44748. */
  44749. export interface VRExperienceHelperOptions extends WebVROptions {
  44750. /**
  44751. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44752. */
  44753. createDeviceOrientationCamera?: boolean;
  44754. /**
  44755. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44756. */
  44757. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44758. /**
  44759. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44760. */
  44761. laserToggle?: boolean;
  44762. /**
  44763. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44764. */
  44765. floorMeshes?: Mesh[];
  44766. /**
  44767. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44768. */
  44769. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44770. /**
  44771. * Defines if WebXR should be used instead of WebVR (if available)
  44772. */
  44773. useXR?: boolean;
  44774. }
  44775. /**
  44776. * Event containing information after VR has been entered
  44777. */
  44778. export class OnAfterEnteringVRObservableEvent {
  44779. /**
  44780. * If entering vr was successful
  44781. */
  44782. success: boolean;
  44783. }
  44784. /**
  44785. * Helps to quickly add VR support to an existing scene.
  44786. * See http://doc.babylonjs.com/how_to/webvr_helper
  44787. */
  44788. export class VRExperienceHelper {
  44789. /** Options to modify the vr experience helper's behavior. */
  44790. webVROptions: VRExperienceHelperOptions;
  44791. private _scene;
  44792. private _position;
  44793. private _btnVR;
  44794. private _btnVRDisplayed;
  44795. private _webVRsupported;
  44796. private _webVRready;
  44797. private _webVRrequesting;
  44798. private _webVRpresenting;
  44799. private _hasEnteredVR;
  44800. private _fullscreenVRpresenting;
  44801. private _inputElement;
  44802. private _webVRCamera;
  44803. private _vrDeviceOrientationCamera;
  44804. private _deviceOrientationCamera;
  44805. private _existingCamera;
  44806. private _onKeyDown;
  44807. private _onVrDisplayPresentChange;
  44808. private _onVRDisplayChanged;
  44809. private _onVRRequestPresentStart;
  44810. private _onVRRequestPresentComplete;
  44811. /**
  44812. * 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)
  44813. */
  44814. enableGazeEvenWhenNoPointerLock: boolean;
  44815. /**
  44816. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44817. */
  44818. exitVROnDoubleTap: boolean;
  44819. /**
  44820. * Observable raised right before entering VR.
  44821. */
  44822. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44823. /**
  44824. * Observable raised when entering VR has completed.
  44825. */
  44826. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44827. /**
  44828. * Observable raised when exiting VR.
  44829. */
  44830. onExitingVRObservable: Observable<VRExperienceHelper>;
  44831. /**
  44832. * Observable raised when controller mesh is loaded.
  44833. */
  44834. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44835. /** Return this.onEnteringVRObservable
  44836. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44837. */
  44838. readonly onEnteringVR: Observable<VRExperienceHelper>;
  44839. /** Return this.onExitingVRObservable
  44840. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44841. */
  44842. readonly onExitingVR: Observable<VRExperienceHelper>;
  44843. /** Return this.onControllerMeshLoadedObservable
  44844. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44845. */
  44846. readonly onControllerMeshLoaded: Observable<WebVRController>;
  44847. private _rayLength;
  44848. private _useCustomVRButton;
  44849. private _teleportationRequested;
  44850. private _teleportActive;
  44851. private _floorMeshName;
  44852. private _floorMeshesCollection;
  44853. private _teleportationMode;
  44854. private _teleportationTime;
  44855. private _teleportationSpeed;
  44856. private _teleportationEasing;
  44857. private _rotationAllowed;
  44858. private _teleportBackwardsVector;
  44859. private _teleportationTarget;
  44860. private _isDefaultTeleportationTarget;
  44861. private _postProcessMove;
  44862. private _teleportationFillColor;
  44863. private _teleportationBorderColor;
  44864. private _rotationAngle;
  44865. private _haloCenter;
  44866. private _cameraGazer;
  44867. private _padSensibilityUp;
  44868. private _padSensibilityDown;
  44869. private _leftController;
  44870. private _rightController;
  44871. /**
  44872. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44873. */
  44874. onNewMeshSelected: Observable<AbstractMesh>;
  44875. /**
  44876. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44877. * This observable will provide the mesh and the controller used to select the mesh
  44878. */
  44879. onMeshSelectedWithController: Observable<{
  44880. mesh: AbstractMesh;
  44881. controller: WebVRController;
  44882. }>;
  44883. /**
  44884. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44885. */
  44886. onNewMeshPicked: Observable<PickingInfo>;
  44887. private _circleEase;
  44888. /**
  44889. * Observable raised before camera teleportation
  44890. */
  44891. onBeforeCameraTeleport: Observable<Vector3>;
  44892. /**
  44893. * Observable raised after camera teleportation
  44894. */
  44895. onAfterCameraTeleport: Observable<Vector3>;
  44896. /**
  44897. * Observable raised when current selected mesh gets unselected
  44898. */
  44899. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44900. private _raySelectionPredicate;
  44901. /**
  44902. * To be optionaly changed by user to define custom ray selection
  44903. */
  44904. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44905. /**
  44906. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44907. */
  44908. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44909. /**
  44910. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44911. */
  44912. teleportationEnabled: boolean;
  44913. private _defaultHeight;
  44914. private _teleportationInitialized;
  44915. private _interactionsEnabled;
  44916. private _interactionsRequested;
  44917. private _displayGaze;
  44918. private _displayLaserPointer;
  44919. /**
  44920. * The mesh used to display where the user is going to teleport.
  44921. */
  44922. /**
  44923. * Sets the mesh to be used to display where the user is going to teleport.
  44924. */
  44925. teleportationTarget: Mesh;
  44926. /**
  44927. * 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
  44928. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44929. * See http://doc.babylonjs.com/resources/baking_transformations
  44930. */
  44931. gazeTrackerMesh: Mesh;
  44932. /**
  44933. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44934. */
  44935. updateGazeTrackerScale: boolean;
  44936. /**
  44937. * If the gaze trackers color should be updated when selecting meshes
  44938. */
  44939. updateGazeTrackerColor: boolean;
  44940. /**
  44941. * If the controller laser color should be updated when selecting meshes
  44942. */
  44943. updateControllerLaserColor: boolean;
  44944. /**
  44945. * The gaze tracking mesh corresponding to the left controller
  44946. */
  44947. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  44948. /**
  44949. * The gaze tracking mesh corresponding to the right controller
  44950. */
  44951. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  44952. /**
  44953. * If the ray of the gaze should be displayed.
  44954. */
  44955. /**
  44956. * Sets if the ray of the gaze should be displayed.
  44957. */
  44958. displayGaze: boolean;
  44959. /**
  44960. * If the ray of the LaserPointer should be displayed.
  44961. */
  44962. /**
  44963. * Sets if the ray of the LaserPointer should be displayed.
  44964. */
  44965. displayLaserPointer: boolean;
  44966. /**
  44967. * The deviceOrientationCamera used as the camera when not in VR.
  44968. */
  44969. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  44970. /**
  44971. * Based on the current WebVR support, returns the current VR camera used.
  44972. */
  44973. readonly currentVRCamera: Nullable<Camera>;
  44974. /**
  44975. * The webVRCamera which is used when in VR.
  44976. */
  44977. readonly webVRCamera: WebVRFreeCamera;
  44978. /**
  44979. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44980. */
  44981. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  44982. /**
  44983. * The html button that is used to trigger entering into VR.
  44984. */
  44985. readonly vrButton: Nullable<HTMLButtonElement>;
  44986. private readonly _teleportationRequestInitiated;
  44987. /**
  44988. * Defines wether or not Pointer lock should be requested when switching to
  44989. * full screen.
  44990. */
  44991. requestPointerLockOnFullScreen: boolean;
  44992. /**
  44993. * If asking to force XR, this will be populated with the default xr experience
  44994. */
  44995. xr: WebXRDefaultExperience;
  44996. /**
  44997. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44998. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44999. */
  45000. xrTestDone: boolean;
  45001. /**
  45002. * Instantiates a VRExperienceHelper.
  45003. * Helps to quickly add VR support to an existing scene.
  45004. * @param scene The scene the VRExperienceHelper belongs to.
  45005. * @param webVROptions Options to modify the vr experience helper's behavior.
  45006. */
  45007. constructor(scene: Scene,
  45008. /** Options to modify the vr experience helper's behavior. */
  45009. webVROptions?: VRExperienceHelperOptions);
  45010. private completeVRInit;
  45011. private _onDefaultMeshLoaded;
  45012. private _onResize;
  45013. private _onFullscreenChange;
  45014. /**
  45015. * Gets a value indicating if we are currently in VR mode.
  45016. */
  45017. readonly isInVRMode: boolean;
  45018. private onVrDisplayPresentChange;
  45019. private onVRDisplayChanged;
  45020. private moveButtonToBottomRight;
  45021. private displayVRButton;
  45022. private updateButtonVisibility;
  45023. private _cachedAngularSensibility;
  45024. /**
  45025. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45026. * Otherwise, will use the fullscreen API.
  45027. */
  45028. enterVR(): void;
  45029. /**
  45030. * Attempt to exit VR, or fullscreen.
  45031. */
  45032. exitVR(): void;
  45033. /**
  45034. * The position of the vr experience helper.
  45035. */
  45036. /**
  45037. * Sets the position of the vr experience helper.
  45038. */
  45039. position: Vector3;
  45040. /**
  45041. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45042. */
  45043. enableInteractions(): void;
  45044. private readonly _noControllerIsActive;
  45045. private beforeRender;
  45046. private _isTeleportationFloor;
  45047. /**
  45048. * Adds a floor mesh to be used for teleportation.
  45049. * @param floorMesh the mesh to be used for teleportation.
  45050. */
  45051. addFloorMesh(floorMesh: Mesh): void;
  45052. /**
  45053. * Removes a floor mesh from being used for teleportation.
  45054. * @param floorMesh the mesh to be removed.
  45055. */
  45056. removeFloorMesh(floorMesh: Mesh): void;
  45057. /**
  45058. * Enables interactions and teleportation using the VR controllers and gaze.
  45059. * @param vrTeleportationOptions options to modify teleportation behavior.
  45060. */
  45061. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45062. private _onNewGamepadConnected;
  45063. private _tryEnableInteractionOnController;
  45064. private _onNewGamepadDisconnected;
  45065. private _enableInteractionOnController;
  45066. private _checkTeleportWithRay;
  45067. private _checkRotate;
  45068. private _checkTeleportBackwards;
  45069. private _enableTeleportationOnController;
  45070. private _createTeleportationCircles;
  45071. private _displayTeleportationTarget;
  45072. private _hideTeleportationTarget;
  45073. private _rotateCamera;
  45074. private _moveTeleportationSelectorTo;
  45075. private _workingVector;
  45076. private _workingQuaternion;
  45077. private _workingMatrix;
  45078. /**
  45079. * Time Constant Teleportation Mode
  45080. */
  45081. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45082. /**
  45083. * Speed Constant Teleportation Mode
  45084. */
  45085. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45086. /**
  45087. * Teleports the users feet to the desired location
  45088. * @param location The location where the user's feet should be placed
  45089. */
  45090. teleportCamera(location: Vector3): void;
  45091. private _convertNormalToDirectionOfRay;
  45092. private _castRayAndSelectObject;
  45093. private _notifySelectedMeshUnselected;
  45094. /**
  45095. * Sets the color of the laser ray from the vr controllers.
  45096. * @param color new color for the ray.
  45097. */
  45098. changeLaserColor(color: Color3): void;
  45099. /**
  45100. * Sets the color of the ray from the vr headsets gaze.
  45101. * @param color new color for the ray.
  45102. */
  45103. changeGazeColor(color: Color3): void;
  45104. /**
  45105. * Exits VR and disposes of the vr experience helper
  45106. */
  45107. dispose(): void;
  45108. /**
  45109. * Gets the name of the VRExperienceHelper class
  45110. * @returns "VRExperienceHelper"
  45111. */
  45112. getClassName(): string;
  45113. }
  45114. }
  45115. declare module "babylonjs/Cameras/VR/index" {
  45116. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45117. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45118. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45119. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45120. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45121. export * from "babylonjs/Cameras/VR/webVRCamera";
  45122. }
  45123. declare module "babylonjs/Cameras/XR/index" {
  45124. export * from "babylonjs/Cameras/XR/webXRCamera";
  45125. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  45126. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45127. export * from "babylonjs/Cameras/XR/webXRInput";
  45128. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45129. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45130. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45131. export * from "babylonjs/Cameras/XR/webXRController";
  45132. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45133. export * from "babylonjs/Cameras/XR/webXRTypes";
  45134. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  45135. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45136. }
  45137. declare module "babylonjs/Cameras/RigModes/index" {
  45138. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  45139. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  45140. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  45141. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  45142. }
  45143. declare module "babylonjs/Cameras/index" {
  45144. export * from "babylonjs/Cameras/Inputs/index";
  45145. export * from "babylonjs/Cameras/cameraInputsManager";
  45146. export * from "babylonjs/Cameras/camera";
  45147. export * from "babylonjs/Cameras/targetCamera";
  45148. export * from "babylonjs/Cameras/freeCamera";
  45149. export * from "babylonjs/Cameras/freeCameraInputsManager";
  45150. export * from "babylonjs/Cameras/touchCamera";
  45151. export * from "babylonjs/Cameras/arcRotateCamera";
  45152. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  45153. export * from "babylonjs/Cameras/deviceOrientationCamera";
  45154. export * from "babylonjs/Cameras/flyCamera";
  45155. export * from "babylonjs/Cameras/flyCameraInputsManager";
  45156. export * from "babylonjs/Cameras/followCamera";
  45157. export * from "babylonjs/Cameras/followCameraInputsManager";
  45158. export * from "babylonjs/Cameras/gamepadCamera";
  45159. export * from "babylonjs/Cameras/Stereoscopic/index";
  45160. export * from "babylonjs/Cameras/universalCamera";
  45161. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  45162. export * from "babylonjs/Cameras/VR/index";
  45163. export * from "babylonjs/Cameras/XR/index";
  45164. export * from "babylonjs/Cameras/RigModes/index";
  45165. }
  45166. declare module "babylonjs/Collisions/index" {
  45167. export * from "babylonjs/Collisions/collider";
  45168. export * from "babylonjs/Collisions/collisionCoordinator";
  45169. export * from "babylonjs/Collisions/pickingInfo";
  45170. export * from "babylonjs/Collisions/intersectionInfo";
  45171. export * from "babylonjs/Collisions/meshCollisionData";
  45172. }
  45173. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  45174. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  45175. import { Vector3 } from "babylonjs/Maths/math.vector";
  45176. import { Ray } from "babylonjs/Culling/ray";
  45177. import { Plane } from "babylonjs/Maths/math.plane";
  45178. /**
  45179. * Contains an array of blocks representing the octree
  45180. */
  45181. export interface IOctreeContainer<T> {
  45182. /**
  45183. * Blocks within the octree
  45184. */
  45185. blocks: Array<OctreeBlock<T>>;
  45186. }
  45187. /**
  45188. * Class used to store a cell in an octree
  45189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45190. */
  45191. export class OctreeBlock<T> {
  45192. /**
  45193. * Gets the content of the current block
  45194. */
  45195. entries: T[];
  45196. /**
  45197. * Gets the list of block children
  45198. */
  45199. blocks: Array<OctreeBlock<T>>;
  45200. private _depth;
  45201. private _maxDepth;
  45202. private _capacity;
  45203. private _minPoint;
  45204. private _maxPoint;
  45205. private _boundingVectors;
  45206. private _creationFunc;
  45207. /**
  45208. * Creates a new block
  45209. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45210. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45211. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45212. * @param depth defines the current depth of this block in the octree
  45213. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45214. * @param creationFunc defines a callback to call when an element is added to the block
  45215. */
  45216. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45217. /**
  45218. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45219. */
  45220. readonly capacity: number;
  45221. /**
  45222. * Gets the minimum vector (in world space) of the block's bounding box
  45223. */
  45224. readonly minPoint: Vector3;
  45225. /**
  45226. * Gets the maximum vector (in world space) of the block's bounding box
  45227. */
  45228. readonly maxPoint: Vector3;
  45229. /**
  45230. * Add a new element to this block
  45231. * @param entry defines the element to add
  45232. */
  45233. addEntry(entry: T): void;
  45234. /**
  45235. * Remove an element from this block
  45236. * @param entry defines the element to remove
  45237. */
  45238. removeEntry(entry: T): void;
  45239. /**
  45240. * Add an array of elements to this block
  45241. * @param entries defines the array of elements to add
  45242. */
  45243. addEntries(entries: T[]): void;
  45244. /**
  45245. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45246. * @param frustumPlanes defines the frustum planes to test
  45247. * @param selection defines the array to store current content if selection is positive
  45248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45249. */
  45250. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45251. /**
  45252. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45253. * @param sphereCenter defines the bounding sphere center
  45254. * @param sphereRadius defines the bounding sphere radius
  45255. * @param selection defines the array to store current content if selection is positive
  45256. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45257. */
  45258. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45259. /**
  45260. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45261. * @param ray defines the ray to test with
  45262. * @param selection defines the array to store current content if selection is positive
  45263. */
  45264. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45265. /**
  45266. * Subdivide the content into child blocks (this block will then be empty)
  45267. */
  45268. createInnerBlocks(): void;
  45269. /**
  45270. * @hidden
  45271. */
  45272. 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;
  45273. }
  45274. }
  45275. declare module "babylonjs/Culling/Octrees/octree" {
  45276. import { SmartArray } from "babylonjs/Misc/smartArray";
  45277. import { Vector3 } from "babylonjs/Maths/math.vector";
  45278. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45280. import { Ray } from "babylonjs/Culling/ray";
  45281. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  45282. import { Plane } from "babylonjs/Maths/math.plane";
  45283. /**
  45284. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45285. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45286. */
  45287. export class Octree<T> {
  45288. /** 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.) */
  45289. maxDepth: number;
  45290. /**
  45291. * Blocks within the octree containing objects
  45292. */
  45293. blocks: Array<OctreeBlock<T>>;
  45294. /**
  45295. * Content stored in the octree
  45296. */
  45297. dynamicContent: T[];
  45298. private _maxBlockCapacity;
  45299. private _selectionContent;
  45300. private _creationFunc;
  45301. /**
  45302. * Creates a octree
  45303. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45304. * @param creationFunc function to be used to instatiate the octree
  45305. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45306. * @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.)
  45307. */
  45308. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45309. /** 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.) */
  45310. maxDepth?: number);
  45311. /**
  45312. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45313. * @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);
  45314. * @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);
  45315. * @param entries meshes to be added to the octree blocks
  45316. */
  45317. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45318. /**
  45319. * Adds a mesh to the octree
  45320. * @param entry Mesh to add to the octree
  45321. */
  45322. addMesh(entry: T): void;
  45323. /**
  45324. * Remove an element from the octree
  45325. * @param entry defines the element to remove
  45326. */
  45327. removeMesh(entry: T): void;
  45328. /**
  45329. * Selects an array of meshes within the frustum
  45330. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45331. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45332. * @returns array of meshes within the frustum
  45333. */
  45334. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45335. /**
  45336. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45337. * @param sphereCenter defines the bounding sphere center
  45338. * @param sphereRadius defines the bounding sphere radius
  45339. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45340. * @returns an array of objects that intersect the sphere
  45341. */
  45342. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45343. /**
  45344. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45345. * @param ray defines the ray to test with
  45346. * @returns array of intersected objects
  45347. */
  45348. intersectsRay(ray: Ray): SmartArray<T>;
  45349. /**
  45350. * Adds a mesh into the octree block if it intersects the block
  45351. */
  45352. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45353. /**
  45354. * Adds a submesh into the octree block if it intersects the block
  45355. */
  45356. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45357. }
  45358. }
  45359. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  45360. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  45361. import { Scene } from "babylonjs/scene";
  45362. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45364. import { Ray } from "babylonjs/Culling/ray";
  45365. import { Octree } from "babylonjs/Culling/Octrees/octree";
  45366. import { Collider } from "babylonjs/Collisions/collider";
  45367. module "babylonjs/scene" {
  45368. interface Scene {
  45369. /**
  45370. * @hidden
  45371. * Backing Filed
  45372. */
  45373. _selectionOctree: Octree<AbstractMesh>;
  45374. /**
  45375. * Gets the octree used to boost mesh selection (picking)
  45376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45377. */
  45378. selectionOctree: Octree<AbstractMesh>;
  45379. /**
  45380. * Creates or updates the octree used to boost selection (picking)
  45381. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45382. * @param maxCapacity defines the maximum capacity per leaf
  45383. * @param maxDepth defines the maximum depth of the octree
  45384. * @returns an octree of AbstractMesh
  45385. */
  45386. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45387. }
  45388. }
  45389. module "babylonjs/Meshes/abstractMesh" {
  45390. interface AbstractMesh {
  45391. /**
  45392. * @hidden
  45393. * Backing Field
  45394. */
  45395. _submeshesOctree: Octree<SubMesh>;
  45396. /**
  45397. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45398. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45399. * @param maxCapacity defines the maximum size of each block (64 by default)
  45400. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45401. * @returns the new octree
  45402. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45404. */
  45405. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45406. }
  45407. }
  45408. /**
  45409. * Defines the octree scene component responsible to manage any octrees
  45410. * in a given scene.
  45411. */
  45412. export class OctreeSceneComponent {
  45413. /**
  45414. * The component name help to identify the component in the list of scene components.
  45415. */
  45416. readonly name: string;
  45417. /**
  45418. * The scene the component belongs to.
  45419. */
  45420. scene: Scene;
  45421. /**
  45422. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45423. */
  45424. readonly checksIsEnabled: boolean;
  45425. /**
  45426. * Creates a new instance of the component for the given scene
  45427. * @param scene Defines the scene to register the component in
  45428. */
  45429. constructor(scene: Scene);
  45430. /**
  45431. * Registers the component in a given scene
  45432. */
  45433. register(): void;
  45434. /**
  45435. * Return the list of active meshes
  45436. * @returns the list of active meshes
  45437. */
  45438. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45439. /**
  45440. * Return the list of active sub meshes
  45441. * @param mesh The mesh to get the candidates sub meshes from
  45442. * @returns the list of active sub meshes
  45443. */
  45444. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45445. private _tempRay;
  45446. /**
  45447. * Return the list of sub meshes intersecting with a given local ray
  45448. * @param mesh defines the mesh to find the submesh for
  45449. * @param localRay defines the ray in local space
  45450. * @returns the list of intersecting sub meshes
  45451. */
  45452. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45453. /**
  45454. * Return the list of sub meshes colliding with a collider
  45455. * @param mesh defines the mesh to find the submesh for
  45456. * @param collider defines the collider to evaluate the collision against
  45457. * @returns the list of colliding sub meshes
  45458. */
  45459. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45460. /**
  45461. * Rebuilds the elements related to this component in case of
  45462. * context lost for instance.
  45463. */
  45464. rebuild(): void;
  45465. /**
  45466. * Disposes the component and the associated ressources.
  45467. */
  45468. dispose(): void;
  45469. }
  45470. }
  45471. declare module "babylonjs/Culling/Octrees/index" {
  45472. export * from "babylonjs/Culling/Octrees/octree";
  45473. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45474. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45475. }
  45476. declare module "babylonjs/Culling/index" {
  45477. export * from "babylonjs/Culling/boundingBox";
  45478. export * from "babylonjs/Culling/boundingInfo";
  45479. export * from "babylonjs/Culling/boundingSphere";
  45480. export * from "babylonjs/Culling/Octrees/index";
  45481. export * from "babylonjs/Culling/ray";
  45482. }
  45483. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45484. import { IDisposable, Scene } from "babylonjs/scene";
  45485. import { Nullable } from "babylonjs/types";
  45486. import { Observable } from "babylonjs/Misc/observable";
  45487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45488. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45489. import { Camera } from "babylonjs/Cameras/camera";
  45490. /**
  45491. * Renders a layer on top of an existing scene
  45492. */
  45493. export class UtilityLayerRenderer implements IDisposable {
  45494. /** the original scene that will be rendered on top of */
  45495. originalScene: Scene;
  45496. private _pointerCaptures;
  45497. private _lastPointerEvents;
  45498. private static _DefaultUtilityLayer;
  45499. private static _DefaultKeepDepthUtilityLayer;
  45500. private _sharedGizmoLight;
  45501. private _renderCamera;
  45502. /**
  45503. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45504. * @returns the camera that is used when rendering the utility layer
  45505. */
  45506. getRenderCamera(): Nullable<Camera>;
  45507. /**
  45508. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45509. * @param cam the camera that should be used when rendering the utility layer
  45510. */
  45511. setRenderCamera(cam: Nullable<Camera>): void;
  45512. /**
  45513. * @hidden
  45514. * Light which used by gizmos to get light shading
  45515. */
  45516. _getSharedGizmoLight(): HemisphericLight;
  45517. /**
  45518. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45519. */
  45520. pickUtilitySceneFirst: boolean;
  45521. /**
  45522. * 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)
  45523. */
  45524. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45525. /**
  45526. * 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)
  45527. */
  45528. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45529. /**
  45530. * The scene that is rendered on top of the original scene
  45531. */
  45532. utilityLayerScene: Scene;
  45533. /**
  45534. * If the utility layer should automatically be rendered on top of existing scene
  45535. */
  45536. shouldRender: boolean;
  45537. /**
  45538. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45539. */
  45540. onlyCheckPointerDownEvents: boolean;
  45541. /**
  45542. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45543. */
  45544. processAllEvents: boolean;
  45545. /**
  45546. * Observable raised when the pointer move from the utility layer scene to the main scene
  45547. */
  45548. onPointerOutObservable: Observable<number>;
  45549. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45550. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45551. private _afterRenderObserver;
  45552. private _sceneDisposeObserver;
  45553. private _originalPointerObserver;
  45554. /**
  45555. * Instantiates a UtilityLayerRenderer
  45556. * @param originalScene the original scene that will be rendered on top of
  45557. * @param handleEvents boolean indicating if the utility layer should handle events
  45558. */
  45559. constructor(
  45560. /** the original scene that will be rendered on top of */
  45561. originalScene: Scene, handleEvents?: boolean);
  45562. private _notifyObservers;
  45563. /**
  45564. * Renders the utility layers scene on top of the original scene
  45565. */
  45566. render(): void;
  45567. /**
  45568. * Disposes of the renderer
  45569. */
  45570. dispose(): void;
  45571. private _updateCamera;
  45572. }
  45573. }
  45574. declare module "babylonjs/Gizmos/gizmo" {
  45575. import { Nullable } from "babylonjs/types";
  45576. import { IDisposable } from "babylonjs/scene";
  45577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45578. import { Mesh } from "babylonjs/Meshes/mesh";
  45579. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45580. /**
  45581. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45582. */
  45583. export class Gizmo implements IDisposable {
  45584. /** The utility layer the gizmo will be added to */
  45585. gizmoLayer: UtilityLayerRenderer;
  45586. /**
  45587. * The root mesh of the gizmo
  45588. */
  45589. _rootMesh: Mesh;
  45590. private _attachedMesh;
  45591. /**
  45592. * Ratio for the scale of the gizmo (Default: 1)
  45593. */
  45594. scaleRatio: number;
  45595. /**
  45596. * If a custom mesh has been set (Default: false)
  45597. */
  45598. protected _customMeshSet: boolean;
  45599. /**
  45600. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45601. * * When set, interactions will be enabled
  45602. */
  45603. attachedMesh: Nullable<AbstractMesh>;
  45604. /**
  45605. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45606. * @param mesh The mesh to replace the default mesh of the gizmo
  45607. */
  45608. setCustomMesh(mesh: Mesh): void;
  45609. /**
  45610. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45611. */
  45612. updateGizmoRotationToMatchAttachedMesh: boolean;
  45613. /**
  45614. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45615. */
  45616. updateGizmoPositionToMatchAttachedMesh: boolean;
  45617. /**
  45618. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45619. */
  45620. updateScale: boolean;
  45621. protected _interactionsEnabled: boolean;
  45622. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45623. private _beforeRenderObserver;
  45624. private _tempVector;
  45625. /**
  45626. * Creates a gizmo
  45627. * @param gizmoLayer The utility layer the gizmo will be added to
  45628. */
  45629. constructor(
  45630. /** The utility layer the gizmo will be added to */
  45631. gizmoLayer?: UtilityLayerRenderer);
  45632. /**
  45633. * Updates the gizmo to match the attached mesh's position/rotation
  45634. */
  45635. protected _update(): void;
  45636. /**
  45637. * Disposes of the gizmo
  45638. */
  45639. dispose(): void;
  45640. }
  45641. }
  45642. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45643. import { Observable } from "babylonjs/Misc/observable";
  45644. import { Nullable } from "babylonjs/types";
  45645. import { Vector3 } from "babylonjs/Maths/math.vector";
  45646. import { Color3 } from "babylonjs/Maths/math.color";
  45647. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45649. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45650. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45651. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45652. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45653. import { Scene } from "babylonjs/scene";
  45654. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45655. /**
  45656. * Single plane drag gizmo
  45657. */
  45658. export class PlaneDragGizmo extends Gizmo {
  45659. /**
  45660. * Drag behavior responsible for the gizmos dragging interactions
  45661. */
  45662. dragBehavior: PointerDragBehavior;
  45663. private _pointerObserver;
  45664. /**
  45665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45666. */
  45667. snapDistance: number;
  45668. /**
  45669. * Event that fires each time the gizmo snaps to a new location.
  45670. * * snapDistance is the the change in distance
  45671. */
  45672. onSnapObservable: Observable<{
  45673. snapDistance: number;
  45674. }>;
  45675. private _plane;
  45676. private _coloredMaterial;
  45677. private _hoverMaterial;
  45678. private _isEnabled;
  45679. private _parent;
  45680. /** @hidden */
  45681. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45682. /** @hidden */
  45683. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45684. /**
  45685. * Creates a PlaneDragGizmo
  45686. * @param gizmoLayer The utility layer the gizmo will be added to
  45687. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45688. * @param color The color of the gizmo
  45689. */
  45690. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45691. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45692. /**
  45693. * If the gizmo is enabled
  45694. */
  45695. isEnabled: boolean;
  45696. /**
  45697. * Disposes of the gizmo
  45698. */
  45699. dispose(): void;
  45700. }
  45701. }
  45702. declare module "babylonjs/Gizmos/positionGizmo" {
  45703. import { Observable } from "babylonjs/Misc/observable";
  45704. import { Nullable } from "babylonjs/types";
  45705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45706. import { Mesh } from "babylonjs/Meshes/mesh";
  45707. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45708. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45709. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45710. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45711. /**
  45712. * Gizmo that enables dragging a mesh along 3 axis
  45713. */
  45714. export class PositionGizmo extends Gizmo {
  45715. /**
  45716. * Internal gizmo used for interactions on the x axis
  45717. */
  45718. xGizmo: AxisDragGizmo;
  45719. /**
  45720. * Internal gizmo used for interactions on the y axis
  45721. */
  45722. yGizmo: AxisDragGizmo;
  45723. /**
  45724. * Internal gizmo used for interactions on the z axis
  45725. */
  45726. zGizmo: AxisDragGizmo;
  45727. /**
  45728. * Internal gizmo used for interactions on the yz plane
  45729. */
  45730. xPlaneGizmo: PlaneDragGizmo;
  45731. /**
  45732. * Internal gizmo used for interactions on the xz plane
  45733. */
  45734. yPlaneGizmo: PlaneDragGizmo;
  45735. /**
  45736. * Internal gizmo used for interactions on the xy plane
  45737. */
  45738. zPlaneGizmo: PlaneDragGizmo;
  45739. /**
  45740. * private variables
  45741. */
  45742. private _meshAttached;
  45743. private _updateGizmoRotationToMatchAttachedMesh;
  45744. private _snapDistance;
  45745. private _scaleRatio;
  45746. /** Fires an event when any of it's sub gizmos are dragged */
  45747. onDragStartObservable: Observable<unknown>;
  45748. /** Fires an event when any of it's sub gizmos are released from dragging */
  45749. onDragEndObservable: Observable<unknown>;
  45750. /**
  45751. * If set to true, planar drag is enabled
  45752. */
  45753. private _planarGizmoEnabled;
  45754. attachedMesh: Nullable<AbstractMesh>;
  45755. /**
  45756. * Creates a PositionGizmo
  45757. * @param gizmoLayer The utility layer the gizmo will be added to
  45758. */
  45759. constructor(gizmoLayer?: UtilityLayerRenderer);
  45760. /**
  45761. * If the planar drag gizmo is enabled
  45762. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45763. */
  45764. planarGizmoEnabled: boolean;
  45765. updateGizmoRotationToMatchAttachedMesh: boolean;
  45766. /**
  45767. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45768. */
  45769. snapDistance: number;
  45770. /**
  45771. * Ratio for the scale of the gizmo (Default: 1)
  45772. */
  45773. scaleRatio: number;
  45774. /**
  45775. * Disposes of the gizmo
  45776. */
  45777. dispose(): void;
  45778. /**
  45779. * CustomMeshes are not supported by this gizmo
  45780. * @param mesh The mesh to replace the default mesh of the gizmo
  45781. */
  45782. setCustomMesh(mesh: Mesh): void;
  45783. }
  45784. }
  45785. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45786. import { Observable } from "babylonjs/Misc/observable";
  45787. import { Nullable } from "babylonjs/types";
  45788. import { Vector3 } from "babylonjs/Maths/math.vector";
  45789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45791. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45792. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45793. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45794. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45795. import { Scene } from "babylonjs/scene";
  45796. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45797. import { Color3 } from "babylonjs/Maths/math.color";
  45798. /**
  45799. * Single axis drag gizmo
  45800. */
  45801. export class AxisDragGizmo extends Gizmo {
  45802. /**
  45803. * Drag behavior responsible for the gizmos dragging interactions
  45804. */
  45805. dragBehavior: PointerDragBehavior;
  45806. private _pointerObserver;
  45807. /**
  45808. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45809. */
  45810. snapDistance: number;
  45811. /**
  45812. * Event that fires each time the gizmo snaps to a new location.
  45813. * * snapDistance is the the change in distance
  45814. */
  45815. onSnapObservable: Observable<{
  45816. snapDistance: number;
  45817. }>;
  45818. private _isEnabled;
  45819. private _parent;
  45820. private _arrow;
  45821. private _coloredMaterial;
  45822. private _hoverMaterial;
  45823. /** @hidden */
  45824. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45825. /** @hidden */
  45826. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45827. /**
  45828. * Creates an AxisDragGizmo
  45829. * @param gizmoLayer The utility layer the gizmo will be added to
  45830. * @param dragAxis The axis which the gizmo will be able to drag on
  45831. * @param color The color of the gizmo
  45832. */
  45833. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45834. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45835. /**
  45836. * If the gizmo is enabled
  45837. */
  45838. isEnabled: boolean;
  45839. /**
  45840. * Disposes of the gizmo
  45841. */
  45842. dispose(): void;
  45843. }
  45844. }
  45845. declare module "babylonjs/Debug/axesViewer" {
  45846. import { Vector3 } from "babylonjs/Maths/math.vector";
  45847. import { Nullable } from "babylonjs/types";
  45848. import { Scene } from "babylonjs/scene";
  45849. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45850. /**
  45851. * The Axes viewer will show 3 axes in a specific point in space
  45852. */
  45853. export class AxesViewer {
  45854. private _xAxis;
  45855. private _yAxis;
  45856. private _zAxis;
  45857. private _scaleLinesFactor;
  45858. private _instanced;
  45859. /**
  45860. * Gets the hosting scene
  45861. */
  45862. scene: Scene;
  45863. /**
  45864. * Gets or sets a number used to scale line length
  45865. */
  45866. scaleLines: number;
  45867. /** Gets the node hierarchy used to render x-axis */
  45868. readonly xAxis: TransformNode;
  45869. /** Gets the node hierarchy used to render y-axis */
  45870. readonly yAxis: TransformNode;
  45871. /** Gets the node hierarchy used to render z-axis */
  45872. readonly zAxis: TransformNode;
  45873. /**
  45874. * Creates a new AxesViewer
  45875. * @param scene defines the hosting scene
  45876. * @param scaleLines defines a number used to scale line length (1 by default)
  45877. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45878. * @param xAxis defines the node hierarchy used to render the x-axis
  45879. * @param yAxis defines the node hierarchy used to render the y-axis
  45880. * @param zAxis defines the node hierarchy used to render the z-axis
  45881. */
  45882. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45883. /**
  45884. * Force the viewer to update
  45885. * @param position defines the position of the viewer
  45886. * @param xaxis defines the x axis of the viewer
  45887. * @param yaxis defines the y axis of the viewer
  45888. * @param zaxis defines the z axis of the viewer
  45889. */
  45890. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45891. /**
  45892. * Creates an instance of this axes viewer.
  45893. * @returns a new axes viewer with instanced meshes
  45894. */
  45895. createInstance(): AxesViewer;
  45896. /** Releases resources */
  45897. dispose(): void;
  45898. private static _SetRenderingGroupId;
  45899. }
  45900. }
  45901. declare module "babylonjs/Debug/boneAxesViewer" {
  45902. import { Nullable } from "babylonjs/types";
  45903. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45904. import { Vector3 } from "babylonjs/Maths/math.vector";
  45905. import { Mesh } from "babylonjs/Meshes/mesh";
  45906. import { Bone } from "babylonjs/Bones/bone";
  45907. import { Scene } from "babylonjs/scene";
  45908. /**
  45909. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45910. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45911. */
  45912. export class BoneAxesViewer extends AxesViewer {
  45913. /**
  45914. * Gets or sets the target mesh where to display the axes viewer
  45915. */
  45916. mesh: Nullable<Mesh>;
  45917. /**
  45918. * Gets or sets the target bone where to display the axes viewer
  45919. */
  45920. bone: Nullable<Bone>;
  45921. /** Gets current position */
  45922. pos: Vector3;
  45923. /** Gets direction of X axis */
  45924. xaxis: Vector3;
  45925. /** Gets direction of Y axis */
  45926. yaxis: Vector3;
  45927. /** Gets direction of Z axis */
  45928. zaxis: Vector3;
  45929. /**
  45930. * Creates a new BoneAxesViewer
  45931. * @param scene defines the hosting scene
  45932. * @param bone defines the target bone
  45933. * @param mesh defines the target mesh
  45934. * @param scaleLines defines a scaling factor for line length (1 by default)
  45935. */
  45936. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45937. /**
  45938. * Force the viewer to update
  45939. */
  45940. update(): void;
  45941. /** Releases resources */
  45942. dispose(): void;
  45943. }
  45944. }
  45945. declare module "babylonjs/Debug/debugLayer" {
  45946. import { Scene } from "babylonjs/scene";
  45947. /**
  45948. * Interface used to define scene explorer extensibility option
  45949. */
  45950. export interface IExplorerExtensibilityOption {
  45951. /**
  45952. * Define the option label
  45953. */
  45954. label: string;
  45955. /**
  45956. * Defines the action to execute on click
  45957. */
  45958. action: (entity: any) => void;
  45959. }
  45960. /**
  45961. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45962. */
  45963. export interface IExplorerExtensibilityGroup {
  45964. /**
  45965. * Defines a predicate to test if a given type mut be extended
  45966. */
  45967. predicate: (entity: any) => boolean;
  45968. /**
  45969. * Gets the list of options added to a type
  45970. */
  45971. entries: IExplorerExtensibilityOption[];
  45972. }
  45973. /**
  45974. * Interface used to define the options to use to create the Inspector
  45975. */
  45976. export interface IInspectorOptions {
  45977. /**
  45978. * Display in overlay mode (default: false)
  45979. */
  45980. overlay?: boolean;
  45981. /**
  45982. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45983. */
  45984. globalRoot?: HTMLElement;
  45985. /**
  45986. * Display the Scene explorer
  45987. */
  45988. showExplorer?: boolean;
  45989. /**
  45990. * Display the property inspector
  45991. */
  45992. showInspector?: boolean;
  45993. /**
  45994. * Display in embed mode (both panes on the right)
  45995. */
  45996. embedMode?: boolean;
  45997. /**
  45998. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45999. */
  46000. handleResize?: boolean;
  46001. /**
  46002. * Allow the panes to popup (default: true)
  46003. */
  46004. enablePopup?: boolean;
  46005. /**
  46006. * Allow the panes to be closed by users (default: true)
  46007. */
  46008. enableClose?: boolean;
  46009. /**
  46010. * Optional list of extensibility entries
  46011. */
  46012. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46013. /**
  46014. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46015. */
  46016. inspectorURL?: string;
  46017. /**
  46018. * Optional initial tab (default to DebugLayerTab.Properties)
  46019. */
  46020. initialTab?: DebugLayerTab;
  46021. }
  46022. module "babylonjs/scene" {
  46023. interface Scene {
  46024. /**
  46025. * @hidden
  46026. * Backing field
  46027. */
  46028. _debugLayer: DebugLayer;
  46029. /**
  46030. * Gets the debug layer (aka Inspector) associated with the scene
  46031. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46032. */
  46033. debugLayer: DebugLayer;
  46034. }
  46035. }
  46036. /**
  46037. * Enum of inspector action tab
  46038. */
  46039. export enum DebugLayerTab {
  46040. /**
  46041. * Properties tag (default)
  46042. */
  46043. Properties = 0,
  46044. /**
  46045. * Debug tab
  46046. */
  46047. Debug = 1,
  46048. /**
  46049. * Statistics tab
  46050. */
  46051. Statistics = 2,
  46052. /**
  46053. * Tools tab
  46054. */
  46055. Tools = 3,
  46056. /**
  46057. * Settings tab
  46058. */
  46059. Settings = 4
  46060. }
  46061. /**
  46062. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46063. * what is happening in your scene
  46064. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46065. */
  46066. export class DebugLayer {
  46067. /**
  46068. * Define the url to get the inspector script from.
  46069. * By default it uses the babylonjs CDN.
  46070. * @ignoreNaming
  46071. */
  46072. static InspectorURL: string;
  46073. private _scene;
  46074. private BJSINSPECTOR;
  46075. private _onPropertyChangedObservable?;
  46076. /**
  46077. * Observable triggered when a property is changed through the inspector.
  46078. */
  46079. readonly onPropertyChangedObservable: any;
  46080. /**
  46081. * Instantiates a new debug layer.
  46082. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46083. * what is happening in your scene
  46084. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46085. * @param scene Defines the scene to inspect
  46086. */
  46087. constructor(scene: Scene);
  46088. /** Creates the inspector window. */
  46089. private _createInspector;
  46090. /**
  46091. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46092. * @param entity defines the entity to select
  46093. * @param lineContainerTitle defines the specific block to highlight
  46094. */
  46095. select(entity: any, lineContainerTitle?: string): void;
  46096. /** Get the inspector from bundle or global */
  46097. private _getGlobalInspector;
  46098. /**
  46099. * Get if the inspector is visible or not.
  46100. * @returns true if visible otherwise, false
  46101. */
  46102. isVisible(): boolean;
  46103. /**
  46104. * Hide the inspector and close its window.
  46105. */
  46106. hide(): void;
  46107. /**
  46108. * Launch the debugLayer.
  46109. * @param config Define the configuration of the inspector
  46110. * @return a promise fulfilled when the debug layer is visible
  46111. */
  46112. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46113. }
  46114. }
  46115. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  46116. import { Nullable } from "babylonjs/types";
  46117. import { Scene } from "babylonjs/scene";
  46118. import { Vector4 } from "babylonjs/Maths/math.vector";
  46119. import { Color4 } from "babylonjs/Maths/math.color";
  46120. import { Mesh } from "babylonjs/Meshes/mesh";
  46121. /**
  46122. * Class containing static functions to help procedurally build meshes
  46123. */
  46124. export class BoxBuilder {
  46125. /**
  46126. * Creates a box mesh
  46127. * * The parameter `size` sets the size (float) of each box side (default 1)
  46128. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46129. * * 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)
  46130. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46134. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46135. * @param name defines the name of the mesh
  46136. * @param options defines the options used to create the mesh
  46137. * @param scene defines the hosting scene
  46138. * @returns the box mesh
  46139. */
  46140. static CreateBox(name: string, options: {
  46141. size?: number;
  46142. width?: number;
  46143. height?: number;
  46144. depth?: number;
  46145. faceUV?: Vector4[];
  46146. faceColors?: Color4[];
  46147. sideOrientation?: number;
  46148. frontUVs?: Vector4;
  46149. backUVs?: Vector4;
  46150. wrap?: boolean;
  46151. topBaseAt?: number;
  46152. bottomBaseAt?: number;
  46153. updatable?: boolean;
  46154. }, scene?: Nullable<Scene>): Mesh;
  46155. }
  46156. }
  46157. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  46158. import { Vector4 } from "babylonjs/Maths/math.vector";
  46159. import { Mesh } from "babylonjs/Meshes/mesh";
  46160. import { Scene } from "babylonjs/scene";
  46161. import { Nullable } from "babylonjs/types";
  46162. /**
  46163. * Class containing static functions to help procedurally build meshes
  46164. */
  46165. export class SphereBuilder {
  46166. /**
  46167. * Creates a sphere mesh
  46168. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46169. * * 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`)
  46170. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46171. * * 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
  46172. * * 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)
  46173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46176. * @param name defines the name of the mesh
  46177. * @param options defines the options used to create the mesh
  46178. * @param scene defines the hosting scene
  46179. * @returns the sphere mesh
  46180. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46181. */
  46182. static CreateSphere(name: string, options: {
  46183. segments?: number;
  46184. diameter?: number;
  46185. diameterX?: number;
  46186. diameterY?: number;
  46187. diameterZ?: number;
  46188. arc?: number;
  46189. slice?: number;
  46190. sideOrientation?: number;
  46191. frontUVs?: Vector4;
  46192. backUVs?: Vector4;
  46193. updatable?: boolean;
  46194. }, scene?: Nullable<Scene>): Mesh;
  46195. }
  46196. }
  46197. declare module "babylonjs/Debug/physicsViewer" {
  46198. import { Nullable } from "babylonjs/types";
  46199. import { Scene } from "babylonjs/scene";
  46200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46201. import { Mesh } from "babylonjs/Meshes/mesh";
  46202. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46203. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  46204. /**
  46205. * Used to show the physics impostor around the specific mesh
  46206. */
  46207. export class PhysicsViewer {
  46208. /** @hidden */
  46209. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46210. /** @hidden */
  46211. protected _meshes: Array<Nullable<AbstractMesh>>;
  46212. /** @hidden */
  46213. protected _scene: Nullable<Scene>;
  46214. /** @hidden */
  46215. protected _numMeshes: number;
  46216. /** @hidden */
  46217. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46218. private _renderFunction;
  46219. private _utilityLayer;
  46220. private _debugBoxMesh;
  46221. private _debugSphereMesh;
  46222. private _debugCylinderMesh;
  46223. private _debugMaterial;
  46224. private _debugMeshMeshes;
  46225. /**
  46226. * Creates a new PhysicsViewer
  46227. * @param scene defines the hosting scene
  46228. */
  46229. constructor(scene: Scene);
  46230. /** @hidden */
  46231. protected _updateDebugMeshes(): void;
  46232. /**
  46233. * Renders a specified physic impostor
  46234. * @param impostor defines the impostor to render
  46235. * @param targetMesh defines the mesh represented by the impostor
  46236. * @returns the new debug mesh used to render the impostor
  46237. */
  46238. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46239. /**
  46240. * Hides a specified physic impostor
  46241. * @param impostor defines the impostor to hide
  46242. */
  46243. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46244. private _getDebugMaterial;
  46245. private _getDebugBoxMesh;
  46246. private _getDebugSphereMesh;
  46247. private _getDebugCylinderMesh;
  46248. private _getDebugMeshMesh;
  46249. private _getDebugMesh;
  46250. /** Releases all resources */
  46251. dispose(): void;
  46252. }
  46253. }
  46254. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46255. import { Vector3 } from "babylonjs/Maths/math.vector";
  46256. import { Color4 } from "babylonjs/Maths/math.color";
  46257. import { Nullable } from "babylonjs/types";
  46258. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46259. import { Scene } from "babylonjs/scene";
  46260. /**
  46261. * Class containing static functions to help procedurally build meshes
  46262. */
  46263. export class LinesBuilder {
  46264. /**
  46265. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46266. * * 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
  46267. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46268. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46269. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46270. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46271. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46272. * * 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
  46273. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46276. * @param name defines the name of the new line system
  46277. * @param options defines the options used to create the line system
  46278. * @param scene defines the hosting scene
  46279. * @returns a new line system mesh
  46280. */
  46281. static CreateLineSystem(name: string, options: {
  46282. lines: Vector3[][];
  46283. updatable?: boolean;
  46284. instance?: Nullable<LinesMesh>;
  46285. colors?: Nullable<Color4[][]>;
  46286. useVertexAlpha?: boolean;
  46287. }, scene: Nullable<Scene>): LinesMesh;
  46288. /**
  46289. * Creates a line mesh
  46290. * 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
  46291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46292. * * The parameter `points` is an array successive Vector3
  46293. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  46294. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46295. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46296. * * When updating an instance, remember that only point positions can change, not the number of points
  46297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46299. * @param name defines the name of the new line system
  46300. * @param options defines the options used to create the line system
  46301. * @param scene defines the hosting scene
  46302. * @returns a new line mesh
  46303. */
  46304. static CreateLines(name: string, options: {
  46305. points: Vector3[];
  46306. updatable?: boolean;
  46307. instance?: Nullable<LinesMesh>;
  46308. colors?: Color4[];
  46309. useVertexAlpha?: boolean;
  46310. }, scene?: Nullable<Scene>): LinesMesh;
  46311. /**
  46312. * Creates a dashed line mesh
  46313. * * 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
  46314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46315. * * The parameter `points` is an array successive Vector3
  46316. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46317. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46318. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46319. * * 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
  46320. * * When updating an instance, remember that only point positions can change, not the number of points
  46321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46322. * @param name defines the name of the mesh
  46323. * @param options defines the options used to create the mesh
  46324. * @param scene defines the hosting scene
  46325. * @returns the dashed line mesh
  46326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46327. */
  46328. static CreateDashedLines(name: string, options: {
  46329. points: Vector3[];
  46330. dashSize?: number;
  46331. gapSize?: number;
  46332. dashNb?: number;
  46333. updatable?: boolean;
  46334. instance?: LinesMesh;
  46335. }, scene?: Nullable<Scene>): LinesMesh;
  46336. }
  46337. }
  46338. declare module "babylonjs/Debug/rayHelper" {
  46339. import { Nullable } from "babylonjs/types";
  46340. import { Ray } from "babylonjs/Culling/ray";
  46341. import { Vector3 } from "babylonjs/Maths/math.vector";
  46342. import { Color3 } from "babylonjs/Maths/math.color";
  46343. import { Scene } from "babylonjs/scene";
  46344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46345. import "babylonjs/Meshes/Builders/linesBuilder";
  46346. /**
  46347. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46348. * in order to better appreciate the issue one might have.
  46349. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46350. */
  46351. export class RayHelper {
  46352. /**
  46353. * Defines the ray we are currently tryin to visualize.
  46354. */
  46355. ray: Nullable<Ray>;
  46356. private _renderPoints;
  46357. private _renderLine;
  46358. private _renderFunction;
  46359. private _scene;
  46360. private _updateToMeshFunction;
  46361. private _attachedToMesh;
  46362. private _meshSpaceDirection;
  46363. private _meshSpaceOrigin;
  46364. /**
  46365. * Helper function to create a colored helper in a scene in one line.
  46366. * @param ray Defines the ray we are currently tryin to visualize
  46367. * @param scene Defines the scene the ray is used in
  46368. * @param color Defines the color we want to see the ray in
  46369. * @returns The newly created ray helper.
  46370. */
  46371. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46372. /**
  46373. * Instantiate a new ray helper.
  46374. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46375. * in order to better appreciate the issue one might have.
  46376. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46377. * @param ray Defines the ray we are currently tryin to visualize
  46378. */
  46379. constructor(ray: Ray);
  46380. /**
  46381. * Shows the ray we are willing to debug.
  46382. * @param scene Defines the scene the ray needs to be rendered in
  46383. * @param color Defines the color the ray needs to be rendered in
  46384. */
  46385. show(scene: Scene, color?: Color3): void;
  46386. /**
  46387. * Hides the ray we are debugging.
  46388. */
  46389. hide(): void;
  46390. private _render;
  46391. /**
  46392. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46393. * @param mesh Defines the mesh we want the helper attached to
  46394. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46395. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46396. * @param length Defines the length of the ray
  46397. */
  46398. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46399. /**
  46400. * Detach the ray helper from the mesh it has previously been attached to.
  46401. */
  46402. detachFromMesh(): void;
  46403. private _updateToMesh;
  46404. /**
  46405. * Dispose the helper and release its associated resources.
  46406. */
  46407. dispose(): void;
  46408. }
  46409. }
  46410. declare module "babylonjs/Debug/skeletonViewer" {
  46411. import { Color3 } from "babylonjs/Maths/math.color";
  46412. import { Scene } from "babylonjs/scene";
  46413. import { Nullable } from "babylonjs/types";
  46414. import { Skeleton } from "babylonjs/Bones/skeleton";
  46415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46416. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46417. /**
  46418. * Class used to render a debug view of a given skeleton
  46419. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46420. */
  46421. export class SkeletonViewer {
  46422. /** defines the skeleton to render */
  46423. skeleton: Skeleton;
  46424. /** defines the mesh attached to the skeleton */
  46425. mesh: AbstractMesh;
  46426. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46427. autoUpdateBonesMatrices: boolean;
  46428. /** defines the rendering group id to use with the viewer */
  46429. renderingGroupId: number;
  46430. /** Gets or sets the color used to render the skeleton */
  46431. color: Color3;
  46432. private _scene;
  46433. private _debugLines;
  46434. private _debugMesh;
  46435. private _isEnabled;
  46436. private _renderFunction;
  46437. private _utilityLayer;
  46438. /**
  46439. * Returns the mesh used to render the bones
  46440. */
  46441. readonly debugMesh: Nullable<LinesMesh>;
  46442. /**
  46443. * Creates a new SkeletonViewer
  46444. * @param skeleton defines the skeleton to render
  46445. * @param mesh defines the mesh attached to the skeleton
  46446. * @param scene defines the hosting scene
  46447. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46448. * @param renderingGroupId defines the rendering group id to use with the viewer
  46449. */
  46450. constructor(
  46451. /** defines the skeleton to render */
  46452. skeleton: Skeleton,
  46453. /** defines the mesh attached to the skeleton */
  46454. mesh: AbstractMesh, scene: Scene,
  46455. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46456. autoUpdateBonesMatrices?: boolean,
  46457. /** defines the rendering group id to use with the viewer */
  46458. renderingGroupId?: number);
  46459. /** Gets or sets a boolean indicating if the viewer is enabled */
  46460. isEnabled: boolean;
  46461. private _getBonePosition;
  46462. private _getLinesForBonesWithLength;
  46463. private _getLinesForBonesNoLength;
  46464. /** Update the viewer to sync with current skeleton state */
  46465. update(): void;
  46466. /** Release associated resources */
  46467. dispose(): void;
  46468. }
  46469. }
  46470. declare module "babylonjs/Debug/index" {
  46471. export * from "babylonjs/Debug/axesViewer";
  46472. export * from "babylonjs/Debug/boneAxesViewer";
  46473. export * from "babylonjs/Debug/debugLayer";
  46474. export * from "babylonjs/Debug/physicsViewer";
  46475. export * from "babylonjs/Debug/rayHelper";
  46476. export * from "babylonjs/Debug/skeletonViewer";
  46477. }
  46478. declare module "babylonjs/Engines/nullEngine" {
  46479. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46480. import { Scene } from "babylonjs/scene";
  46481. import { Engine } from "babylonjs/Engines/engine";
  46482. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46483. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46485. import { Effect } from "babylonjs/Materials/effect";
  46486. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46487. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46488. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46489. /**
  46490. * Options to create the null engine
  46491. */
  46492. export class NullEngineOptions {
  46493. /**
  46494. * Render width (Default: 512)
  46495. */
  46496. renderWidth: number;
  46497. /**
  46498. * Render height (Default: 256)
  46499. */
  46500. renderHeight: number;
  46501. /**
  46502. * Texture size (Default: 512)
  46503. */
  46504. textureSize: number;
  46505. /**
  46506. * If delta time between frames should be constant
  46507. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46508. */
  46509. deterministicLockstep: boolean;
  46510. /**
  46511. * Maximum about of steps between frames (Default: 4)
  46512. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46513. */
  46514. lockstepMaxSteps: number;
  46515. }
  46516. /**
  46517. * The null engine class provides support for headless version of babylon.js.
  46518. * This can be used in server side scenario or for testing purposes
  46519. */
  46520. export class NullEngine extends Engine {
  46521. private _options;
  46522. /**
  46523. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46524. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46525. * @returns true if engine is in deterministic lock step mode
  46526. */
  46527. isDeterministicLockStep(): boolean;
  46528. /**
  46529. * Gets the max steps when engine is running in deterministic lock step
  46530. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46531. * @returns the max steps
  46532. */
  46533. getLockstepMaxSteps(): number;
  46534. /**
  46535. * Gets the current hardware scaling level.
  46536. * By default the hardware scaling level is computed from the window device ratio.
  46537. * 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.
  46538. * @returns a number indicating the current hardware scaling level
  46539. */
  46540. getHardwareScalingLevel(): number;
  46541. constructor(options?: NullEngineOptions);
  46542. /**
  46543. * Creates a vertex buffer
  46544. * @param vertices the data for the vertex buffer
  46545. * @returns the new WebGL static buffer
  46546. */
  46547. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46548. /**
  46549. * Creates a new index buffer
  46550. * @param indices defines the content of the index buffer
  46551. * @param updatable defines if the index buffer must be updatable
  46552. * @returns a new webGL buffer
  46553. */
  46554. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46555. /**
  46556. * Clear the current render buffer or the current render target (if any is set up)
  46557. * @param color defines the color to use
  46558. * @param backBuffer defines if the back buffer must be cleared
  46559. * @param depth defines if the depth buffer must be cleared
  46560. * @param stencil defines if the stencil buffer must be cleared
  46561. */
  46562. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46563. /**
  46564. * Gets the current render width
  46565. * @param useScreen defines if screen size must be used (or the current render target if any)
  46566. * @returns a number defining the current render width
  46567. */
  46568. getRenderWidth(useScreen?: boolean): number;
  46569. /**
  46570. * Gets the current render height
  46571. * @param useScreen defines if screen size must be used (or the current render target if any)
  46572. * @returns a number defining the current render height
  46573. */
  46574. getRenderHeight(useScreen?: boolean): number;
  46575. /**
  46576. * Set the WebGL's viewport
  46577. * @param viewport defines the viewport element to be used
  46578. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46579. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46580. */
  46581. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46582. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46583. /**
  46584. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46585. * @param pipelineContext defines the pipeline context to use
  46586. * @param uniformsNames defines the list of uniform names
  46587. * @returns an array of webGL uniform locations
  46588. */
  46589. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46590. /**
  46591. * Gets the lsit of active attributes for a given webGL program
  46592. * @param pipelineContext defines the pipeline context to use
  46593. * @param attributesNames defines the list of attribute names to get
  46594. * @returns an array of indices indicating the offset of each attribute
  46595. */
  46596. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46597. /**
  46598. * Binds an effect to the webGL context
  46599. * @param effect defines the effect to bind
  46600. */
  46601. bindSamplers(effect: Effect): void;
  46602. /**
  46603. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46604. * @param effect defines the effect to activate
  46605. */
  46606. enableEffect(effect: Effect): void;
  46607. /**
  46608. * Set various states to the webGL context
  46609. * @param culling defines backface culling state
  46610. * @param zOffset defines the value to apply to zOffset (0 by default)
  46611. * @param force defines if states must be applied even if cache is up to date
  46612. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46613. */
  46614. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46615. /**
  46616. * Set the value of an uniform to an array of int32
  46617. * @param uniform defines the webGL uniform location where to store the value
  46618. * @param array defines the array of int32 to store
  46619. */
  46620. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46621. /**
  46622. * Set the value of an uniform to an array of int32 (stored as vec2)
  46623. * @param uniform defines the webGL uniform location where to store the value
  46624. * @param array defines the array of int32 to store
  46625. */
  46626. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46627. /**
  46628. * Set the value of an uniform to an array of int32 (stored as vec3)
  46629. * @param uniform defines the webGL uniform location where to store the value
  46630. * @param array defines the array of int32 to store
  46631. */
  46632. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46633. /**
  46634. * Set the value of an uniform to an array of int32 (stored as vec4)
  46635. * @param uniform defines the webGL uniform location where to store the value
  46636. * @param array defines the array of int32 to store
  46637. */
  46638. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46639. /**
  46640. * Set the value of an uniform to an array of float32
  46641. * @param uniform defines the webGL uniform location where to store the value
  46642. * @param array defines the array of float32 to store
  46643. */
  46644. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46645. /**
  46646. * Set the value of an uniform to an array of float32 (stored as vec2)
  46647. * @param uniform defines the webGL uniform location where to store the value
  46648. * @param array defines the array of float32 to store
  46649. */
  46650. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46651. /**
  46652. * Set the value of an uniform to an array of float32 (stored as vec3)
  46653. * @param uniform defines the webGL uniform location where to store the value
  46654. * @param array defines the array of float32 to store
  46655. */
  46656. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46657. /**
  46658. * Set the value of an uniform to an array of float32 (stored as vec4)
  46659. * @param uniform defines the webGL uniform location where to store the value
  46660. * @param array defines the array of float32 to store
  46661. */
  46662. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46663. /**
  46664. * Set the value of an uniform to an array of number
  46665. * @param uniform defines the webGL uniform location where to store the value
  46666. * @param array defines the array of number to store
  46667. */
  46668. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46669. /**
  46670. * Set the value of an uniform to an array of number (stored as vec2)
  46671. * @param uniform defines the webGL uniform location where to store the value
  46672. * @param array defines the array of number to store
  46673. */
  46674. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46675. /**
  46676. * Set the value of an uniform to an array of number (stored as vec3)
  46677. * @param uniform defines the webGL uniform location where to store the value
  46678. * @param array defines the array of number to store
  46679. */
  46680. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46681. /**
  46682. * Set the value of an uniform to an array of number (stored as vec4)
  46683. * @param uniform defines the webGL uniform location where to store the value
  46684. * @param array defines the array of number to store
  46685. */
  46686. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46687. /**
  46688. * Set the value of an uniform to an array of float32 (stored as matrices)
  46689. * @param uniform defines the webGL uniform location where to store the value
  46690. * @param matrices defines the array of float32 to store
  46691. */
  46692. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46693. /**
  46694. * Set the value of an uniform to a matrix (3x3)
  46695. * @param uniform defines the webGL uniform location where to store the value
  46696. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46697. */
  46698. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46699. /**
  46700. * Set the value of an uniform to a matrix (2x2)
  46701. * @param uniform defines the webGL uniform location where to store the value
  46702. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46703. */
  46704. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46705. /**
  46706. * Set the value of an uniform to a number (float)
  46707. * @param uniform defines the webGL uniform location where to store the value
  46708. * @param value defines the float number to store
  46709. */
  46710. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46711. /**
  46712. * Set the value of an uniform to a vec2
  46713. * @param uniform defines the webGL uniform location where to store the value
  46714. * @param x defines the 1st component of the value
  46715. * @param y defines the 2nd component of the value
  46716. */
  46717. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46718. /**
  46719. * Set the value of an uniform to a vec3
  46720. * @param uniform defines the webGL uniform location where to store the value
  46721. * @param x defines the 1st component of the value
  46722. * @param y defines the 2nd component of the value
  46723. * @param z defines the 3rd component of the value
  46724. */
  46725. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46726. /**
  46727. * Set the value of an uniform to a boolean
  46728. * @param uniform defines the webGL uniform location where to store the value
  46729. * @param bool defines the boolean to store
  46730. */
  46731. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46732. /**
  46733. * Set the value of an uniform to a vec4
  46734. * @param uniform defines the webGL uniform location where to store the value
  46735. * @param x defines the 1st component of the value
  46736. * @param y defines the 2nd component of the value
  46737. * @param z defines the 3rd component of the value
  46738. * @param w defines the 4th component of the value
  46739. */
  46740. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46741. /**
  46742. * Sets the current alpha mode
  46743. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46744. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46745. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46746. */
  46747. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46748. /**
  46749. * Bind webGl buffers directly to the webGL context
  46750. * @param vertexBuffers defines the vertex buffer to bind
  46751. * @param indexBuffer defines the index buffer to bind
  46752. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46753. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46754. * @param effect defines the effect associated with the vertex buffer
  46755. */
  46756. bindBuffers(vertexBuffers: {
  46757. [key: string]: VertexBuffer;
  46758. }, indexBuffer: DataBuffer, effect: Effect): void;
  46759. /**
  46760. * Force the entire cache to be cleared
  46761. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46762. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46763. */
  46764. wipeCaches(bruteForce?: boolean): void;
  46765. /**
  46766. * Send a draw order
  46767. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46768. * @param indexStart defines the starting index
  46769. * @param indexCount defines the number of index to draw
  46770. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46771. */
  46772. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46773. /**
  46774. * Draw a list of indexed primitives
  46775. * @param fillMode defines the primitive to use
  46776. * @param indexStart defines the starting index
  46777. * @param indexCount defines the number of index to draw
  46778. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46779. */
  46780. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46781. /**
  46782. * Draw a list of unindexed primitives
  46783. * @param fillMode defines the primitive to use
  46784. * @param verticesStart defines the index of first vertex to draw
  46785. * @param verticesCount defines the count of vertices to draw
  46786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46787. */
  46788. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46789. /** @hidden */
  46790. _createTexture(): WebGLTexture;
  46791. /** @hidden */
  46792. _releaseTexture(texture: InternalTexture): void;
  46793. /**
  46794. * Usually called from Texture.ts.
  46795. * Passed information to create a WebGLTexture
  46796. * @param urlArg defines a value which contains one of the following:
  46797. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46798. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46799. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46801. * @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)
  46802. * @param scene needed for loading to the correct scene
  46803. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46804. * @param onLoad optional callback to be called upon successful completion
  46805. * @param onError optional callback to be called upon failure
  46806. * @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
  46807. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46808. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46809. * @param forcedExtension defines the extension to use to pick the right loader
  46810. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46811. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46812. */
  46813. 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;
  46814. /**
  46815. * Creates a new render target texture
  46816. * @param size defines the size of the texture
  46817. * @param options defines the options used to create the texture
  46818. * @returns a new render target texture stored in an InternalTexture
  46819. */
  46820. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46821. /**
  46822. * Update the sampling mode of a given texture
  46823. * @param samplingMode defines the required sampling mode
  46824. * @param texture defines the texture to update
  46825. */
  46826. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46827. /**
  46828. * Binds the frame buffer to the specified texture.
  46829. * @param texture The texture to render to or null for the default canvas
  46830. * @param faceIndex The face of the texture to render to in case of cube texture
  46831. * @param requiredWidth The width of the target to render to
  46832. * @param requiredHeight The height of the target to render to
  46833. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46834. * @param depthStencilTexture The depth stencil texture to use to render
  46835. * @param lodLevel defines le lod level to bind to the frame buffer
  46836. */
  46837. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46838. /**
  46839. * Unbind the current render target texture from the webGL context
  46840. * @param texture defines the render target texture to unbind
  46841. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46842. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46843. */
  46844. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46845. /**
  46846. * Creates a dynamic vertex buffer
  46847. * @param vertices the data for the dynamic vertex buffer
  46848. * @returns the new WebGL dynamic buffer
  46849. */
  46850. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46851. /**
  46852. * Update the content of a dynamic texture
  46853. * @param texture defines the texture to update
  46854. * @param canvas defines the canvas containing the source
  46855. * @param invertY defines if data must be stored with Y axis inverted
  46856. * @param premulAlpha defines if alpha is stored as premultiplied
  46857. * @param format defines the format of the data
  46858. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46859. */
  46860. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46861. /**
  46862. * Gets a boolean indicating if all created effects are ready
  46863. * @returns true if all effects are ready
  46864. */
  46865. areAllEffectsReady(): boolean;
  46866. /**
  46867. * @hidden
  46868. * Get the current error code of the webGL context
  46869. * @returns the error code
  46870. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46871. */
  46872. getError(): number;
  46873. /** @hidden */
  46874. _getUnpackAlignement(): number;
  46875. /** @hidden */
  46876. _unpackFlipY(value: boolean): void;
  46877. /**
  46878. * Update a dynamic index buffer
  46879. * @param indexBuffer defines the target index buffer
  46880. * @param indices defines the data to update
  46881. * @param offset defines the offset in the target index buffer where update should start
  46882. */
  46883. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46884. /**
  46885. * Updates a dynamic vertex buffer.
  46886. * @param vertexBuffer the vertex buffer to update
  46887. * @param vertices the data used to update the vertex buffer
  46888. * @param byteOffset the byte offset of the data (optional)
  46889. * @param byteLength the byte length of the data (optional)
  46890. */
  46891. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46892. /** @hidden */
  46893. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46894. /** @hidden */
  46895. _bindTexture(channel: number, texture: InternalTexture): void;
  46896. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46897. /**
  46898. * 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
  46899. */
  46900. releaseEffects(): void;
  46901. displayLoadingUI(): void;
  46902. hideLoadingUI(): void;
  46903. /** @hidden */
  46904. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46905. /** @hidden */
  46906. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46907. /** @hidden */
  46908. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46909. /** @hidden */
  46910. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46911. }
  46912. }
  46913. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46914. import { Nullable, int } from "babylonjs/types";
  46915. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46916. /** @hidden */
  46917. export class _OcclusionDataStorage {
  46918. /** @hidden */
  46919. occlusionInternalRetryCounter: number;
  46920. /** @hidden */
  46921. isOcclusionQueryInProgress: boolean;
  46922. /** @hidden */
  46923. isOccluded: boolean;
  46924. /** @hidden */
  46925. occlusionRetryCount: number;
  46926. /** @hidden */
  46927. occlusionType: number;
  46928. /** @hidden */
  46929. occlusionQueryAlgorithmType: number;
  46930. }
  46931. module "babylonjs/Engines/engine" {
  46932. interface Engine {
  46933. /**
  46934. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46935. * @return the new query
  46936. */
  46937. createQuery(): WebGLQuery;
  46938. /**
  46939. * Delete and release a webGL query
  46940. * @param query defines the query to delete
  46941. * @return the current engine
  46942. */
  46943. deleteQuery(query: WebGLQuery): Engine;
  46944. /**
  46945. * Check if a given query has resolved and got its value
  46946. * @param query defines the query to check
  46947. * @returns true if the query got its value
  46948. */
  46949. isQueryResultAvailable(query: WebGLQuery): boolean;
  46950. /**
  46951. * Gets the value of a given query
  46952. * @param query defines the query to check
  46953. * @returns the value of the query
  46954. */
  46955. getQueryResult(query: WebGLQuery): number;
  46956. /**
  46957. * Initiates an occlusion query
  46958. * @param algorithmType defines the algorithm to use
  46959. * @param query defines the query to use
  46960. * @returns the current engine
  46961. * @see http://doc.babylonjs.com/features/occlusionquery
  46962. */
  46963. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46964. /**
  46965. * Ends an occlusion query
  46966. * @see http://doc.babylonjs.com/features/occlusionquery
  46967. * @param algorithmType defines the algorithm to use
  46968. * @returns the current engine
  46969. */
  46970. endOcclusionQuery(algorithmType: number): Engine;
  46971. /**
  46972. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46973. * Please note that only one query can be issued at a time
  46974. * @returns a time token used to track the time span
  46975. */
  46976. startTimeQuery(): Nullable<_TimeToken>;
  46977. /**
  46978. * Ends a time query
  46979. * @param token defines the token used to measure the time span
  46980. * @returns the time spent (in ns)
  46981. */
  46982. endTimeQuery(token: _TimeToken): int;
  46983. /** @hidden */
  46984. _currentNonTimestampToken: Nullable<_TimeToken>;
  46985. /** @hidden */
  46986. _createTimeQuery(): WebGLQuery;
  46987. /** @hidden */
  46988. _deleteTimeQuery(query: WebGLQuery): void;
  46989. /** @hidden */
  46990. _getGlAlgorithmType(algorithmType: number): number;
  46991. /** @hidden */
  46992. _getTimeQueryResult(query: WebGLQuery): any;
  46993. /** @hidden */
  46994. _getTimeQueryAvailability(query: WebGLQuery): any;
  46995. }
  46996. }
  46997. module "babylonjs/Meshes/abstractMesh" {
  46998. interface AbstractMesh {
  46999. /**
  47000. * Backing filed
  47001. * @hidden
  47002. */
  47003. __occlusionDataStorage: _OcclusionDataStorage;
  47004. /**
  47005. * Access property
  47006. * @hidden
  47007. */
  47008. _occlusionDataStorage: _OcclusionDataStorage;
  47009. /**
  47010. * 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.
  47011. * The default value is -1 which means don't break the query and wait till the result
  47012. * @see http://doc.babylonjs.com/features/occlusionquery
  47013. */
  47014. occlusionRetryCount: number;
  47015. /**
  47016. * 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:
  47017. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47018. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47019. * * 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.
  47020. * @see http://doc.babylonjs.com/features/occlusionquery
  47021. */
  47022. occlusionType: number;
  47023. /**
  47024. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47025. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47026. * * 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.
  47027. * @see http://doc.babylonjs.com/features/occlusionquery
  47028. */
  47029. occlusionQueryAlgorithmType: number;
  47030. /**
  47031. * 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
  47032. * @see http://doc.babylonjs.com/features/occlusionquery
  47033. */
  47034. isOccluded: boolean;
  47035. /**
  47036. * Flag to check the progress status of the query
  47037. * @see http://doc.babylonjs.com/features/occlusionquery
  47038. */
  47039. isOcclusionQueryInProgress: boolean;
  47040. }
  47041. }
  47042. }
  47043. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  47044. import { Nullable } from "babylonjs/types";
  47045. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47046. /** @hidden */
  47047. export var _forceTransformFeedbackToBundle: boolean;
  47048. module "babylonjs/Engines/engine" {
  47049. interface Engine {
  47050. /**
  47051. * Creates a webGL transform feedback object
  47052. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47053. * @returns the webGL transform feedback object
  47054. */
  47055. createTransformFeedback(): WebGLTransformFeedback;
  47056. /**
  47057. * Delete a webGL transform feedback object
  47058. * @param value defines the webGL transform feedback object to delete
  47059. */
  47060. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47061. /**
  47062. * Bind a webGL transform feedback object to the webgl context
  47063. * @param value defines the webGL transform feedback object to bind
  47064. */
  47065. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47066. /**
  47067. * Begins a transform feedback operation
  47068. * @param usePoints defines if points or triangles must be used
  47069. */
  47070. beginTransformFeedback(usePoints: boolean): void;
  47071. /**
  47072. * Ends a transform feedback operation
  47073. */
  47074. endTransformFeedback(): void;
  47075. /**
  47076. * Specify the varyings to use with transform feedback
  47077. * @param program defines the associated webGL program
  47078. * @param value defines the list of strings representing the varying names
  47079. */
  47080. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47081. /**
  47082. * Bind a webGL buffer for a transform feedback operation
  47083. * @param value defines the webGL buffer to bind
  47084. */
  47085. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47086. }
  47087. }
  47088. }
  47089. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  47090. import { Scene } from "babylonjs/scene";
  47091. import { Engine } from "babylonjs/Engines/engine";
  47092. import { Texture } from "babylonjs/Materials/Textures/texture";
  47093. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47094. import "babylonjs/Engines/Extensions/engine.multiRender";
  47095. /**
  47096. * Creation options of the multi render target texture.
  47097. */
  47098. export interface IMultiRenderTargetOptions {
  47099. /**
  47100. * Define if the texture needs to create mip maps after render.
  47101. */
  47102. generateMipMaps?: boolean;
  47103. /**
  47104. * Define the types of all the draw buffers we want to create
  47105. */
  47106. types?: number[];
  47107. /**
  47108. * Define the sampling modes of all the draw buffers we want to create
  47109. */
  47110. samplingModes?: number[];
  47111. /**
  47112. * Define if a depth buffer is required
  47113. */
  47114. generateDepthBuffer?: boolean;
  47115. /**
  47116. * Define if a stencil buffer is required
  47117. */
  47118. generateStencilBuffer?: boolean;
  47119. /**
  47120. * Define if a depth texture is required instead of a depth buffer
  47121. */
  47122. generateDepthTexture?: boolean;
  47123. /**
  47124. * Define the number of desired draw buffers
  47125. */
  47126. textureCount?: number;
  47127. /**
  47128. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47129. */
  47130. doNotChangeAspectRatio?: boolean;
  47131. /**
  47132. * Define the default type of the buffers we are creating
  47133. */
  47134. defaultType?: number;
  47135. }
  47136. /**
  47137. * A multi render target, like a render target provides the ability to render to a texture.
  47138. * Unlike the render target, it can render to several draw buffers in one draw.
  47139. * This is specially interesting in deferred rendering or for any effects requiring more than
  47140. * just one color from a single pass.
  47141. */
  47142. export class MultiRenderTarget extends RenderTargetTexture {
  47143. private _internalTextures;
  47144. private _textures;
  47145. private _multiRenderTargetOptions;
  47146. /**
  47147. * Get if draw buffers are currently supported by the used hardware and browser.
  47148. */
  47149. readonly isSupported: boolean;
  47150. /**
  47151. * Get the list of textures generated by the multi render target.
  47152. */
  47153. readonly textures: Texture[];
  47154. /**
  47155. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47156. */
  47157. readonly depthTexture: Texture;
  47158. /**
  47159. * Set the wrapping mode on U of all the textures we are rendering to.
  47160. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47161. */
  47162. wrapU: number;
  47163. /**
  47164. * Set the wrapping mode on V of all the textures we are rendering to.
  47165. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47166. */
  47167. wrapV: number;
  47168. /**
  47169. * Instantiate a new multi render target texture.
  47170. * A multi render target, like a render target provides the ability to render to a texture.
  47171. * Unlike the render target, it can render to several draw buffers in one draw.
  47172. * This is specially interesting in deferred rendering or for any effects requiring more than
  47173. * just one color from a single pass.
  47174. * @param name Define the name of the texture
  47175. * @param size Define the size of the buffers to render to
  47176. * @param count Define the number of target we are rendering into
  47177. * @param scene Define the scene the texture belongs to
  47178. * @param options Define the options used to create the multi render target
  47179. */
  47180. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47181. /** @hidden */
  47182. _rebuild(): void;
  47183. private _createInternalTextures;
  47184. private _createTextures;
  47185. /**
  47186. * Define the number of samples used if MSAA is enabled.
  47187. */
  47188. samples: number;
  47189. /**
  47190. * Resize all the textures in the multi render target.
  47191. * Be carrefull as it will recreate all the data in the new texture.
  47192. * @param size Define the new size
  47193. */
  47194. resize(size: any): void;
  47195. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47196. /**
  47197. * Dispose the render targets and their associated resources
  47198. */
  47199. dispose(): void;
  47200. /**
  47201. * Release all the underlying texture used as draw buffers.
  47202. */
  47203. releaseInternalTextures(): void;
  47204. }
  47205. }
  47206. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  47207. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47208. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  47209. import { Nullable } from "babylonjs/types";
  47210. module "babylonjs/Engines/thinEngine" {
  47211. interface ThinEngine {
  47212. /**
  47213. * Unbind a list of render target textures from the webGL context
  47214. * This is used only when drawBuffer extension or webGL2 are active
  47215. * @param textures defines the render target textures to unbind
  47216. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47217. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47218. */
  47219. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47220. /**
  47221. * Create a multi render target texture
  47222. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47223. * @param size defines the size of the texture
  47224. * @param options defines the creation options
  47225. * @returns the cube texture as an InternalTexture
  47226. */
  47227. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47228. /**
  47229. * Update the sample count for a given multiple render target texture
  47230. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47231. * @param textures defines the textures to update
  47232. * @param samples defines the sample count to set
  47233. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47234. */
  47235. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47236. }
  47237. }
  47238. }
  47239. declare module "babylonjs/Engines/Extensions/engine.views" {
  47240. import { Camera } from "babylonjs/Cameras/camera";
  47241. import { Nullable } from "babylonjs/types";
  47242. /**
  47243. * Class used to define an additional view for the engine
  47244. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47245. */
  47246. export class EngineView {
  47247. /** Defines the canvas where to render the view */
  47248. target: HTMLCanvasElement;
  47249. /** Defines an optional camera used to render the view (will use active camera else) */
  47250. camera?: Camera;
  47251. }
  47252. module "babylonjs/Engines/engine" {
  47253. interface Engine {
  47254. /**
  47255. * Gets or sets the HTML element to use for attaching events
  47256. */
  47257. inputElement: Nullable<HTMLElement>;
  47258. /**
  47259. * Gets the current engine view
  47260. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47261. */
  47262. activeView: Nullable<EngineView>;
  47263. /** Gets or sets the list of views */
  47264. views: EngineView[];
  47265. /**
  47266. * Register a new child canvas
  47267. * @param canvas defines the canvas to register
  47268. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47269. * @returns the associated view
  47270. */
  47271. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47272. /**
  47273. * Remove a registered child canvas
  47274. * @param canvas defines the canvas to remove
  47275. * @returns the current engine
  47276. */
  47277. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47278. }
  47279. }
  47280. }
  47281. declare module "babylonjs/Engines/Extensions/index" {
  47282. export * from "babylonjs/Engines/Extensions/engine.alpha";
  47283. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  47284. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  47285. export * from "babylonjs/Engines/Extensions/engine.multiview";
  47286. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  47287. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47288. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  47289. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  47290. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  47291. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  47292. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47293. export * from "babylonjs/Engines/Extensions/engine.webVR";
  47294. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  47295. export * from "babylonjs/Engines/Extensions/engine.views";
  47296. }
  47297. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  47298. import { Nullable } from "babylonjs/types";
  47299. /**
  47300. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47301. */
  47302. export interface CubeMapInfo {
  47303. /**
  47304. * The pixel array for the front face.
  47305. * This is stored in format, left to right, up to down format.
  47306. */
  47307. front: Nullable<ArrayBufferView>;
  47308. /**
  47309. * The pixel array for the back face.
  47310. * This is stored in format, left to right, up to down format.
  47311. */
  47312. back: Nullable<ArrayBufferView>;
  47313. /**
  47314. * The pixel array for the left face.
  47315. * This is stored in format, left to right, up to down format.
  47316. */
  47317. left: Nullable<ArrayBufferView>;
  47318. /**
  47319. * The pixel array for the right face.
  47320. * This is stored in format, left to right, up to down format.
  47321. */
  47322. right: Nullable<ArrayBufferView>;
  47323. /**
  47324. * The pixel array for the up face.
  47325. * This is stored in format, left to right, up to down format.
  47326. */
  47327. up: Nullable<ArrayBufferView>;
  47328. /**
  47329. * The pixel array for the down face.
  47330. * This is stored in format, left to right, up to down format.
  47331. */
  47332. down: Nullable<ArrayBufferView>;
  47333. /**
  47334. * The size of the cubemap stored.
  47335. *
  47336. * Each faces will be size * size pixels.
  47337. */
  47338. size: number;
  47339. /**
  47340. * The format of the texture.
  47341. *
  47342. * RGBA, RGB.
  47343. */
  47344. format: number;
  47345. /**
  47346. * The type of the texture data.
  47347. *
  47348. * UNSIGNED_INT, FLOAT.
  47349. */
  47350. type: number;
  47351. /**
  47352. * Specifies whether the texture is in gamma space.
  47353. */
  47354. gammaSpace: boolean;
  47355. }
  47356. /**
  47357. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47358. */
  47359. export class PanoramaToCubeMapTools {
  47360. private static FACE_FRONT;
  47361. private static FACE_BACK;
  47362. private static FACE_RIGHT;
  47363. private static FACE_LEFT;
  47364. private static FACE_DOWN;
  47365. private static FACE_UP;
  47366. /**
  47367. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47368. *
  47369. * @param float32Array The source data.
  47370. * @param inputWidth The width of the input panorama.
  47371. * @param inputHeight The height of the input panorama.
  47372. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47373. * @return The cubemap data
  47374. */
  47375. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47376. private static CreateCubemapTexture;
  47377. private static CalcProjectionSpherical;
  47378. }
  47379. }
  47380. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  47381. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47383. import { Nullable } from "babylonjs/types";
  47384. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  47385. /**
  47386. * Helper class dealing with the extraction of spherical polynomial dataArray
  47387. * from a cube map.
  47388. */
  47389. export class CubeMapToSphericalPolynomialTools {
  47390. private static FileFaces;
  47391. /**
  47392. * Converts a texture to the according Spherical Polynomial data.
  47393. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47394. *
  47395. * @param texture The texture to extract the information from.
  47396. * @return The Spherical Polynomial data.
  47397. */
  47398. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47399. /**
  47400. * Converts a cubemap to the according Spherical Polynomial data.
  47401. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47402. *
  47403. * @param cubeInfo The Cube map to extract the information from.
  47404. * @return The Spherical Polynomial data.
  47405. */
  47406. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47407. }
  47408. }
  47409. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  47410. import { Nullable } from "babylonjs/types";
  47411. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47412. module "babylonjs/Materials/Textures/baseTexture" {
  47413. interface BaseTexture {
  47414. /**
  47415. * Get the polynomial representation of the texture data.
  47416. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47417. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47418. */
  47419. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47420. }
  47421. }
  47422. }
  47423. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47424. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47425. /** @hidden */
  47426. export var rgbdEncodePixelShader: {
  47427. name: string;
  47428. shader: string;
  47429. };
  47430. }
  47431. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47432. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47433. /** @hidden */
  47434. export var rgbdDecodePixelShader: {
  47435. name: string;
  47436. shader: string;
  47437. };
  47438. }
  47439. declare module "babylonjs/Misc/environmentTextureTools" {
  47440. import { Nullable } from "babylonjs/types";
  47441. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47442. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47443. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47444. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  47445. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  47446. import "babylonjs/Shaders/rgbdEncode.fragment";
  47447. import "babylonjs/Shaders/rgbdDecode.fragment";
  47448. /**
  47449. * Raw texture data and descriptor sufficient for WebGL texture upload
  47450. */
  47451. export interface EnvironmentTextureInfo {
  47452. /**
  47453. * Version of the environment map
  47454. */
  47455. version: number;
  47456. /**
  47457. * Width of image
  47458. */
  47459. width: number;
  47460. /**
  47461. * Irradiance information stored in the file.
  47462. */
  47463. irradiance: any;
  47464. /**
  47465. * Specular information stored in the file.
  47466. */
  47467. specular: any;
  47468. }
  47469. /**
  47470. * Defines One Image in the file. It requires only the position in the file
  47471. * as well as the length.
  47472. */
  47473. interface BufferImageData {
  47474. /**
  47475. * Length of the image data.
  47476. */
  47477. length: number;
  47478. /**
  47479. * Position of the data from the null terminator delimiting the end of the JSON.
  47480. */
  47481. position: number;
  47482. }
  47483. /**
  47484. * Defines the specular data enclosed in the file.
  47485. * This corresponds to the version 1 of the data.
  47486. */
  47487. export interface EnvironmentTextureSpecularInfoV1 {
  47488. /**
  47489. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47490. */
  47491. specularDataPosition?: number;
  47492. /**
  47493. * This contains all the images data needed to reconstruct the cubemap.
  47494. */
  47495. mipmaps: Array<BufferImageData>;
  47496. /**
  47497. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47498. */
  47499. lodGenerationScale: number;
  47500. }
  47501. /**
  47502. * Sets of helpers addressing the serialization and deserialization of environment texture
  47503. * stored in a BabylonJS env file.
  47504. * Those files are usually stored as .env files.
  47505. */
  47506. export class EnvironmentTextureTools {
  47507. /**
  47508. * Magic number identifying the env file.
  47509. */
  47510. private static _MagicBytes;
  47511. /**
  47512. * Gets the environment info from an env file.
  47513. * @param data The array buffer containing the .env bytes.
  47514. * @returns the environment file info (the json header) if successfully parsed.
  47515. */
  47516. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47517. /**
  47518. * Creates an environment texture from a loaded cube texture.
  47519. * @param texture defines the cube texture to convert in env file
  47520. * @return a promise containing the environment data if succesfull.
  47521. */
  47522. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47523. /**
  47524. * Creates a JSON representation of the spherical data.
  47525. * @param texture defines the texture containing the polynomials
  47526. * @return the JSON representation of the spherical info
  47527. */
  47528. private static _CreateEnvTextureIrradiance;
  47529. /**
  47530. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47531. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47532. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47533. * @return the views described by info providing access to the underlying buffer
  47534. */
  47535. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47536. /**
  47537. * Uploads the texture info contained in the env file to the GPU.
  47538. * @param texture defines the internal texture to upload to
  47539. * @param arrayBuffer defines the buffer cotaining the data to load
  47540. * @param info defines the texture info retrieved through the GetEnvInfo method
  47541. * @returns a promise
  47542. */
  47543. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47544. private static _OnImageReadyAsync;
  47545. /**
  47546. * Uploads the levels of image data to the GPU.
  47547. * @param texture defines the internal texture to upload to
  47548. * @param imageData defines the array buffer views of image data [mipmap][face]
  47549. * @returns a promise
  47550. */
  47551. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47552. /**
  47553. * Uploads spherical polynomials information to the texture.
  47554. * @param texture defines the texture we are trying to upload the information to
  47555. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47556. */
  47557. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47558. /** @hidden */
  47559. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47560. }
  47561. }
  47562. declare module "babylonjs/Maths/math.vertexFormat" {
  47563. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47564. /**
  47565. * Contains position and normal vectors for a vertex
  47566. */
  47567. export class PositionNormalVertex {
  47568. /** the position of the vertex (defaut: 0,0,0) */
  47569. position: Vector3;
  47570. /** the normal of the vertex (defaut: 0,1,0) */
  47571. normal: Vector3;
  47572. /**
  47573. * Creates a PositionNormalVertex
  47574. * @param position the position of the vertex (defaut: 0,0,0)
  47575. * @param normal the normal of the vertex (defaut: 0,1,0)
  47576. */
  47577. constructor(
  47578. /** the position of the vertex (defaut: 0,0,0) */
  47579. position?: Vector3,
  47580. /** the normal of the vertex (defaut: 0,1,0) */
  47581. normal?: Vector3);
  47582. /**
  47583. * Clones the PositionNormalVertex
  47584. * @returns the cloned PositionNormalVertex
  47585. */
  47586. clone(): PositionNormalVertex;
  47587. }
  47588. /**
  47589. * Contains position, normal and uv vectors for a vertex
  47590. */
  47591. export class PositionNormalTextureVertex {
  47592. /** the position of the vertex (defaut: 0,0,0) */
  47593. position: Vector3;
  47594. /** the normal of the vertex (defaut: 0,1,0) */
  47595. normal: Vector3;
  47596. /** the uv of the vertex (default: 0,0) */
  47597. uv: Vector2;
  47598. /**
  47599. * Creates a PositionNormalTextureVertex
  47600. * @param position the position of the vertex (defaut: 0,0,0)
  47601. * @param normal the normal of the vertex (defaut: 0,1,0)
  47602. * @param uv the uv of the vertex (default: 0,0)
  47603. */
  47604. constructor(
  47605. /** the position of the vertex (defaut: 0,0,0) */
  47606. position?: Vector3,
  47607. /** the normal of the vertex (defaut: 0,1,0) */
  47608. normal?: Vector3,
  47609. /** the uv of the vertex (default: 0,0) */
  47610. uv?: Vector2);
  47611. /**
  47612. * Clones the PositionNormalTextureVertex
  47613. * @returns the cloned PositionNormalTextureVertex
  47614. */
  47615. clone(): PositionNormalTextureVertex;
  47616. }
  47617. }
  47618. declare module "babylonjs/Maths/math" {
  47619. export * from "babylonjs/Maths/math.axis";
  47620. export * from "babylonjs/Maths/math.color";
  47621. export * from "babylonjs/Maths/math.constants";
  47622. export * from "babylonjs/Maths/math.frustum";
  47623. export * from "babylonjs/Maths/math.path";
  47624. export * from "babylonjs/Maths/math.plane";
  47625. export * from "babylonjs/Maths/math.size";
  47626. export * from "babylonjs/Maths/math.vector";
  47627. export * from "babylonjs/Maths/math.vertexFormat";
  47628. export * from "babylonjs/Maths/math.viewport";
  47629. }
  47630. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47631. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47632. /** @hidden */
  47633. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47634. private _genericAttributeLocation;
  47635. private _varyingLocationCount;
  47636. private _varyingLocationMap;
  47637. private _replacements;
  47638. private _textureCount;
  47639. private _uniforms;
  47640. lineProcessor(line: string): string;
  47641. attributeProcessor(attribute: string): string;
  47642. varyingProcessor(varying: string, isFragment: boolean): string;
  47643. uniformProcessor(uniform: string): string;
  47644. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47645. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47646. }
  47647. }
  47648. declare module "babylonjs/Engines/nativeEngine" {
  47649. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47650. import { Engine } from "babylonjs/Engines/engine";
  47651. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47652. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47654. import { Effect } from "babylonjs/Materials/effect";
  47655. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47656. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47657. import { IColor4Like } from "babylonjs/Maths/math.like";
  47658. import { Scene } from "babylonjs/scene";
  47659. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47660. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47661. /**
  47662. * Container for accessors for natively-stored mesh data buffers.
  47663. */
  47664. class NativeDataBuffer extends DataBuffer {
  47665. /**
  47666. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47667. */
  47668. nativeIndexBuffer?: any;
  47669. /**
  47670. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47671. */
  47672. nativeVertexBuffer?: any;
  47673. }
  47674. /** @hidden */
  47675. class NativeTexture extends InternalTexture {
  47676. getInternalTexture(): InternalTexture;
  47677. getViewCount(): number;
  47678. }
  47679. /** @hidden */
  47680. export class NativeEngine extends Engine {
  47681. private readonly _native;
  47682. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47683. private readonly INVALID_HANDLE;
  47684. getHardwareScalingLevel(): number;
  47685. constructor();
  47686. /**
  47687. * Can be used to override the current requestAnimationFrame requester.
  47688. * @hidden
  47689. */
  47690. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47691. /**
  47692. * Override default engine behavior.
  47693. * @param color
  47694. * @param backBuffer
  47695. * @param depth
  47696. * @param stencil
  47697. */
  47698. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47699. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47700. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47701. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47702. recordVertexArrayObject(vertexBuffers: {
  47703. [key: string]: VertexBuffer;
  47704. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47705. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47706. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47707. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47708. /**
  47709. * Draw a list of indexed primitives
  47710. * @param fillMode defines the primitive to use
  47711. * @param indexStart defines the starting index
  47712. * @param indexCount defines the number of index to draw
  47713. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47714. */
  47715. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47716. /**
  47717. * Draw a list of unindexed primitives
  47718. * @param fillMode defines the primitive to use
  47719. * @param verticesStart defines the index of first vertex to draw
  47720. * @param verticesCount defines the count of vertices to draw
  47721. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47722. */
  47723. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47724. createPipelineContext(): IPipelineContext;
  47725. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47726. /** @hidden */
  47727. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47728. /** @hidden */
  47729. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47730. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47731. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47732. protected _setProgram(program: WebGLProgram): void;
  47733. _releaseEffect(effect: Effect): void;
  47734. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47735. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47736. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47737. bindSamplers(effect: Effect): void;
  47738. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47739. getRenderWidth(useScreen?: boolean): number;
  47740. getRenderHeight(useScreen?: boolean): number;
  47741. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47742. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47743. /**
  47744. * Set the z offset to apply to current rendering
  47745. * @param value defines the offset to apply
  47746. */
  47747. setZOffset(value: number): void;
  47748. /**
  47749. * Gets the current value of the zOffset
  47750. * @returns the current zOffset state
  47751. */
  47752. getZOffset(): number;
  47753. /**
  47754. * Enable or disable depth buffering
  47755. * @param enable defines the state to set
  47756. */
  47757. setDepthBuffer(enable: boolean): void;
  47758. /**
  47759. * Gets a boolean indicating if depth writing is enabled
  47760. * @returns the current depth writing state
  47761. */
  47762. getDepthWrite(): boolean;
  47763. /**
  47764. * Enable or disable depth writing
  47765. * @param enable defines the state to set
  47766. */
  47767. setDepthWrite(enable: boolean): void;
  47768. /**
  47769. * Enable or disable color writing
  47770. * @param enable defines the state to set
  47771. */
  47772. setColorWrite(enable: boolean): void;
  47773. /**
  47774. * Gets a boolean indicating if color writing is enabled
  47775. * @returns the current color writing state
  47776. */
  47777. getColorWrite(): boolean;
  47778. /**
  47779. * Sets alpha constants used by some alpha blending modes
  47780. * @param r defines the red component
  47781. * @param g defines the green component
  47782. * @param b defines the blue component
  47783. * @param a defines the alpha component
  47784. */
  47785. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47786. /**
  47787. * Sets the current alpha mode
  47788. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47789. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47790. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47791. */
  47792. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47793. /**
  47794. * Gets the current alpha mode
  47795. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47796. * @returns the current alpha mode
  47797. */
  47798. getAlphaMode(): number;
  47799. setInt(uniform: WebGLUniformLocation, int: number): void;
  47800. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47801. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47802. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47803. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47804. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47805. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47806. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47807. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47808. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47809. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47810. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47811. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47812. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47813. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47814. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47815. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47816. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47817. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47818. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47819. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47820. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47821. wipeCaches(bruteForce?: boolean): void;
  47822. _createTexture(): WebGLTexture;
  47823. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47824. /**
  47825. * Usually called from BABYLON.Texture.ts.
  47826. * Passed information to create a WebGLTexture
  47827. * @param urlArg defines a value which contains one of the following:
  47828. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47829. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47830. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47831. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47832. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47833. * @param scene needed for loading to the correct scene
  47834. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47835. * @param onLoad optional callback to be called upon successful completion
  47836. * @param onError optional callback to be called upon failure
  47837. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47838. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47839. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47840. * @param forcedExtension defines the extension to use to pick the right loader
  47841. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47842. */
  47843. 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;
  47844. /**
  47845. * Creates a cube texture
  47846. * @param rootUrl defines the url where the files to load is located
  47847. * @param scene defines the current scene
  47848. * @param files defines the list of files to load (1 per face)
  47849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47850. * @param onLoad defines an optional callback raised when the texture is loaded
  47851. * @param onError defines an optional callback raised if there is an issue to load the texture
  47852. * @param format defines the format of the data
  47853. * @param forcedExtension defines the extension to use to pick the right loader
  47854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47857. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47858. * @returns the cube texture as an InternalTexture
  47859. */
  47860. 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;
  47861. private _getSamplingFilter;
  47862. private static _GetNativeTextureFormat;
  47863. createRenderTargetTexture(size: number | {
  47864. width: number;
  47865. height: number;
  47866. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47867. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47868. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47869. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47870. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47871. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47872. /**
  47873. * Updates a dynamic vertex buffer.
  47874. * @param vertexBuffer the vertex buffer to update
  47875. * @param data the data used to update the vertex buffer
  47876. * @param byteOffset the byte offset of the data (optional)
  47877. * @param byteLength the byte length of the data (optional)
  47878. */
  47879. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47880. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47881. private _updateAnisotropicLevel;
  47882. private _getAddressMode;
  47883. /** @hidden */
  47884. _bindTexture(channel: number, texture: InternalTexture): void;
  47885. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47886. releaseEffects(): void;
  47887. /** @hidden */
  47888. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47889. /** @hidden */
  47890. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47891. /** @hidden */
  47892. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47893. /** @hidden */
  47894. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47895. }
  47896. }
  47897. declare module "babylonjs/Engines/index" {
  47898. export * from "babylonjs/Engines/constants";
  47899. export * from "babylonjs/Engines/engineCapabilities";
  47900. export * from "babylonjs/Engines/instancingAttributeInfo";
  47901. export * from "babylonjs/Engines/thinEngine";
  47902. export * from "babylonjs/Engines/engine";
  47903. export * from "babylonjs/Engines/engineStore";
  47904. export * from "babylonjs/Engines/nullEngine";
  47905. export * from "babylonjs/Engines/Extensions/index";
  47906. export * from "babylonjs/Engines/IPipelineContext";
  47907. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47908. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47909. export * from "babylonjs/Engines/nativeEngine";
  47910. }
  47911. declare module "babylonjs/Events/clipboardEvents" {
  47912. /**
  47913. * Gather the list of clipboard event types as constants.
  47914. */
  47915. export class ClipboardEventTypes {
  47916. /**
  47917. * The clipboard event is fired when a copy command is active (pressed).
  47918. */
  47919. static readonly COPY: number;
  47920. /**
  47921. * The clipboard event is fired when a cut command is active (pressed).
  47922. */
  47923. static readonly CUT: number;
  47924. /**
  47925. * The clipboard event is fired when a paste command is active (pressed).
  47926. */
  47927. static readonly PASTE: number;
  47928. }
  47929. /**
  47930. * This class is used to store clipboard related info for the onClipboardObservable event.
  47931. */
  47932. export class ClipboardInfo {
  47933. /**
  47934. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47935. */
  47936. type: number;
  47937. /**
  47938. * Defines the related dom event
  47939. */
  47940. event: ClipboardEvent;
  47941. /**
  47942. *Creates an instance of ClipboardInfo.
  47943. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47944. * @param event Defines the related dom event
  47945. */
  47946. constructor(
  47947. /**
  47948. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47949. */
  47950. type: number,
  47951. /**
  47952. * Defines the related dom event
  47953. */
  47954. event: ClipboardEvent);
  47955. /**
  47956. * Get the clipboard event's type from the keycode.
  47957. * @param keyCode Defines the keyCode for the current keyboard event.
  47958. * @return {number}
  47959. */
  47960. static GetTypeFromCharacter(keyCode: number): number;
  47961. }
  47962. }
  47963. declare module "babylonjs/Events/index" {
  47964. export * from "babylonjs/Events/keyboardEvents";
  47965. export * from "babylonjs/Events/pointerEvents";
  47966. export * from "babylonjs/Events/clipboardEvents";
  47967. }
  47968. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  47969. import { Scene } from "babylonjs/scene";
  47970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47971. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47972. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47973. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47974. /**
  47975. * Google Daydream controller
  47976. */
  47977. export class DaydreamController extends WebVRController {
  47978. /**
  47979. * Base Url for the controller model.
  47980. */
  47981. static MODEL_BASE_URL: string;
  47982. /**
  47983. * File name for the controller model.
  47984. */
  47985. static MODEL_FILENAME: string;
  47986. /**
  47987. * Gamepad Id prefix used to identify Daydream Controller.
  47988. */
  47989. static readonly GAMEPAD_ID_PREFIX: string;
  47990. /**
  47991. * Creates a new DaydreamController from a gamepad
  47992. * @param vrGamepad the gamepad that the controller should be created from
  47993. */
  47994. constructor(vrGamepad: any);
  47995. /**
  47996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47997. * @param scene scene in which to add meshes
  47998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47999. */
  48000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48001. /**
  48002. * Called once for each button that changed state since the last frame
  48003. * @param buttonIdx Which button index changed
  48004. * @param state New state of the button
  48005. * @param changes Which properties on the state changed since last frame
  48006. */
  48007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48008. }
  48009. }
  48010. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  48011. import { Scene } from "babylonjs/scene";
  48012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48013. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  48014. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  48015. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48016. /**
  48017. * Gear VR Controller
  48018. */
  48019. export class GearVRController extends WebVRController {
  48020. /**
  48021. * Base Url for the controller model.
  48022. */
  48023. static MODEL_BASE_URL: string;
  48024. /**
  48025. * File name for the controller model.
  48026. */
  48027. static MODEL_FILENAME: string;
  48028. /**
  48029. * Gamepad Id prefix used to identify this controller.
  48030. */
  48031. static readonly GAMEPAD_ID_PREFIX: string;
  48032. private readonly _buttonIndexToObservableNameMap;
  48033. /**
  48034. * Creates a new GearVRController from a gamepad
  48035. * @param vrGamepad the gamepad that the controller should be created from
  48036. */
  48037. constructor(vrGamepad: any);
  48038. /**
  48039. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48040. * @param scene scene in which to add meshes
  48041. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48042. */
  48043. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48044. /**
  48045. * Called once for each button that changed state since the last frame
  48046. * @param buttonIdx Which button index changed
  48047. * @param state New state of the button
  48048. * @param changes Which properties on the state changed since last frame
  48049. */
  48050. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48051. }
  48052. }
  48053. declare module "babylonjs/Gamepads/Controllers/index" {
  48054. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  48055. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  48056. export * from "babylonjs/Gamepads/Controllers/genericController";
  48057. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  48058. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  48059. export * from "babylonjs/Gamepads/Controllers/viveController";
  48060. export * from "babylonjs/Gamepads/Controllers/webVRController";
  48061. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  48062. }
  48063. declare module "babylonjs/Gamepads/index" {
  48064. export * from "babylonjs/Gamepads/Controllers/index";
  48065. export * from "babylonjs/Gamepads/gamepad";
  48066. export * from "babylonjs/Gamepads/gamepadManager";
  48067. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  48068. export * from "babylonjs/Gamepads/xboxGamepad";
  48069. export * from "babylonjs/Gamepads/dualShockGamepad";
  48070. }
  48071. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  48072. import { Scene } from "babylonjs/scene";
  48073. import { Vector4 } from "babylonjs/Maths/math.vector";
  48074. import { Color4 } from "babylonjs/Maths/math.color";
  48075. import { Mesh } from "babylonjs/Meshes/mesh";
  48076. import { Nullable } from "babylonjs/types";
  48077. /**
  48078. * Class containing static functions to help procedurally build meshes
  48079. */
  48080. export class PolyhedronBuilder {
  48081. /**
  48082. * Creates a polyhedron mesh
  48083. * * 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
  48084. * * The parameter `size` (positive float, default 1) sets the polygon size
  48085. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48086. * * 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`
  48087. * * 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
  48088. * * 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)`)
  48089. * * 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
  48090. * * 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
  48091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48094. * @param name defines the name of the mesh
  48095. * @param options defines the options used to create the mesh
  48096. * @param scene defines the hosting scene
  48097. * @returns the polyhedron mesh
  48098. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48099. */
  48100. static CreatePolyhedron(name: string, options: {
  48101. type?: number;
  48102. size?: number;
  48103. sizeX?: number;
  48104. sizeY?: number;
  48105. sizeZ?: number;
  48106. custom?: any;
  48107. faceUV?: Vector4[];
  48108. faceColors?: Color4[];
  48109. flat?: boolean;
  48110. updatable?: boolean;
  48111. sideOrientation?: number;
  48112. frontUVs?: Vector4;
  48113. backUVs?: Vector4;
  48114. }, scene?: Nullable<Scene>): Mesh;
  48115. }
  48116. }
  48117. declare module "babylonjs/Gizmos/scaleGizmo" {
  48118. import { Observable } from "babylonjs/Misc/observable";
  48119. import { Nullable } from "babylonjs/types";
  48120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48121. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48122. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  48123. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48124. /**
  48125. * Gizmo that enables scaling a mesh along 3 axis
  48126. */
  48127. export class ScaleGizmo extends Gizmo {
  48128. /**
  48129. * Internal gizmo used for interactions on the x axis
  48130. */
  48131. xGizmo: AxisScaleGizmo;
  48132. /**
  48133. * Internal gizmo used for interactions on the y axis
  48134. */
  48135. yGizmo: AxisScaleGizmo;
  48136. /**
  48137. * Internal gizmo used for interactions on the z axis
  48138. */
  48139. zGizmo: AxisScaleGizmo;
  48140. /**
  48141. * Internal gizmo used to scale all axis equally
  48142. */
  48143. uniformScaleGizmo: AxisScaleGizmo;
  48144. private _meshAttached;
  48145. private _updateGizmoRotationToMatchAttachedMesh;
  48146. private _snapDistance;
  48147. private _scaleRatio;
  48148. private _uniformScalingMesh;
  48149. private _octahedron;
  48150. private _sensitivity;
  48151. /** Fires an event when any of it's sub gizmos are dragged */
  48152. onDragStartObservable: Observable<unknown>;
  48153. /** Fires an event when any of it's sub gizmos are released from dragging */
  48154. onDragEndObservable: Observable<unknown>;
  48155. attachedMesh: Nullable<AbstractMesh>;
  48156. /**
  48157. * Creates a ScaleGizmo
  48158. * @param gizmoLayer The utility layer the gizmo will be added to
  48159. */
  48160. constructor(gizmoLayer?: UtilityLayerRenderer);
  48161. updateGizmoRotationToMatchAttachedMesh: boolean;
  48162. /**
  48163. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48164. */
  48165. snapDistance: number;
  48166. /**
  48167. * Ratio for the scale of the gizmo (Default: 1)
  48168. */
  48169. scaleRatio: number;
  48170. /**
  48171. * Sensitivity factor for dragging (Default: 1)
  48172. */
  48173. sensitivity: number;
  48174. /**
  48175. * Disposes of the gizmo
  48176. */
  48177. dispose(): void;
  48178. }
  48179. }
  48180. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  48181. import { Observable } from "babylonjs/Misc/observable";
  48182. import { Nullable } from "babylonjs/types";
  48183. import { Vector3 } from "babylonjs/Maths/math.vector";
  48184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48185. import { Mesh } from "babylonjs/Meshes/mesh";
  48186. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48187. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48188. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48189. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48190. import { Color3 } from "babylonjs/Maths/math.color";
  48191. /**
  48192. * Single axis scale gizmo
  48193. */
  48194. export class AxisScaleGizmo extends Gizmo {
  48195. /**
  48196. * Drag behavior responsible for the gizmos dragging interactions
  48197. */
  48198. dragBehavior: PointerDragBehavior;
  48199. private _pointerObserver;
  48200. /**
  48201. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48202. */
  48203. snapDistance: number;
  48204. /**
  48205. * Event that fires each time the gizmo snaps to a new location.
  48206. * * snapDistance is the the change in distance
  48207. */
  48208. onSnapObservable: Observable<{
  48209. snapDistance: number;
  48210. }>;
  48211. /**
  48212. * If the scaling operation should be done on all axis (default: false)
  48213. */
  48214. uniformScaling: boolean;
  48215. /**
  48216. * Custom sensitivity value for the drag strength
  48217. */
  48218. sensitivity: number;
  48219. private _isEnabled;
  48220. private _parent;
  48221. private _arrow;
  48222. private _coloredMaterial;
  48223. private _hoverMaterial;
  48224. /**
  48225. * Creates an AxisScaleGizmo
  48226. * @param gizmoLayer The utility layer the gizmo will be added to
  48227. * @param dragAxis The axis which the gizmo will be able to scale on
  48228. * @param color The color of the gizmo
  48229. */
  48230. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48231. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48232. /**
  48233. * If the gizmo is enabled
  48234. */
  48235. isEnabled: boolean;
  48236. /**
  48237. * Disposes of the gizmo
  48238. */
  48239. dispose(): void;
  48240. /**
  48241. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48242. * @param mesh The mesh to replace the default mesh of the gizmo
  48243. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48244. */
  48245. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48246. }
  48247. }
  48248. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  48249. import { Observable } from "babylonjs/Misc/observable";
  48250. import { Nullable } from "babylonjs/types";
  48251. import { Vector3 } from "babylonjs/Maths/math.vector";
  48252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48253. import { Mesh } from "babylonjs/Meshes/mesh";
  48254. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48255. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48256. import { Color3 } from "babylonjs/Maths/math.color";
  48257. import "babylonjs/Meshes/Builders/boxBuilder";
  48258. /**
  48259. * Bounding box gizmo
  48260. */
  48261. export class BoundingBoxGizmo extends Gizmo {
  48262. private _lineBoundingBox;
  48263. private _rotateSpheresParent;
  48264. private _scaleBoxesParent;
  48265. private _boundingDimensions;
  48266. private _renderObserver;
  48267. private _pointerObserver;
  48268. private _scaleDragSpeed;
  48269. private _tmpQuaternion;
  48270. private _tmpVector;
  48271. private _tmpRotationMatrix;
  48272. /**
  48273. * 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)
  48274. */
  48275. ignoreChildren: boolean;
  48276. /**
  48277. * 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)
  48278. */
  48279. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48280. /**
  48281. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48282. */
  48283. rotationSphereSize: number;
  48284. /**
  48285. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48286. */
  48287. scaleBoxSize: number;
  48288. /**
  48289. * 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)
  48290. */
  48291. fixedDragMeshScreenSize: boolean;
  48292. /**
  48293. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48294. */
  48295. fixedDragMeshScreenSizeDistanceFactor: number;
  48296. /**
  48297. * Fired when a rotation sphere or scale box is dragged
  48298. */
  48299. onDragStartObservable: Observable<{}>;
  48300. /**
  48301. * Fired when a scale box is dragged
  48302. */
  48303. onScaleBoxDragObservable: Observable<{}>;
  48304. /**
  48305. * Fired when a scale box drag is ended
  48306. */
  48307. onScaleBoxDragEndObservable: Observable<{}>;
  48308. /**
  48309. * Fired when a rotation sphere is dragged
  48310. */
  48311. onRotationSphereDragObservable: Observable<{}>;
  48312. /**
  48313. * Fired when a rotation sphere drag is ended
  48314. */
  48315. onRotationSphereDragEndObservable: Observable<{}>;
  48316. /**
  48317. * 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)
  48318. */
  48319. scalePivot: Nullable<Vector3>;
  48320. /**
  48321. * Mesh used as a pivot to rotate the attached mesh
  48322. */
  48323. private _anchorMesh;
  48324. private _existingMeshScale;
  48325. private _dragMesh;
  48326. private pointerDragBehavior;
  48327. private coloredMaterial;
  48328. private hoverColoredMaterial;
  48329. /**
  48330. * Sets the color of the bounding box gizmo
  48331. * @param color the color to set
  48332. */
  48333. setColor(color: Color3): void;
  48334. /**
  48335. * Creates an BoundingBoxGizmo
  48336. * @param gizmoLayer The utility layer the gizmo will be added to
  48337. * @param color The color of the gizmo
  48338. */
  48339. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48341. private _selectNode;
  48342. /**
  48343. * Updates the bounding box information for the Gizmo
  48344. */
  48345. updateBoundingBox(): void;
  48346. private _updateRotationSpheres;
  48347. private _updateScaleBoxes;
  48348. /**
  48349. * Enables rotation on the specified axis and disables rotation on the others
  48350. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48351. */
  48352. setEnabledRotationAxis(axis: string): void;
  48353. /**
  48354. * Enables/disables scaling
  48355. * @param enable if scaling should be enabled
  48356. */
  48357. setEnabledScaling(enable: boolean): void;
  48358. private _updateDummy;
  48359. /**
  48360. * Enables a pointer drag behavior on the bounding box of the gizmo
  48361. */
  48362. enableDragBehavior(): void;
  48363. /**
  48364. * Disposes of the gizmo
  48365. */
  48366. dispose(): void;
  48367. /**
  48368. * 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)
  48369. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48370. * @returns the bounding box mesh with the passed in mesh as a child
  48371. */
  48372. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48373. /**
  48374. * CustomMeshes are not supported by this gizmo
  48375. * @param mesh The mesh to replace the default mesh of the gizmo
  48376. */
  48377. setCustomMesh(mesh: Mesh): void;
  48378. }
  48379. }
  48380. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  48381. import { Observable } from "babylonjs/Misc/observable";
  48382. import { Nullable } from "babylonjs/types";
  48383. import { Vector3 } from "babylonjs/Maths/math.vector";
  48384. import { Color3 } from "babylonjs/Maths/math.color";
  48385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48386. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48387. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48388. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48389. import "babylonjs/Meshes/Builders/linesBuilder";
  48390. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48391. /**
  48392. * Single plane rotation gizmo
  48393. */
  48394. export class PlaneRotationGizmo extends Gizmo {
  48395. /**
  48396. * Drag behavior responsible for the gizmos dragging interactions
  48397. */
  48398. dragBehavior: PointerDragBehavior;
  48399. private _pointerObserver;
  48400. /**
  48401. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48402. */
  48403. snapDistance: number;
  48404. /**
  48405. * Event that fires each time the gizmo snaps to a new location.
  48406. * * snapDistance is the the change in distance
  48407. */
  48408. onSnapObservable: Observable<{
  48409. snapDistance: number;
  48410. }>;
  48411. private _isEnabled;
  48412. private _parent;
  48413. /**
  48414. * Creates a PlaneRotationGizmo
  48415. * @param gizmoLayer The utility layer the gizmo will be added to
  48416. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48417. * @param color The color of the gizmo
  48418. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48419. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48420. */
  48421. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48423. /**
  48424. * If the gizmo is enabled
  48425. */
  48426. isEnabled: boolean;
  48427. /**
  48428. * Disposes of the gizmo
  48429. */
  48430. dispose(): void;
  48431. }
  48432. }
  48433. declare module "babylonjs/Gizmos/rotationGizmo" {
  48434. import { Observable } from "babylonjs/Misc/observable";
  48435. import { Nullable } from "babylonjs/types";
  48436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48437. import { Mesh } from "babylonjs/Meshes/mesh";
  48438. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48439. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  48440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48441. /**
  48442. * Gizmo that enables rotating a mesh along 3 axis
  48443. */
  48444. export class RotationGizmo extends Gizmo {
  48445. /**
  48446. * Internal gizmo used for interactions on the x axis
  48447. */
  48448. xGizmo: PlaneRotationGizmo;
  48449. /**
  48450. * Internal gizmo used for interactions on the y axis
  48451. */
  48452. yGizmo: PlaneRotationGizmo;
  48453. /**
  48454. * Internal gizmo used for interactions on the z axis
  48455. */
  48456. zGizmo: PlaneRotationGizmo;
  48457. /** Fires an event when any of it's sub gizmos are dragged */
  48458. onDragStartObservable: Observable<unknown>;
  48459. /** Fires an event when any of it's sub gizmos are released from dragging */
  48460. onDragEndObservable: Observable<unknown>;
  48461. private _meshAttached;
  48462. attachedMesh: Nullable<AbstractMesh>;
  48463. /**
  48464. * Creates a RotationGizmo
  48465. * @param gizmoLayer The utility layer the gizmo will be added to
  48466. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48467. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48468. */
  48469. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48470. updateGizmoRotationToMatchAttachedMesh: boolean;
  48471. /**
  48472. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48473. */
  48474. snapDistance: number;
  48475. /**
  48476. * Ratio for the scale of the gizmo (Default: 1)
  48477. */
  48478. scaleRatio: number;
  48479. /**
  48480. * Disposes of the gizmo
  48481. */
  48482. dispose(): void;
  48483. /**
  48484. * CustomMeshes are not supported by this gizmo
  48485. * @param mesh The mesh to replace the default mesh of the gizmo
  48486. */
  48487. setCustomMesh(mesh: Mesh): void;
  48488. }
  48489. }
  48490. declare module "babylonjs/Gizmos/gizmoManager" {
  48491. import { Observable } from "babylonjs/Misc/observable";
  48492. import { Nullable } from "babylonjs/types";
  48493. import { Scene, IDisposable } from "babylonjs/scene";
  48494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48495. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48496. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48497. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48498. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48499. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48500. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48501. /**
  48502. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48503. */
  48504. export class GizmoManager implements IDisposable {
  48505. private scene;
  48506. /**
  48507. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48508. */
  48509. gizmos: {
  48510. positionGizmo: Nullable<PositionGizmo>;
  48511. rotationGizmo: Nullable<RotationGizmo>;
  48512. scaleGizmo: Nullable<ScaleGizmo>;
  48513. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48514. };
  48515. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48516. clearGizmoOnEmptyPointerEvent: boolean;
  48517. /** Fires an event when the manager is attached to a mesh */
  48518. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48519. private _gizmosEnabled;
  48520. private _pointerObserver;
  48521. private _attachedMesh;
  48522. private _boundingBoxColor;
  48523. private _defaultUtilityLayer;
  48524. private _defaultKeepDepthUtilityLayer;
  48525. /**
  48526. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48527. */
  48528. boundingBoxDragBehavior: SixDofDragBehavior;
  48529. /**
  48530. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48531. */
  48532. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48533. /**
  48534. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48535. */
  48536. usePointerToAttachGizmos: boolean;
  48537. /**
  48538. * Utility layer that the bounding box gizmo belongs to
  48539. */
  48540. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48541. /**
  48542. * Utility layer that all gizmos besides bounding box belong to
  48543. */
  48544. readonly utilityLayer: UtilityLayerRenderer;
  48545. /**
  48546. * Instatiates a gizmo manager
  48547. * @param scene the scene to overlay the gizmos on top of
  48548. */
  48549. constructor(scene: Scene);
  48550. /**
  48551. * Attaches a set of gizmos to the specified mesh
  48552. * @param mesh The mesh the gizmo's should be attached to
  48553. */
  48554. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48555. /**
  48556. * If the position gizmo is enabled
  48557. */
  48558. positionGizmoEnabled: boolean;
  48559. /**
  48560. * If the rotation gizmo is enabled
  48561. */
  48562. rotationGizmoEnabled: boolean;
  48563. /**
  48564. * If the scale gizmo is enabled
  48565. */
  48566. scaleGizmoEnabled: boolean;
  48567. /**
  48568. * If the boundingBox gizmo is enabled
  48569. */
  48570. boundingBoxGizmoEnabled: boolean;
  48571. /**
  48572. * Disposes of the gizmo manager
  48573. */
  48574. dispose(): void;
  48575. }
  48576. }
  48577. declare module "babylonjs/Lights/directionalLight" {
  48578. import { Camera } from "babylonjs/Cameras/camera";
  48579. import { Scene } from "babylonjs/scene";
  48580. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48582. import { Light } from "babylonjs/Lights/light";
  48583. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48584. import { Effect } from "babylonjs/Materials/effect";
  48585. /**
  48586. * A directional light is defined by a direction (what a surprise!).
  48587. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48588. * 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.
  48589. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48590. */
  48591. export class DirectionalLight extends ShadowLight {
  48592. private _shadowFrustumSize;
  48593. /**
  48594. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48595. */
  48596. /**
  48597. * Specifies a fix frustum size for the shadow generation.
  48598. */
  48599. shadowFrustumSize: number;
  48600. private _shadowOrthoScale;
  48601. /**
  48602. * Gets the shadow projection scale against the optimal computed one.
  48603. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48604. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48605. */
  48606. /**
  48607. * Sets the shadow projection scale against the optimal computed one.
  48608. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48609. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48610. */
  48611. shadowOrthoScale: number;
  48612. /**
  48613. * Automatically compute the projection matrix to best fit (including all the casters)
  48614. * on each frame.
  48615. */
  48616. autoUpdateExtends: boolean;
  48617. private _orthoLeft;
  48618. private _orthoRight;
  48619. private _orthoTop;
  48620. private _orthoBottom;
  48621. /**
  48622. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48623. * The directional light is emitted from everywhere in the given direction.
  48624. * It can cast shadows.
  48625. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48626. * @param name The friendly name of the light
  48627. * @param direction The direction of the light
  48628. * @param scene The scene the light belongs to
  48629. */
  48630. constructor(name: string, direction: Vector3, scene: Scene);
  48631. /**
  48632. * Returns the string "DirectionalLight".
  48633. * @return The class name
  48634. */
  48635. getClassName(): string;
  48636. /**
  48637. * Returns the integer 1.
  48638. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48639. */
  48640. getTypeID(): number;
  48641. /**
  48642. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48643. * Returns the DirectionalLight Shadow projection matrix.
  48644. */
  48645. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48646. /**
  48647. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48648. * Returns the DirectionalLight Shadow projection matrix.
  48649. */
  48650. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48651. /**
  48652. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48653. * Returns the DirectionalLight Shadow projection matrix.
  48654. */
  48655. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48656. protected _buildUniformLayout(): void;
  48657. /**
  48658. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48659. * @param effect The effect to update
  48660. * @param lightIndex The index of the light in the effect to update
  48661. * @returns The directional light
  48662. */
  48663. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48664. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48665. /**
  48666. * Gets the minZ used for shadow according to both the scene and the light.
  48667. *
  48668. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48669. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48670. * @param activeCamera The camera we are returning the min for
  48671. * @returns the depth min z
  48672. */
  48673. getDepthMinZ(activeCamera: Camera): number;
  48674. /**
  48675. * Gets the maxZ used for shadow according to both the scene and the light.
  48676. *
  48677. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48678. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48679. * @param activeCamera The camera we are returning the max for
  48680. * @returns the depth max z
  48681. */
  48682. getDepthMaxZ(activeCamera: Camera): number;
  48683. /**
  48684. * Prepares the list of defines specific to the light type.
  48685. * @param defines the list of defines
  48686. * @param lightIndex defines the index of the light for the effect
  48687. */
  48688. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48689. }
  48690. }
  48691. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48692. import { Mesh } from "babylonjs/Meshes/mesh";
  48693. /**
  48694. * Class containing static functions to help procedurally build meshes
  48695. */
  48696. export class HemisphereBuilder {
  48697. /**
  48698. * Creates a hemisphere mesh
  48699. * @param name defines the name of the mesh
  48700. * @param options defines the options used to create the mesh
  48701. * @param scene defines the hosting scene
  48702. * @returns the hemisphere mesh
  48703. */
  48704. static CreateHemisphere(name: string, options: {
  48705. segments?: number;
  48706. diameter?: number;
  48707. sideOrientation?: number;
  48708. }, scene: any): Mesh;
  48709. }
  48710. }
  48711. declare module "babylonjs/Lights/spotLight" {
  48712. import { Nullable } from "babylonjs/types";
  48713. import { Scene } from "babylonjs/scene";
  48714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48716. import { Effect } from "babylonjs/Materials/effect";
  48717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48718. import { Light } from "babylonjs/Lights/light";
  48719. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48720. /**
  48721. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48722. * These values define a cone of light starting from the position, emitting toward the direction.
  48723. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48724. * and the exponent defines the speed of the decay of the light with distance (reach).
  48725. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48726. */
  48727. export class SpotLight extends ShadowLight {
  48728. private _angle;
  48729. private _innerAngle;
  48730. private _cosHalfAngle;
  48731. private _lightAngleScale;
  48732. private _lightAngleOffset;
  48733. /**
  48734. * Gets the cone angle of the spot light in Radians.
  48735. */
  48736. /**
  48737. * Sets the cone angle of the spot light in Radians.
  48738. */
  48739. angle: number;
  48740. /**
  48741. * Only used in gltf falloff mode, this defines the angle where
  48742. * the directional falloff will start before cutting at angle which could be seen
  48743. * as outer angle.
  48744. */
  48745. /**
  48746. * Only used in gltf falloff mode, this defines the angle where
  48747. * the directional falloff will start before cutting at angle which could be seen
  48748. * as outer angle.
  48749. */
  48750. innerAngle: number;
  48751. private _shadowAngleScale;
  48752. /**
  48753. * Allows scaling the angle of the light for shadow generation only.
  48754. */
  48755. /**
  48756. * Allows scaling the angle of the light for shadow generation only.
  48757. */
  48758. shadowAngleScale: number;
  48759. /**
  48760. * The light decay speed with the distance from the emission spot.
  48761. */
  48762. exponent: number;
  48763. private _projectionTextureMatrix;
  48764. /**
  48765. * Allows reading the projecton texture
  48766. */
  48767. readonly projectionTextureMatrix: Matrix;
  48768. protected _projectionTextureLightNear: number;
  48769. /**
  48770. * Gets the near clip of the Spotlight for texture projection.
  48771. */
  48772. /**
  48773. * Sets the near clip of the Spotlight for texture projection.
  48774. */
  48775. projectionTextureLightNear: number;
  48776. protected _projectionTextureLightFar: number;
  48777. /**
  48778. * Gets the far clip of the Spotlight for texture projection.
  48779. */
  48780. /**
  48781. * Sets the far clip of the Spotlight for texture projection.
  48782. */
  48783. projectionTextureLightFar: number;
  48784. protected _projectionTextureUpDirection: Vector3;
  48785. /**
  48786. * Gets the Up vector of the Spotlight for texture projection.
  48787. */
  48788. /**
  48789. * Sets the Up vector of the Spotlight for texture projection.
  48790. */
  48791. projectionTextureUpDirection: Vector3;
  48792. private _projectionTexture;
  48793. /**
  48794. * Gets the projection texture of the light.
  48795. */
  48796. /**
  48797. * Sets the projection texture of the light.
  48798. */
  48799. projectionTexture: Nullable<BaseTexture>;
  48800. private _projectionTextureViewLightDirty;
  48801. private _projectionTextureProjectionLightDirty;
  48802. private _projectionTextureDirty;
  48803. private _projectionTextureViewTargetVector;
  48804. private _projectionTextureViewLightMatrix;
  48805. private _projectionTextureProjectionLightMatrix;
  48806. private _projectionTextureScalingMatrix;
  48807. /**
  48808. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48809. * It can cast shadows.
  48810. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48811. * @param name The light friendly name
  48812. * @param position The position of the spot light in the scene
  48813. * @param direction The direction of the light in the scene
  48814. * @param angle The cone angle of the light in Radians
  48815. * @param exponent The light decay speed with the distance from the emission spot
  48816. * @param scene The scene the lights belongs to
  48817. */
  48818. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48819. /**
  48820. * Returns the string "SpotLight".
  48821. * @returns the class name
  48822. */
  48823. getClassName(): string;
  48824. /**
  48825. * Returns the integer 2.
  48826. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48827. */
  48828. getTypeID(): number;
  48829. /**
  48830. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48831. */
  48832. protected _setDirection(value: Vector3): void;
  48833. /**
  48834. * Overrides the position setter to recompute the projection texture view light Matrix.
  48835. */
  48836. protected _setPosition(value: Vector3): void;
  48837. /**
  48838. * 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.
  48839. * Returns the SpotLight.
  48840. */
  48841. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48842. protected _computeProjectionTextureViewLightMatrix(): void;
  48843. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48844. /**
  48845. * Main function for light texture projection matrix computing.
  48846. */
  48847. protected _computeProjectionTextureMatrix(): void;
  48848. protected _buildUniformLayout(): void;
  48849. private _computeAngleValues;
  48850. /**
  48851. * Sets the passed Effect "effect" with the Light textures.
  48852. * @param effect The effect to update
  48853. * @param lightIndex The index of the light in the effect to update
  48854. * @returns The light
  48855. */
  48856. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48857. /**
  48858. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48859. * @param effect The effect to update
  48860. * @param lightIndex The index of the light in the effect to update
  48861. * @returns The spot light
  48862. */
  48863. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48864. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48865. /**
  48866. * Disposes the light and the associated resources.
  48867. */
  48868. dispose(): void;
  48869. /**
  48870. * Prepares the list of defines specific to the light type.
  48871. * @param defines the list of defines
  48872. * @param lightIndex defines the index of the light for the effect
  48873. */
  48874. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48875. }
  48876. }
  48877. declare module "babylonjs/Gizmos/lightGizmo" {
  48878. import { Nullable } from "babylonjs/types";
  48879. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48880. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48881. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48882. import { Light } from "babylonjs/Lights/light";
  48883. /**
  48884. * Gizmo that enables viewing a light
  48885. */
  48886. export class LightGizmo extends Gizmo {
  48887. private _lightMesh;
  48888. private _material;
  48889. private _cachedPosition;
  48890. private _cachedForward;
  48891. private _attachedMeshParent;
  48892. /**
  48893. * Creates a LightGizmo
  48894. * @param gizmoLayer The utility layer the gizmo will be added to
  48895. */
  48896. constructor(gizmoLayer?: UtilityLayerRenderer);
  48897. private _light;
  48898. /**
  48899. * The light that the gizmo is attached to
  48900. */
  48901. light: Nullable<Light>;
  48902. /**
  48903. * Gets the material used to render the light gizmo
  48904. */
  48905. readonly material: StandardMaterial;
  48906. /**
  48907. * @hidden
  48908. * Updates the gizmo to match the attached mesh's position/rotation
  48909. */
  48910. protected _update(): void;
  48911. private static _Scale;
  48912. /**
  48913. * Creates the lines for a light mesh
  48914. */
  48915. private static _CreateLightLines;
  48916. /**
  48917. * Disposes of the light gizmo
  48918. */
  48919. dispose(): void;
  48920. private static _CreateHemisphericLightMesh;
  48921. private static _CreatePointLightMesh;
  48922. private static _CreateSpotLightMesh;
  48923. private static _CreateDirectionalLightMesh;
  48924. }
  48925. }
  48926. declare module "babylonjs/Gizmos/index" {
  48927. export * from "babylonjs/Gizmos/axisDragGizmo";
  48928. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48929. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48930. export * from "babylonjs/Gizmos/gizmo";
  48931. export * from "babylonjs/Gizmos/gizmoManager";
  48932. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48933. export * from "babylonjs/Gizmos/positionGizmo";
  48934. export * from "babylonjs/Gizmos/rotationGizmo";
  48935. export * from "babylonjs/Gizmos/scaleGizmo";
  48936. export * from "babylonjs/Gizmos/lightGizmo";
  48937. export * from "babylonjs/Gizmos/planeDragGizmo";
  48938. }
  48939. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48940. /** @hidden */
  48941. export var backgroundFragmentDeclaration: {
  48942. name: string;
  48943. shader: string;
  48944. };
  48945. }
  48946. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48947. /** @hidden */
  48948. export var backgroundUboDeclaration: {
  48949. name: string;
  48950. shader: string;
  48951. };
  48952. }
  48953. declare module "babylonjs/Shaders/background.fragment" {
  48954. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48955. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48956. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48957. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48958. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48959. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48961. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48962. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48963. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48964. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48965. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48966. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48967. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48968. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48969. /** @hidden */
  48970. export var backgroundPixelShader: {
  48971. name: string;
  48972. shader: string;
  48973. };
  48974. }
  48975. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48976. /** @hidden */
  48977. export var backgroundVertexDeclaration: {
  48978. name: string;
  48979. shader: string;
  48980. };
  48981. }
  48982. declare module "babylonjs/Shaders/background.vertex" {
  48983. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48984. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48985. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48986. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48987. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48988. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48989. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48990. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48991. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48994. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48995. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48996. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48997. /** @hidden */
  48998. export var backgroundVertexShader: {
  48999. name: string;
  49000. shader: string;
  49001. };
  49002. }
  49003. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  49004. import { Nullable, int, float } from "babylonjs/types";
  49005. import { Scene } from "babylonjs/scene";
  49006. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49009. import { Mesh } from "babylonjs/Meshes/mesh";
  49010. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49011. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49012. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49014. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  49015. import { Color3 } from "babylonjs/Maths/math.color";
  49016. import "babylonjs/Shaders/background.fragment";
  49017. import "babylonjs/Shaders/background.vertex";
  49018. /**
  49019. * Background material used to create an efficient environement around your scene.
  49020. */
  49021. export class BackgroundMaterial extends PushMaterial {
  49022. /**
  49023. * Standard reflectance value at parallel view angle.
  49024. */
  49025. static StandardReflectance0: number;
  49026. /**
  49027. * Standard reflectance value at grazing angle.
  49028. */
  49029. static StandardReflectance90: number;
  49030. protected _primaryColor: Color3;
  49031. /**
  49032. * Key light Color (multiply against the environement texture)
  49033. */
  49034. primaryColor: Color3;
  49035. protected __perceptualColor: Nullable<Color3>;
  49036. /**
  49037. * Experimental Internal Use Only.
  49038. *
  49039. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49040. * This acts as a helper to set the primary color to a more "human friendly" value.
  49041. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49042. * output color as close as possible from the chosen value.
  49043. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49044. * part of lighting setup.)
  49045. */
  49046. _perceptualColor: Nullable<Color3>;
  49047. protected _primaryColorShadowLevel: float;
  49048. /**
  49049. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49050. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49051. */
  49052. primaryColorShadowLevel: float;
  49053. protected _primaryColorHighlightLevel: float;
  49054. /**
  49055. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49056. * The primary color is used at the level chosen to define what the white area would look.
  49057. */
  49058. primaryColorHighlightLevel: float;
  49059. protected _reflectionTexture: Nullable<BaseTexture>;
  49060. /**
  49061. * Reflection Texture used in the material.
  49062. * Should be author in a specific way for the best result (refer to the documentation).
  49063. */
  49064. reflectionTexture: Nullable<BaseTexture>;
  49065. protected _reflectionBlur: float;
  49066. /**
  49067. * Reflection Texture level of blur.
  49068. *
  49069. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49070. * texture twice.
  49071. */
  49072. reflectionBlur: float;
  49073. protected _diffuseTexture: Nullable<BaseTexture>;
  49074. /**
  49075. * Diffuse Texture used in the material.
  49076. * Should be author in a specific way for the best result (refer to the documentation).
  49077. */
  49078. diffuseTexture: Nullable<BaseTexture>;
  49079. protected _shadowLights: Nullable<IShadowLight[]>;
  49080. /**
  49081. * Specify the list of lights casting shadow on the material.
  49082. * All scene shadow lights will be included if null.
  49083. */
  49084. shadowLights: Nullable<IShadowLight[]>;
  49085. protected _shadowLevel: float;
  49086. /**
  49087. * Helps adjusting the shadow to a softer level if required.
  49088. * 0 means black shadows and 1 means no shadows.
  49089. */
  49090. shadowLevel: float;
  49091. protected _sceneCenter: Vector3;
  49092. /**
  49093. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49094. * It is usually zero but might be interesting to modify according to your setup.
  49095. */
  49096. sceneCenter: Vector3;
  49097. protected _opacityFresnel: boolean;
  49098. /**
  49099. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49100. * This helps ensuring a nice transition when the camera goes under the ground.
  49101. */
  49102. opacityFresnel: boolean;
  49103. protected _reflectionFresnel: boolean;
  49104. /**
  49105. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49106. * This helps adding a mirror texture on the ground.
  49107. */
  49108. reflectionFresnel: boolean;
  49109. protected _reflectionFalloffDistance: number;
  49110. /**
  49111. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49112. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49113. */
  49114. reflectionFalloffDistance: number;
  49115. protected _reflectionAmount: number;
  49116. /**
  49117. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49118. */
  49119. reflectionAmount: number;
  49120. protected _reflectionReflectance0: number;
  49121. /**
  49122. * This specifies the weight of the reflection at grazing angle.
  49123. */
  49124. reflectionReflectance0: number;
  49125. protected _reflectionReflectance90: number;
  49126. /**
  49127. * This specifies the weight of the reflection at a perpendicular point of view.
  49128. */
  49129. reflectionReflectance90: number;
  49130. /**
  49131. * Sets the reflection reflectance fresnel values according to the default standard
  49132. * empirically know to work well :-)
  49133. */
  49134. reflectionStandardFresnelWeight: number;
  49135. protected _useRGBColor: boolean;
  49136. /**
  49137. * Helps to directly use the maps channels instead of their level.
  49138. */
  49139. useRGBColor: boolean;
  49140. protected _enableNoise: boolean;
  49141. /**
  49142. * This helps reducing the banding effect that could occur on the background.
  49143. */
  49144. enableNoise: boolean;
  49145. /**
  49146. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49147. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49148. * Recommended to be keep at 1.0 except for special cases.
  49149. */
  49150. fovMultiplier: number;
  49151. private _fovMultiplier;
  49152. /**
  49153. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49154. */
  49155. useEquirectangularFOV: boolean;
  49156. private _maxSimultaneousLights;
  49157. /**
  49158. * Number of Simultaneous lights allowed on the material.
  49159. */
  49160. maxSimultaneousLights: int;
  49161. /**
  49162. * Default configuration related to image processing available in the Background Material.
  49163. */
  49164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49165. /**
  49166. * Keep track of the image processing observer to allow dispose and replace.
  49167. */
  49168. private _imageProcessingObserver;
  49169. /**
  49170. * Attaches a new image processing configuration to the PBR Material.
  49171. * @param configuration (if null the scene configuration will be use)
  49172. */
  49173. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49174. /**
  49175. * Gets the image processing configuration used either in this material.
  49176. */
  49177. /**
  49178. * Sets the Default image processing configuration used either in the this material.
  49179. *
  49180. * If sets to null, the scene one is in use.
  49181. */
  49182. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  49183. /**
  49184. * Gets wether the color curves effect is enabled.
  49185. */
  49186. /**
  49187. * Sets wether the color curves effect is enabled.
  49188. */
  49189. cameraColorCurvesEnabled: boolean;
  49190. /**
  49191. * Gets wether the color grading effect is enabled.
  49192. */
  49193. /**
  49194. * Gets wether the color grading effect is enabled.
  49195. */
  49196. cameraColorGradingEnabled: boolean;
  49197. /**
  49198. * Gets wether tonemapping is enabled or not.
  49199. */
  49200. /**
  49201. * Sets wether tonemapping is enabled or not
  49202. */
  49203. cameraToneMappingEnabled: boolean;
  49204. /**
  49205. * The camera exposure used on this material.
  49206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49207. * This corresponds to a photographic exposure.
  49208. */
  49209. /**
  49210. * The camera exposure used on this material.
  49211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49212. * This corresponds to a photographic exposure.
  49213. */
  49214. cameraExposure: float;
  49215. /**
  49216. * Gets The camera contrast used on this material.
  49217. */
  49218. /**
  49219. * Sets The camera contrast used on this material.
  49220. */
  49221. cameraContrast: float;
  49222. /**
  49223. * Gets the Color Grading 2D Lookup Texture.
  49224. */
  49225. /**
  49226. * Sets the Color Grading 2D Lookup Texture.
  49227. */
  49228. cameraColorGradingTexture: Nullable<BaseTexture>;
  49229. /**
  49230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49232. * 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;
  49233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49234. */
  49235. /**
  49236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49238. * 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;
  49239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49240. */
  49241. cameraColorCurves: Nullable<ColorCurves>;
  49242. /**
  49243. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49244. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49245. */
  49246. switchToBGR: boolean;
  49247. private _renderTargets;
  49248. private _reflectionControls;
  49249. private _white;
  49250. private _primaryShadowColor;
  49251. private _primaryHighlightColor;
  49252. /**
  49253. * Instantiates a Background Material in the given scene
  49254. * @param name The friendly name of the material
  49255. * @param scene The scene to add the material to
  49256. */
  49257. constructor(name: string, scene: Scene);
  49258. /**
  49259. * Gets a boolean indicating that current material needs to register RTT
  49260. */
  49261. readonly hasRenderTargetTextures: boolean;
  49262. /**
  49263. * The entire material has been created in order to prevent overdraw.
  49264. * @returns false
  49265. */
  49266. needAlphaTesting(): boolean;
  49267. /**
  49268. * The entire material has been created in order to prevent overdraw.
  49269. * @returns true if blending is enable
  49270. */
  49271. needAlphaBlending(): boolean;
  49272. /**
  49273. * Checks wether the material is ready to be rendered for a given mesh.
  49274. * @param mesh The mesh to render
  49275. * @param subMesh The submesh to check against
  49276. * @param useInstances Specify wether or not the material is used with instances
  49277. * @returns true if all the dependencies are ready (Textures, Effects...)
  49278. */
  49279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49280. /**
  49281. * Compute the primary color according to the chosen perceptual color.
  49282. */
  49283. private _computePrimaryColorFromPerceptualColor;
  49284. /**
  49285. * Compute the highlights and shadow colors according to their chosen levels.
  49286. */
  49287. private _computePrimaryColors;
  49288. /**
  49289. * Build the uniform buffer used in the material.
  49290. */
  49291. buildUniformLayout(): void;
  49292. /**
  49293. * Unbind the material.
  49294. */
  49295. unbind(): void;
  49296. /**
  49297. * Bind only the world matrix to the material.
  49298. * @param world The world matrix to bind.
  49299. */
  49300. bindOnlyWorldMatrix(world: Matrix): void;
  49301. /**
  49302. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49303. * @param world The world matrix to bind.
  49304. * @param subMesh The submesh to bind for.
  49305. */
  49306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49307. /**
  49308. * Checks to see if a texture is used in the material.
  49309. * @param texture - Base texture to use.
  49310. * @returns - Boolean specifying if a texture is used in the material.
  49311. */
  49312. hasTexture(texture: BaseTexture): boolean;
  49313. /**
  49314. * Dispose the material.
  49315. * @param forceDisposeEffect Force disposal of the associated effect.
  49316. * @param forceDisposeTextures Force disposal of the associated textures.
  49317. */
  49318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49319. /**
  49320. * Clones the material.
  49321. * @param name The cloned name.
  49322. * @returns The cloned material.
  49323. */
  49324. clone(name: string): BackgroundMaterial;
  49325. /**
  49326. * Serializes the current material to its JSON representation.
  49327. * @returns The JSON representation.
  49328. */
  49329. serialize(): any;
  49330. /**
  49331. * Gets the class name of the material
  49332. * @returns "BackgroundMaterial"
  49333. */
  49334. getClassName(): string;
  49335. /**
  49336. * Parse a JSON input to create back a background material.
  49337. * @param source The JSON data to parse
  49338. * @param scene The scene to create the parsed material in
  49339. * @param rootUrl The root url of the assets the material depends upon
  49340. * @returns the instantiated BackgroundMaterial.
  49341. */
  49342. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49343. }
  49344. }
  49345. declare module "babylonjs/Helpers/environmentHelper" {
  49346. import { Observable } from "babylonjs/Misc/observable";
  49347. import { Nullable } from "babylonjs/types";
  49348. import { Scene } from "babylonjs/scene";
  49349. import { Vector3 } from "babylonjs/Maths/math.vector";
  49350. import { Color3 } from "babylonjs/Maths/math.color";
  49351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49352. import { Mesh } from "babylonjs/Meshes/mesh";
  49353. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49354. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  49355. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49356. import "babylonjs/Meshes/Builders/planeBuilder";
  49357. import "babylonjs/Meshes/Builders/boxBuilder";
  49358. /**
  49359. * Represents the different options available during the creation of
  49360. * a Environment helper.
  49361. *
  49362. * This can control the default ground, skybox and image processing setup of your scene.
  49363. */
  49364. export interface IEnvironmentHelperOptions {
  49365. /**
  49366. * Specifies wether or not to create a ground.
  49367. * True by default.
  49368. */
  49369. createGround: boolean;
  49370. /**
  49371. * Specifies the ground size.
  49372. * 15 by default.
  49373. */
  49374. groundSize: number;
  49375. /**
  49376. * The texture used on the ground for the main color.
  49377. * Comes from the BabylonJS CDN by default.
  49378. *
  49379. * Remarks: Can be either a texture or a url.
  49380. */
  49381. groundTexture: string | BaseTexture;
  49382. /**
  49383. * The color mixed in the ground texture by default.
  49384. * BabylonJS clearColor by default.
  49385. */
  49386. groundColor: Color3;
  49387. /**
  49388. * Specifies the ground opacity.
  49389. * 1 by default.
  49390. */
  49391. groundOpacity: number;
  49392. /**
  49393. * Enables the ground to receive shadows.
  49394. * True by default.
  49395. */
  49396. enableGroundShadow: boolean;
  49397. /**
  49398. * Helps preventing the shadow to be fully black on the ground.
  49399. * 0.5 by default.
  49400. */
  49401. groundShadowLevel: number;
  49402. /**
  49403. * Creates a mirror texture attach to the ground.
  49404. * false by default.
  49405. */
  49406. enableGroundMirror: boolean;
  49407. /**
  49408. * Specifies the ground mirror size ratio.
  49409. * 0.3 by default as the default kernel is 64.
  49410. */
  49411. groundMirrorSizeRatio: number;
  49412. /**
  49413. * Specifies the ground mirror blur kernel size.
  49414. * 64 by default.
  49415. */
  49416. groundMirrorBlurKernel: number;
  49417. /**
  49418. * Specifies the ground mirror visibility amount.
  49419. * 1 by default
  49420. */
  49421. groundMirrorAmount: number;
  49422. /**
  49423. * Specifies the ground mirror reflectance weight.
  49424. * This uses the standard weight of the background material to setup the fresnel effect
  49425. * of the mirror.
  49426. * 1 by default.
  49427. */
  49428. groundMirrorFresnelWeight: number;
  49429. /**
  49430. * Specifies the ground mirror Falloff distance.
  49431. * This can helps reducing the size of the reflection.
  49432. * 0 by Default.
  49433. */
  49434. groundMirrorFallOffDistance: number;
  49435. /**
  49436. * Specifies the ground mirror texture type.
  49437. * Unsigned Int by Default.
  49438. */
  49439. groundMirrorTextureType: number;
  49440. /**
  49441. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49442. * the shown objects.
  49443. */
  49444. groundYBias: number;
  49445. /**
  49446. * Specifies wether or not to create a skybox.
  49447. * True by default.
  49448. */
  49449. createSkybox: boolean;
  49450. /**
  49451. * Specifies the skybox size.
  49452. * 20 by default.
  49453. */
  49454. skyboxSize: number;
  49455. /**
  49456. * The texture used on the skybox for the main color.
  49457. * Comes from the BabylonJS CDN by default.
  49458. *
  49459. * Remarks: Can be either a texture or a url.
  49460. */
  49461. skyboxTexture: string | BaseTexture;
  49462. /**
  49463. * The color mixed in the skybox texture by default.
  49464. * BabylonJS clearColor by default.
  49465. */
  49466. skyboxColor: Color3;
  49467. /**
  49468. * The background rotation around the Y axis of the scene.
  49469. * This helps aligning the key lights of your scene with the background.
  49470. * 0 by default.
  49471. */
  49472. backgroundYRotation: number;
  49473. /**
  49474. * Compute automatically the size of the elements to best fit with the scene.
  49475. */
  49476. sizeAuto: boolean;
  49477. /**
  49478. * Default position of the rootMesh if autoSize is not true.
  49479. */
  49480. rootPosition: Vector3;
  49481. /**
  49482. * Sets up the image processing in the scene.
  49483. * true by default.
  49484. */
  49485. setupImageProcessing: boolean;
  49486. /**
  49487. * The texture used as your environment texture in the scene.
  49488. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49489. *
  49490. * Remarks: Can be either a texture or a url.
  49491. */
  49492. environmentTexture: string | BaseTexture;
  49493. /**
  49494. * The value of the exposure to apply to the scene.
  49495. * 0.6 by default if setupImageProcessing is true.
  49496. */
  49497. cameraExposure: number;
  49498. /**
  49499. * The value of the contrast to apply to the scene.
  49500. * 1.6 by default if setupImageProcessing is true.
  49501. */
  49502. cameraContrast: number;
  49503. /**
  49504. * Specifies wether or not tonemapping should be enabled in the scene.
  49505. * true by default if setupImageProcessing is true.
  49506. */
  49507. toneMappingEnabled: boolean;
  49508. }
  49509. /**
  49510. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49511. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49512. * It also helps with the default setup of your imageProcessing configuration.
  49513. */
  49514. export class EnvironmentHelper {
  49515. /**
  49516. * Default ground texture URL.
  49517. */
  49518. private static _groundTextureCDNUrl;
  49519. /**
  49520. * Default skybox texture URL.
  49521. */
  49522. private static _skyboxTextureCDNUrl;
  49523. /**
  49524. * Default environment texture URL.
  49525. */
  49526. private static _environmentTextureCDNUrl;
  49527. /**
  49528. * Creates the default options for the helper.
  49529. */
  49530. private static _getDefaultOptions;
  49531. private _rootMesh;
  49532. /**
  49533. * Gets the root mesh created by the helper.
  49534. */
  49535. readonly rootMesh: Mesh;
  49536. private _skybox;
  49537. /**
  49538. * Gets the skybox created by the helper.
  49539. */
  49540. readonly skybox: Nullable<Mesh>;
  49541. private _skyboxTexture;
  49542. /**
  49543. * Gets the skybox texture created by the helper.
  49544. */
  49545. readonly skyboxTexture: Nullable<BaseTexture>;
  49546. private _skyboxMaterial;
  49547. /**
  49548. * Gets the skybox material created by the helper.
  49549. */
  49550. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49551. private _ground;
  49552. /**
  49553. * Gets the ground mesh created by the helper.
  49554. */
  49555. readonly ground: Nullable<Mesh>;
  49556. private _groundTexture;
  49557. /**
  49558. * Gets the ground texture created by the helper.
  49559. */
  49560. readonly groundTexture: Nullable<BaseTexture>;
  49561. private _groundMirror;
  49562. /**
  49563. * Gets the ground mirror created by the helper.
  49564. */
  49565. readonly groundMirror: Nullable<MirrorTexture>;
  49566. /**
  49567. * Gets the ground mirror render list to helps pushing the meshes
  49568. * you wish in the ground reflection.
  49569. */
  49570. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49571. private _groundMaterial;
  49572. /**
  49573. * Gets the ground material created by the helper.
  49574. */
  49575. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49576. /**
  49577. * Stores the creation options.
  49578. */
  49579. private readonly _scene;
  49580. private _options;
  49581. /**
  49582. * This observable will be notified with any error during the creation of the environment,
  49583. * mainly texture creation errors.
  49584. */
  49585. onErrorObservable: Observable<{
  49586. message?: string;
  49587. exception?: any;
  49588. }>;
  49589. /**
  49590. * constructor
  49591. * @param options Defines the options we want to customize the helper
  49592. * @param scene The scene to add the material to
  49593. */
  49594. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49595. /**
  49596. * Updates the background according to the new options
  49597. * @param options
  49598. */
  49599. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49600. /**
  49601. * Sets the primary color of all the available elements.
  49602. * @param color the main color to affect to the ground and the background
  49603. */
  49604. setMainColor(color: Color3): void;
  49605. /**
  49606. * Setup the image processing according to the specified options.
  49607. */
  49608. private _setupImageProcessing;
  49609. /**
  49610. * Setup the environment texture according to the specified options.
  49611. */
  49612. private _setupEnvironmentTexture;
  49613. /**
  49614. * Setup the background according to the specified options.
  49615. */
  49616. private _setupBackground;
  49617. /**
  49618. * Get the scene sizes according to the setup.
  49619. */
  49620. private _getSceneSize;
  49621. /**
  49622. * Setup the ground according to the specified options.
  49623. */
  49624. private _setupGround;
  49625. /**
  49626. * Setup the ground material according to the specified options.
  49627. */
  49628. private _setupGroundMaterial;
  49629. /**
  49630. * Setup the ground diffuse texture according to the specified options.
  49631. */
  49632. private _setupGroundDiffuseTexture;
  49633. /**
  49634. * Setup the ground mirror texture according to the specified options.
  49635. */
  49636. private _setupGroundMirrorTexture;
  49637. /**
  49638. * Setup the ground to receive the mirror texture.
  49639. */
  49640. private _setupMirrorInGroundMaterial;
  49641. /**
  49642. * Setup the skybox according to the specified options.
  49643. */
  49644. private _setupSkybox;
  49645. /**
  49646. * Setup the skybox material according to the specified options.
  49647. */
  49648. private _setupSkyboxMaterial;
  49649. /**
  49650. * Setup the skybox reflection texture according to the specified options.
  49651. */
  49652. private _setupSkyboxReflectionTexture;
  49653. private _errorHandler;
  49654. /**
  49655. * Dispose all the elements created by the Helper.
  49656. */
  49657. dispose(): void;
  49658. }
  49659. }
  49660. declare module "babylonjs/Helpers/photoDome" {
  49661. import { Observable } from "babylonjs/Misc/observable";
  49662. import { Nullable } from "babylonjs/types";
  49663. import { Scene } from "babylonjs/scene";
  49664. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49665. import { Mesh } from "babylonjs/Meshes/mesh";
  49666. import { Texture } from "babylonjs/Materials/Textures/texture";
  49667. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49668. import "babylonjs/Meshes/Builders/sphereBuilder";
  49669. /**
  49670. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49671. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49672. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49673. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49674. */
  49675. export class PhotoDome extends TransformNode {
  49676. /**
  49677. * Define the image as a Monoscopic panoramic 360 image.
  49678. */
  49679. static readonly MODE_MONOSCOPIC: number;
  49680. /**
  49681. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49682. */
  49683. static readonly MODE_TOPBOTTOM: number;
  49684. /**
  49685. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49686. */
  49687. static readonly MODE_SIDEBYSIDE: number;
  49688. private _useDirectMapping;
  49689. /**
  49690. * The texture being displayed on the sphere
  49691. */
  49692. protected _photoTexture: Texture;
  49693. /**
  49694. * Gets or sets the texture being displayed on the sphere
  49695. */
  49696. photoTexture: Texture;
  49697. /**
  49698. * Observable raised when an error occured while loading the 360 image
  49699. */
  49700. onLoadErrorObservable: Observable<string>;
  49701. /**
  49702. * The skybox material
  49703. */
  49704. protected _material: BackgroundMaterial;
  49705. /**
  49706. * The surface used for the skybox
  49707. */
  49708. protected _mesh: Mesh;
  49709. /**
  49710. * Gets the mesh used for the skybox.
  49711. */
  49712. readonly mesh: Mesh;
  49713. /**
  49714. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49715. * Also see the options.resolution property.
  49716. */
  49717. fovMultiplier: number;
  49718. private _imageMode;
  49719. /**
  49720. * Gets or set the current video mode for the video. It can be:
  49721. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49722. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49723. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49724. */
  49725. imageMode: number;
  49726. /**
  49727. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49728. * @param name Element's name, child elements will append suffixes for their own names.
  49729. * @param urlsOfPhoto defines the url of the photo to display
  49730. * @param options defines an object containing optional or exposed sub element properties
  49731. * @param onError defines a callback called when an error occured while loading the texture
  49732. */
  49733. constructor(name: string, urlOfPhoto: string, options: {
  49734. resolution?: number;
  49735. size?: number;
  49736. useDirectMapping?: boolean;
  49737. faceForward?: boolean;
  49738. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49739. private _onBeforeCameraRenderObserver;
  49740. private _changeImageMode;
  49741. /**
  49742. * Releases resources associated with this node.
  49743. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49744. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49745. */
  49746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49747. }
  49748. }
  49749. declare module "babylonjs/Misc/rgbdTextureTools" {
  49750. import "babylonjs/Shaders/rgbdDecode.fragment";
  49751. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49752. import { Texture } from "babylonjs/Materials/Textures/texture";
  49753. /**
  49754. * Class used to host RGBD texture specific utilities
  49755. */
  49756. export class RGBDTextureTools {
  49757. /**
  49758. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49759. * @param texture the texture to expand.
  49760. */
  49761. static ExpandRGBDTexture(texture: Texture): void;
  49762. }
  49763. }
  49764. declare module "babylonjs/Misc/brdfTextureTools" {
  49765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49766. import { Scene } from "babylonjs/scene";
  49767. /**
  49768. * Class used to host texture specific utilities
  49769. */
  49770. export class BRDFTextureTools {
  49771. /**
  49772. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49773. * @param scene defines the hosting scene
  49774. * @returns the environment BRDF texture
  49775. */
  49776. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49777. private static _environmentBRDFBase64Texture;
  49778. }
  49779. }
  49780. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49781. import { Nullable } from "babylonjs/types";
  49782. import { Color3 } from "babylonjs/Maths/math.color";
  49783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49784. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49785. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49786. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49787. import { Engine } from "babylonjs/Engines/engine";
  49788. import { Scene } from "babylonjs/scene";
  49789. /**
  49790. * @hidden
  49791. */
  49792. export interface IMaterialClearCoatDefines {
  49793. CLEARCOAT: boolean;
  49794. CLEARCOAT_DEFAULTIOR: boolean;
  49795. CLEARCOAT_TEXTURE: boolean;
  49796. CLEARCOAT_TEXTUREDIRECTUV: number;
  49797. CLEARCOAT_BUMP: boolean;
  49798. CLEARCOAT_BUMPDIRECTUV: number;
  49799. CLEARCOAT_TINT: boolean;
  49800. CLEARCOAT_TINT_TEXTURE: boolean;
  49801. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49802. /** @hidden */
  49803. _areTexturesDirty: boolean;
  49804. }
  49805. /**
  49806. * Define the code related to the clear coat parameters of the pbr material.
  49807. */
  49808. export class PBRClearCoatConfiguration {
  49809. /**
  49810. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49811. * The default fits with a polyurethane material.
  49812. */
  49813. private static readonly _DefaultIndexOfRefraction;
  49814. private _isEnabled;
  49815. /**
  49816. * Defines if the clear coat is enabled in the material.
  49817. */
  49818. isEnabled: boolean;
  49819. /**
  49820. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49821. */
  49822. intensity: number;
  49823. /**
  49824. * Defines the clear coat layer roughness.
  49825. */
  49826. roughness: number;
  49827. private _indexOfRefraction;
  49828. /**
  49829. * Defines the index of refraction of the clear coat.
  49830. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49831. * The default fits with a polyurethane material.
  49832. * Changing the default value is more performance intensive.
  49833. */
  49834. indexOfRefraction: number;
  49835. private _texture;
  49836. /**
  49837. * Stores the clear coat values in a texture.
  49838. */
  49839. texture: Nullable<BaseTexture>;
  49840. private _bumpTexture;
  49841. /**
  49842. * Define the clear coat specific bump texture.
  49843. */
  49844. bumpTexture: Nullable<BaseTexture>;
  49845. private _isTintEnabled;
  49846. /**
  49847. * Defines if the clear coat tint is enabled in the material.
  49848. */
  49849. isTintEnabled: boolean;
  49850. /**
  49851. * Defines the clear coat tint of the material.
  49852. * This is only use if tint is enabled
  49853. */
  49854. tintColor: Color3;
  49855. /**
  49856. * Defines the distance at which the tint color should be found in the
  49857. * clear coat media.
  49858. * This is only use if tint is enabled
  49859. */
  49860. tintColorAtDistance: number;
  49861. /**
  49862. * Defines the clear coat layer thickness.
  49863. * This is only use if tint is enabled
  49864. */
  49865. tintThickness: number;
  49866. private _tintTexture;
  49867. /**
  49868. * Stores the clear tint values in a texture.
  49869. * rgb is tint
  49870. * a is a thickness factor
  49871. */
  49872. tintTexture: Nullable<BaseTexture>;
  49873. /** @hidden */
  49874. private _internalMarkAllSubMeshesAsTexturesDirty;
  49875. /** @hidden */
  49876. _markAllSubMeshesAsTexturesDirty(): void;
  49877. /**
  49878. * Instantiate a new istance of clear coat configuration.
  49879. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49880. */
  49881. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49882. /**
  49883. * Gets wehter the submesh is ready to be used or not.
  49884. * @param defines the list of "defines" to update.
  49885. * @param scene defines the scene the material belongs to.
  49886. * @param engine defines the engine the material belongs to.
  49887. * @param disableBumpMap defines wether the material disables bump or not.
  49888. * @returns - boolean indicating that the submesh is ready or not.
  49889. */
  49890. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49891. /**
  49892. * Checks to see if a texture is used in the material.
  49893. * @param defines the list of "defines" to update.
  49894. * @param scene defines the scene to the material belongs to.
  49895. */
  49896. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49897. /**
  49898. * Binds the material data.
  49899. * @param uniformBuffer defines the Uniform buffer to fill in.
  49900. * @param scene defines the scene the material belongs to.
  49901. * @param engine defines the engine the material belongs to.
  49902. * @param disableBumpMap defines wether the material disables bump or not.
  49903. * @param isFrozen defines wether the material is frozen or not.
  49904. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49905. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49906. */
  49907. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49908. /**
  49909. * Checks to see if a texture is used in the material.
  49910. * @param texture - Base texture to use.
  49911. * @returns - Boolean specifying if a texture is used in the material.
  49912. */
  49913. hasTexture(texture: BaseTexture): boolean;
  49914. /**
  49915. * Returns an array of the actively used textures.
  49916. * @param activeTextures Array of BaseTextures
  49917. */
  49918. getActiveTextures(activeTextures: BaseTexture[]): void;
  49919. /**
  49920. * Returns the animatable textures.
  49921. * @param animatables Array of animatable textures.
  49922. */
  49923. getAnimatables(animatables: IAnimatable[]): void;
  49924. /**
  49925. * Disposes the resources of the material.
  49926. * @param forceDisposeTextures - Forces the disposal of all textures.
  49927. */
  49928. dispose(forceDisposeTextures?: boolean): void;
  49929. /**
  49930. * Get the current class name of the texture useful for serialization or dynamic coding.
  49931. * @returns "PBRClearCoatConfiguration"
  49932. */
  49933. getClassName(): string;
  49934. /**
  49935. * Add fallbacks to the effect fallbacks list.
  49936. * @param defines defines the Base texture to use.
  49937. * @param fallbacks defines the current fallback list.
  49938. * @param currentRank defines the current fallback rank.
  49939. * @returns the new fallback rank.
  49940. */
  49941. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49942. /**
  49943. * Add the required uniforms to the current list.
  49944. * @param uniforms defines the current uniform list.
  49945. */
  49946. static AddUniforms(uniforms: string[]): void;
  49947. /**
  49948. * Add the required samplers to the current list.
  49949. * @param samplers defines the current sampler list.
  49950. */
  49951. static AddSamplers(samplers: string[]): void;
  49952. /**
  49953. * Add the required uniforms to the current buffer.
  49954. * @param uniformBuffer defines the current uniform buffer.
  49955. */
  49956. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49957. /**
  49958. * Makes a duplicate of the current configuration into another one.
  49959. * @param clearCoatConfiguration define the config where to copy the info
  49960. */
  49961. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49962. /**
  49963. * Serializes this clear coat configuration.
  49964. * @returns - An object with the serialized config.
  49965. */
  49966. serialize(): any;
  49967. /**
  49968. * Parses a anisotropy Configuration from a serialized object.
  49969. * @param source - Serialized object.
  49970. * @param scene Defines the scene we are parsing for
  49971. * @param rootUrl Defines the rootUrl to load from
  49972. */
  49973. parse(source: any, scene: Scene, rootUrl: string): void;
  49974. }
  49975. }
  49976. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49977. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49979. import { Vector2 } from "babylonjs/Maths/math.vector";
  49980. import { Scene } from "babylonjs/scene";
  49981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49982. import { Nullable } from "babylonjs/types";
  49983. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49984. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49985. /**
  49986. * @hidden
  49987. */
  49988. export interface IMaterialAnisotropicDefines {
  49989. ANISOTROPIC: boolean;
  49990. ANISOTROPIC_TEXTURE: boolean;
  49991. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49992. MAINUV1: boolean;
  49993. _areTexturesDirty: boolean;
  49994. _needUVs: boolean;
  49995. }
  49996. /**
  49997. * Define the code related to the anisotropic parameters of the pbr material.
  49998. */
  49999. export class PBRAnisotropicConfiguration {
  50000. private _isEnabled;
  50001. /**
  50002. * Defines if the anisotropy is enabled in the material.
  50003. */
  50004. isEnabled: boolean;
  50005. /**
  50006. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50007. */
  50008. intensity: number;
  50009. /**
  50010. * Defines if the effect is along the tangents, bitangents or in between.
  50011. * By default, the effect is "strectching" the highlights along the tangents.
  50012. */
  50013. direction: Vector2;
  50014. private _texture;
  50015. /**
  50016. * Stores the anisotropy values in a texture.
  50017. * rg is direction (like normal from -1 to 1)
  50018. * b is a intensity
  50019. */
  50020. texture: Nullable<BaseTexture>;
  50021. /** @hidden */
  50022. private _internalMarkAllSubMeshesAsTexturesDirty;
  50023. /** @hidden */
  50024. _markAllSubMeshesAsTexturesDirty(): void;
  50025. /**
  50026. * Instantiate a new istance of anisotropy configuration.
  50027. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50028. */
  50029. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50030. /**
  50031. * Specifies that the submesh is ready to be used.
  50032. * @param defines the list of "defines" to update.
  50033. * @param scene defines the scene the material belongs to.
  50034. * @returns - boolean indicating that the submesh is ready or not.
  50035. */
  50036. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50037. /**
  50038. * Checks to see if a texture is used in the material.
  50039. * @param defines the list of "defines" to update.
  50040. * @param mesh the mesh we are preparing the defines for.
  50041. * @param scene defines the scene the material belongs to.
  50042. */
  50043. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50044. /**
  50045. * Binds the material data.
  50046. * @param uniformBuffer defines the Uniform buffer to fill in.
  50047. * @param scene defines the scene the material belongs to.
  50048. * @param isFrozen defines wether the material is frozen or not.
  50049. */
  50050. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50051. /**
  50052. * Checks to see if a texture is used in the material.
  50053. * @param texture - Base texture to use.
  50054. * @returns - Boolean specifying if a texture is used in the material.
  50055. */
  50056. hasTexture(texture: BaseTexture): boolean;
  50057. /**
  50058. * Returns an array of the actively used textures.
  50059. * @param activeTextures Array of BaseTextures
  50060. */
  50061. getActiveTextures(activeTextures: BaseTexture[]): void;
  50062. /**
  50063. * Returns the animatable textures.
  50064. * @param animatables Array of animatable textures.
  50065. */
  50066. getAnimatables(animatables: IAnimatable[]): void;
  50067. /**
  50068. * Disposes the resources of the material.
  50069. * @param forceDisposeTextures - Forces the disposal of all textures.
  50070. */
  50071. dispose(forceDisposeTextures?: boolean): void;
  50072. /**
  50073. * Get the current class name of the texture useful for serialization or dynamic coding.
  50074. * @returns "PBRAnisotropicConfiguration"
  50075. */
  50076. getClassName(): string;
  50077. /**
  50078. * Add fallbacks to the effect fallbacks list.
  50079. * @param defines defines the Base texture to use.
  50080. * @param fallbacks defines the current fallback list.
  50081. * @param currentRank defines the current fallback rank.
  50082. * @returns the new fallback rank.
  50083. */
  50084. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50085. /**
  50086. * Add the required uniforms to the current list.
  50087. * @param uniforms defines the current uniform list.
  50088. */
  50089. static AddUniforms(uniforms: string[]): void;
  50090. /**
  50091. * Add the required uniforms to the current buffer.
  50092. * @param uniformBuffer defines the current uniform buffer.
  50093. */
  50094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50095. /**
  50096. * Add the required samplers to the current list.
  50097. * @param samplers defines the current sampler list.
  50098. */
  50099. static AddSamplers(samplers: string[]): void;
  50100. /**
  50101. * Makes a duplicate of the current configuration into another one.
  50102. * @param anisotropicConfiguration define the config where to copy the info
  50103. */
  50104. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50105. /**
  50106. * Serializes this anisotropy configuration.
  50107. * @returns - An object with the serialized config.
  50108. */
  50109. serialize(): any;
  50110. /**
  50111. * Parses a anisotropy Configuration from a serialized object.
  50112. * @param source - Serialized object.
  50113. * @param scene Defines the scene we are parsing for
  50114. * @param rootUrl Defines the rootUrl to load from
  50115. */
  50116. parse(source: any, scene: Scene, rootUrl: string): void;
  50117. }
  50118. }
  50119. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  50120. import { Scene } from "babylonjs/scene";
  50121. /**
  50122. * @hidden
  50123. */
  50124. export interface IMaterialBRDFDefines {
  50125. BRDF_V_HEIGHT_CORRELATED: boolean;
  50126. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50127. SPHERICAL_HARMONICS: boolean;
  50128. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50129. /** @hidden */
  50130. _areMiscDirty: boolean;
  50131. }
  50132. /**
  50133. * Define the code related to the BRDF parameters of the pbr material.
  50134. */
  50135. export class PBRBRDFConfiguration {
  50136. /**
  50137. * Default value used for the energy conservation.
  50138. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50139. */
  50140. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50141. /**
  50142. * Default value used for the Smith Visibility Height Correlated mode.
  50143. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50144. */
  50145. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50146. /**
  50147. * Default value used for the IBL diffuse part.
  50148. * This can help switching back to the polynomials mode globally which is a tiny bit
  50149. * less GPU intensive at the drawback of a lower quality.
  50150. */
  50151. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50152. /**
  50153. * Default value used for activating energy conservation for the specular workflow.
  50154. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50155. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50156. */
  50157. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50158. private _useEnergyConservation;
  50159. /**
  50160. * Defines if the material uses energy conservation.
  50161. */
  50162. useEnergyConservation: boolean;
  50163. private _useSmithVisibilityHeightCorrelated;
  50164. /**
  50165. * LEGACY Mode set to false
  50166. * Defines if the material uses height smith correlated visibility term.
  50167. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50168. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50169. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50170. * Not relying on height correlated will also disable energy conservation.
  50171. */
  50172. useSmithVisibilityHeightCorrelated: boolean;
  50173. private _useSphericalHarmonics;
  50174. /**
  50175. * LEGACY Mode set to false
  50176. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50177. * diffuse part of the IBL.
  50178. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50179. * to the ground truth.
  50180. */
  50181. useSphericalHarmonics: boolean;
  50182. private _useSpecularGlossinessInputEnergyConservation;
  50183. /**
  50184. * Defines if the material uses energy conservation, when the specular workflow is active.
  50185. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50186. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50187. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50188. */
  50189. useSpecularGlossinessInputEnergyConservation: boolean;
  50190. /** @hidden */
  50191. private _internalMarkAllSubMeshesAsMiscDirty;
  50192. /** @hidden */
  50193. _markAllSubMeshesAsMiscDirty(): void;
  50194. /**
  50195. * Instantiate a new istance of clear coat configuration.
  50196. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50197. */
  50198. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50199. /**
  50200. * Checks to see if a texture is used in the material.
  50201. * @param defines the list of "defines" to update.
  50202. */
  50203. prepareDefines(defines: IMaterialBRDFDefines): void;
  50204. /**
  50205. * Get the current class name of the texture useful for serialization or dynamic coding.
  50206. * @returns "PBRClearCoatConfiguration"
  50207. */
  50208. getClassName(): string;
  50209. /**
  50210. * Makes a duplicate of the current configuration into another one.
  50211. * @param brdfConfiguration define the config where to copy the info
  50212. */
  50213. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50214. /**
  50215. * Serializes this BRDF configuration.
  50216. * @returns - An object with the serialized config.
  50217. */
  50218. serialize(): any;
  50219. /**
  50220. * Parses a anisotropy Configuration from a serialized object.
  50221. * @param source - Serialized object.
  50222. * @param scene Defines the scene we are parsing for
  50223. * @param rootUrl Defines the rootUrl to load from
  50224. */
  50225. parse(source: any, scene: Scene, rootUrl: string): void;
  50226. }
  50227. }
  50228. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  50229. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50230. import { Color3 } from "babylonjs/Maths/math.color";
  50231. import { Scene } from "babylonjs/scene";
  50232. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50233. import { Nullable } from "babylonjs/types";
  50234. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50235. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50236. /**
  50237. * @hidden
  50238. */
  50239. export interface IMaterialSheenDefines {
  50240. SHEEN: boolean;
  50241. SHEEN_TEXTURE: boolean;
  50242. SHEEN_TEXTUREDIRECTUV: number;
  50243. SHEEN_LINKWITHALBEDO: boolean;
  50244. /** @hidden */
  50245. _areTexturesDirty: boolean;
  50246. }
  50247. /**
  50248. * Define the code related to the Sheen parameters of the pbr material.
  50249. */
  50250. export class PBRSheenConfiguration {
  50251. private _isEnabled;
  50252. /**
  50253. * Defines if the material uses sheen.
  50254. */
  50255. isEnabled: boolean;
  50256. private _linkSheenWithAlbedo;
  50257. /**
  50258. * Defines if the sheen is linked to the sheen color.
  50259. */
  50260. linkSheenWithAlbedo: boolean;
  50261. /**
  50262. * Defines the sheen intensity.
  50263. */
  50264. intensity: number;
  50265. /**
  50266. * Defines the sheen color.
  50267. */
  50268. color: Color3;
  50269. private _texture;
  50270. /**
  50271. * Stores the sheen tint values in a texture.
  50272. * rgb is tint
  50273. * a is a intensity
  50274. */
  50275. texture: Nullable<BaseTexture>;
  50276. /** @hidden */
  50277. private _internalMarkAllSubMeshesAsTexturesDirty;
  50278. /** @hidden */
  50279. _markAllSubMeshesAsTexturesDirty(): void;
  50280. /**
  50281. * Instantiate a new istance of clear coat configuration.
  50282. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50283. */
  50284. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50285. /**
  50286. * Specifies that the submesh is ready to be used.
  50287. * @param defines the list of "defines" to update.
  50288. * @param scene defines the scene the material belongs to.
  50289. * @returns - boolean indicating that the submesh is ready or not.
  50290. */
  50291. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50292. /**
  50293. * Checks to see if a texture is used in the material.
  50294. * @param defines the list of "defines" to update.
  50295. * @param scene defines the scene the material belongs to.
  50296. */
  50297. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50298. /**
  50299. * Binds the material data.
  50300. * @param uniformBuffer defines the Uniform buffer to fill in.
  50301. * @param scene defines the scene the material belongs to.
  50302. * @param isFrozen defines wether the material is frozen or not.
  50303. */
  50304. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50305. /**
  50306. * Checks to see if a texture is used in the material.
  50307. * @param texture - Base texture to use.
  50308. * @returns - Boolean specifying if a texture is used in the material.
  50309. */
  50310. hasTexture(texture: BaseTexture): boolean;
  50311. /**
  50312. * Returns an array of the actively used textures.
  50313. * @param activeTextures Array of BaseTextures
  50314. */
  50315. getActiveTextures(activeTextures: BaseTexture[]): void;
  50316. /**
  50317. * Returns the animatable textures.
  50318. * @param animatables Array of animatable textures.
  50319. */
  50320. getAnimatables(animatables: IAnimatable[]): void;
  50321. /**
  50322. * Disposes the resources of the material.
  50323. * @param forceDisposeTextures - Forces the disposal of all textures.
  50324. */
  50325. dispose(forceDisposeTextures?: boolean): void;
  50326. /**
  50327. * Get the current class name of the texture useful for serialization or dynamic coding.
  50328. * @returns "PBRSheenConfiguration"
  50329. */
  50330. getClassName(): string;
  50331. /**
  50332. * Add fallbacks to the effect fallbacks list.
  50333. * @param defines defines the Base texture to use.
  50334. * @param fallbacks defines the current fallback list.
  50335. * @param currentRank defines the current fallback rank.
  50336. * @returns the new fallback rank.
  50337. */
  50338. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50339. /**
  50340. * Add the required uniforms to the current list.
  50341. * @param uniforms defines the current uniform list.
  50342. */
  50343. static AddUniforms(uniforms: string[]): void;
  50344. /**
  50345. * Add the required uniforms to the current buffer.
  50346. * @param uniformBuffer defines the current uniform buffer.
  50347. */
  50348. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50349. /**
  50350. * Add the required samplers to the current list.
  50351. * @param samplers defines the current sampler list.
  50352. */
  50353. static AddSamplers(samplers: string[]): void;
  50354. /**
  50355. * Makes a duplicate of the current configuration into another one.
  50356. * @param sheenConfiguration define the config where to copy the info
  50357. */
  50358. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50359. /**
  50360. * Serializes this BRDF configuration.
  50361. * @returns - An object with the serialized config.
  50362. */
  50363. serialize(): any;
  50364. /**
  50365. * Parses a anisotropy Configuration from a serialized object.
  50366. * @param source - Serialized object.
  50367. * @param scene Defines the scene we are parsing for
  50368. * @param rootUrl Defines the rootUrl to load from
  50369. */
  50370. parse(source: any, scene: Scene, rootUrl: string): void;
  50371. }
  50372. }
  50373. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  50374. import { Nullable } from "babylonjs/types";
  50375. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50376. import { Color3 } from "babylonjs/Maths/math.color";
  50377. import { SmartArray } from "babylonjs/Misc/smartArray";
  50378. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50379. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50380. import { Effect } from "babylonjs/Materials/effect";
  50381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50382. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50383. import { Engine } from "babylonjs/Engines/engine";
  50384. import { Scene } from "babylonjs/scene";
  50385. /**
  50386. * @hidden
  50387. */
  50388. export interface IMaterialSubSurfaceDefines {
  50389. SUBSURFACE: boolean;
  50390. SS_REFRACTION: boolean;
  50391. SS_TRANSLUCENCY: boolean;
  50392. SS_SCATERRING: boolean;
  50393. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50394. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50395. SS_REFRACTIONMAP_3D: boolean;
  50396. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50397. SS_LODINREFRACTIONALPHA: boolean;
  50398. SS_GAMMAREFRACTION: boolean;
  50399. SS_RGBDREFRACTION: boolean;
  50400. SS_LINEARSPECULARREFRACTION: boolean;
  50401. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50402. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50403. /** @hidden */
  50404. _areTexturesDirty: boolean;
  50405. }
  50406. /**
  50407. * Define the code related to the sub surface parameters of the pbr material.
  50408. */
  50409. export class PBRSubSurfaceConfiguration {
  50410. private _isRefractionEnabled;
  50411. /**
  50412. * Defines if the refraction is enabled in the material.
  50413. */
  50414. isRefractionEnabled: boolean;
  50415. private _isTranslucencyEnabled;
  50416. /**
  50417. * Defines if the translucency is enabled in the material.
  50418. */
  50419. isTranslucencyEnabled: boolean;
  50420. private _isScatteringEnabled;
  50421. /**
  50422. * Defines the refraction intensity of the material.
  50423. * The refraction when enabled replaces the Diffuse part of the material.
  50424. * The intensity helps transitionning between diffuse and refraction.
  50425. */
  50426. refractionIntensity: number;
  50427. /**
  50428. * Defines the translucency intensity of the material.
  50429. * When translucency has been enabled, this defines how much of the "translucency"
  50430. * is addded to the diffuse part of the material.
  50431. */
  50432. translucencyIntensity: number;
  50433. /**
  50434. * Defines the scattering intensity of the material.
  50435. * When scattering has been enabled, this defines how much of the "scattered light"
  50436. * is addded to the diffuse part of the material.
  50437. */
  50438. scatteringIntensity: number;
  50439. private _thicknessTexture;
  50440. /**
  50441. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50442. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50443. * 0 would mean minimumThickness
  50444. * 1 would mean maximumThickness
  50445. * The other channels might be use as a mask to vary the different effects intensity.
  50446. */
  50447. thicknessTexture: Nullable<BaseTexture>;
  50448. private _refractionTexture;
  50449. /**
  50450. * Defines the texture to use for refraction.
  50451. */
  50452. refractionTexture: Nullable<BaseTexture>;
  50453. private _indexOfRefraction;
  50454. /**
  50455. * Defines the index of refraction used in the material.
  50456. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50457. */
  50458. indexOfRefraction: number;
  50459. private _invertRefractionY;
  50460. /**
  50461. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50462. */
  50463. invertRefractionY: boolean;
  50464. private _linkRefractionWithTransparency;
  50465. /**
  50466. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50467. * Materials half opaque for instance using refraction could benefit from this control.
  50468. */
  50469. linkRefractionWithTransparency: boolean;
  50470. /**
  50471. * Defines the minimum thickness stored in the thickness map.
  50472. * If no thickness map is defined, this value will be used to simulate thickness.
  50473. */
  50474. minimumThickness: number;
  50475. /**
  50476. * Defines the maximum thickness stored in the thickness map.
  50477. */
  50478. maximumThickness: number;
  50479. /**
  50480. * Defines the volume tint of the material.
  50481. * This is used for both translucency and scattering.
  50482. */
  50483. tintColor: Color3;
  50484. /**
  50485. * Defines the distance at which the tint color should be found in the media.
  50486. * This is used for refraction only.
  50487. */
  50488. tintColorAtDistance: number;
  50489. /**
  50490. * Defines how far each channel transmit through the media.
  50491. * It is defined as a color to simplify it selection.
  50492. */
  50493. diffusionDistance: Color3;
  50494. private _useMaskFromThicknessTexture;
  50495. /**
  50496. * Stores the intensity of the different subsurface effects in the thickness texture.
  50497. * * the green channel is the translucency intensity.
  50498. * * the blue channel is the scattering intensity.
  50499. * * the alpha channel is the refraction intensity.
  50500. */
  50501. useMaskFromThicknessTexture: boolean;
  50502. /** @hidden */
  50503. private _internalMarkAllSubMeshesAsTexturesDirty;
  50504. /** @hidden */
  50505. _markAllSubMeshesAsTexturesDirty(): void;
  50506. /**
  50507. * Instantiate a new istance of sub surface configuration.
  50508. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50509. */
  50510. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50511. /**
  50512. * Gets wehter the submesh is ready to be used or not.
  50513. * @param defines the list of "defines" to update.
  50514. * @param scene defines the scene the material belongs to.
  50515. * @returns - boolean indicating that the submesh is ready or not.
  50516. */
  50517. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50518. /**
  50519. * Checks to see if a texture is used in the material.
  50520. * @param defines the list of "defines" to update.
  50521. * @param scene defines the scene to the material belongs to.
  50522. */
  50523. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50524. /**
  50525. * Binds the material data.
  50526. * @param uniformBuffer defines the Uniform buffer to fill in.
  50527. * @param scene defines the scene the material belongs to.
  50528. * @param engine defines the engine the material belongs to.
  50529. * @param isFrozen defines wether the material is frozen or not.
  50530. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50531. */
  50532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50533. /**
  50534. * Unbinds the material from the mesh.
  50535. * @param activeEffect defines the effect that should be unbound from.
  50536. * @returns true if unbound, otherwise false
  50537. */
  50538. unbind(activeEffect: Effect): boolean;
  50539. /**
  50540. * Returns the texture used for refraction or null if none is used.
  50541. * @param scene defines the scene the material belongs to.
  50542. * @returns - Refraction texture if present. If no refraction texture and refraction
  50543. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50544. */
  50545. private _getRefractionTexture;
  50546. /**
  50547. * Returns true if alpha blending should be disabled.
  50548. */
  50549. readonly disableAlphaBlending: boolean;
  50550. /**
  50551. * Fills the list of render target textures.
  50552. * @param renderTargets the list of render targets to update
  50553. */
  50554. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50555. /**
  50556. * Checks to see if a texture is used in the material.
  50557. * @param texture - Base texture to use.
  50558. * @returns - Boolean specifying if a texture is used in the material.
  50559. */
  50560. hasTexture(texture: BaseTexture): boolean;
  50561. /**
  50562. * Gets a boolean indicating that current material needs to register RTT
  50563. * @returns true if this uses a render target otherwise false.
  50564. */
  50565. hasRenderTargetTextures(): boolean;
  50566. /**
  50567. * Returns an array of the actively used textures.
  50568. * @param activeTextures Array of BaseTextures
  50569. */
  50570. getActiveTextures(activeTextures: BaseTexture[]): void;
  50571. /**
  50572. * Returns the animatable textures.
  50573. * @param animatables Array of animatable textures.
  50574. */
  50575. getAnimatables(animatables: IAnimatable[]): void;
  50576. /**
  50577. * Disposes the resources of the material.
  50578. * @param forceDisposeTextures - Forces the disposal of all textures.
  50579. */
  50580. dispose(forceDisposeTextures?: boolean): void;
  50581. /**
  50582. * Get the current class name of the texture useful for serialization or dynamic coding.
  50583. * @returns "PBRSubSurfaceConfiguration"
  50584. */
  50585. getClassName(): string;
  50586. /**
  50587. * Add fallbacks to the effect fallbacks list.
  50588. * @param defines defines the Base texture to use.
  50589. * @param fallbacks defines the current fallback list.
  50590. * @param currentRank defines the current fallback rank.
  50591. * @returns the new fallback rank.
  50592. */
  50593. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50594. /**
  50595. * Add the required uniforms to the current list.
  50596. * @param uniforms defines the current uniform list.
  50597. */
  50598. static AddUniforms(uniforms: string[]): void;
  50599. /**
  50600. * Add the required samplers to the current list.
  50601. * @param samplers defines the current sampler list.
  50602. */
  50603. static AddSamplers(samplers: string[]): void;
  50604. /**
  50605. * Add the required uniforms to the current buffer.
  50606. * @param uniformBuffer defines the current uniform buffer.
  50607. */
  50608. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50609. /**
  50610. * Makes a duplicate of the current configuration into another one.
  50611. * @param configuration define the config where to copy the info
  50612. */
  50613. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50614. /**
  50615. * Serializes this Sub Surface configuration.
  50616. * @returns - An object with the serialized config.
  50617. */
  50618. serialize(): any;
  50619. /**
  50620. * Parses a anisotropy Configuration from a serialized object.
  50621. * @param source - Serialized object.
  50622. * @param scene Defines the scene we are parsing for
  50623. * @param rootUrl Defines the rootUrl to load from
  50624. */
  50625. parse(source: any, scene: Scene, rootUrl: string): void;
  50626. }
  50627. }
  50628. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50629. /** @hidden */
  50630. export var pbrFragmentDeclaration: {
  50631. name: string;
  50632. shader: string;
  50633. };
  50634. }
  50635. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50636. /** @hidden */
  50637. export var pbrUboDeclaration: {
  50638. name: string;
  50639. shader: string;
  50640. };
  50641. }
  50642. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50643. /** @hidden */
  50644. export var pbrFragmentExtraDeclaration: {
  50645. name: string;
  50646. shader: string;
  50647. };
  50648. }
  50649. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50650. /** @hidden */
  50651. export var pbrFragmentSamplersDeclaration: {
  50652. name: string;
  50653. shader: string;
  50654. };
  50655. }
  50656. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50657. /** @hidden */
  50658. export var pbrHelperFunctions: {
  50659. name: string;
  50660. shader: string;
  50661. };
  50662. }
  50663. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50664. /** @hidden */
  50665. export var harmonicsFunctions: {
  50666. name: string;
  50667. shader: string;
  50668. };
  50669. }
  50670. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50671. /** @hidden */
  50672. export var pbrDirectLightingSetupFunctions: {
  50673. name: string;
  50674. shader: string;
  50675. };
  50676. }
  50677. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50678. /** @hidden */
  50679. export var pbrDirectLightingFalloffFunctions: {
  50680. name: string;
  50681. shader: string;
  50682. };
  50683. }
  50684. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50685. /** @hidden */
  50686. export var pbrBRDFFunctions: {
  50687. name: string;
  50688. shader: string;
  50689. };
  50690. }
  50691. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50692. /** @hidden */
  50693. export var pbrDirectLightingFunctions: {
  50694. name: string;
  50695. shader: string;
  50696. };
  50697. }
  50698. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50699. /** @hidden */
  50700. export var pbrIBLFunctions: {
  50701. name: string;
  50702. shader: string;
  50703. };
  50704. }
  50705. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50706. /** @hidden */
  50707. export var pbrDebug: {
  50708. name: string;
  50709. shader: string;
  50710. };
  50711. }
  50712. declare module "babylonjs/Shaders/pbr.fragment" {
  50713. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50714. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50715. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50716. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50717. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50718. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50719. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50721. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50722. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50723. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50724. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50725. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50726. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50727. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50728. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50729. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50730. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50731. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50732. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50733. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50734. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50735. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50736. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50737. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50738. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50739. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50740. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50741. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50742. /** @hidden */
  50743. export var pbrPixelShader: {
  50744. name: string;
  50745. shader: string;
  50746. };
  50747. }
  50748. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50749. /** @hidden */
  50750. export var pbrVertexDeclaration: {
  50751. name: string;
  50752. shader: string;
  50753. };
  50754. }
  50755. declare module "babylonjs/Shaders/pbr.vertex" {
  50756. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50757. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50758. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50759. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50760. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50761. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50762. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50763. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50764. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50765. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50766. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50767. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50769. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50770. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50771. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50772. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50773. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50774. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50775. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50776. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50777. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50778. /** @hidden */
  50779. export var pbrVertexShader: {
  50780. name: string;
  50781. shader: string;
  50782. };
  50783. }
  50784. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50785. import { Nullable } from "babylonjs/types";
  50786. import { Scene } from "babylonjs/scene";
  50787. import { Matrix } from "babylonjs/Maths/math.vector";
  50788. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50790. import { Mesh } from "babylonjs/Meshes/mesh";
  50791. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50792. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50793. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50794. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50795. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50796. import { Color3 } from "babylonjs/Maths/math.color";
  50797. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50798. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50799. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50800. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50802. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50803. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50804. import "babylonjs/Shaders/pbr.fragment";
  50805. import "babylonjs/Shaders/pbr.vertex";
  50806. /**
  50807. * Manages the defines for the PBR Material.
  50808. * @hidden
  50809. */
  50810. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50811. PBR: boolean;
  50812. MAINUV1: boolean;
  50813. MAINUV2: boolean;
  50814. UV1: boolean;
  50815. UV2: boolean;
  50816. ALBEDO: boolean;
  50817. ALBEDODIRECTUV: number;
  50818. VERTEXCOLOR: boolean;
  50819. AMBIENT: boolean;
  50820. AMBIENTDIRECTUV: number;
  50821. AMBIENTINGRAYSCALE: boolean;
  50822. OPACITY: boolean;
  50823. VERTEXALPHA: boolean;
  50824. OPACITYDIRECTUV: number;
  50825. OPACITYRGB: boolean;
  50826. ALPHATEST: boolean;
  50827. DEPTHPREPASS: boolean;
  50828. ALPHABLEND: boolean;
  50829. ALPHAFROMALBEDO: boolean;
  50830. ALPHATESTVALUE: string;
  50831. SPECULAROVERALPHA: boolean;
  50832. RADIANCEOVERALPHA: boolean;
  50833. ALPHAFRESNEL: boolean;
  50834. LINEARALPHAFRESNEL: boolean;
  50835. PREMULTIPLYALPHA: boolean;
  50836. EMISSIVE: boolean;
  50837. EMISSIVEDIRECTUV: number;
  50838. REFLECTIVITY: boolean;
  50839. REFLECTIVITYDIRECTUV: number;
  50840. SPECULARTERM: boolean;
  50841. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50842. MICROSURFACEAUTOMATIC: boolean;
  50843. LODBASEDMICROSFURACE: boolean;
  50844. MICROSURFACEMAP: boolean;
  50845. MICROSURFACEMAPDIRECTUV: number;
  50846. METALLICWORKFLOW: boolean;
  50847. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50848. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50849. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50850. AOSTOREINMETALMAPRED: boolean;
  50851. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50852. ENVIRONMENTBRDF: boolean;
  50853. ENVIRONMENTBRDF_RGBD: boolean;
  50854. NORMAL: boolean;
  50855. TANGENT: boolean;
  50856. BUMP: boolean;
  50857. BUMPDIRECTUV: number;
  50858. OBJECTSPACE_NORMALMAP: boolean;
  50859. PARALLAX: boolean;
  50860. PARALLAXOCCLUSION: boolean;
  50861. NORMALXYSCALE: boolean;
  50862. LIGHTMAP: boolean;
  50863. LIGHTMAPDIRECTUV: number;
  50864. USELIGHTMAPASSHADOWMAP: boolean;
  50865. GAMMALIGHTMAP: boolean;
  50866. RGBDLIGHTMAP: boolean;
  50867. REFLECTION: boolean;
  50868. REFLECTIONMAP_3D: boolean;
  50869. REFLECTIONMAP_SPHERICAL: boolean;
  50870. REFLECTIONMAP_PLANAR: boolean;
  50871. REFLECTIONMAP_CUBIC: boolean;
  50872. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50873. REFLECTIONMAP_PROJECTION: boolean;
  50874. REFLECTIONMAP_SKYBOX: boolean;
  50875. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50876. REFLECTIONMAP_EXPLICIT: boolean;
  50877. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50878. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50879. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50880. INVERTCUBICMAP: boolean;
  50881. USESPHERICALFROMREFLECTIONMAP: boolean;
  50882. USEIRRADIANCEMAP: boolean;
  50883. SPHERICAL_HARMONICS: boolean;
  50884. USESPHERICALINVERTEX: boolean;
  50885. REFLECTIONMAP_OPPOSITEZ: boolean;
  50886. LODINREFLECTIONALPHA: boolean;
  50887. GAMMAREFLECTION: boolean;
  50888. RGBDREFLECTION: boolean;
  50889. LINEARSPECULARREFLECTION: boolean;
  50890. RADIANCEOCCLUSION: boolean;
  50891. HORIZONOCCLUSION: boolean;
  50892. INSTANCES: boolean;
  50893. NUM_BONE_INFLUENCERS: number;
  50894. BonesPerMesh: number;
  50895. BONETEXTURE: boolean;
  50896. NONUNIFORMSCALING: boolean;
  50897. MORPHTARGETS: boolean;
  50898. MORPHTARGETS_NORMAL: boolean;
  50899. MORPHTARGETS_TANGENT: boolean;
  50900. MORPHTARGETS_UV: boolean;
  50901. NUM_MORPH_INFLUENCERS: number;
  50902. IMAGEPROCESSING: boolean;
  50903. VIGNETTE: boolean;
  50904. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50905. VIGNETTEBLENDMODEOPAQUE: boolean;
  50906. TONEMAPPING: boolean;
  50907. TONEMAPPING_ACES: boolean;
  50908. CONTRAST: boolean;
  50909. COLORCURVES: boolean;
  50910. COLORGRADING: boolean;
  50911. COLORGRADING3D: boolean;
  50912. SAMPLER3DGREENDEPTH: boolean;
  50913. SAMPLER3DBGRMAP: boolean;
  50914. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50915. EXPOSURE: boolean;
  50916. MULTIVIEW: boolean;
  50917. USEPHYSICALLIGHTFALLOFF: boolean;
  50918. USEGLTFLIGHTFALLOFF: boolean;
  50919. TWOSIDEDLIGHTING: boolean;
  50920. SHADOWFLOAT: boolean;
  50921. CLIPPLANE: boolean;
  50922. CLIPPLANE2: boolean;
  50923. CLIPPLANE3: boolean;
  50924. CLIPPLANE4: boolean;
  50925. POINTSIZE: boolean;
  50926. FOG: boolean;
  50927. LOGARITHMICDEPTH: boolean;
  50928. FORCENORMALFORWARD: boolean;
  50929. SPECULARAA: boolean;
  50930. CLEARCOAT: boolean;
  50931. CLEARCOAT_DEFAULTIOR: boolean;
  50932. CLEARCOAT_TEXTURE: boolean;
  50933. CLEARCOAT_TEXTUREDIRECTUV: number;
  50934. CLEARCOAT_BUMP: boolean;
  50935. CLEARCOAT_BUMPDIRECTUV: number;
  50936. CLEARCOAT_TINT: boolean;
  50937. CLEARCOAT_TINT_TEXTURE: boolean;
  50938. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50939. ANISOTROPIC: boolean;
  50940. ANISOTROPIC_TEXTURE: boolean;
  50941. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50942. BRDF_V_HEIGHT_CORRELATED: boolean;
  50943. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50944. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50945. SHEEN: boolean;
  50946. SHEEN_TEXTURE: boolean;
  50947. SHEEN_TEXTUREDIRECTUV: number;
  50948. SHEEN_LINKWITHALBEDO: boolean;
  50949. SUBSURFACE: boolean;
  50950. SS_REFRACTION: boolean;
  50951. SS_TRANSLUCENCY: boolean;
  50952. SS_SCATERRING: boolean;
  50953. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50954. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50955. SS_REFRACTIONMAP_3D: boolean;
  50956. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50957. SS_LODINREFRACTIONALPHA: boolean;
  50958. SS_GAMMAREFRACTION: boolean;
  50959. SS_RGBDREFRACTION: boolean;
  50960. SS_LINEARSPECULARREFRACTION: boolean;
  50961. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50962. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50963. UNLIT: boolean;
  50964. DEBUGMODE: number;
  50965. /**
  50966. * Initializes the PBR Material defines.
  50967. */
  50968. constructor();
  50969. /**
  50970. * Resets the PBR Material defines.
  50971. */
  50972. reset(): void;
  50973. }
  50974. /**
  50975. * The Physically based material base class of BJS.
  50976. *
  50977. * This offers the main features of a standard PBR material.
  50978. * For more information, please refer to the documentation :
  50979. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50980. */
  50981. export abstract class PBRBaseMaterial extends PushMaterial {
  50982. /**
  50983. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50984. */
  50985. static readonly PBRMATERIAL_OPAQUE: number;
  50986. /**
  50987. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50988. */
  50989. static readonly PBRMATERIAL_ALPHATEST: number;
  50990. /**
  50991. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50992. */
  50993. static readonly PBRMATERIAL_ALPHABLEND: number;
  50994. /**
  50995. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50996. * They are also discarded below the alpha cutoff threshold to improve performances.
  50997. */
  50998. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50999. /**
  51000. * Defines the default value of how much AO map is occluding the analytical lights
  51001. * (point spot...).
  51002. */
  51003. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51004. /**
  51005. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51006. */
  51007. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51008. /**
  51009. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51010. * to enhance interoperability with other engines.
  51011. */
  51012. static readonly LIGHTFALLOFF_GLTF: number;
  51013. /**
  51014. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51015. * to enhance interoperability with other materials.
  51016. */
  51017. static readonly LIGHTFALLOFF_STANDARD: number;
  51018. /**
  51019. * Intensity of the direct lights e.g. the four lights available in your scene.
  51020. * This impacts both the direct diffuse and specular highlights.
  51021. */
  51022. protected _directIntensity: number;
  51023. /**
  51024. * Intensity of the emissive part of the material.
  51025. * This helps controlling the emissive effect without modifying the emissive color.
  51026. */
  51027. protected _emissiveIntensity: number;
  51028. /**
  51029. * Intensity of the environment e.g. how much the environment will light the object
  51030. * either through harmonics for rough material or through the refelction for shiny ones.
  51031. */
  51032. protected _environmentIntensity: number;
  51033. /**
  51034. * This is a special control allowing the reduction of the specular highlights coming from the
  51035. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51036. */
  51037. protected _specularIntensity: number;
  51038. /**
  51039. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51040. */
  51041. private _lightingInfos;
  51042. /**
  51043. * Debug Control allowing disabling the bump map on this material.
  51044. */
  51045. protected _disableBumpMap: boolean;
  51046. /**
  51047. * AKA Diffuse Texture in standard nomenclature.
  51048. */
  51049. protected _albedoTexture: Nullable<BaseTexture>;
  51050. /**
  51051. * AKA Occlusion Texture in other nomenclature.
  51052. */
  51053. protected _ambientTexture: Nullable<BaseTexture>;
  51054. /**
  51055. * AKA Occlusion Texture Intensity in other nomenclature.
  51056. */
  51057. protected _ambientTextureStrength: number;
  51058. /**
  51059. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51060. * 1 means it completely occludes it
  51061. * 0 mean it has no impact
  51062. */
  51063. protected _ambientTextureImpactOnAnalyticalLights: number;
  51064. /**
  51065. * Stores the alpha values in a texture.
  51066. */
  51067. protected _opacityTexture: Nullable<BaseTexture>;
  51068. /**
  51069. * Stores the reflection values in a texture.
  51070. */
  51071. protected _reflectionTexture: Nullable<BaseTexture>;
  51072. /**
  51073. * Stores the emissive values in a texture.
  51074. */
  51075. protected _emissiveTexture: Nullable<BaseTexture>;
  51076. /**
  51077. * AKA Specular texture in other nomenclature.
  51078. */
  51079. protected _reflectivityTexture: Nullable<BaseTexture>;
  51080. /**
  51081. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51082. */
  51083. protected _metallicTexture: Nullable<BaseTexture>;
  51084. /**
  51085. * Specifies the metallic scalar of the metallic/roughness workflow.
  51086. * Can also be used to scale the metalness values of the metallic texture.
  51087. */
  51088. protected _metallic: Nullable<number>;
  51089. /**
  51090. * Specifies the roughness scalar of the metallic/roughness workflow.
  51091. * Can also be used to scale the roughness values of the metallic texture.
  51092. */
  51093. protected _roughness: Nullable<number>;
  51094. /**
  51095. * Specifies the an F0 factor to help configuring the material F0.
  51096. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51097. * to 0.5 the previously hard coded value stays the same.
  51098. * Can also be used to scale the F0 values of the metallic texture.
  51099. */
  51100. protected _metallicF0Factor: number;
  51101. /**
  51102. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51103. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51104. * your expectation as it multiplies with the texture data.
  51105. */
  51106. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51107. /**
  51108. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51109. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51110. */
  51111. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51112. /**
  51113. * Stores surface normal data used to displace a mesh in a texture.
  51114. */
  51115. protected _bumpTexture: Nullable<BaseTexture>;
  51116. /**
  51117. * Stores the pre-calculated light information of a mesh in a texture.
  51118. */
  51119. protected _lightmapTexture: Nullable<BaseTexture>;
  51120. /**
  51121. * The color of a material in ambient lighting.
  51122. */
  51123. protected _ambientColor: Color3;
  51124. /**
  51125. * AKA Diffuse Color in other nomenclature.
  51126. */
  51127. protected _albedoColor: Color3;
  51128. /**
  51129. * AKA Specular Color in other nomenclature.
  51130. */
  51131. protected _reflectivityColor: Color3;
  51132. /**
  51133. * The color applied when light is reflected from a material.
  51134. */
  51135. protected _reflectionColor: Color3;
  51136. /**
  51137. * The color applied when light is emitted from a material.
  51138. */
  51139. protected _emissiveColor: Color3;
  51140. /**
  51141. * AKA Glossiness in other nomenclature.
  51142. */
  51143. protected _microSurface: number;
  51144. /**
  51145. * Specifies that the material will use the light map as a show map.
  51146. */
  51147. protected _useLightmapAsShadowmap: boolean;
  51148. /**
  51149. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51150. * makes the reflect vector face the model (under horizon).
  51151. */
  51152. protected _useHorizonOcclusion: boolean;
  51153. /**
  51154. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51155. * too much the area relying on ambient texture to define their ambient occlusion.
  51156. */
  51157. protected _useRadianceOcclusion: boolean;
  51158. /**
  51159. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51160. */
  51161. protected _useAlphaFromAlbedoTexture: boolean;
  51162. /**
  51163. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51164. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51165. */
  51166. protected _useSpecularOverAlpha: boolean;
  51167. /**
  51168. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51169. */
  51170. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51171. /**
  51172. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51173. */
  51174. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51175. /**
  51176. * Specifies if the metallic texture contains the roughness information in its green channel.
  51177. */
  51178. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51179. /**
  51180. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51181. */
  51182. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51183. /**
  51184. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51185. */
  51186. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51187. /**
  51188. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51189. */
  51190. protected _useAmbientInGrayScale: boolean;
  51191. /**
  51192. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51193. * The material will try to infer what glossiness each pixel should be.
  51194. */
  51195. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51196. /**
  51197. * Defines the falloff type used in this material.
  51198. * It by default is Physical.
  51199. */
  51200. protected _lightFalloff: number;
  51201. /**
  51202. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51203. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51204. */
  51205. protected _useRadianceOverAlpha: boolean;
  51206. /**
  51207. * Allows using an object space normal map (instead of tangent space).
  51208. */
  51209. protected _useObjectSpaceNormalMap: boolean;
  51210. /**
  51211. * Allows using the bump map in parallax mode.
  51212. */
  51213. protected _useParallax: boolean;
  51214. /**
  51215. * Allows using the bump map in parallax occlusion mode.
  51216. */
  51217. protected _useParallaxOcclusion: boolean;
  51218. /**
  51219. * Controls the scale bias of the parallax mode.
  51220. */
  51221. protected _parallaxScaleBias: number;
  51222. /**
  51223. * If sets to true, disables all the lights affecting the material.
  51224. */
  51225. protected _disableLighting: boolean;
  51226. /**
  51227. * Number of Simultaneous lights allowed on the material.
  51228. */
  51229. protected _maxSimultaneousLights: number;
  51230. /**
  51231. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51232. */
  51233. protected _invertNormalMapX: boolean;
  51234. /**
  51235. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51236. */
  51237. protected _invertNormalMapY: boolean;
  51238. /**
  51239. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51240. */
  51241. protected _twoSidedLighting: boolean;
  51242. /**
  51243. * Defines the alpha limits in alpha test mode.
  51244. */
  51245. protected _alphaCutOff: number;
  51246. /**
  51247. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51248. */
  51249. protected _forceAlphaTest: boolean;
  51250. /**
  51251. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51252. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51253. */
  51254. protected _useAlphaFresnel: boolean;
  51255. /**
  51256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51257. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51258. */
  51259. protected _useLinearAlphaFresnel: boolean;
  51260. /**
  51261. * The transparency mode of the material.
  51262. */
  51263. protected _transparencyMode: Nullable<number>;
  51264. /**
  51265. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51266. * from cos thetav and roughness:
  51267. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51268. */
  51269. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51270. /**
  51271. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51272. */
  51273. protected _forceIrradianceInFragment: boolean;
  51274. /**
  51275. * Force normal to face away from face.
  51276. */
  51277. protected _forceNormalForward: boolean;
  51278. /**
  51279. * Enables specular anti aliasing in the PBR shader.
  51280. * It will both interacts on the Geometry for analytical and IBL lighting.
  51281. * It also prefilter the roughness map based on the bump values.
  51282. */
  51283. protected _enableSpecularAntiAliasing: boolean;
  51284. /**
  51285. * Default configuration related to image processing available in the PBR Material.
  51286. */
  51287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51288. /**
  51289. * Keep track of the image processing observer to allow dispose and replace.
  51290. */
  51291. private _imageProcessingObserver;
  51292. /**
  51293. * Attaches a new image processing configuration to the PBR Material.
  51294. * @param configuration
  51295. */
  51296. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51297. /**
  51298. * Stores the available render targets.
  51299. */
  51300. private _renderTargets;
  51301. /**
  51302. * Sets the global ambient color for the material used in lighting calculations.
  51303. */
  51304. private _globalAmbientColor;
  51305. /**
  51306. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51307. */
  51308. private _useLogarithmicDepth;
  51309. /**
  51310. * If set to true, no lighting calculations will be applied.
  51311. */
  51312. private _unlit;
  51313. private _debugMode;
  51314. /**
  51315. * @hidden
  51316. * This is reserved for the inspector.
  51317. * Defines the material debug mode.
  51318. * It helps seeing only some components of the material while troubleshooting.
  51319. */
  51320. debugMode: number;
  51321. /**
  51322. * @hidden
  51323. * This is reserved for the inspector.
  51324. * Specify from where on screen the debug mode should start.
  51325. * The value goes from -1 (full screen) to 1 (not visible)
  51326. * It helps with side by side comparison against the final render
  51327. * This defaults to -1
  51328. */
  51329. private debugLimit;
  51330. /**
  51331. * @hidden
  51332. * This is reserved for the inspector.
  51333. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51334. * You can use the factor to better multiply the final value.
  51335. */
  51336. private debugFactor;
  51337. /**
  51338. * Defines the clear coat layer parameters for the material.
  51339. */
  51340. readonly clearCoat: PBRClearCoatConfiguration;
  51341. /**
  51342. * Defines the anisotropic parameters for the material.
  51343. */
  51344. readonly anisotropy: PBRAnisotropicConfiguration;
  51345. /**
  51346. * Defines the BRDF parameters for the material.
  51347. */
  51348. readonly brdf: PBRBRDFConfiguration;
  51349. /**
  51350. * Defines the Sheen parameters for the material.
  51351. */
  51352. readonly sheen: PBRSheenConfiguration;
  51353. /**
  51354. * Defines the SubSurface parameters for the material.
  51355. */
  51356. readonly subSurface: PBRSubSurfaceConfiguration;
  51357. /**
  51358. * Custom callback helping to override the default shader used in the material.
  51359. */
  51360. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51361. protected _rebuildInParallel: boolean;
  51362. /**
  51363. * Instantiates a new PBRMaterial instance.
  51364. *
  51365. * @param name The material name
  51366. * @param scene The scene the material will be use in.
  51367. */
  51368. constructor(name: string, scene: Scene);
  51369. /**
  51370. * Gets a boolean indicating that current material needs to register RTT
  51371. */
  51372. readonly hasRenderTargetTextures: boolean;
  51373. /**
  51374. * Gets the name of the material class.
  51375. */
  51376. getClassName(): string;
  51377. /**
  51378. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51379. */
  51380. /**
  51381. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51382. */
  51383. useLogarithmicDepth: boolean;
  51384. /**
  51385. * Gets the current transparency mode.
  51386. */
  51387. /**
  51388. * Sets the transparency mode of the material.
  51389. *
  51390. * | Value | Type | Description |
  51391. * | ----- | ----------------------------------- | ----------- |
  51392. * | 0 | OPAQUE | |
  51393. * | 1 | ALPHATEST | |
  51394. * | 2 | ALPHABLEND | |
  51395. * | 3 | ALPHATESTANDBLEND | |
  51396. *
  51397. */
  51398. transparencyMode: Nullable<number>;
  51399. /**
  51400. * Returns true if alpha blending should be disabled.
  51401. */
  51402. private readonly _disableAlphaBlending;
  51403. /**
  51404. * Specifies whether or not this material should be rendered in alpha blend mode.
  51405. */
  51406. needAlphaBlending(): boolean;
  51407. /**
  51408. * Specifies if the mesh will require alpha blending.
  51409. * @param mesh - BJS mesh.
  51410. */
  51411. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51412. /**
  51413. * Specifies whether or not this material should be rendered in alpha test mode.
  51414. */
  51415. needAlphaTesting(): boolean;
  51416. /**
  51417. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51418. */
  51419. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51420. /**
  51421. * Gets the texture used for the alpha test.
  51422. */
  51423. getAlphaTestTexture(): Nullable<BaseTexture>;
  51424. /**
  51425. * Specifies that the submesh is ready to be used.
  51426. * @param mesh - BJS mesh.
  51427. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51428. * @param useInstances - Specifies that instances should be used.
  51429. * @returns - boolean indicating that the submesh is ready or not.
  51430. */
  51431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51432. /**
  51433. * Specifies if the material uses metallic roughness workflow.
  51434. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51435. */
  51436. isMetallicWorkflow(): boolean;
  51437. private _prepareEffect;
  51438. private _prepareDefines;
  51439. /**
  51440. * Force shader compilation
  51441. */
  51442. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51443. /**
  51444. * Initializes the uniform buffer layout for the shader.
  51445. */
  51446. buildUniformLayout(): void;
  51447. /**
  51448. * Unbinds the material from the mesh
  51449. */
  51450. unbind(): void;
  51451. /**
  51452. * Binds the submesh data.
  51453. * @param world - The world matrix.
  51454. * @param mesh - The BJS mesh.
  51455. * @param subMesh - A submesh of the BJS mesh.
  51456. */
  51457. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51458. /**
  51459. * Returns the animatable textures.
  51460. * @returns - Array of animatable textures.
  51461. */
  51462. getAnimatables(): IAnimatable[];
  51463. /**
  51464. * Returns the texture used for reflections.
  51465. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51466. */
  51467. private _getReflectionTexture;
  51468. /**
  51469. * Returns an array of the actively used textures.
  51470. * @returns - Array of BaseTextures
  51471. */
  51472. getActiveTextures(): BaseTexture[];
  51473. /**
  51474. * Checks to see if a texture is used in the material.
  51475. * @param texture - Base texture to use.
  51476. * @returns - Boolean specifying if a texture is used in the material.
  51477. */
  51478. hasTexture(texture: BaseTexture): boolean;
  51479. /**
  51480. * Disposes the resources of the material.
  51481. * @param forceDisposeEffect - Forces the disposal of effects.
  51482. * @param forceDisposeTextures - Forces the disposal of all textures.
  51483. */
  51484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51485. }
  51486. }
  51487. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51488. import { Nullable } from "babylonjs/types";
  51489. import { Scene } from "babylonjs/scene";
  51490. import { Color3 } from "babylonjs/Maths/math.color";
  51491. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51492. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51494. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51495. /**
  51496. * The Physically based material of BJS.
  51497. *
  51498. * This offers the main features of a standard PBR material.
  51499. * For more information, please refer to the documentation :
  51500. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51501. */
  51502. export class PBRMaterial extends PBRBaseMaterial {
  51503. /**
  51504. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51505. */
  51506. static readonly PBRMATERIAL_OPAQUE: number;
  51507. /**
  51508. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51509. */
  51510. static readonly PBRMATERIAL_ALPHATEST: number;
  51511. /**
  51512. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51513. */
  51514. static readonly PBRMATERIAL_ALPHABLEND: number;
  51515. /**
  51516. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51517. * They are also discarded below the alpha cutoff threshold to improve performances.
  51518. */
  51519. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51520. /**
  51521. * Defines the default value of how much AO map is occluding the analytical lights
  51522. * (point spot...).
  51523. */
  51524. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51525. /**
  51526. * Intensity of the direct lights e.g. the four lights available in your scene.
  51527. * This impacts both the direct diffuse and specular highlights.
  51528. */
  51529. directIntensity: number;
  51530. /**
  51531. * Intensity of the emissive part of the material.
  51532. * This helps controlling the emissive effect without modifying the emissive color.
  51533. */
  51534. emissiveIntensity: number;
  51535. /**
  51536. * Intensity of the environment e.g. how much the environment will light the object
  51537. * either through harmonics for rough material or through the refelction for shiny ones.
  51538. */
  51539. environmentIntensity: number;
  51540. /**
  51541. * This is a special control allowing the reduction of the specular highlights coming from the
  51542. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51543. */
  51544. specularIntensity: number;
  51545. /**
  51546. * Debug Control allowing disabling the bump map on this material.
  51547. */
  51548. disableBumpMap: boolean;
  51549. /**
  51550. * AKA Diffuse Texture in standard nomenclature.
  51551. */
  51552. albedoTexture: BaseTexture;
  51553. /**
  51554. * AKA Occlusion Texture in other nomenclature.
  51555. */
  51556. ambientTexture: BaseTexture;
  51557. /**
  51558. * AKA Occlusion Texture Intensity in other nomenclature.
  51559. */
  51560. ambientTextureStrength: number;
  51561. /**
  51562. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51563. * 1 means it completely occludes it
  51564. * 0 mean it has no impact
  51565. */
  51566. ambientTextureImpactOnAnalyticalLights: number;
  51567. /**
  51568. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51569. */
  51570. opacityTexture: BaseTexture;
  51571. /**
  51572. * Stores the reflection values in a texture.
  51573. */
  51574. reflectionTexture: Nullable<BaseTexture>;
  51575. /**
  51576. * Stores the emissive values in a texture.
  51577. */
  51578. emissiveTexture: BaseTexture;
  51579. /**
  51580. * AKA Specular texture in other nomenclature.
  51581. */
  51582. reflectivityTexture: BaseTexture;
  51583. /**
  51584. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51585. */
  51586. metallicTexture: BaseTexture;
  51587. /**
  51588. * Specifies the metallic scalar of the metallic/roughness workflow.
  51589. * Can also be used to scale the metalness values of the metallic texture.
  51590. */
  51591. metallic: Nullable<number>;
  51592. /**
  51593. * Specifies the roughness scalar of the metallic/roughness workflow.
  51594. * Can also be used to scale the roughness values of the metallic texture.
  51595. */
  51596. roughness: Nullable<number>;
  51597. /**
  51598. * Specifies the an F0 factor to help configuring the material F0.
  51599. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51600. * to 0.5 the previously hard coded value stays the same.
  51601. * Can also be used to scale the F0 values of the metallic texture.
  51602. */
  51603. metallicF0Factor: number;
  51604. /**
  51605. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51606. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51607. * your expectation as it multiplies with the texture data.
  51608. */
  51609. useMetallicF0FactorFromMetallicTexture: boolean;
  51610. /**
  51611. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51612. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51613. */
  51614. microSurfaceTexture: BaseTexture;
  51615. /**
  51616. * Stores surface normal data used to displace a mesh in a texture.
  51617. */
  51618. bumpTexture: BaseTexture;
  51619. /**
  51620. * Stores the pre-calculated light information of a mesh in a texture.
  51621. */
  51622. lightmapTexture: BaseTexture;
  51623. /**
  51624. * Stores the refracted light information in a texture.
  51625. */
  51626. refractionTexture: Nullable<BaseTexture>;
  51627. /**
  51628. * The color of a material in ambient lighting.
  51629. */
  51630. ambientColor: Color3;
  51631. /**
  51632. * AKA Diffuse Color in other nomenclature.
  51633. */
  51634. albedoColor: Color3;
  51635. /**
  51636. * AKA Specular Color in other nomenclature.
  51637. */
  51638. reflectivityColor: Color3;
  51639. /**
  51640. * The color reflected from the material.
  51641. */
  51642. reflectionColor: Color3;
  51643. /**
  51644. * The color emitted from the material.
  51645. */
  51646. emissiveColor: Color3;
  51647. /**
  51648. * AKA Glossiness in other nomenclature.
  51649. */
  51650. microSurface: number;
  51651. /**
  51652. * source material index of refraction (IOR)' / 'destination material IOR.
  51653. */
  51654. indexOfRefraction: number;
  51655. /**
  51656. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51657. */
  51658. invertRefractionY: boolean;
  51659. /**
  51660. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51661. * Materials half opaque for instance using refraction could benefit from this control.
  51662. */
  51663. linkRefractionWithTransparency: boolean;
  51664. /**
  51665. * If true, the light map contains occlusion information instead of lighting info.
  51666. */
  51667. useLightmapAsShadowmap: boolean;
  51668. /**
  51669. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51670. */
  51671. useAlphaFromAlbedoTexture: boolean;
  51672. /**
  51673. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51674. */
  51675. forceAlphaTest: boolean;
  51676. /**
  51677. * Defines the alpha limits in alpha test mode.
  51678. */
  51679. alphaCutOff: number;
  51680. /**
  51681. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51682. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51683. */
  51684. useSpecularOverAlpha: boolean;
  51685. /**
  51686. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51687. */
  51688. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51689. /**
  51690. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51691. */
  51692. useRoughnessFromMetallicTextureAlpha: boolean;
  51693. /**
  51694. * Specifies if the metallic texture contains the roughness information in its green channel.
  51695. */
  51696. useRoughnessFromMetallicTextureGreen: boolean;
  51697. /**
  51698. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51699. */
  51700. useMetallnessFromMetallicTextureBlue: boolean;
  51701. /**
  51702. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51703. */
  51704. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51705. /**
  51706. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51707. */
  51708. useAmbientInGrayScale: boolean;
  51709. /**
  51710. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51711. * The material will try to infer what glossiness each pixel should be.
  51712. */
  51713. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51714. /**
  51715. * BJS is using an harcoded light falloff based on a manually sets up range.
  51716. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51717. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51718. */
  51719. /**
  51720. * BJS is using an harcoded light falloff based on a manually sets up range.
  51721. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51722. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51723. */
  51724. usePhysicalLightFalloff: boolean;
  51725. /**
  51726. * In order to support the falloff compatibility with gltf, a special mode has been added
  51727. * to reproduce the gltf light falloff.
  51728. */
  51729. /**
  51730. * In order to support the falloff compatibility with gltf, a special mode has been added
  51731. * to reproduce the gltf light falloff.
  51732. */
  51733. useGLTFLightFalloff: boolean;
  51734. /**
  51735. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51736. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51737. */
  51738. useRadianceOverAlpha: boolean;
  51739. /**
  51740. * Allows using an object space normal map (instead of tangent space).
  51741. */
  51742. useObjectSpaceNormalMap: boolean;
  51743. /**
  51744. * Allows using the bump map in parallax mode.
  51745. */
  51746. useParallax: boolean;
  51747. /**
  51748. * Allows using the bump map in parallax occlusion mode.
  51749. */
  51750. useParallaxOcclusion: boolean;
  51751. /**
  51752. * Controls the scale bias of the parallax mode.
  51753. */
  51754. parallaxScaleBias: number;
  51755. /**
  51756. * If sets to true, disables all the lights affecting the material.
  51757. */
  51758. disableLighting: boolean;
  51759. /**
  51760. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51761. */
  51762. forceIrradianceInFragment: boolean;
  51763. /**
  51764. * Number of Simultaneous lights allowed on the material.
  51765. */
  51766. maxSimultaneousLights: number;
  51767. /**
  51768. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51769. */
  51770. invertNormalMapX: boolean;
  51771. /**
  51772. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51773. */
  51774. invertNormalMapY: boolean;
  51775. /**
  51776. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51777. */
  51778. twoSidedLighting: boolean;
  51779. /**
  51780. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51781. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51782. */
  51783. useAlphaFresnel: boolean;
  51784. /**
  51785. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51786. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51787. */
  51788. useLinearAlphaFresnel: boolean;
  51789. /**
  51790. * Let user defines the brdf lookup texture used for IBL.
  51791. * A default 8bit version is embedded but you could point at :
  51792. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51793. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51794. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51795. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51796. */
  51797. environmentBRDFTexture: Nullable<BaseTexture>;
  51798. /**
  51799. * Force normal to face away from face.
  51800. */
  51801. forceNormalForward: boolean;
  51802. /**
  51803. * Enables specular anti aliasing in the PBR shader.
  51804. * It will both interacts on the Geometry for analytical and IBL lighting.
  51805. * It also prefilter the roughness map based on the bump values.
  51806. */
  51807. enableSpecularAntiAliasing: boolean;
  51808. /**
  51809. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51810. * makes the reflect vector face the model (under horizon).
  51811. */
  51812. useHorizonOcclusion: boolean;
  51813. /**
  51814. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51815. * too much the area relying on ambient texture to define their ambient occlusion.
  51816. */
  51817. useRadianceOcclusion: boolean;
  51818. /**
  51819. * If set to true, no lighting calculations will be applied.
  51820. */
  51821. unlit: boolean;
  51822. /**
  51823. * Gets the image processing configuration used either in this material.
  51824. */
  51825. /**
  51826. * Sets the Default image processing configuration used either in the this material.
  51827. *
  51828. * If sets to null, the scene one is in use.
  51829. */
  51830. imageProcessingConfiguration: ImageProcessingConfiguration;
  51831. /**
  51832. * Gets wether the color curves effect is enabled.
  51833. */
  51834. /**
  51835. * Sets wether the color curves effect is enabled.
  51836. */
  51837. cameraColorCurvesEnabled: boolean;
  51838. /**
  51839. * Gets wether the color grading effect is enabled.
  51840. */
  51841. /**
  51842. * Gets wether the color grading effect is enabled.
  51843. */
  51844. cameraColorGradingEnabled: boolean;
  51845. /**
  51846. * Gets wether tonemapping is enabled or not.
  51847. */
  51848. /**
  51849. * Sets wether tonemapping is enabled or not
  51850. */
  51851. cameraToneMappingEnabled: boolean;
  51852. /**
  51853. * The camera exposure used on this material.
  51854. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51855. * This corresponds to a photographic exposure.
  51856. */
  51857. /**
  51858. * The camera exposure used on this material.
  51859. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51860. * This corresponds to a photographic exposure.
  51861. */
  51862. cameraExposure: number;
  51863. /**
  51864. * Gets The camera contrast used on this material.
  51865. */
  51866. /**
  51867. * Sets The camera contrast used on this material.
  51868. */
  51869. cameraContrast: number;
  51870. /**
  51871. * Gets the Color Grading 2D Lookup Texture.
  51872. */
  51873. /**
  51874. * Sets the Color Grading 2D Lookup Texture.
  51875. */
  51876. cameraColorGradingTexture: Nullable<BaseTexture>;
  51877. /**
  51878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51880. * 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;
  51881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51882. */
  51883. /**
  51884. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51885. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51886. * 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;
  51887. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51888. */
  51889. cameraColorCurves: Nullable<ColorCurves>;
  51890. /**
  51891. * Instantiates a new PBRMaterial instance.
  51892. *
  51893. * @param name The material name
  51894. * @param scene The scene the material will be use in.
  51895. */
  51896. constructor(name: string, scene: Scene);
  51897. /**
  51898. * Returns the name of this material class.
  51899. */
  51900. getClassName(): string;
  51901. /**
  51902. * Makes a duplicate of the current material.
  51903. * @param name - name to use for the new material.
  51904. */
  51905. clone(name: string): PBRMaterial;
  51906. /**
  51907. * Serializes this PBR Material.
  51908. * @returns - An object with the serialized material.
  51909. */
  51910. serialize(): any;
  51911. /**
  51912. * Parses a PBR Material from a serialized object.
  51913. * @param source - Serialized object.
  51914. * @param scene - BJS scene instance.
  51915. * @param rootUrl - url for the scene object
  51916. * @returns - PBRMaterial
  51917. */
  51918. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51919. }
  51920. }
  51921. declare module "babylonjs/Misc/dds" {
  51922. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51923. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51924. import { Nullable } from "babylonjs/types";
  51925. import { Scene } from "babylonjs/scene";
  51926. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51927. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51928. /**
  51929. * Direct draw surface info
  51930. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51931. */
  51932. export interface DDSInfo {
  51933. /**
  51934. * Width of the texture
  51935. */
  51936. width: number;
  51937. /**
  51938. * Width of the texture
  51939. */
  51940. height: number;
  51941. /**
  51942. * Number of Mipmaps for the texture
  51943. * @see https://en.wikipedia.org/wiki/Mipmap
  51944. */
  51945. mipmapCount: number;
  51946. /**
  51947. * If the textures format is a known fourCC format
  51948. * @see https://www.fourcc.org/
  51949. */
  51950. isFourCC: boolean;
  51951. /**
  51952. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51953. */
  51954. isRGB: boolean;
  51955. /**
  51956. * If the texture is a lumincance format
  51957. */
  51958. isLuminance: boolean;
  51959. /**
  51960. * If this is a cube texture
  51961. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51962. */
  51963. isCube: boolean;
  51964. /**
  51965. * If the texture is a compressed format eg. FOURCC_DXT1
  51966. */
  51967. isCompressed: boolean;
  51968. /**
  51969. * The dxgiFormat of the texture
  51970. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51971. */
  51972. dxgiFormat: number;
  51973. /**
  51974. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51975. */
  51976. textureType: number;
  51977. /**
  51978. * Sphericle polynomial created for the dds texture
  51979. */
  51980. sphericalPolynomial?: SphericalPolynomial;
  51981. }
  51982. /**
  51983. * Class used to provide DDS decompression tools
  51984. */
  51985. export class DDSTools {
  51986. /**
  51987. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51988. */
  51989. static StoreLODInAlphaChannel: boolean;
  51990. /**
  51991. * Gets DDS information from an array buffer
  51992. * @param arrayBuffer defines the array buffer to read data from
  51993. * @returns the DDS information
  51994. */
  51995. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51996. private static _FloatView;
  51997. private static _Int32View;
  51998. private static _ToHalfFloat;
  51999. private static _FromHalfFloat;
  52000. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52001. private static _GetHalfFloatRGBAArrayBuffer;
  52002. private static _GetFloatRGBAArrayBuffer;
  52003. private static _GetFloatAsUIntRGBAArrayBuffer;
  52004. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52005. private static _GetRGBAArrayBuffer;
  52006. private static _ExtractLongWordOrder;
  52007. private static _GetRGBArrayBuffer;
  52008. private static _GetLuminanceArrayBuffer;
  52009. /**
  52010. * Uploads DDS Levels to a Babylon Texture
  52011. * @hidden
  52012. */
  52013. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52014. }
  52015. module "babylonjs/Engines/thinEngine" {
  52016. interface ThinEngine {
  52017. /**
  52018. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52019. * @param rootUrl defines the url where the file to load is located
  52020. * @param scene defines the current scene
  52021. * @param lodScale defines scale to apply to the mip map selection
  52022. * @param lodOffset defines offset to apply to the mip map selection
  52023. * @param onLoad defines an optional callback raised when the texture is loaded
  52024. * @param onError defines an optional callback raised if there is an issue to load the texture
  52025. * @param format defines the format of the data
  52026. * @param forcedExtension defines the extension to use to pick the right loader
  52027. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52028. * @returns the cube texture as an InternalTexture
  52029. */
  52030. 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;
  52031. }
  52032. }
  52033. }
  52034. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  52035. import { Nullable } from "babylonjs/types";
  52036. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52037. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52038. /**
  52039. * Implementation of the DDS Texture Loader.
  52040. * @hidden
  52041. */
  52042. export class _DDSTextureLoader implements IInternalTextureLoader {
  52043. /**
  52044. * Defines wether the loader supports cascade loading the different faces.
  52045. */
  52046. readonly supportCascades: boolean;
  52047. /**
  52048. * This returns if the loader support the current file information.
  52049. * @param extension defines the file extension of the file being loaded
  52050. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52051. * @param fallback defines the fallback internal texture if any
  52052. * @param isBase64 defines whether the texture is encoded as a base64
  52053. * @param isBuffer defines whether the texture data are stored as a buffer
  52054. * @returns true if the loader can load the specified file
  52055. */
  52056. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52057. /**
  52058. * Transform the url before loading if required.
  52059. * @param rootUrl the url of the texture
  52060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52061. * @returns the transformed texture
  52062. */
  52063. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52064. /**
  52065. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52066. * @param rootUrl the url of the texture
  52067. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52068. * @returns the fallback texture
  52069. */
  52070. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52071. /**
  52072. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52073. * @param data contains the texture data
  52074. * @param texture defines the BabylonJS internal texture
  52075. * @param createPolynomials will be true if polynomials have been requested
  52076. * @param onLoad defines the callback to trigger once the texture is ready
  52077. * @param onError defines the callback to trigger in case of error
  52078. */
  52079. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52080. /**
  52081. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52082. * @param data contains the texture data
  52083. * @param texture defines the BabylonJS internal texture
  52084. * @param callback defines the method to call once ready to upload
  52085. */
  52086. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52087. }
  52088. }
  52089. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  52090. import { Nullable } from "babylonjs/types";
  52091. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52092. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52093. /**
  52094. * Implementation of the ENV Texture Loader.
  52095. * @hidden
  52096. */
  52097. export class _ENVTextureLoader implements IInternalTextureLoader {
  52098. /**
  52099. * Defines wether the loader supports cascade loading the different faces.
  52100. */
  52101. readonly supportCascades: boolean;
  52102. /**
  52103. * This returns if the loader support the current file information.
  52104. * @param extension defines the file extension of the file being loaded
  52105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52106. * @param fallback defines the fallback internal texture if any
  52107. * @param isBase64 defines whether the texture is encoded as a base64
  52108. * @param isBuffer defines whether the texture data are stored as a buffer
  52109. * @returns true if the loader can load the specified file
  52110. */
  52111. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52112. /**
  52113. * Transform the url before loading if required.
  52114. * @param rootUrl the url of the texture
  52115. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52116. * @returns the transformed texture
  52117. */
  52118. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52119. /**
  52120. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52121. * @param rootUrl the url of the texture
  52122. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52123. * @returns the fallback texture
  52124. */
  52125. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52126. /**
  52127. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52128. * @param data contains the texture data
  52129. * @param texture defines the BabylonJS internal texture
  52130. * @param createPolynomials will be true if polynomials have been requested
  52131. * @param onLoad defines the callback to trigger once the texture is ready
  52132. * @param onError defines the callback to trigger in case of error
  52133. */
  52134. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52135. /**
  52136. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52137. * @param data contains the texture data
  52138. * @param texture defines the BabylonJS internal texture
  52139. * @param callback defines the method to call once ready to upload
  52140. */
  52141. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52142. }
  52143. }
  52144. declare module "babylonjs/Misc/khronosTextureContainer" {
  52145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52146. /**
  52147. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52148. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52149. */
  52150. export class KhronosTextureContainer {
  52151. /** contents of the KTX container file */
  52152. arrayBuffer: any;
  52153. private static HEADER_LEN;
  52154. private static COMPRESSED_2D;
  52155. private static COMPRESSED_3D;
  52156. private static TEX_2D;
  52157. private static TEX_3D;
  52158. /**
  52159. * Gets the openGL type
  52160. */
  52161. glType: number;
  52162. /**
  52163. * Gets the openGL type size
  52164. */
  52165. glTypeSize: number;
  52166. /**
  52167. * Gets the openGL format
  52168. */
  52169. glFormat: number;
  52170. /**
  52171. * Gets the openGL internal format
  52172. */
  52173. glInternalFormat: number;
  52174. /**
  52175. * Gets the base internal format
  52176. */
  52177. glBaseInternalFormat: number;
  52178. /**
  52179. * Gets image width in pixel
  52180. */
  52181. pixelWidth: number;
  52182. /**
  52183. * Gets image height in pixel
  52184. */
  52185. pixelHeight: number;
  52186. /**
  52187. * Gets image depth in pixels
  52188. */
  52189. pixelDepth: number;
  52190. /**
  52191. * Gets the number of array elements
  52192. */
  52193. numberOfArrayElements: number;
  52194. /**
  52195. * Gets the number of faces
  52196. */
  52197. numberOfFaces: number;
  52198. /**
  52199. * Gets the number of mipmap levels
  52200. */
  52201. numberOfMipmapLevels: number;
  52202. /**
  52203. * Gets the bytes of key value data
  52204. */
  52205. bytesOfKeyValueData: number;
  52206. /**
  52207. * Gets the load type
  52208. */
  52209. loadType: number;
  52210. /**
  52211. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52212. */
  52213. isInvalid: boolean;
  52214. /**
  52215. * Creates a new KhronosTextureContainer
  52216. * @param arrayBuffer contents of the KTX container file
  52217. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52218. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52219. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52220. */
  52221. constructor(
  52222. /** contents of the KTX container file */
  52223. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52224. /**
  52225. * Uploads KTX content to a Babylon Texture.
  52226. * It is assumed that the texture has already been created & is currently bound
  52227. * @hidden
  52228. */
  52229. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52230. private _upload2DCompressedLevels;
  52231. }
  52232. }
  52233. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  52234. import { Nullable } from "babylonjs/types";
  52235. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52236. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52237. /**
  52238. * Implementation of the KTX Texture Loader.
  52239. * @hidden
  52240. */
  52241. export class _KTXTextureLoader implements IInternalTextureLoader {
  52242. /**
  52243. * Defines wether the loader supports cascade loading the different faces.
  52244. */
  52245. readonly supportCascades: boolean;
  52246. /**
  52247. * This returns if the loader support the current file information.
  52248. * @param extension defines the file extension of the file being loaded
  52249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52250. * @param fallback defines the fallback internal texture if any
  52251. * @param isBase64 defines whether the texture is encoded as a base64
  52252. * @param isBuffer defines whether the texture data are stored as a buffer
  52253. * @returns true if the loader can load the specified file
  52254. */
  52255. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52256. /**
  52257. * Transform the url before loading if required.
  52258. * @param rootUrl the url of the texture
  52259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52260. * @returns the transformed texture
  52261. */
  52262. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52263. /**
  52264. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52265. * @param rootUrl the url of the texture
  52266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52267. * @returns the fallback texture
  52268. */
  52269. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52270. /**
  52271. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52272. * @param data contains the texture data
  52273. * @param texture defines the BabylonJS internal texture
  52274. * @param createPolynomials will be true if polynomials have been requested
  52275. * @param onLoad defines the callback to trigger once the texture is ready
  52276. * @param onError defines the callback to trigger in case of error
  52277. */
  52278. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52279. /**
  52280. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52281. * @param data contains the texture data
  52282. * @param texture defines the BabylonJS internal texture
  52283. * @param callback defines the method to call once ready to upload
  52284. */
  52285. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52286. }
  52287. }
  52288. declare module "babylonjs/Helpers/sceneHelpers" {
  52289. import { Nullable } from "babylonjs/types";
  52290. import { Mesh } from "babylonjs/Meshes/mesh";
  52291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52292. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  52293. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  52294. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52295. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52296. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52297. import "babylonjs/Meshes/Builders/boxBuilder";
  52298. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  52299. /** @hidden */
  52300. export var _forceSceneHelpersToBundle: boolean;
  52301. module "babylonjs/scene" {
  52302. interface Scene {
  52303. /**
  52304. * Creates a default light for the scene.
  52305. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52306. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52307. */
  52308. createDefaultLight(replace?: boolean): void;
  52309. /**
  52310. * Creates a default camera for the scene.
  52311. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52312. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52313. * @param replace has default false, when true replaces the active camera in the scene
  52314. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52315. */
  52316. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52317. /**
  52318. * Creates a default camera and a default light.
  52319. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52320. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52321. * @param replace has the default false, when true replaces the active camera/light in the scene
  52322. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52323. */
  52324. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52325. /**
  52326. * Creates a new sky box
  52327. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52328. * @param environmentTexture defines the texture to use as environment texture
  52329. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52330. * @param scale defines the overall scale of the skybox
  52331. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52332. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52333. * @returns a new mesh holding the sky box
  52334. */
  52335. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52336. /**
  52337. * Creates a new environment
  52338. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52339. * @param options defines the options you can use to configure the environment
  52340. * @returns the new EnvironmentHelper
  52341. */
  52342. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52343. /**
  52344. * Creates a new VREXperienceHelper
  52345. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52346. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52347. * @returns a new VREXperienceHelper
  52348. */
  52349. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52350. /**
  52351. * Creates a new WebXRDefaultExperience
  52352. * @see http://doc.babylonjs.com/how_to/webxr
  52353. * @param options experience options
  52354. * @returns a promise for a new WebXRDefaultExperience
  52355. */
  52356. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52357. }
  52358. }
  52359. }
  52360. declare module "babylonjs/Helpers/videoDome" {
  52361. import { Scene } from "babylonjs/scene";
  52362. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52363. import { Mesh } from "babylonjs/Meshes/mesh";
  52364. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  52365. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52366. import "babylonjs/Meshes/Builders/sphereBuilder";
  52367. /**
  52368. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52369. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52370. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52371. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52372. */
  52373. export class VideoDome extends TransformNode {
  52374. /**
  52375. * Define the video source as a Monoscopic panoramic 360 video.
  52376. */
  52377. static readonly MODE_MONOSCOPIC: number;
  52378. /**
  52379. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52380. */
  52381. static readonly MODE_TOPBOTTOM: number;
  52382. /**
  52383. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52384. */
  52385. static readonly MODE_SIDEBYSIDE: number;
  52386. private _halfDome;
  52387. private _useDirectMapping;
  52388. /**
  52389. * The video texture being displayed on the sphere
  52390. */
  52391. protected _videoTexture: VideoTexture;
  52392. /**
  52393. * Gets the video texture being displayed on the sphere
  52394. */
  52395. readonly videoTexture: VideoTexture;
  52396. /**
  52397. * The skybox material
  52398. */
  52399. protected _material: BackgroundMaterial;
  52400. /**
  52401. * The surface used for the skybox
  52402. */
  52403. protected _mesh: Mesh;
  52404. /**
  52405. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52406. */
  52407. private _halfDomeMask;
  52408. /**
  52409. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52410. * Also see the options.resolution property.
  52411. */
  52412. fovMultiplier: number;
  52413. private _videoMode;
  52414. /**
  52415. * Gets or set the current video mode for the video. It can be:
  52416. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52417. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52418. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52419. */
  52420. videoMode: number;
  52421. /**
  52422. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52423. *
  52424. */
  52425. /**
  52426. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52427. */
  52428. halfDome: boolean;
  52429. /**
  52430. * Oberserver used in Stereoscopic VR Mode.
  52431. */
  52432. private _onBeforeCameraRenderObserver;
  52433. /**
  52434. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52435. * @param name Element's name, child elements will append suffixes for their own names.
  52436. * @param urlsOrVideo defines the url(s) or the video element to use
  52437. * @param options An object containing optional or exposed sub element properties
  52438. */
  52439. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52440. resolution?: number;
  52441. clickToPlay?: boolean;
  52442. autoPlay?: boolean;
  52443. loop?: boolean;
  52444. size?: number;
  52445. poster?: string;
  52446. faceForward?: boolean;
  52447. useDirectMapping?: boolean;
  52448. halfDomeMode?: boolean;
  52449. }, scene: Scene);
  52450. private _changeVideoMode;
  52451. /**
  52452. * Releases resources associated with this node.
  52453. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52454. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52455. */
  52456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52457. }
  52458. }
  52459. declare module "babylonjs/Helpers/index" {
  52460. export * from "babylonjs/Helpers/environmentHelper";
  52461. export * from "babylonjs/Helpers/photoDome";
  52462. export * from "babylonjs/Helpers/sceneHelpers";
  52463. export * from "babylonjs/Helpers/videoDome";
  52464. }
  52465. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  52466. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52467. import { IDisposable } from "babylonjs/scene";
  52468. import { Engine } from "babylonjs/Engines/engine";
  52469. /**
  52470. * This class can be used to get instrumentation data from a Babylon engine
  52471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52472. */
  52473. export class EngineInstrumentation implements IDisposable {
  52474. /**
  52475. * Define the instrumented engine.
  52476. */
  52477. engine: Engine;
  52478. private _captureGPUFrameTime;
  52479. private _gpuFrameTimeToken;
  52480. private _gpuFrameTime;
  52481. private _captureShaderCompilationTime;
  52482. private _shaderCompilationTime;
  52483. private _onBeginFrameObserver;
  52484. private _onEndFrameObserver;
  52485. private _onBeforeShaderCompilationObserver;
  52486. private _onAfterShaderCompilationObserver;
  52487. /**
  52488. * Gets the perf counter used for GPU frame time
  52489. */
  52490. readonly gpuFrameTimeCounter: PerfCounter;
  52491. /**
  52492. * Gets the GPU frame time capture status
  52493. */
  52494. /**
  52495. * Enable or disable the GPU frame time capture
  52496. */
  52497. captureGPUFrameTime: boolean;
  52498. /**
  52499. * Gets the perf counter used for shader compilation time
  52500. */
  52501. readonly shaderCompilationTimeCounter: PerfCounter;
  52502. /**
  52503. * Gets the shader compilation time capture status
  52504. */
  52505. /**
  52506. * Enable or disable the shader compilation time capture
  52507. */
  52508. captureShaderCompilationTime: boolean;
  52509. /**
  52510. * Instantiates a new engine instrumentation.
  52511. * This class can be used to get instrumentation data from a Babylon engine
  52512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52513. * @param engine Defines the engine to instrument
  52514. */
  52515. constructor(
  52516. /**
  52517. * Define the instrumented engine.
  52518. */
  52519. engine: Engine);
  52520. /**
  52521. * Dispose and release associated resources.
  52522. */
  52523. dispose(): void;
  52524. }
  52525. }
  52526. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52527. import { Scene, IDisposable } from "babylonjs/scene";
  52528. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52529. /**
  52530. * This class can be used to get instrumentation data from a Babylon engine
  52531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52532. */
  52533. export class SceneInstrumentation implements IDisposable {
  52534. /**
  52535. * Defines the scene to instrument
  52536. */
  52537. scene: Scene;
  52538. private _captureActiveMeshesEvaluationTime;
  52539. private _activeMeshesEvaluationTime;
  52540. private _captureRenderTargetsRenderTime;
  52541. private _renderTargetsRenderTime;
  52542. private _captureFrameTime;
  52543. private _frameTime;
  52544. private _captureRenderTime;
  52545. private _renderTime;
  52546. private _captureInterFrameTime;
  52547. private _interFrameTime;
  52548. private _captureParticlesRenderTime;
  52549. private _particlesRenderTime;
  52550. private _captureSpritesRenderTime;
  52551. private _spritesRenderTime;
  52552. private _capturePhysicsTime;
  52553. private _physicsTime;
  52554. private _captureAnimationsTime;
  52555. private _animationsTime;
  52556. private _captureCameraRenderTime;
  52557. private _cameraRenderTime;
  52558. private _onBeforeActiveMeshesEvaluationObserver;
  52559. private _onAfterActiveMeshesEvaluationObserver;
  52560. private _onBeforeRenderTargetsRenderObserver;
  52561. private _onAfterRenderTargetsRenderObserver;
  52562. private _onAfterRenderObserver;
  52563. private _onBeforeDrawPhaseObserver;
  52564. private _onAfterDrawPhaseObserver;
  52565. private _onBeforeAnimationsObserver;
  52566. private _onBeforeParticlesRenderingObserver;
  52567. private _onAfterParticlesRenderingObserver;
  52568. private _onBeforeSpritesRenderingObserver;
  52569. private _onAfterSpritesRenderingObserver;
  52570. private _onBeforePhysicsObserver;
  52571. private _onAfterPhysicsObserver;
  52572. private _onAfterAnimationsObserver;
  52573. private _onBeforeCameraRenderObserver;
  52574. private _onAfterCameraRenderObserver;
  52575. /**
  52576. * Gets the perf counter used for active meshes evaluation time
  52577. */
  52578. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52579. /**
  52580. * Gets the active meshes evaluation time capture status
  52581. */
  52582. /**
  52583. * Enable or disable the active meshes evaluation time capture
  52584. */
  52585. captureActiveMeshesEvaluationTime: boolean;
  52586. /**
  52587. * Gets the perf counter used for render targets render time
  52588. */
  52589. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52590. /**
  52591. * Gets the render targets render time capture status
  52592. */
  52593. /**
  52594. * Enable or disable the render targets render time capture
  52595. */
  52596. captureRenderTargetsRenderTime: boolean;
  52597. /**
  52598. * Gets the perf counter used for particles render time
  52599. */
  52600. readonly particlesRenderTimeCounter: PerfCounter;
  52601. /**
  52602. * Gets the particles render time capture status
  52603. */
  52604. /**
  52605. * Enable or disable the particles render time capture
  52606. */
  52607. captureParticlesRenderTime: boolean;
  52608. /**
  52609. * Gets the perf counter used for sprites render time
  52610. */
  52611. readonly spritesRenderTimeCounter: PerfCounter;
  52612. /**
  52613. * Gets the sprites render time capture status
  52614. */
  52615. /**
  52616. * Enable or disable the sprites render time capture
  52617. */
  52618. captureSpritesRenderTime: boolean;
  52619. /**
  52620. * Gets the perf counter used for physics time
  52621. */
  52622. readonly physicsTimeCounter: PerfCounter;
  52623. /**
  52624. * Gets the physics time capture status
  52625. */
  52626. /**
  52627. * Enable or disable the physics time capture
  52628. */
  52629. capturePhysicsTime: boolean;
  52630. /**
  52631. * Gets the perf counter used for animations time
  52632. */
  52633. readonly animationsTimeCounter: PerfCounter;
  52634. /**
  52635. * Gets the animations time capture status
  52636. */
  52637. /**
  52638. * Enable or disable the animations time capture
  52639. */
  52640. captureAnimationsTime: boolean;
  52641. /**
  52642. * Gets the perf counter used for frame time capture
  52643. */
  52644. readonly frameTimeCounter: PerfCounter;
  52645. /**
  52646. * Gets the frame time capture status
  52647. */
  52648. /**
  52649. * Enable or disable the frame time capture
  52650. */
  52651. captureFrameTime: boolean;
  52652. /**
  52653. * Gets the perf counter used for inter-frames time capture
  52654. */
  52655. readonly interFrameTimeCounter: PerfCounter;
  52656. /**
  52657. * Gets the inter-frames time capture status
  52658. */
  52659. /**
  52660. * Enable or disable the inter-frames time capture
  52661. */
  52662. captureInterFrameTime: boolean;
  52663. /**
  52664. * Gets the perf counter used for render time capture
  52665. */
  52666. readonly renderTimeCounter: PerfCounter;
  52667. /**
  52668. * Gets the render time capture status
  52669. */
  52670. /**
  52671. * Enable or disable the render time capture
  52672. */
  52673. captureRenderTime: boolean;
  52674. /**
  52675. * Gets the perf counter used for camera render time capture
  52676. */
  52677. readonly cameraRenderTimeCounter: PerfCounter;
  52678. /**
  52679. * Gets the camera render time capture status
  52680. */
  52681. /**
  52682. * Enable or disable the camera render time capture
  52683. */
  52684. captureCameraRenderTime: boolean;
  52685. /**
  52686. * Gets the perf counter used for draw calls
  52687. */
  52688. readonly drawCallsCounter: PerfCounter;
  52689. /**
  52690. * Instantiates a new scene instrumentation.
  52691. * This class can be used to get instrumentation data from a Babylon engine
  52692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52693. * @param scene Defines the scene to instrument
  52694. */
  52695. constructor(
  52696. /**
  52697. * Defines the scene to instrument
  52698. */
  52699. scene: Scene);
  52700. /**
  52701. * Dispose and release associated resources.
  52702. */
  52703. dispose(): void;
  52704. }
  52705. }
  52706. declare module "babylonjs/Instrumentation/index" {
  52707. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52708. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52709. export * from "babylonjs/Instrumentation/timeToken";
  52710. }
  52711. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52712. /** @hidden */
  52713. export var glowMapGenerationPixelShader: {
  52714. name: string;
  52715. shader: string;
  52716. };
  52717. }
  52718. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52719. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52720. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52721. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52722. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52723. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52724. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52725. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52726. /** @hidden */
  52727. export var glowMapGenerationVertexShader: {
  52728. name: string;
  52729. shader: string;
  52730. };
  52731. }
  52732. declare module "babylonjs/Layers/effectLayer" {
  52733. import { Observable } from "babylonjs/Misc/observable";
  52734. import { Nullable } from "babylonjs/types";
  52735. import { Camera } from "babylonjs/Cameras/camera";
  52736. import { Scene } from "babylonjs/scene";
  52737. import { ISize } from "babylonjs/Maths/math.size";
  52738. import { Color4 } from "babylonjs/Maths/math.color";
  52739. import { Engine } from "babylonjs/Engines/engine";
  52740. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52742. import { Mesh } from "babylonjs/Meshes/mesh";
  52743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52746. import { Effect } from "babylonjs/Materials/effect";
  52747. import { Material } from "babylonjs/Materials/material";
  52748. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52749. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52750. /**
  52751. * Effect layer options. This helps customizing the behaviour
  52752. * of the effect layer.
  52753. */
  52754. export interface IEffectLayerOptions {
  52755. /**
  52756. * Multiplication factor apply to the canvas size to compute the render target size
  52757. * used to generated the objects (the smaller the faster).
  52758. */
  52759. mainTextureRatio: number;
  52760. /**
  52761. * Enforces a fixed size texture to ensure effect stability across devices.
  52762. */
  52763. mainTextureFixedSize?: number;
  52764. /**
  52765. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52766. */
  52767. alphaBlendingMode: number;
  52768. /**
  52769. * The camera attached to the layer.
  52770. */
  52771. camera: Nullable<Camera>;
  52772. /**
  52773. * The rendering group to draw the layer in.
  52774. */
  52775. renderingGroupId: number;
  52776. }
  52777. /**
  52778. * The effect layer Helps adding post process effect blended with the main pass.
  52779. *
  52780. * This can be for instance use to generate glow or higlight effects on the scene.
  52781. *
  52782. * The effect layer class can not be used directly and is intented to inherited from to be
  52783. * customized per effects.
  52784. */
  52785. export abstract class EffectLayer {
  52786. private _vertexBuffers;
  52787. private _indexBuffer;
  52788. private _cachedDefines;
  52789. private _effectLayerMapGenerationEffect;
  52790. private _effectLayerOptions;
  52791. private _mergeEffect;
  52792. protected _scene: Scene;
  52793. protected _engine: Engine;
  52794. protected _maxSize: number;
  52795. protected _mainTextureDesiredSize: ISize;
  52796. protected _mainTexture: RenderTargetTexture;
  52797. protected _shouldRender: boolean;
  52798. protected _postProcesses: PostProcess[];
  52799. protected _textures: BaseTexture[];
  52800. protected _emissiveTextureAndColor: {
  52801. texture: Nullable<BaseTexture>;
  52802. color: Color4;
  52803. };
  52804. /**
  52805. * The name of the layer
  52806. */
  52807. name: string;
  52808. /**
  52809. * The clear color of the texture used to generate the glow map.
  52810. */
  52811. neutralColor: Color4;
  52812. /**
  52813. * Specifies wether the highlight layer is enabled or not.
  52814. */
  52815. isEnabled: boolean;
  52816. /**
  52817. * Gets the camera attached to the layer.
  52818. */
  52819. readonly camera: Nullable<Camera>;
  52820. /**
  52821. * Gets the rendering group id the layer should render in.
  52822. */
  52823. renderingGroupId: number;
  52824. /**
  52825. * An event triggered when the effect layer has been disposed.
  52826. */
  52827. onDisposeObservable: Observable<EffectLayer>;
  52828. /**
  52829. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52830. */
  52831. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52832. /**
  52833. * An event triggered when the generated texture is being merged in the scene.
  52834. */
  52835. onBeforeComposeObservable: Observable<EffectLayer>;
  52836. /**
  52837. * An event triggered when the mesh is rendered into the effect render target.
  52838. */
  52839. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52840. /**
  52841. * An event triggered after the mesh has been rendered into the effect render target.
  52842. */
  52843. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52844. /**
  52845. * An event triggered when the generated texture has been merged in the scene.
  52846. */
  52847. onAfterComposeObservable: Observable<EffectLayer>;
  52848. /**
  52849. * An event triggered when the efffect layer changes its size.
  52850. */
  52851. onSizeChangedObservable: Observable<EffectLayer>;
  52852. /** @hidden */
  52853. static _SceneComponentInitialization: (scene: Scene) => void;
  52854. /**
  52855. * Instantiates a new effect Layer and references it in the scene.
  52856. * @param name The name of the layer
  52857. * @param scene The scene to use the layer in
  52858. */
  52859. constructor(
  52860. /** The Friendly of the effect in the scene */
  52861. name: string, scene: Scene);
  52862. /**
  52863. * Get the effect name of the layer.
  52864. * @return The effect name
  52865. */
  52866. abstract getEffectName(): string;
  52867. /**
  52868. * Checks for the readiness of the element composing the layer.
  52869. * @param subMesh the mesh to check for
  52870. * @param useInstances specify wether or not to use instances to render the mesh
  52871. * @return true if ready otherwise, false
  52872. */
  52873. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52874. /**
  52875. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52876. * @returns true if the effect requires stencil during the main canvas render pass.
  52877. */
  52878. abstract needStencil(): boolean;
  52879. /**
  52880. * Create the merge effect. This is the shader use to blit the information back
  52881. * to the main canvas at the end of the scene rendering.
  52882. * @returns The effect containing the shader used to merge the effect on the main canvas
  52883. */
  52884. protected abstract _createMergeEffect(): Effect;
  52885. /**
  52886. * Creates the render target textures and post processes used in the effect layer.
  52887. */
  52888. protected abstract _createTextureAndPostProcesses(): void;
  52889. /**
  52890. * Implementation specific of rendering the generating effect on the main canvas.
  52891. * @param effect The effect used to render through
  52892. */
  52893. protected abstract _internalRender(effect: Effect): void;
  52894. /**
  52895. * Sets the required values for both the emissive texture and and the main color.
  52896. */
  52897. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52898. /**
  52899. * Free any resources and references associated to a mesh.
  52900. * Internal use
  52901. * @param mesh The mesh to free.
  52902. */
  52903. abstract _disposeMesh(mesh: Mesh): void;
  52904. /**
  52905. * Serializes this layer (Glow or Highlight for example)
  52906. * @returns a serialized layer object
  52907. */
  52908. abstract serialize?(): any;
  52909. /**
  52910. * Initializes the effect layer with the required options.
  52911. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52912. */
  52913. protected _init(options: Partial<IEffectLayerOptions>): void;
  52914. /**
  52915. * Generates the index buffer of the full screen quad blending to the main canvas.
  52916. */
  52917. private _generateIndexBuffer;
  52918. /**
  52919. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52920. */
  52921. private _generateVertexBuffer;
  52922. /**
  52923. * Sets the main texture desired size which is the closest power of two
  52924. * of the engine canvas size.
  52925. */
  52926. private _setMainTextureSize;
  52927. /**
  52928. * Creates the main texture for the effect layer.
  52929. */
  52930. protected _createMainTexture(): void;
  52931. /**
  52932. * Adds specific effects defines.
  52933. * @param defines The defines to add specifics to.
  52934. */
  52935. protected _addCustomEffectDefines(defines: string[]): void;
  52936. /**
  52937. * Checks for the readiness of the element composing the layer.
  52938. * @param subMesh the mesh to check for
  52939. * @param useInstances specify wether or not to use instances to render the mesh
  52940. * @param emissiveTexture the associated emissive texture used to generate the glow
  52941. * @return true if ready otherwise, false
  52942. */
  52943. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52944. /**
  52945. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52946. */
  52947. render(): void;
  52948. /**
  52949. * Determine if a given mesh will be used in the current effect.
  52950. * @param mesh mesh to test
  52951. * @returns true if the mesh will be used
  52952. */
  52953. hasMesh(mesh: AbstractMesh): boolean;
  52954. /**
  52955. * Returns true if the layer contains information to display, otherwise false.
  52956. * @returns true if the glow layer should be rendered
  52957. */
  52958. shouldRender(): boolean;
  52959. /**
  52960. * Returns true if the mesh should render, otherwise false.
  52961. * @param mesh The mesh to render
  52962. * @returns true if it should render otherwise false
  52963. */
  52964. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52965. /**
  52966. * Returns true if the mesh can be rendered, otherwise false.
  52967. * @param mesh The mesh to render
  52968. * @param material The material used on the mesh
  52969. * @returns true if it can be rendered otherwise false
  52970. */
  52971. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52972. /**
  52973. * Returns true if the mesh should render, otherwise false.
  52974. * @param mesh The mesh to render
  52975. * @returns true if it should render otherwise false
  52976. */
  52977. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52978. /**
  52979. * Renders the submesh passed in parameter to the generation map.
  52980. */
  52981. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52982. /**
  52983. * Defines wether the current material of the mesh should be use to render the effect.
  52984. * @param mesh defines the current mesh to render
  52985. */
  52986. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52987. /**
  52988. * Rebuild the required buffers.
  52989. * @hidden Internal use only.
  52990. */
  52991. _rebuild(): void;
  52992. /**
  52993. * Dispose only the render target textures and post process.
  52994. */
  52995. private _disposeTextureAndPostProcesses;
  52996. /**
  52997. * Dispose the highlight layer and free resources.
  52998. */
  52999. dispose(): void;
  53000. /**
  53001. * Gets the class name of the effect layer
  53002. * @returns the string with the class name of the effect layer
  53003. */
  53004. getClassName(): string;
  53005. /**
  53006. * Creates an effect layer from parsed effect layer data
  53007. * @param parsedEffectLayer defines effect layer data
  53008. * @param scene defines the current scene
  53009. * @param rootUrl defines the root URL containing the effect layer information
  53010. * @returns a parsed effect Layer
  53011. */
  53012. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53013. }
  53014. }
  53015. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  53016. import { Scene } from "babylonjs/scene";
  53017. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53018. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53019. import { AbstractScene } from "babylonjs/abstractScene";
  53020. module "babylonjs/abstractScene" {
  53021. interface AbstractScene {
  53022. /**
  53023. * The list of effect layers (highlights/glow) added to the scene
  53024. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53025. * @see http://doc.babylonjs.com/how_to/glow_layer
  53026. */
  53027. effectLayers: Array<EffectLayer>;
  53028. /**
  53029. * Removes the given effect layer from this scene.
  53030. * @param toRemove defines the effect layer to remove
  53031. * @returns the index of the removed effect layer
  53032. */
  53033. removeEffectLayer(toRemove: EffectLayer): number;
  53034. /**
  53035. * Adds the given effect layer to this scene
  53036. * @param newEffectLayer defines the effect layer to add
  53037. */
  53038. addEffectLayer(newEffectLayer: EffectLayer): void;
  53039. }
  53040. }
  53041. /**
  53042. * Defines the layer scene component responsible to manage any effect layers
  53043. * in a given scene.
  53044. */
  53045. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53046. /**
  53047. * The component name helpfull to identify the component in the list of scene components.
  53048. */
  53049. readonly name: string;
  53050. /**
  53051. * The scene the component belongs to.
  53052. */
  53053. scene: Scene;
  53054. private _engine;
  53055. private _renderEffects;
  53056. private _needStencil;
  53057. private _previousStencilState;
  53058. /**
  53059. * Creates a new instance of the component for the given scene
  53060. * @param scene Defines the scene to register the component in
  53061. */
  53062. constructor(scene: Scene);
  53063. /**
  53064. * Registers the component in a given scene
  53065. */
  53066. register(): void;
  53067. /**
  53068. * Rebuilds the elements related to this component in case of
  53069. * context lost for instance.
  53070. */
  53071. rebuild(): void;
  53072. /**
  53073. * Serializes the component data to the specified json object
  53074. * @param serializationObject The object to serialize to
  53075. */
  53076. serialize(serializationObject: any): void;
  53077. /**
  53078. * Adds all the elements from the container to the scene
  53079. * @param container the container holding the elements
  53080. */
  53081. addFromContainer(container: AbstractScene): void;
  53082. /**
  53083. * Removes all the elements in the container from the scene
  53084. * @param container contains the elements to remove
  53085. * @param dispose if the removed element should be disposed (default: false)
  53086. */
  53087. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53088. /**
  53089. * Disposes the component and the associated ressources.
  53090. */
  53091. dispose(): void;
  53092. private _isReadyForMesh;
  53093. private _renderMainTexture;
  53094. private _setStencil;
  53095. private _setStencilBack;
  53096. private _draw;
  53097. private _drawCamera;
  53098. private _drawRenderingGroup;
  53099. }
  53100. }
  53101. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  53102. /** @hidden */
  53103. export var glowMapMergePixelShader: {
  53104. name: string;
  53105. shader: string;
  53106. };
  53107. }
  53108. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  53109. /** @hidden */
  53110. export var glowMapMergeVertexShader: {
  53111. name: string;
  53112. shader: string;
  53113. };
  53114. }
  53115. declare module "babylonjs/Layers/glowLayer" {
  53116. import { Nullable } from "babylonjs/types";
  53117. import { Camera } from "babylonjs/Cameras/camera";
  53118. import { Scene } from "babylonjs/scene";
  53119. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53121. import { Mesh } from "babylonjs/Meshes/mesh";
  53122. import { Texture } from "babylonjs/Materials/Textures/texture";
  53123. import { Effect } from "babylonjs/Materials/effect";
  53124. import { Material } from "babylonjs/Materials/material";
  53125. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53126. import { Color4 } from "babylonjs/Maths/math.color";
  53127. import "babylonjs/Shaders/glowMapMerge.fragment";
  53128. import "babylonjs/Shaders/glowMapMerge.vertex";
  53129. import "babylonjs/Layers/effectLayerSceneComponent";
  53130. module "babylonjs/abstractScene" {
  53131. interface AbstractScene {
  53132. /**
  53133. * Return a the first highlight layer of the scene with a given name.
  53134. * @param name The name of the highlight layer to look for.
  53135. * @return The highlight layer if found otherwise null.
  53136. */
  53137. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53138. }
  53139. }
  53140. /**
  53141. * Glow layer options. This helps customizing the behaviour
  53142. * of the glow layer.
  53143. */
  53144. export interface IGlowLayerOptions {
  53145. /**
  53146. * Multiplication factor apply to the canvas size to compute the render target size
  53147. * used to generated the glowing objects (the smaller the faster).
  53148. */
  53149. mainTextureRatio: number;
  53150. /**
  53151. * Enforces a fixed size texture to ensure resize independant blur.
  53152. */
  53153. mainTextureFixedSize?: number;
  53154. /**
  53155. * How big is the kernel of the blur texture.
  53156. */
  53157. blurKernelSize: number;
  53158. /**
  53159. * The camera attached to the layer.
  53160. */
  53161. camera: Nullable<Camera>;
  53162. /**
  53163. * Enable MSAA by chosing the number of samples.
  53164. */
  53165. mainTextureSamples?: number;
  53166. /**
  53167. * The rendering group to draw the layer in.
  53168. */
  53169. renderingGroupId: number;
  53170. }
  53171. /**
  53172. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53173. *
  53174. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53175. *
  53176. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53177. */
  53178. export class GlowLayer extends EffectLayer {
  53179. /**
  53180. * Effect Name of the layer.
  53181. */
  53182. static readonly EffectName: string;
  53183. /**
  53184. * The default blur kernel size used for the glow.
  53185. */
  53186. static DefaultBlurKernelSize: number;
  53187. /**
  53188. * The default texture size ratio used for the glow.
  53189. */
  53190. static DefaultTextureRatio: number;
  53191. /**
  53192. * Sets the kernel size of the blur.
  53193. */
  53194. /**
  53195. * Gets the kernel size of the blur.
  53196. */
  53197. blurKernelSize: number;
  53198. /**
  53199. * Sets the glow intensity.
  53200. */
  53201. /**
  53202. * Gets the glow intensity.
  53203. */
  53204. intensity: number;
  53205. private _options;
  53206. private _intensity;
  53207. private _horizontalBlurPostprocess1;
  53208. private _verticalBlurPostprocess1;
  53209. private _horizontalBlurPostprocess2;
  53210. private _verticalBlurPostprocess2;
  53211. private _blurTexture1;
  53212. private _blurTexture2;
  53213. private _postProcesses1;
  53214. private _postProcesses2;
  53215. private _includedOnlyMeshes;
  53216. private _excludedMeshes;
  53217. private _meshesUsingTheirOwnMaterials;
  53218. /**
  53219. * Callback used to let the user override the color selection on a per mesh basis
  53220. */
  53221. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53222. /**
  53223. * Callback used to let the user override the texture selection on a per mesh basis
  53224. */
  53225. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53226. /**
  53227. * Instantiates a new glow Layer and references it to the scene.
  53228. * @param name The name of the layer
  53229. * @param scene The scene to use the layer in
  53230. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53231. */
  53232. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53233. /**
  53234. * Get the effect name of the layer.
  53235. * @return The effect name
  53236. */
  53237. getEffectName(): string;
  53238. /**
  53239. * Create the merge effect. This is the shader use to blit the information back
  53240. * to the main canvas at the end of the scene rendering.
  53241. */
  53242. protected _createMergeEffect(): Effect;
  53243. /**
  53244. * Creates the render target textures and post processes used in the glow layer.
  53245. */
  53246. protected _createTextureAndPostProcesses(): void;
  53247. /**
  53248. * Checks for the readiness of the element composing the layer.
  53249. * @param subMesh the mesh to check for
  53250. * @param useInstances specify wether or not to use instances to render the mesh
  53251. * @param emissiveTexture the associated emissive texture used to generate the glow
  53252. * @return true if ready otherwise, false
  53253. */
  53254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53255. /**
  53256. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53257. */
  53258. needStencil(): boolean;
  53259. /**
  53260. * Returns true if the mesh can be rendered, otherwise false.
  53261. * @param mesh The mesh to render
  53262. * @param material The material used on the mesh
  53263. * @returns true if it can be rendered otherwise false
  53264. */
  53265. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53266. /**
  53267. * Implementation specific of rendering the generating effect on the main canvas.
  53268. * @param effect The effect used to render through
  53269. */
  53270. protected _internalRender(effect: Effect): void;
  53271. /**
  53272. * Sets the required values for both the emissive texture and and the main color.
  53273. */
  53274. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53275. /**
  53276. * Returns true if the mesh should render, otherwise false.
  53277. * @param mesh The mesh to render
  53278. * @returns true if it should render otherwise false
  53279. */
  53280. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53281. /**
  53282. * Adds specific effects defines.
  53283. * @param defines The defines to add specifics to.
  53284. */
  53285. protected _addCustomEffectDefines(defines: string[]): void;
  53286. /**
  53287. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53288. * @param mesh The mesh to exclude from the glow layer
  53289. */
  53290. addExcludedMesh(mesh: Mesh): void;
  53291. /**
  53292. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53293. * @param mesh The mesh to remove
  53294. */
  53295. removeExcludedMesh(mesh: Mesh): void;
  53296. /**
  53297. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53298. * @param mesh The mesh to include in the glow layer
  53299. */
  53300. addIncludedOnlyMesh(mesh: Mesh): void;
  53301. /**
  53302. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53303. * @param mesh The mesh to remove
  53304. */
  53305. removeIncludedOnlyMesh(mesh: Mesh): void;
  53306. /**
  53307. * Determine if a given mesh will be used in the glow layer
  53308. * @param mesh The mesh to test
  53309. * @returns true if the mesh will be highlighted by the current glow layer
  53310. */
  53311. hasMesh(mesh: AbstractMesh): boolean;
  53312. /**
  53313. * Defines wether the current material of the mesh should be use to render the effect.
  53314. * @param mesh defines the current mesh to render
  53315. */
  53316. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53317. /**
  53318. * Add a mesh to be rendered through its own material and not with emissive only.
  53319. * @param mesh The mesh for which we need to use its material
  53320. */
  53321. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53322. /**
  53323. * Remove a mesh from being rendered through its own material and not with emissive only.
  53324. * @param mesh The mesh for which we need to not use its material
  53325. */
  53326. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53327. /**
  53328. * Free any resources and references associated to a mesh.
  53329. * Internal use
  53330. * @param mesh The mesh to free.
  53331. * @hidden
  53332. */
  53333. _disposeMesh(mesh: Mesh): void;
  53334. /**
  53335. * Gets the class name of the effect layer
  53336. * @returns the string with the class name of the effect layer
  53337. */
  53338. getClassName(): string;
  53339. /**
  53340. * Serializes this glow layer
  53341. * @returns a serialized glow layer object
  53342. */
  53343. serialize(): any;
  53344. /**
  53345. * Creates a Glow Layer from parsed glow layer data
  53346. * @param parsedGlowLayer defines glow layer data
  53347. * @param scene defines the current scene
  53348. * @param rootUrl defines the root URL containing the glow layer information
  53349. * @returns a parsed Glow Layer
  53350. */
  53351. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53352. }
  53353. }
  53354. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  53355. /** @hidden */
  53356. export var glowBlurPostProcessPixelShader: {
  53357. name: string;
  53358. shader: string;
  53359. };
  53360. }
  53361. declare module "babylonjs/Layers/highlightLayer" {
  53362. import { Observable } from "babylonjs/Misc/observable";
  53363. import { Nullable } from "babylonjs/types";
  53364. import { Camera } from "babylonjs/Cameras/camera";
  53365. import { Scene } from "babylonjs/scene";
  53366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53368. import { Mesh } from "babylonjs/Meshes/mesh";
  53369. import { Effect } from "babylonjs/Materials/effect";
  53370. import { Material } from "babylonjs/Materials/material";
  53371. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  53372. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  53373. import "babylonjs/Shaders/glowMapMerge.fragment";
  53374. import "babylonjs/Shaders/glowMapMerge.vertex";
  53375. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  53376. module "babylonjs/abstractScene" {
  53377. interface AbstractScene {
  53378. /**
  53379. * Return a the first highlight layer of the scene with a given name.
  53380. * @param name The name of the highlight layer to look for.
  53381. * @return The highlight layer if found otherwise null.
  53382. */
  53383. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53384. }
  53385. }
  53386. /**
  53387. * Highlight layer options. This helps customizing the behaviour
  53388. * of the highlight layer.
  53389. */
  53390. export interface IHighlightLayerOptions {
  53391. /**
  53392. * Multiplication factor apply to the canvas size to compute the render target size
  53393. * used to generated the glowing objects (the smaller the faster).
  53394. */
  53395. mainTextureRatio: number;
  53396. /**
  53397. * Enforces a fixed size texture to ensure resize independant blur.
  53398. */
  53399. mainTextureFixedSize?: number;
  53400. /**
  53401. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53402. * of the picture to blur (the smaller the faster).
  53403. */
  53404. blurTextureSizeRatio: number;
  53405. /**
  53406. * How big in texel of the blur texture is the vertical blur.
  53407. */
  53408. blurVerticalSize: number;
  53409. /**
  53410. * How big in texel of the blur texture is the horizontal blur.
  53411. */
  53412. blurHorizontalSize: number;
  53413. /**
  53414. * Alpha blending mode used to apply the blur. Default is combine.
  53415. */
  53416. alphaBlendingMode: number;
  53417. /**
  53418. * The camera attached to the layer.
  53419. */
  53420. camera: Nullable<Camera>;
  53421. /**
  53422. * Should we display highlight as a solid stroke?
  53423. */
  53424. isStroke?: boolean;
  53425. /**
  53426. * The rendering group to draw the layer in.
  53427. */
  53428. renderingGroupId: number;
  53429. }
  53430. /**
  53431. * The highlight layer Helps adding a glow effect around a mesh.
  53432. *
  53433. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53434. * glowy meshes to your scene.
  53435. *
  53436. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53437. */
  53438. export class HighlightLayer extends EffectLayer {
  53439. name: string;
  53440. /**
  53441. * Effect Name of the highlight layer.
  53442. */
  53443. static readonly EffectName: string;
  53444. /**
  53445. * The neutral color used during the preparation of the glow effect.
  53446. * This is black by default as the blend operation is a blend operation.
  53447. */
  53448. static NeutralColor: Color4;
  53449. /**
  53450. * Stencil value used for glowing meshes.
  53451. */
  53452. static GlowingMeshStencilReference: number;
  53453. /**
  53454. * Stencil value used for the other meshes in the scene.
  53455. */
  53456. static NormalMeshStencilReference: number;
  53457. /**
  53458. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53459. */
  53460. innerGlow: boolean;
  53461. /**
  53462. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53463. */
  53464. outerGlow: boolean;
  53465. /**
  53466. * Specifies the horizontal size of the blur.
  53467. */
  53468. /**
  53469. * Gets the horizontal size of the blur.
  53470. */
  53471. blurHorizontalSize: number;
  53472. /**
  53473. * Specifies the vertical size of the blur.
  53474. */
  53475. /**
  53476. * Gets the vertical size of the blur.
  53477. */
  53478. blurVerticalSize: number;
  53479. /**
  53480. * An event triggered when the highlight layer is being blurred.
  53481. */
  53482. onBeforeBlurObservable: Observable<HighlightLayer>;
  53483. /**
  53484. * An event triggered when the highlight layer has been blurred.
  53485. */
  53486. onAfterBlurObservable: Observable<HighlightLayer>;
  53487. private _instanceGlowingMeshStencilReference;
  53488. private _options;
  53489. private _downSamplePostprocess;
  53490. private _horizontalBlurPostprocess;
  53491. private _verticalBlurPostprocess;
  53492. private _blurTexture;
  53493. private _meshes;
  53494. private _excludedMeshes;
  53495. /**
  53496. * Instantiates a new highlight Layer and references it to the scene..
  53497. * @param name The name of the layer
  53498. * @param scene The scene to use the layer in
  53499. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53500. */
  53501. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53502. /**
  53503. * Get the effect name of the layer.
  53504. * @return The effect name
  53505. */
  53506. getEffectName(): string;
  53507. /**
  53508. * Create the merge effect. This is the shader use to blit the information back
  53509. * to the main canvas at the end of the scene rendering.
  53510. */
  53511. protected _createMergeEffect(): Effect;
  53512. /**
  53513. * Creates the render target textures and post processes used in the highlight layer.
  53514. */
  53515. protected _createTextureAndPostProcesses(): void;
  53516. /**
  53517. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53518. */
  53519. needStencil(): boolean;
  53520. /**
  53521. * Checks for the readiness of the element composing the layer.
  53522. * @param subMesh the mesh to check for
  53523. * @param useInstances specify wether or not to use instances to render the mesh
  53524. * @param emissiveTexture the associated emissive texture used to generate the glow
  53525. * @return true if ready otherwise, false
  53526. */
  53527. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53528. /**
  53529. * Implementation specific of rendering the generating effect on the main canvas.
  53530. * @param effect The effect used to render through
  53531. */
  53532. protected _internalRender(effect: Effect): void;
  53533. /**
  53534. * Returns true if the layer contains information to display, otherwise false.
  53535. */
  53536. shouldRender(): boolean;
  53537. /**
  53538. * Returns true if the mesh should render, otherwise false.
  53539. * @param mesh The mesh to render
  53540. * @returns true if it should render otherwise false
  53541. */
  53542. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53543. /**
  53544. * Sets the required values for both the emissive texture and and the main color.
  53545. */
  53546. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53547. /**
  53548. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53549. * @param mesh The mesh to exclude from the highlight layer
  53550. */
  53551. addExcludedMesh(mesh: Mesh): void;
  53552. /**
  53553. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53554. * @param mesh The mesh to highlight
  53555. */
  53556. removeExcludedMesh(mesh: Mesh): void;
  53557. /**
  53558. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53559. * @param mesh mesh to test
  53560. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53561. */
  53562. hasMesh(mesh: AbstractMesh): boolean;
  53563. /**
  53564. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53565. * @param mesh The mesh to highlight
  53566. * @param color The color of the highlight
  53567. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53568. */
  53569. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53570. /**
  53571. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53572. * @param mesh The mesh to highlight
  53573. */
  53574. removeMesh(mesh: Mesh): void;
  53575. /**
  53576. * Force the stencil to the normal expected value for none glowing parts
  53577. */
  53578. private _defaultStencilReference;
  53579. /**
  53580. * Free any resources and references associated to a mesh.
  53581. * Internal use
  53582. * @param mesh The mesh to free.
  53583. * @hidden
  53584. */
  53585. _disposeMesh(mesh: Mesh): void;
  53586. /**
  53587. * Dispose the highlight layer and free resources.
  53588. */
  53589. dispose(): void;
  53590. /**
  53591. * Gets the class name of the effect layer
  53592. * @returns the string with the class name of the effect layer
  53593. */
  53594. getClassName(): string;
  53595. /**
  53596. * Serializes this Highlight layer
  53597. * @returns a serialized Highlight layer object
  53598. */
  53599. serialize(): any;
  53600. /**
  53601. * Creates a Highlight layer from parsed Highlight layer data
  53602. * @param parsedHightlightLayer defines the Highlight layer data
  53603. * @param scene defines the current scene
  53604. * @param rootUrl defines the root URL containing the Highlight layer information
  53605. * @returns a parsed Highlight layer
  53606. */
  53607. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53608. }
  53609. }
  53610. declare module "babylonjs/Layers/layerSceneComponent" {
  53611. import { Scene } from "babylonjs/scene";
  53612. import { ISceneComponent } from "babylonjs/sceneComponent";
  53613. import { Layer } from "babylonjs/Layers/layer";
  53614. import { AbstractScene } from "babylonjs/abstractScene";
  53615. module "babylonjs/abstractScene" {
  53616. interface AbstractScene {
  53617. /**
  53618. * The list of layers (background and foreground) of the scene
  53619. */
  53620. layers: Array<Layer>;
  53621. }
  53622. }
  53623. /**
  53624. * Defines the layer scene component responsible to manage any layers
  53625. * in a given scene.
  53626. */
  53627. export class LayerSceneComponent implements ISceneComponent {
  53628. /**
  53629. * The component name helpfull to identify the component in the list of scene components.
  53630. */
  53631. readonly name: string;
  53632. /**
  53633. * The scene the component belongs to.
  53634. */
  53635. scene: Scene;
  53636. private _engine;
  53637. /**
  53638. * Creates a new instance of the component for the given scene
  53639. * @param scene Defines the scene to register the component in
  53640. */
  53641. constructor(scene: Scene);
  53642. /**
  53643. * Registers the component in a given scene
  53644. */
  53645. register(): void;
  53646. /**
  53647. * Rebuilds the elements related to this component in case of
  53648. * context lost for instance.
  53649. */
  53650. rebuild(): void;
  53651. /**
  53652. * Disposes the component and the associated ressources.
  53653. */
  53654. dispose(): void;
  53655. private _draw;
  53656. private _drawCameraPredicate;
  53657. private _drawCameraBackground;
  53658. private _drawCameraForeground;
  53659. private _drawRenderTargetPredicate;
  53660. private _drawRenderTargetBackground;
  53661. private _drawRenderTargetForeground;
  53662. /**
  53663. * Adds all the elements from the container to the scene
  53664. * @param container the container holding the elements
  53665. */
  53666. addFromContainer(container: AbstractScene): void;
  53667. /**
  53668. * Removes all the elements in the container from the scene
  53669. * @param container contains the elements to remove
  53670. * @param dispose if the removed element should be disposed (default: false)
  53671. */
  53672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53673. }
  53674. }
  53675. declare module "babylonjs/Shaders/layer.fragment" {
  53676. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53677. /** @hidden */
  53678. export var layerPixelShader: {
  53679. name: string;
  53680. shader: string;
  53681. };
  53682. }
  53683. declare module "babylonjs/Shaders/layer.vertex" {
  53684. /** @hidden */
  53685. export var layerVertexShader: {
  53686. name: string;
  53687. shader: string;
  53688. };
  53689. }
  53690. declare module "babylonjs/Layers/layer" {
  53691. import { Observable } from "babylonjs/Misc/observable";
  53692. import { Nullable } from "babylonjs/types";
  53693. import { Scene } from "babylonjs/scene";
  53694. import { Vector2 } from "babylonjs/Maths/math.vector";
  53695. import { Color4 } from "babylonjs/Maths/math.color";
  53696. import { Texture } from "babylonjs/Materials/Textures/texture";
  53697. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53698. import "babylonjs/Shaders/layer.fragment";
  53699. import "babylonjs/Shaders/layer.vertex";
  53700. /**
  53701. * This represents a full screen 2d layer.
  53702. * This can be useful to display a picture in the background of your scene for instance.
  53703. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53704. */
  53705. export class Layer {
  53706. /**
  53707. * Define the name of the layer.
  53708. */
  53709. name: string;
  53710. /**
  53711. * Define the texture the layer should display.
  53712. */
  53713. texture: Nullable<Texture>;
  53714. /**
  53715. * Is the layer in background or foreground.
  53716. */
  53717. isBackground: boolean;
  53718. /**
  53719. * Define the color of the layer (instead of texture).
  53720. */
  53721. color: Color4;
  53722. /**
  53723. * Define the scale of the layer in order to zoom in out of the texture.
  53724. */
  53725. scale: Vector2;
  53726. /**
  53727. * Define an offset for the layer in order to shift the texture.
  53728. */
  53729. offset: Vector2;
  53730. /**
  53731. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53732. */
  53733. alphaBlendingMode: number;
  53734. /**
  53735. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53736. * Alpha test will not mix with the background color in case of transparency.
  53737. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53738. */
  53739. alphaTest: boolean;
  53740. /**
  53741. * Define a mask to restrict the layer to only some of the scene cameras.
  53742. */
  53743. layerMask: number;
  53744. /**
  53745. * Define the list of render target the layer is visible into.
  53746. */
  53747. renderTargetTextures: RenderTargetTexture[];
  53748. /**
  53749. * Define if the layer is only used in renderTarget or if it also
  53750. * renders in the main frame buffer of the canvas.
  53751. */
  53752. renderOnlyInRenderTargetTextures: boolean;
  53753. private _scene;
  53754. private _vertexBuffers;
  53755. private _indexBuffer;
  53756. private _effect;
  53757. private _previousDefines;
  53758. /**
  53759. * An event triggered when the layer is disposed.
  53760. */
  53761. onDisposeObservable: Observable<Layer>;
  53762. private _onDisposeObserver;
  53763. /**
  53764. * Back compatibility with callback before the onDisposeObservable existed.
  53765. * The set callback will be triggered when the layer has been disposed.
  53766. */
  53767. onDispose: () => void;
  53768. /**
  53769. * An event triggered before rendering the scene
  53770. */
  53771. onBeforeRenderObservable: Observable<Layer>;
  53772. private _onBeforeRenderObserver;
  53773. /**
  53774. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53775. * The set callback will be triggered just before rendering the layer.
  53776. */
  53777. onBeforeRender: () => void;
  53778. /**
  53779. * An event triggered after rendering the scene
  53780. */
  53781. onAfterRenderObservable: Observable<Layer>;
  53782. private _onAfterRenderObserver;
  53783. /**
  53784. * Back compatibility with callback before the onAfterRenderObservable existed.
  53785. * The set callback will be triggered just after rendering the layer.
  53786. */
  53787. onAfterRender: () => void;
  53788. /**
  53789. * Instantiates a new layer.
  53790. * This represents a full screen 2d layer.
  53791. * This can be useful to display a picture in the background of your scene for instance.
  53792. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53793. * @param name Define the name of the layer in the scene
  53794. * @param imgUrl Define the url of the texture to display in the layer
  53795. * @param scene Define the scene the layer belongs to
  53796. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53797. * @param color Defines a color for the layer
  53798. */
  53799. constructor(
  53800. /**
  53801. * Define the name of the layer.
  53802. */
  53803. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53804. private _createIndexBuffer;
  53805. /** @hidden */
  53806. _rebuild(): void;
  53807. /**
  53808. * Renders the layer in the scene.
  53809. */
  53810. render(): void;
  53811. /**
  53812. * Disposes and releases the associated ressources.
  53813. */
  53814. dispose(): void;
  53815. }
  53816. }
  53817. declare module "babylonjs/Layers/index" {
  53818. export * from "babylonjs/Layers/effectLayer";
  53819. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53820. export * from "babylonjs/Layers/glowLayer";
  53821. export * from "babylonjs/Layers/highlightLayer";
  53822. export * from "babylonjs/Layers/layer";
  53823. export * from "babylonjs/Layers/layerSceneComponent";
  53824. }
  53825. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53826. /** @hidden */
  53827. export var lensFlarePixelShader: {
  53828. name: string;
  53829. shader: string;
  53830. };
  53831. }
  53832. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53833. /** @hidden */
  53834. export var lensFlareVertexShader: {
  53835. name: string;
  53836. shader: string;
  53837. };
  53838. }
  53839. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53840. import { Scene } from "babylonjs/scene";
  53841. import { Vector3 } from "babylonjs/Maths/math.vector";
  53842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53843. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53844. import "babylonjs/Shaders/lensFlare.fragment";
  53845. import "babylonjs/Shaders/lensFlare.vertex";
  53846. import { Viewport } from "babylonjs/Maths/math.viewport";
  53847. /**
  53848. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53849. * It is usually composed of several `lensFlare`.
  53850. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53851. */
  53852. export class LensFlareSystem {
  53853. /**
  53854. * Define the name of the lens flare system
  53855. */
  53856. name: string;
  53857. /**
  53858. * List of lens flares used in this system.
  53859. */
  53860. lensFlares: LensFlare[];
  53861. /**
  53862. * Define a limit from the border the lens flare can be visible.
  53863. */
  53864. borderLimit: number;
  53865. /**
  53866. * Define a viewport border we do not want to see the lens flare in.
  53867. */
  53868. viewportBorder: number;
  53869. /**
  53870. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53871. */
  53872. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53873. /**
  53874. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53875. */
  53876. layerMask: number;
  53877. /**
  53878. * Define the id of the lens flare system in the scene.
  53879. * (equal to name by default)
  53880. */
  53881. id: string;
  53882. private _scene;
  53883. private _emitter;
  53884. private _vertexBuffers;
  53885. private _indexBuffer;
  53886. private _effect;
  53887. private _positionX;
  53888. private _positionY;
  53889. private _isEnabled;
  53890. /** @hidden */
  53891. static _SceneComponentInitialization: (scene: Scene) => void;
  53892. /**
  53893. * Instantiates a lens flare system.
  53894. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53895. * It is usually composed of several `lensFlare`.
  53896. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53897. * @param name Define the name of the lens flare system in the scene
  53898. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53899. * @param scene Define the scene the lens flare system belongs to
  53900. */
  53901. constructor(
  53902. /**
  53903. * Define the name of the lens flare system
  53904. */
  53905. name: string, emitter: any, scene: Scene);
  53906. /**
  53907. * Define if the lens flare system is enabled.
  53908. */
  53909. isEnabled: boolean;
  53910. /**
  53911. * Get the scene the effects belongs to.
  53912. * @returns the scene holding the lens flare system
  53913. */
  53914. getScene(): Scene;
  53915. /**
  53916. * Get the emitter of the lens flare system.
  53917. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53918. * @returns the emitter of the lens flare system
  53919. */
  53920. getEmitter(): any;
  53921. /**
  53922. * Set the emitter of the lens flare system.
  53923. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53924. * @param newEmitter Define the new emitter of the system
  53925. */
  53926. setEmitter(newEmitter: any): void;
  53927. /**
  53928. * Get the lens flare system emitter position.
  53929. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53930. * @returns the position
  53931. */
  53932. getEmitterPosition(): Vector3;
  53933. /**
  53934. * @hidden
  53935. */
  53936. computeEffectivePosition(globalViewport: Viewport): boolean;
  53937. /** @hidden */
  53938. _isVisible(): boolean;
  53939. /**
  53940. * @hidden
  53941. */
  53942. render(): boolean;
  53943. /**
  53944. * Dispose and release the lens flare with its associated resources.
  53945. */
  53946. dispose(): void;
  53947. /**
  53948. * Parse a lens flare system from a JSON repressentation
  53949. * @param parsedLensFlareSystem Define the JSON to parse
  53950. * @param scene Define the scene the parsed system should be instantiated in
  53951. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53952. * @returns the parsed system
  53953. */
  53954. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53955. /**
  53956. * Serialize the current Lens Flare System into a JSON representation.
  53957. * @returns the serialized JSON
  53958. */
  53959. serialize(): any;
  53960. }
  53961. }
  53962. declare module "babylonjs/LensFlares/lensFlare" {
  53963. import { Nullable } from "babylonjs/types";
  53964. import { Color3 } from "babylonjs/Maths/math.color";
  53965. import { Texture } from "babylonjs/Materials/Textures/texture";
  53966. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53967. /**
  53968. * This represents one of the lens effect in a `lensFlareSystem`.
  53969. * It controls one of the indiviual texture used in the effect.
  53970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53971. */
  53972. export class LensFlare {
  53973. /**
  53974. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53975. */
  53976. size: number;
  53977. /**
  53978. * 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.
  53979. */
  53980. position: number;
  53981. /**
  53982. * Define the lens color.
  53983. */
  53984. color: Color3;
  53985. /**
  53986. * Define the lens texture.
  53987. */
  53988. texture: Nullable<Texture>;
  53989. /**
  53990. * Define the alpha mode to render this particular lens.
  53991. */
  53992. alphaMode: number;
  53993. private _system;
  53994. /**
  53995. * Creates a new Lens Flare.
  53996. * This represents one of the lens effect in a `lensFlareSystem`.
  53997. * It controls one of the indiviual texture used in the effect.
  53998. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53999. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54000. * @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.
  54001. * @param color Define the lens color
  54002. * @param imgUrl Define the lens texture url
  54003. * @param system Define the `lensFlareSystem` this flare is part of
  54004. * @returns The newly created Lens Flare
  54005. */
  54006. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54007. /**
  54008. * Instantiates a new Lens Flare.
  54009. * This represents one of the lens effect in a `lensFlareSystem`.
  54010. * It controls one of the indiviual texture used in the effect.
  54011. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54012. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54013. * @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.
  54014. * @param color Define the lens color
  54015. * @param imgUrl Define the lens texture url
  54016. * @param system Define the `lensFlareSystem` this flare is part of
  54017. */
  54018. constructor(
  54019. /**
  54020. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54021. */
  54022. size: number,
  54023. /**
  54024. * 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.
  54025. */
  54026. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54027. /**
  54028. * Dispose and release the lens flare with its associated resources.
  54029. */
  54030. dispose(): void;
  54031. }
  54032. }
  54033. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  54034. import { Nullable } from "babylonjs/types";
  54035. import { Scene } from "babylonjs/scene";
  54036. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54037. import { AbstractScene } from "babylonjs/abstractScene";
  54038. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  54039. module "babylonjs/abstractScene" {
  54040. interface AbstractScene {
  54041. /**
  54042. * The list of lens flare system added to the scene
  54043. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54044. */
  54045. lensFlareSystems: Array<LensFlareSystem>;
  54046. /**
  54047. * Removes the given lens flare system from this scene.
  54048. * @param toRemove The lens flare system to remove
  54049. * @returns The index of the removed lens flare system
  54050. */
  54051. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54052. /**
  54053. * Adds the given lens flare system to this scene
  54054. * @param newLensFlareSystem The lens flare system to add
  54055. */
  54056. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54057. /**
  54058. * Gets a lens flare system using its name
  54059. * @param name defines the name to look for
  54060. * @returns the lens flare system or null if not found
  54061. */
  54062. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54063. /**
  54064. * Gets a lens flare system using its id
  54065. * @param id defines the id to look for
  54066. * @returns the lens flare system or null if not found
  54067. */
  54068. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54069. }
  54070. }
  54071. /**
  54072. * Defines the lens flare scene component responsible to manage any lens flares
  54073. * in a given scene.
  54074. */
  54075. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54076. /**
  54077. * The component name helpfull to identify the component in the list of scene components.
  54078. */
  54079. readonly name: string;
  54080. /**
  54081. * The scene the component belongs to.
  54082. */
  54083. scene: Scene;
  54084. /**
  54085. * Creates a new instance of the component for the given scene
  54086. * @param scene Defines the scene to register the component in
  54087. */
  54088. constructor(scene: Scene);
  54089. /**
  54090. * Registers the component in a given scene
  54091. */
  54092. register(): void;
  54093. /**
  54094. * Rebuilds the elements related to this component in case of
  54095. * context lost for instance.
  54096. */
  54097. rebuild(): void;
  54098. /**
  54099. * Adds all the elements from the container to the scene
  54100. * @param container the container holding the elements
  54101. */
  54102. addFromContainer(container: AbstractScene): void;
  54103. /**
  54104. * Removes all the elements in the container from the scene
  54105. * @param container contains the elements to remove
  54106. * @param dispose if the removed element should be disposed (default: false)
  54107. */
  54108. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54109. /**
  54110. * Serializes the component data to the specified json object
  54111. * @param serializationObject The object to serialize to
  54112. */
  54113. serialize(serializationObject: any): void;
  54114. /**
  54115. * Disposes the component and the associated ressources.
  54116. */
  54117. dispose(): void;
  54118. private _draw;
  54119. }
  54120. }
  54121. declare module "babylonjs/LensFlares/index" {
  54122. export * from "babylonjs/LensFlares/lensFlare";
  54123. export * from "babylonjs/LensFlares/lensFlareSystem";
  54124. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  54125. }
  54126. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  54127. import { Scene } from "babylonjs/scene";
  54128. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54129. import { AbstractScene } from "babylonjs/abstractScene";
  54130. /**
  54131. * Defines the shadow generator component responsible to manage any shadow generators
  54132. * in a given scene.
  54133. */
  54134. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54135. /**
  54136. * The component name helpfull to identify the component in the list of scene components.
  54137. */
  54138. readonly name: string;
  54139. /**
  54140. * The scene the component belongs to.
  54141. */
  54142. scene: Scene;
  54143. /**
  54144. * Creates a new instance of the component for the given scene
  54145. * @param scene Defines the scene to register the component in
  54146. */
  54147. constructor(scene: Scene);
  54148. /**
  54149. * Registers the component in a given scene
  54150. */
  54151. register(): void;
  54152. /**
  54153. * Rebuilds the elements related to this component in case of
  54154. * context lost for instance.
  54155. */
  54156. rebuild(): void;
  54157. /**
  54158. * Serializes the component data to the specified json object
  54159. * @param serializationObject The object to serialize to
  54160. */
  54161. serialize(serializationObject: any): void;
  54162. /**
  54163. * Adds all the elements from the container to the scene
  54164. * @param container the container holding the elements
  54165. */
  54166. addFromContainer(container: AbstractScene): void;
  54167. /**
  54168. * Removes all the elements in the container from the scene
  54169. * @param container contains the elements to remove
  54170. * @param dispose if the removed element should be disposed (default: false)
  54171. */
  54172. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54173. /**
  54174. * Rebuilds the elements related to this component in case of
  54175. * context lost for instance.
  54176. */
  54177. dispose(): void;
  54178. private _gatherRenderTargets;
  54179. }
  54180. }
  54181. declare module "babylonjs/Lights/Shadows/index" {
  54182. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  54183. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  54184. }
  54185. declare module "babylonjs/Lights/pointLight" {
  54186. import { Scene } from "babylonjs/scene";
  54187. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54189. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54190. import { Effect } from "babylonjs/Materials/effect";
  54191. /**
  54192. * A point light is a light defined by an unique point in world space.
  54193. * The light is emitted in every direction from this point.
  54194. * A good example of a point light is a standard light bulb.
  54195. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54196. */
  54197. export class PointLight extends ShadowLight {
  54198. private _shadowAngle;
  54199. /**
  54200. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54201. * This specifies what angle the shadow will use to be created.
  54202. *
  54203. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54204. */
  54205. /**
  54206. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54207. * This specifies what angle the shadow will use to be created.
  54208. *
  54209. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54210. */
  54211. shadowAngle: number;
  54212. /**
  54213. * Gets the direction if it has been set.
  54214. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54215. */
  54216. /**
  54217. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54218. */
  54219. direction: Vector3;
  54220. /**
  54221. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54222. * A PointLight emits the light in every direction.
  54223. * It can cast shadows.
  54224. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54225. * ```javascript
  54226. * var pointLight = new PointLight("pl", camera.position, scene);
  54227. * ```
  54228. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54229. * @param name The light friendly name
  54230. * @param position The position of the point light in the scene
  54231. * @param scene The scene the lights belongs to
  54232. */
  54233. constructor(name: string, position: Vector3, scene: Scene);
  54234. /**
  54235. * Returns the string "PointLight"
  54236. * @returns the class name
  54237. */
  54238. getClassName(): string;
  54239. /**
  54240. * Returns the integer 0.
  54241. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54242. */
  54243. getTypeID(): number;
  54244. /**
  54245. * Specifies wether or not the shadowmap should be a cube texture.
  54246. * @returns true if the shadowmap needs to be a cube texture.
  54247. */
  54248. needCube(): boolean;
  54249. /**
  54250. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54251. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54252. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54253. */
  54254. getShadowDirection(faceIndex?: number): Vector3;
  54255. /**
  54256. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54257. * - fov = PI / 2
  54258. * - aspect ratio : 1.0
  54259. * - z-near and far equal to the active camera minZ and maxZ.
  54260. * Returns the PointLight.
  54261. */
  54262. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54263. protected _buildUniformLayout(): void;
  54264. /**
  54265. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54266. * @param effect The effect to update
  54267. * @param lightIndex The index of the light in the effect to update
  54268. * @returns The point light
  54269. */
  54270. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54271. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54272. /**
  54273. * Prepares the list of defines specific to the light type.
  54274. * @param defines the list of defines
  54275. * @param lightIndex defines the index of the light for the effect
  54276. */
  54277. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54278. }
  54279. }
  54280. declare module "babylonjs/Lights/index" {
  54281. export * from "babylonjs/Lights/light";
  54282. export * from "babylonjs/Lights/shadowLight";
  54283. export * from "babylonjs/Lights/Shadows/index";
  54284. export * from "babylonjs/Lights/directionalLight";
  54285. export * from "babylonjs/Lights/hemisphericLight";
  54286. export * from "babylonjs/Lights/pointLight";
  54287. export * from "babylonjs/Lights/spotLight";
  54288. }
  54289. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  54290. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54291. /**
  54292. * Header information of HDR texture files.
  54293. */
  54294. export interface HDRInfo {
  54295. /**
  54296. * The height of the texture in pixels.
  54297. */
  54298. height: number;
  54299. /**
  54300. * The width of the texture in pixels.
  54301. */
  54302. width: number;
  54303. /**
  54304. * The index of the beginning of the data in the binary file.
  54305. */
  54306. dataPosition: number;
  54307. }
  54308. /**
  54309. * This groups tools to convert HDR texture to native colors array.
  54310. */
  54311. export class HDRTools {
  54312. private static Ldexp;
  54313. private static Rgbe2float;
  54314. private static readStringLine;
  54315. /**
  54316. * Reads header information from an RGBE texture stored in a native array.
  54317. * More information on this format are available here:
  54318. * https://en.wikipedia.org/wiki/RGBE_image_format
  54319. *
  54320. * @param uint8array The binary file stored in native array.
  54321. * @return The header information.
  54322. */
  54323. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54324. /**
  54325. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54326. * This RGBE texture needs to store the information as a panorama.
  54327. *
  54328. * More information on this format are available here:
  54329. * https://en.wikipedia.org/wiki/RGBE_image_format
  54330. *
  54331. * @param buffer The binary file stored in an array buffer.
  54332. * @param size The expected size of the extracted cubemap.
  54333. * @return The Cube Map information.
  54334. */
  54335. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54336. /**
  54337. * Returns the pixels data extracted from an RGBE texture.
  54338. * This pixels will be stored left to right up to down in the R G B order in one array.
  54339. *
  54340. * More information on this format are available here:
  54341. * https://en.wikipedia.org/wiki/RGBE_image_format
  54342. *
  54343. * @param uint8array The binary file stored in an array buffer.
  54344. * @param hdrInfo The header information of the file.
  54345. * @return The pixels data in RGB right to left up to down order.
  54346. */
  54347. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54348. private static RGBE_ReadPixels_RLE;
  54349. }
  54350. }
  54351. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  54352. import { Nullable } from "babylonjs/types";
  54353. import { Scene } from "babylonjs/scene";
  54354. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54356. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54357. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54358. /**
  54359. * This represents a texture coming from an HDR input.
  54360. *
  54361. * The only supported format is currently panorama picture stored in RGBE format.
  54362. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54363. */
  54364. export class HDRCubeTexture extends BaseTexture {
  54365. private static _facesMapping;
  54366. private _generateHarmonics;
  54367. private _noMipmap;
  54368. private _textureMatrix;
  54369. private _size;
  54370. private _onLoad;
  54371. private _onError;
  54372. /**
  54373. * The texture URL.
  54374. */
  54375. url: string;
  54376. /**
  54377. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54378. */
  54379. coordinatesMode: number;
  54380. protected _isBlocking: boolean;
  54381. /**
  54382. * Sets wether or not the texture is blocking during loading.
  54383. */
  54384. /**
  54385. * Gets wether or not the texture is blocking during loading.
  54386. */
  54387. isBlocking: boolean;
  54388. protected _rotationY: number;
  54389. /**
  54390. * Sets texture matrix rotation angle around Y axis in radians.
  54391. */
  54392. /**
  54393. * Gets texture matrix rotation angle around Y axis radians.
  54394. */
  54395. rotationY: number;
  54396. /**
  54397. * Gets or sets the center of the bounding box associated with the cube texture
  54398. * It must define where the camera used to render the texture was set
  54399. */
  54400. boundingBoxPosition: Vector3;
  54401. private _boundingBoxSize;
  54402. /**
  54403. * Gets or sets the size of the bounding box associated with the cube texture
  54404. * When defined, the cubemap will switch to local mode
  54405. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54406. * @example https://www.babylonjs-playground.com/#RNASML
  54407. */
  54408. boundingBoxSize: Vector3;
  54409. /**
  54410. * Instantiates an HDRTexture from the following parameters.
  54411. *
  54412. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54413. * @param scene The scene the texture will be used in
  54414. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54415. * @param noMipmap Forces to not generate the mipmap if true
  54416. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54417. * @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)
  54418. * @param reserved Reserved flag for internal use.
  54419. */
  54420. 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>);
  54421. /**
  54422. * Get the current class name of the texture useful for serialization or dynamic coding.
  54423. * @returns "HDRCubeTexture"
  54424. */
  54425. getClassName(): string;
  54426. /**
  54427. * Occurs when the file is raw .hdr file.
  54428. */
  54429. private loadTexture;
  54430. clone(): HDRCubeTexture;
  54431. delayLoad(): void;
  54432. /**
  54433. * Get the texture reflection matrix used to rotate/transform the reflection.
  54434. * @returns the reflection matrix
  54435. */
  54436. getReflectionTextureMatrix(): Matrix;
  54437. /**
  54438. * Set the texture reflection matrix used to rotate/transform the reflection.
  54439. * @param value Define the reflection matrix to set
  54440. */
  54441. setReflectionTextureMatrix(value: Matrix): void;
  54442. /**
  54443. * Parses a JSON representation of an HDR Texture in order to create the texture
  54444. * @param parsedTexture Define the JSON representation
  54445. * @param scene Define the scene the texture should be created in
  54446. * @param rootUrl Define the root url in case we need to load relative dependencies
  54447. * @returns the newly created texture after parsing
  54448. */
  54449. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54450. serialize(): any;
  54451. }
  54452. }
  54453. declare module "babylonjs/Physics/physicsEngine" {
  54454. import { Nullable } from "babylonjs/types";
  54455. import { Vector3 } from "babylonjs/Maths/math.vector";
  54456. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  54457. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  54458. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  54459. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54460. /**
  54461. * Class used to control physics engine
  54462. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54463. */
  54464. export class PhysicsEngine implements IPhysicsEngine {
  54465. private _physicsPlugin;
  54466. /**
  54467. * Global value used to control the smallest number supported by the simulation
  54468. */
  54469. static Epsilon: number;
  54470. private _impostors;
  54471. private _joints;
  54472. private _subTimeStep;
  54473. /**
  54474. * Gets the gravity vector used by the simulation
  54475. */
  54476. gravity: Vector3;
  54477. /**
  54478. * Factory used to create the default physics plugin.
  54479. * @returns The default physics plugin
  54480. */
  54481. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54482. /**
  54483. * Creates a new Physics Engine
  54484. * @param gravity defines the gravity vector used by the simulation
  54485. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54486. */
  54487. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54488. /**
  54489. * Sets the gravity vector used by the simulation
  54490. * @param gravity defines the gravity vector to use
  54491. */
  54492. setGravity(gravity: Vector3): void;
  54493. /**
  54494. * Set the time step of the physics engine.
  54495. * Default is 1/60.
  54496. * To slow it down, enter 1/600 for example.
  54497. * To speed it up, 1/30
  54498. * @param newTimeStep defines the new timestep to apply to this world.
  54499. */
  54500. setTimeStep(newTimeStep?: number): void;
  54501. /**
  54502. * Get the time step of the physics engine.
  54503. * @returns the current time step
  54504. */
  54505. getTimeStep(): number;
  54506. /**
  54507. * Set the sub time step of the physics engine.
  54508. * Default is 0 meaning there is no sub steps
  54509. * To increase physics resolution precision, set a small value (like 1 ms)
  54510. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54511. */
  54512. setSubTimeStep(subTimeStep?: number): void;
  54513. /**
  54514. * Get the sub time step of the physics engine.
  54515. * @returns the current sub time step
  54516. */
  54517. getSubTimeStep(): number;
  54518. /**
  54519. * Release all resources
  54520. */
  54521. dispose(): void;
  54522. /**
  54523. * Gets the name of the current physics plugin
  54524. * @returns the name of the plugin
  54525. */
  54526. getPhysicsPluginName(): string;
  54527. /**
  54528. * Adding a new impostor for the impostor tracking.
  54529. * This will be done by the impostor itself.
  54530. * @param impostor the impostor to add
  54531. */
  54532. addImpostor(impostor: PhysicsImpostor): void;
  54533. /**
  54534. * Remove an impostor from the engine.
  54535. * This impostor and its mesh will not longer be updated by the physics engine.
  54536. * @param impostor the impostor to remove
  54537. */
  54538. removeImpostor(impostor: PhysicsImpostor): void;
  54539. /**
  54540. * Add a joint to the physics engine
  54541. * @param mainImpostor defines the main impostor to which the joint is added.
  54542. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54543. * @param joint defines the joint that will connect both impostors.
  54544. */
  54545. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54546. /**
  54547. * Removes a joint from the simulation
  54548. * @param mainImpostor defines the impostor used with the joint
  54549. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54550. * @param joint defines the joint to remove
  54551. */
  54552. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54553. /**
  54554. * Called by the scene. No need to call it.
  54555. * @param delta defines the timespam between frames
  54556. */
  54557. _step(delta: number): void;
  54558. /**
  54559. * Gets the current plugin used to run the simulation
  54560. * @returns current plugin
  54561. */
  54562. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54563. /**
  54564. * Gets the list of physic impostors
  54565. * @returns an array of PhysicsImpostor
  54566. */
  54567. getImpostors(): Array<PhysicsImpostor>;
  54568. /**
  54569. * Gets the impostor for a physics enabled object
  54570. * @param object defines the object impersonated by the impostor
  54571. * @returns the PhysicsImpostor or null if not found
  54572. */
  54573. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54574. /**
  54575. * Gets the impostor for a physics body object
  54576. * @param body defines physics body used by the impostor
  54577. * @returns the PhysicsImpostor or null if not found
  54578. */
  54579. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54580. /**
  54581. * Does a raycast in the physics world
  54582. * @param from when should the ray start?
  54583. * @param to when should the ray end?
  54584. * @returns PhysicsRaycastResult
  54585. */
  54586. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54587. }
  54588. }
  54589. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54590. import { Nullable } from "babylonjs/types";
  54591. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54593. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54594. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54595. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54596. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54597. /** @hidden */
  54598. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54599. private _useDeltaForWorldStep;
  54600. world: any;
  54601. name: string;
  54602. private _physicsMaterials;
  54603. private _fixedTimeStep;
  54604. private _cannonRaycastResult;
  54605. private _raycastResult;
  54606. private _physicsBodysToRemoveAfterStep;
  54607. BJSCANNON: any;
  54608. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54609. setGravity(gravity: Vector3): void;
  54610. setTimeStep(timeStep: number): void;
  54611. getTimeStep(): number;
  54612. executeStep(delta: number): void;
  54613. private _removeMarkedPhysicsBodiesFromWorld;
  54614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54617. private _processChildMeshes;
  54618. removePhysicsBody(impostor: PhysicsImpostor): void;
  54619. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54621. private _addMaterial;
  54622. private _checkWithEpsilon;
  54623. private _createShape;
  54624. private _createHeightmap;
  54625. private _minus90X;
  54626. private _plus90X;
  54627. private _tmpPosition;
  54628. private _tmpDeltaPosition;
  54629. private _tmpUnityRotation;
  54630. private _updatePhysicsBodyTransformation;
  54631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54633. isSupported(): boolean;
  54634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54635. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54636. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54637. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54638. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54639. getBodyMass(impostor: PhysicsImpostor): number;
  54640. getBodyFriction(impostor: PhysicsImpostor): number;
  54641. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54642. getBodyRestitution(impostor: PhysicsImpostor): number;
  54643. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54644. sleepBody(impostor: PhysicsImpostor): void;
  54645. wakeUpBody(impostor: PhysicsImpostor): void;
  54646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54647. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54650. getRadius(impostor: PhysicsImpostor): number;
  54651. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54652. dispose(): void;
  54653. private _extendNamespace;
  54654. /**
  54655. * Does a raycast in the physics world
  54656. * @param from when should the ray start?
  54657. * @param to when should the ray end?
  54658. * @returns PhysicsRaycastResult
  54659. */
  54660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54661. }
  54662. }
  54663. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54664. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54666. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54668. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54669. import { Nullable } from "babylonjs/types";
  54670. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54671. /** @hidden */
  54672. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54673. world: any;
  54674. name: string;
  54675. BJSOIMO: any;
  54676. private _raycastResult;
  54677. constructor(iterations?: number, oimoInjection?: any);
  54678. setGravity(gravity: Vector3): void;
  54679. setTimeStep(timeStep: number): void;
  54680. getTimeStep(): number;
  54681. private _tmpImpostorsArray;
  54682. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54683. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54684. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54685. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54686. private _tmpPositionVector;
  54687. removePhysicsBody(impostor: PhysicsImpostor): void;
  54688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54689. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54690. isSupported(): boolean;
  54691. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54692. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54693. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54694. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54695. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54696. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54697. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54698. getBodyMass(impostor: PhysicsImpostor): number;
  54699. getBodyFriction(impostor: PhysicsImpostor): number;
  54700. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54701. getBodyRestitution(impostor: PhysicsImpostor): number;
  54702. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54703. sleepBody(impostor: PhysicsImpostor): void;
  54704. wakeUpBody(impostor: PhysicsImpostor): void;
  54705. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54706. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54707. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54708. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54709. getRadius(impostor: PhysicsImpostor): number;
  54710. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54711. dispose(): void;
  54712. /**
  54713. * Does a raycast in the physics world
  54714. * @param from when should the ray start?
  54715. * @param to when should the ray end?
  54716. * @returns PhysicsRaycastResult
  54717. */
  54718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54719. }
  54720. }
  54721. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54722. import { Nullable } from "babylonjs/types";
  54723. import { Scene } from "babylonjs/scene";
  54724. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54725. import { Color4 } from "babylonjs/Maths/math.color";
  54726. import { Mesh } from "babylonjs/Meshes/mesh";
  54727. /**
  54728. * Class containing static functions to help procedurally build meshes
  54729. */
  54730. export class RibbonBuilder {
  54731. /**
  54732. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54733. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54734. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54735. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54736. * * 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
  54737. * * 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
  54738. * * 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
  54739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54741. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54742. * * 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
  54743. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54744. * * 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
  54745. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54747. * @param name defines the name of the mesh
  54748. * @param options defines the options used to create the mesh
  54749. * @param scene defines the hosting scene
  54750. * @returns the ribbon mesh
  54751. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54753. */
  54754. static CreateRibbon(name: string, options: {
  54755. pathArray: Vector3[][];
  54756. closeArray?: boolean;
  54757. closePath?: boolean;
  54758. offset?: number;
  54759. updatable?: boolean;
  54760. sideOrientation?: number;
  54761. frontUVs?: Vector4;
  54762. backUVs?: Vector4;
  54763. instance?: Mesh;
  54764. invertUV?: boolean;
  54765. uvs?: Vector2[];
  54766. colors?: Color4[];
  54767. }, scene?: Nullable<Scene>): Mesh;
  54768. }
  54769. }
  54770. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54771. import { Nullable } from "babylonjs/types";
  54772. import { Scene } from "babylonjs/scene";
  54773. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54774. import { Mesh } from "babylonjs/Meshes/mesh";
  54775. /**
  54776. * Class containing static functions to help procedurally build meshes
  54777. */
  54778. export class ShapeBuilder {
  54779. /**
  54780. * 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.
  54781. * * 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.
  54782. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54783. * * 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.
  54784. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54785. * * 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
  54786. * * 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
  54787. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54790. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54792. * @param name defines the name of the mesh
  54793. * @param options defines the options used to create the mesh
  54794. * @param scene defines the hosting scene
  54795. * @returns the extruded shape mesh
  54796. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54798. */
  54799. static ExtrudeShape(name: string, options: {
  54800. shape: Vector3[];
  54801. path: Vector3[];
  54802. scale?: number;
  54803. rotation?: number;
  54804. cap?: number;
  54805. updatable?: boolean;
  54806. sideOrientation?: number;
  54807. frontUVs?: Vector4;
  54808. backUVs?: Vector4;
  54809. instance?: Mesh;
  54810. invertUV?: boolean;
  54811. }, scene?: Nullable<Scene>): Mesh;
  54812. /**
  54813. * Creates an custom extruded shape mesh.
  54814. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54815. * * 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.
  54816. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54817. * * 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
  54818. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54819. * * 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
  54820. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54821. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54822. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54823. * * 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
  54824. * * 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
  54825. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54828. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54830. * @param name defines the name of the mesh
  54831. * @param options defines the options used to create the mesh
  54832. * @param scene defines the hosting scene
  54833. * @returns the custom extruded shape mesh
  54834. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54835. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54836. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54837. */
  54838. static ExtrudeShapeCustom(name: string, options: {
  54839. shape: Vector3[];
  54840. path: Vector3[];
  54841. scaleFunction?: any;
  54842. rotationFunction?: any;
  54843. ribbonCloseArray?: boolean;
  54844. ribbonClosePath?: boolean;
  54845. cap?: number;
  54846. updatable?: boolean;
  54847. sideOrientation?: number;
  54848. frontUVs?: Vector4;
  54849. backUVs?: Vector4;
  54850. instance?: Mesh;
  54851. invertUV?: boolean;
  54852. }, scene?: Nullable<Scene>): Mesh;
  54853. private static _ExtrudeShapeGeneric;
  54854. }
  54855. }
  54856. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54857. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54858. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54859. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54860. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54861. import { Nullable } from "babylonjs/types";
  54862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54863. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54864. /**
  54865. * AmmoJS Physics plugin
  54866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54867. * @see https://github.com/kripken/ammo.js/
  54868. */
  54869. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54870. private _useDeltaForWorldStep;
  54871. /**
  54872. * Reference to the Ammo library
  54873. */
  54874. bjsAMMO: any;
  54875. /**
  54876. * Created ammoJS world which physics bodies are added to
  54877. */
  54878. world: any;
  54879. /**
  54880. * Name of the plugin
  54881. */
  54882. name: string;
  54883. private _timeStep;
  54884. private _fixedTimeStep;
  54885. private _maxSteps;
  54886. private _tmpQuaternion;
  54887. private _tmpAmmoTransform;
  54888. private _tmpAmmoQuaternion;
  54889. private _tmpAmmoConcreteContactResultCallback;
  54890. private _collisionConfiguration;
  54891. private _dispatcher;
  54892. private _overlappingPairCache;
  54893. private _solver;
  54894. private _softBodySolver;
  54895. private _tmpAmmoVectorA;
  54896. private _tmpAmmoVectorB;
  54897. private _tmpAmmoVectorC;
  54898. private _tmpAmmoVectorD;
  54899. private _tmpContactCallbackResult;
  54900. private _tmpAmmoVectorRCA;
  54901. private _tmpAmmoVectorRCB;
  54902. private _raycastResult;
  54903. private static readonly DISABLE_COLLISION_FLAG;
  54904. private static readonly KINEMATIC_FLAG;
  54905. private static readonly DISABLE_DEACTIVATION_FLAG;
  54906. /**
  54907. * Initializes the ammoJS plugin
  54908. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54909. * @param ammoInjection can be used to inject your own ammo reference
  54910. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54911. */
  54912. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54913. /**
  54914. * Sets the gravity of the physics world (m/(s^2))
  54915. * @param gravity Gravity to set
  54916. */
  54917. setGravity(gravity: Vector3): void;
  54918. /**
  54919. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54920. * @param timeStep timestep to use in seconds
  54921. */
  54922. setTimeStep(timeStep: number): void;
  54923. /**
  54924. * 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)
  54925. * @param fixedTimeStep fixedTimeStep to use in seconds
  54926. */
  54927. setFixedTimeStep(fixedTimeStep: number): void;
  54928. /**
  54929. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54930. * @param maxSteps the maximum number of steps by the physics engine per frame
  54931. */
  54932. setMaxSteps(maxSteps: number): void;
  54933. /**
  54934. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54935. * @returns the current timestep in seconds
  54936. */
  54937. getTimeStep(): number;
  54938. /**
  54939. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  54940. */
  54941. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  54942. private _isImpostorInContact;
  54943. private _isImpostorPairInContact;
  54944. private _stepSimulation;
  54945. /**
  54946. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54947. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54948. * After the step the babylon meshes are set to the position of the physics imposters
  54949. * @param delta amount of time to step forward
  54950. * @param impostors array of imposters to update before/after the step
  54951. */
  54952. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54953. /**
  54954. * Update babylon mesh to match physics world object
  54955. * @param impostor imposter to match
  54956. */
  54957. private _afterSoftStep;
  54958. /**
  54959. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54960. * @param impostor imposter to match
  54961. */
  54962. private _ropeStep;
  54963. /**
  54964. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54965. * @param impostor imposter to match
  54966. */
  54967. private _softbodyOrClothStep;
  54968. private _tmpVector;
  54969. private _tmpMatrix;
  54970. /**
  54971. * Applies an impulse on the imposter
  54972. * @param impostor imposter to apply impulse to
  54973. * @param force amount of force to be applied to the imposter
  54974. * @param contactPoint the location to apply the impulse on the imposter
  54975. */
  54976. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54977. /**
  54978. * Applies a force on the imposter
  54979. * @param impostor imposter to apply force
  54980. * @param force amount of force to be applied to the imposter
  54981. * @param contactPoint the location to apply the force on the imposter
  54982. */
  54983. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54984. /**
  54985. * Creates a physics body using the plugin
  54986. * @param impostor the imposter to create the physics body on
  54987. */
  54988. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54989. /**
  54990. * Removes the physics body from the imposter and disposes of the body's memory
  54991. * @param impostor imposter to remove the physics body from
  54992. */
  54993. removePhysicsBody(impostor: PhysicsImpostor): void;
  54994. /**
  54995. * Generates a joint
  54996. * @param impostorJoint the imposter joint to create the joint with
  54997. */
  54998. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54999. /**
  55000. * Removes a joint
  55001. * @param impostorJoint the imposter joint to remove the joint from
  55002. */
  55003. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55004. private _addMeshVerts;
  55005. /**
  55006. * Initialise the soft body vertices to match its object's (mesh) vertices
  55007. * Softbody vertices (nodes) are in world space and to match this
  55008. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55009. * @param impostor to create the softbody for
  55010. */
  55011. private _softVertexData;
  55012. /**
  55013. * Create an impostor's soft body
  55014. * @param impostor to create the softbody for
  55015. */
  55016. private _createSoftbody;
  55017. /**
  55018. * Create cloth for an impostor
  55019. * @param impostor to create the softbody for
  55020. */
  55021. private _createCloth;
  55022. /**
  55023. * Create rope for an impostor
  55024. * @param impostor to create the softbody for
  55025. */
  55026. private _createRope;
  55027. /**
  55028. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55029. * @param impostor to create the custom physics shape for
  55030. */
  55031. private _createCustom;
  55032. private _addHullVerts;
  55033. private _createShape;
  55034. /**
  55035. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55036. * @param impostor imposter containing the physics body and babylon object
  55037. */
  55038. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55039. /**
  55040. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55041. * @param impostor imposter containing the physics body and babylon object
  55042. * @param newPosition new position
  55043. * @param newRotation new rotation
  55044. */
  55045. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55046. /**
  55047. * If this plugin is supported
  55048. * @returns true if its supported
  55049. */
  55050. isSupported(): boolean;
  55051. /**
  55052. * Sets the linear velocity of the physics body
  55053. * @param impostor imposter to set the velocity on
  55054. * @param velocity velocity to set
  55055. */
  55056. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55057. /**
  55058. * Sets the angular velocity of the physics body
  55059. * @param impostor imposter to set the velocity on
  55060. * @param velocity velocity to set
  55061. */
  55062. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55063. /**
  55064. * gets the linear velocity
  55065. * @param impostor imposter to get linear velocity from
  55066. * @returns linear velocity
  55067. */
  55068. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55069. /**
  55070. * gets the angular velocity
  55071. * @param impostor imposter to get angular velocity from
  55072. * @returns angular velocity
  55073. */
  55074. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55075. /**
  55076. * Sets the mass of physics body
  55077. * @param impostor imposter to set the mass on
  55078. * @param mass mass to set
  55079. */
  55080. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55081. /**
  55082. * Gets the mass of the physics body
  55083. * @param impostor imposter to get the mass from
  55084. * @returns mass
  55085. */
  55086. getBodyMass(impostor: PhysicsImpostor): number;
  55087. /**
  55088. * Gets friction of the impostor
  55089. * @param impostor impostor to get friction from
  55090. * @returns friction value
  55091. */
  55092. getBodyFriction(impostor: PhysicsImpostor): number;
  55093. /**
  55094. * Sets friction of the impostor
  55095. * @param impostor impostor to set friction on
  55096. * @param friction friction value
  55097. */
  55098. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55099. /**
  55100. * Gets restitution of the impostor
  55101. * @param impostor impostor to get restitution from
  55102. * @returns restitution value
  55103. */
  55104. getBodyRestitution(impostor: PhysicsImpostor): number;
  55105. /**
  55106. * Sets resitution of the impostor
  55107. * @param impostor impostor to set resitution on
  55108. * @param restitution resitution value
  55109. */
  55110. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55111. /**
  55112. * Gets pressure inside the impostor
  55113. * @param impostor impostor to get pressure from
  55114. * @returns pressure value
  55115. */
  55116. getBodyPressure(impostor: PhysicsImpostor): number;
  55117. /**
  55118. * Sets pressure inside a soft body impostor
  55119. * Cloth and rope must remain 0 pressure
  55120. * @param impostor impostor to set pressure on
  55121. * @param pressure pressure value
  55122. */
  55123. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55124. /**
  55125. * Gets stiffness of the impostor
  55126. * @param impostor impostor to get stiffness from
  55127. * @returns pressure value
  55128. */
  55129. getBodyStiffness(impostor: PhysicsImpostor): number;
  55130. /**
  55131. * Sets stiffness of the impostor
  55132. * @param impostor impostor to set stiffness on
  55133. * @param stiffness stiffness value from 0 to 1
  55134. */
  55135. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55136. /**
  55137. * Gets velocityIterations of the impostor
  55138. * @param impostor impostor to get velocity iterations from
  55139. * @returns velocityIterations value
  55140. */
  55141. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55142. /**
  55143. * Sets velocityIterations of the impostor
  55144. * @param impostor impostor to set velocity iterations on
  55145. * @param velocityIterations velocityIterations value
  55146. */
  55147. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55148. /**
  55149. * Gets positionIterations of the impostor
  55150. * @param impostor impostor to get position iterations from
  55151. * @returns positionIterations value
  55152. */
  55153. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55154. /**
  55155. * Sets positionIterations of the impostor
  55156. * @param impostor impostor to set position on
  55157. * @param positionIterations positionIterations value
  55158. */
  55159. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55160. /**
  55161. * Append an anchor to a cloth object
  55162. * @param impostor is the cloth impostor to add anchor to
  55163. * @param otherImpostor is the rigid impostor to anchor to
  55164. * @param width ratio across width from 0 to 1
  55165. * @param height ratio up height from 0 to 1
  55166. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55167. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55168. */
  55169. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55170. /**
  55171. * Append an hook to a rope object
  55172. * @param impostor is the rope impostor to add hook to
  55173. * @param otherImpostor is the rigid impostor to hook to
  55174. * @param length ratio along the rope from 0 to 1
  55175. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55176. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55177. */
  55178. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55179. /**
  55180. * Sleeps the physics body and stops it from being active
  55181. * @param impostor impostor to sleep
  55182. */
  55183. sleepBody(impostor: PhysicsImpostor): void;
  55184. /**
  55185. * Activates the physics body
  55186. * @param impostor impostor to activate
  55187. */
  55188. wakeUpBody(impostor: PhysicsImpostor): void;
  55189. /**
  55190. * Updates the distance parameters of the joint
  55191. * @param joint joint to update
  55192. * @param maxDistance maximum distance of the joint
  55193. * @param minDistance minimum distance of the joint
  55194. */
  55195. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55196. /**
  55197. * Sets a motor on the joint
  55198. * @param joint joint to set motor on
  55199. * @param speed speed of the motor
  55200. * @param maxForce maximum force of the motor
  55201. * @param motorIndex index of the motor
  55202. */
  55203. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55204. /**
  55205. * Sets the motors limit
  55206. * @param joint joint to set limit on
  55207. * @param upperLimit upper limit
  55208. * @param lowerLimit lower limit
  55209. */
  55210. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55211. /**
  55212. * Syncs the position and rotation of a mesh with the impostor
  55213. * @param mesh mesh to sync
  55214. * @param impostor impostor to update the mesh with
  55215. */
  55216. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55217. /**
  55218. * Gets the radius of the impostor
  55219. * @param impostor impostor to get radius from
  55220. * @returns the radius
  55221. */
  55222. getRadius(impostor: PhysicsImpostor): number;
  55223. /**
  55224. * Gets the box size of the impostor
  55225. * @param impostor impostor to get box size from
  55226. * @param result the resulting box size
  55227. */
  55228. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55229. /**
  55230. * Disposes of the impostor
  55231. */
  55232. dispose(): void;
  55233. /**
  55234. * Does a raycast in the physics world
  55235. * @param from when should the ray start?
  55236. * @param to when should the ray end?
  55237. * @returns PhysicsRaycastResult
  55238. */
  55239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55240. }
  55241. }
  55242. declare module "babylonjs/Probes/reflectionProbe" {
  55243. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55244. import { Vector3 } from "babylonjs/Maths/math.vector";
  55245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55246. import { Nullable } from "babylonjs/types";
  55247. import { Scene } from "babylonjs/scene";
  55248. module "babylonjs/abstractScene" {
  55249. interface AbstractScene {
  55250. /**
  55251. * The list of reflection probes added to the scene
  55252. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55253. */
  55254. reflectionProbes: Array<ReflectionProbe>;
  55255. /**
  55256. * Removes the given reflection probe from this scene.
  55257. * @param toRemove The reflection probe to remove
  55258. * @returns The index of the removed reflection probe
  55259. */
  55260. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55261. /**
  55262. * Adds the given reflection probe to this scene.
  55263. * @param newReflectionProbe The reflection probe to add
  55264. */
  55265. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55266. }
  55267. }
  55268. /**
  55269. * Class used to generate realtime reflection / refraction cube textures
  55270. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55271. */
  55272. export class ReflectionProbe {
  55273. /** defines the name of the probe */
  55274. name: string;
  55275. private _scene;
  55276. private _renderTargetTexture;
  55277. private _projectionMatrix;
  55278. private _viewMatrix;
  55279. private _target;
  55280. private _add;
  55281. private _attachedMesh;
  55282. private _invertYAxis;
  55283. /** Gets or sets probe position (center of the cube map) */
  55284. position: Vector3;
  55285. /**
  55286. * Creates a new reflection probe
  55287. * @param name defines the name of the probe
  55288. * @param size defines the texture resolution (for each face)
  55289. * @param scene defines the hosting scene
  55290. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55291. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55292. */
  55293. constructor(
  55294. /** defines the name of the probe */
  55295. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55296. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55297. samples: number;
  55298. /** Gets or sets the refresh rate to use (on every frame by default) */
  55299. refreshRate: number;
  55300. /**
  55301. * Gets the hosting scene
  55302. * @returns a Scene
  55303. */
  55304. getScene(): Scene;
  55305. /** Gets the internal CubeTexture used to render to */
  55306. readonly cubeTexture: RenderTargetTexture;
  55307. /** Gets the list of meshes to render */
  55308. readonly renderList: Nullable<AbstractMesh[]>;
  55309. /**
  55310. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55311. * @param mesh defines the mesh to attach to
  55312. */
  55313. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55314. /**
  55315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55316. * @param renderingGroupId The rendering group id corresponding to its index
  55317. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55318. */
  55319. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55320. /**
  55321. * Clean all associated resources
  55322. */
  55323. dispose(): void;
  55324. /**
  55325. * Converts the reflection probe information to a readable string for debug purpose.
  55326. * @param fullDetails Supports for multiple levels of logging within scene loading
  55327. * @returns the human readable reflection probe info
  55328. */
  55329. toString(fullDetails?: boolean): string;
  55330. /**
  55331. * Get the class name of the relfection probe.
  55332. * @returns "ReflectionProbe"
  55333. */
  55334. getClassName(): string;
  55335. /**
  55336. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55337. * @returns The JSON representation of the texture
  55338. */
  55339. serialize(): any;
  55340. /**
  55341. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55342. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55343. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55344. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55345. * @returns The parsed reflection probe if successful
  55346. */
  55347. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55348. }
  55349. }
  55350. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  55351. /** @hidden */
  55352. export var _BabylonLoaderRegistered: boolean;
  55353. /**
  55354. * Helps setting up some configuration for the babylon file loader.
  55355. */
  55356. export class BabylonFileLoaderConfiguration {
  55357. /**
  55358. * The loader does not allow injecting custom physix engine into the plugins.
  55359. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55360. * So you could set this variable to your engine import to make it work.
  55361. */
  55362. static LoaderInjectedPhysicsEngine: any;
  55363. }
  55364. }
  55365. declare module "babylonjs/Loading/Plugins/index" {
  55366. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  55367. }
  55368. declare module "babylonjs/Loading/index" {
  55369. export * from "babylonjs/Loading/loadingScreen";
  55370. export * from "babylonjs/Loading/Plugins/index";
  55371. export * from "babylonjs/Loading/sceneLoader";
  55372. export * from "babylonjs/Loading/sceneLoaderFlags";
  55373. }
  55374. declare module "babylonjs/Materials/Background/index" {
  55375. export * from "babylonjs/Materials/Background/backgroundMaterial";
  55376. }
  55377. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  55378. import { Scene } from "babylonjs/scene";
  55379. import { Color3 } from "babylonjs/Maths/math.color";
  55380. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55382. /**
  55383. * The Physically based simple base material of BJS.
  55384. *
  55385. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55386. * It is used as the base class for both the specGloss and metalRough conventions.
  55387. */
  55388. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55389. /**
  55390. * Number of Simultaneous lights allowed on the material.
  55391. */
  55392. maxSimultaneousLights: number;
  55393. /**
  55394. * If sets to true, disables all the lights affecting the material.
  55395. */
  55396. disableLighting: boolean;
  55397. /**
  55398. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55399. */
  55400. environmentTexture: BaseTexture;
  55401. /**
  55402. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55403. */
  55404. invertNormalMapX: boolean;
  55405. /**
  55406. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55407. */
  55408. invertNormalMapY: boolean;
  55409. /**
  55410. * Normal map used in the model.
  55411. */
  55412. normalTexture: BaseTexture;
  55413. /**
  55414. * Emissivie color used to self-illuminate the model.
  55415. */
  55416. emissiveColor: Color3;
  55417. /**
  55418. * Emissivie texture used to self-illuminate the model.
  55419. */
  55420. emissiveTexture: BaseTexture;
  55421. /**
  55422. * Occlusion Channel Strenght.
  55423. */
  55424. occlusionStrength: number;
  55425. /**
  55426. * Occlusion Texture of the material (adding extra occlusion effects).
  55427. */
  55428. occlusionTexture: BaseTexture;
  55429. /**
  55430. * Defines the alpha limits in alpha test mode.
  55431. */
  55432. alphaCutOff: number;
  55433. /**
  55434. * Gets the current double sided mode.
  55435. */
  55436. /**
  55437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55438. */
  55439. doubleSided: boolean;
  55440. /**
  55441. * Stores the pre-calculated light information of a mesh in a texture.
  55442. */
  55443. lightmapTexture: BaseTexture;
  55444. /**
  55445. * If true, the light map contains occlusion information instead of lighting info.
  55446. */
  55447. useLightmapAsShadowmap: boolean;
  55448. /**
  55449. * Instantiates a new PBRMaterial instance.
  55450. *
  55451. * @param name The material name
  55452. * @param scene The scene the material will be use in.
  55453. */
  55454. constructor(name: string, scene: Scene);
  55455. getClassName(): string;
  55456. }
  55457. }
  55458. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  55459. import { Scene } from "babylonjs/scene";
  55460. import { Color3 } from "babylonjs/Maths/math.color";
  55461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55462. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55463. /**
  55464. * The PBR material of BJS following the metal roughness convention.
  55465. *
  55466. * This fits to the PBR convention in the GLTF definition:
  55467. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55468. */
  55469. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55470. /**
  55471. * The base color has two different interpretations depending on the value of metalness.
  55472. * When the material is a metal, the base color is the specific measured reflectance value
  55473. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55474. * of the material.
  55475. */
  55476. baseColor: Color3;
  55477. /**
  55478. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55479. * well as opacity information in the alpha channel.
  55480. */
  55481. baseTexture: BaseTexture;
  55482. /**
  55483. * Specifies the metallic scalar value of the material.
  55484. * Can also be used to scale the metalness values of the metallic texture.
  55485. */
  55486. metallic: number;
  55487. /**
  55488. * Specifies the roughness scalar value of the material.
  55489. * Can also be used to scale the roughness values of the metallic texture.
  55490. */
  55491. roughness: number;
  55492. /**
  55493. * Texture containing both the metallic value in the B channel and the
  55494. * roughness value in the G channel to keep better precision.
  55495. */
  55496. metallicRoughnessTexture: BaseTexture;
  55497. /**
  55498. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55499. *
  55500. * @param name The material name
  55501. * @param scene The scene the material will be use in.
  55502. */
  55503. constructor(name: string, scene: Scene);
  55504. /**
  55505. * Return the currrent class name of the material.
  55506. */
  55507. getClassName(): string;
  55508. /**
  55509. * Makes a duplicate of the current material.
  55510. * @param name - name to use for the new material.
  55511. */
  55512. clone(name: string): PBRMetallicRoughnessMaterial;
  55513. /**
  55514. * Serialize the material to a parsable JSON object.
  55515. */
  55516. serialize(): any;
  55517. /**
  55518. * Parses a JSON object correponding to the serialize function.
  55519. */
  55520. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55521. }
  55522. }
  55523. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55524. import { Scene } from "babylonjs/scene";
  55525. import { Color3 } from "babylonjs/Maths/math.color";
  55526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55527. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55528. /**
  55529. * The PBR material of BJS following the specular glossiness convention.
  55530. *
  55531. * This fits to the PBR convention in the GLTF definition:
  55532. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55533. */
  55534. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55535. /**
  55536. * Specifies the diffuse color of the material.
  55537. */
  55538. diffuseColor: Color3;
  55539. /**
  55540. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55541. * channel.
  55542. */
  55543. diffuseTexture: BaseTexture;
  55544. /**
  55545. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55546. */
  55547. specularColor: Color3;
  55548. /**
  55549. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55550. */
  55551. glossiness: number;
  55552. /**
  55553. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55554. */
  55555. specularGlossinessTexture: BaseTexture;
  55556. /**
  55557. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55558. *
  55559. * @param name The material name
  55560. * @param scene The scene the material will be use in.
  55561. */
  55562. constructor(name: string, scene: Scene);
  55563. /**
  55564. * Return the currrent class name of the material.
  55565. */
  55566. getClassName(): string;
  55567. /**
  55568. * Makes a duplicate of the current material.
  55569. * @param name - name to use for the new material.
  55570. */
  55571. clone(name: string): PBRSpecularGlossinessMaterial;
  55572. /**
  55573. * Serialize the material to a parsable JSON object.
  55574. */
  55575. serialize(): any;
  55576. /**
  55577. * Parses a JSON object correponding to the serialize function.
  55578. */
  55579. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55580. }
  55581. }
  55582. declare module "babylonjs/Materials/PBR/index" {
  55583. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55584. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55585. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55586. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55587. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55588. }
  55589. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55590. import { Nullable } from "babylonjs/types";
  55591. import { Scene } from "babylonjs/scene";
  55592. import { Matrix } from "babylonjs/Maths/math.vector";
  55593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55594. /**
  55595. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55596. * It can help converting any input color in a desired output one. This can then be used to create effects
  55597. * from sepia, black and white to sixties or futuristic rendering...
  55598. *
  55599. * The only supported format is currently 3dl.
  55600. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55601. */
  55602. export class ColorGradingTexture extends BaseTexture {
  55603. /**
  55604. * The current texture matrix. (will always be identity in color grading texture)
  55605. */
  55606. private _textureMatrix;
  55607. /**
  55608. * The texture URL.
  55609. */
  55610. url: string;
  55611. /**
  55612. * Empty line regex stored for GC.
  55613. */
  55614. private static _noneEmptyLineRegex;
  55615. private _engine;
  55616. /**
  55617. * Instantiates a ColorGradingTexture from the following parameters.
  55618. *
  55619. * @param url The location of the color gradind data (currently only supporting 3dl)
  55620. * @param scene The scene the texture will be used in
  55621. */
  55622. constructor(url: string, scene: Scene);
  55623. /**
  55624. * Returns the texture matrix used in most of the material.
  55625. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55626. */
  55627. getTextureMatrix(): Matrix;
  55628. /**
  55629. * Occurs when the file being loaded is a .3dl LUT file.
  55630. */
  55631. private load3dlTexture;
  55632. /**
  55633. * Starts the loading process of the texture.
  55634. */
  55635. private loadTexture;
  55636. /**
  55637. * Clones the color gradind texture.
  55638. */
  55639. clone(): ColorGradingTexture;
  55640. /**
  55641. * Called during delayed load for textures.
  55642. */
  55643. delayLoad(): void;
  55644. /**
  55645. * Parses a color grading texture serialized by Babylon.
  55646. * @param parsedTexture The texture information being parsedTexture
  55647. * @param scene The scene to load the texture in
  55648. * @param rootUrl The root url of the data assets to load
  55649. * @return A color gradind texture
  55650. */
  55651. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55652. /**
  55653. * Serializes the LUT texture to json format.
  55654. */
  55655. serialize(): any;
  55656. }
  55657. }
  55658. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55660. import { Scene } from "babylonjs/scene";
  55661. import { Nullable } from "babylonjs/types";
  55662. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55663. /**
  55664. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55665. */
  55666. export class EquiRectangularCubeTexture extends BaseTexture {
  55667. /** The six faces of the cube. */
  55668. private static _FacesMapping;
  55669. private _noMipmap;
  55670. private _onLoad;
  55671. private _onError;
  55672. /** The size of the cubemap. */
  55673. private _size;
  55674. /** The buffer of the image. */
  55675. private _buffer;
  55676. /** The width of the input image. */
  55677. private _width;
  55678. /** The height of the input image. */
  55679. private _height;
  55680. /** The URL to the image. */
  55681. url: string;
  55682. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55683. coordinatesMode: number;
  55684. /**
  55685. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55686. * @param url The location of the image
  55687. * @param scene The scene the texture will be used in
  55688. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55689. * @param noMipmap Forces to not generate the mipmap if true
  55690. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55691. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55692. * @param onLoad — defines a callback called when texture is loaded
  55693. * @param onError — defines a callback called if there is an error
  55694. */
  55695. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55696. /**
  55697. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55698. */
  55699. private loadImage;
  55700. /**
  55701. * Convert the image buffer into a cubemap and create a CubeTexture.
  55702. */
  55703. private loadTexture;
  55704. /**
  55705. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55706. * @param buffer The ArrayBuffer that should be converted.
  55707. * @returns The buffer as Float32Array.
  55708. */
  55709. private getFloat32ArrayFromArrayBuffer;
  55710. /**
  55711. * Get the current class name of the texture useful for serialization or dynamic coding.
  55712. * @returns "EquiRectangularCubeTexture"
  55713. */
  55714. getClassName(): string;
  55715. /**
  55716. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55717. * @returns A clone of the current EquiRectangularCubeTexture.
  55718. */
  55719. clone(): EquiRectangularCubeTexture;
  55720. }
  55721. }
  55722. declare module "babylonjs/Misc/tga" {
  55723. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55724. /**
  55725. * Based on jsTGALoader - Javascript loader for TGA file
  55726. * By Vincent Thibault
  55727. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55728. */
  55729. export class TGATools {
  55730. private static _TYPE_INDEXED;
  55731. private static _TYPE_RGB;
  55732. private static _TYPE_GREY;
  55733. private static _TYPE_RLE_INDEXED;
  55734. private static _TYPE_RLE_RGB;
  55735. private static _TYPE_RLE_GREY;
  55736. private static _ORIGIN_MASK;
  55737. private static _ORIGIN_SHIFT;
  55738. private static _ORIGIN_BL;
  55739. private static _ORIGIN_BR;
  55740. private static _ORIGIN_UL;
  55741. private static _ORIGIN_UR;
  55742. /**
  55743. * Gets the header of a TGA file
  55744. * @param data defines the TGA data
  55745. * @returns the header
  55746. */
  55747. static GetTGAHeader(data: Uint8Array): any;
  55748. /**
  55749. * Uploads TGA content to a Babylon Texture
  55750. * @hidden
  55751. */
  55752. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55753. /** @hidden */
  55754. 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;
  55755. /** @hidden */
  55756. 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;
  55757. /** @hidden */
  55758. 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;
  55759. /** @hidden */
  55760. 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;
  55761. /** @hidden */
  55762. 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;
  55763. /** @hidden */
  55764. 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;
  55765. }
  55766. }
  55767. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55768. import { Nullable } from "babylonjs/types";
  55769. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55770. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55771. /**
  55772. * Implementation of the TGA Texture Loader.
  55773. * @hidden
  55774. */
  55775. export class _TGATextureLoader implements IInternalTextureLoader {
  55776. /**
  55777. * Defines wether the loader supports cascade loading the different faces.
  55778. */
  55779. readonly supportCascades: boolean;
  55780. /**
  55781. * This returns if the loader support the current file information.
  55782. * @param extension defines the file extension of the file being loaded
  55783. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55784. * @param fallback defines the fallback internal texture if any
  55785. * @param isBase64 defines whether the texture is encoded as a base64
  55786. * @param isBuffer defines whether the texture data are stored as a buffer
  55787. * @returns true if the loader can load the specified file
  55788. */
  55789. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55790. /**
  55791. * Transform the url before loading if required.
  55792. * @param rootUrl the url of the texture
  55793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55794. * @returns the transformed texture
  55795. */
  55796. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55797. /**
  55798. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55799. * @param rootUrl the url of the texture
  55800. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55801. * @returns the fallback texture
  55802. */
  55803. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55804. /**
  55805. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55806. * @param data contains the texture data
  55807. * @param texture defines the BabylonJS internal texture
  55808. * @param createPolynomials will be true if polynomials have been requested
  55809. * @param onLoad defines the callback to trigger once the texture is ready
  55810. * @param onError defines the callback to trigger in case of error
  55811. */
  55812. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55813. /**
  55814. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55815. * @param data contains the texture data
  55816. * @param texture defines the BabylonJS internal texture
  55817. * @param callback defines the method to call once ready to upload
  55818. */
  55819. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55820. }
  55821. }
  55822. declare module "babylonjs/Misc/basis" {
  55823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55824. /**
  55825. * Info about the .basis files
  55826. */
  55827. class BasisFileInfo {
  55828. /**
  55829. * If the file has alpha
  55830. */
  55831. hasAlpha: boolean;
  55832. /**
  55833. * Info about each image of the basis file
  55834. */
  55835. images: Array<{
  55836. levels: Array<{
  55837. width: number;
  55838. height: number;
  55839. transcodedPixels: ArrayBufferView;
  55840. }>;
  55841. }>;
  55842. }
  55843. /**
  55844. * Result of transcoding a basis file
  55845. */
  55846. class TranscodeResult {
  55847. /**
  55848. * Info about the .basis file
  55849. */
  55850. fileInfo: BasisFileInfo;
  55851. /**
  55852. * Format to use when loading the file
  55853. */
  55854. format: number;
  55855. }
  55856. /**
  55857. * Configuration options for the Basis transcoder
  55858. */
  55859. export class BasisTranscodeConfiguration {
  55860. /**
  55861. * Supported compression formats used to determine the supported output format of the transcoder
  55862. */
  55863. supportedCompressionFormats?: {
  55864. /**
  55865. * etc1 compression format
  55866. */
  55867. etc1?: boolean;
  55868. /**
  55869. * s3tc compression format
  55870. */
  55871. s3tc?: boolean;
  55872. /**
  55873. * pvrtc compression format
  55874. */
  55875. pvrtc?: boolean;
  55876. /**
  55877. * etc2 compression format
  55878. */
  55879. etc2?: boolean;
  55880. };
  55881. /**
  55882. * If mipmap levels should be loaded for transcoded images (Default: true)
  55883. */
  55884. loadMipmapLevels?: boolean;
  55885. /**
  55886. * Index of a single image to load (Default: all images)
  55887. */
  55888. loadSingleImage?: number;
  55889. }
  55890. /**
  55891. * Used to load .Basis files
  55892. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55893. */
  55894. export class BasisTools {
  55895. private static _IgnoreSupportedFormats;
  55896. /**
  55897. * URL to use when loading the basis transcoder
  55898. */
  55899. static JSModuleURL: string;
  55900. /**
  55901. * URL to use when loading the wasm module for the transcoder
  55902. */
  55903. static WasmModuleURL: string;
  55904. /**
  55905. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55906. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55907. * @returns internal format corresponding to the Basis format
  55908. */
  55909. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55910. private static _WorkerPromise;
  55911. private static _Worker;
  55912. private static _actionId;
  55913. private static _CreateWorkerAsync;
  55914. /**
  55915. * Transcodes a loaded image file to compressed pixel data
  55916. * @param imageData image data to transcode
  55917. * @param config configuration options for the transcoding
  55918. * @returns a promise resulting in the transcoded image
  55919. */
  55920. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55921. /**
  55922. * Loads a texture from the transcode result
  55923. * @param texture texture load to
  55924. * @param transcodeResult the result of transcoding the basis file to load from
  55925. */
  55926. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55927. }
  55928. }
  55929. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55930. import { Nullable } from "babylonjs/types";
  55931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55932. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55933. /**
  55934. * Loader for .basis file format
  55935. */
  55936. export class _BasisTextureLoader implements IInternalTextureLoader {
  55937. /**
  55938. * Defines whether the loader supports cascade loading the different faces.
  55939. */
  55940. readonly supportCascades: boolean;
  55941. /**
  55942. * This returns if the loader support the current file information.
  55943. * @param extension defines the file extension of the file being loaded
  55944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55945. * @param fallback defines the fallback internal texture if any
  55946. * @param isBase64 defines whether the texture is encoded as a base64
  55947. * @param isBuffer defines whether the texture data are stored as a buffer
  55948. * @returns true if the loader can load the specified file
  55949. */
  55950. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55951. /**
  55952. * Transform the url before loading if required.
  55953. * @param rootUrl the url of the texture
  55954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55955. * @returns the transformed texture
  55956. */
  55957. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55958. /**
  55959. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55960. * @param rootUrl the url of the texture
  55961. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55962. * @returns the fallback texture
  55963. */
  55964. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55965. /**
  55966. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55967. * @param data contains the texture data
  55968. * @param texture defines the BabylonJS internal texture
  55969. * @param createPolynomials will be true if polynomials have been requested
  55970. * @param onLoad defines the callback to trigger once the texture is ready
  55971. * @param onError defines the callback to trigger in case of error
  55972. */
  55973. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55974. /**
  55975. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55976. * @param data contains the texture data
  55977. * @param texture defines the BabylonJS internal texture
  55978. * @param callback defines the method to call once ready to upload
  55979. */
  55980. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55981. }
  55982. }
  55983. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55984. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55985. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55986. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55987. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55988. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55989. }
  55990. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55991. import { Scene } from "babylonjs/scene";
  55992. import { Texture } from "babylonjs/Materials/Textures/texture";
  55993. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55994. /**
  55995. * 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.
  55996. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55997. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55998. */
  55999. export class CustomProceduralTexture extends ProceduralTexture {
  56000. private _animate;
  56001. private _time;
  56002. private _config;
  56003. private _texturePath;
  56004. /**
  56005. * Instantiates a new Custom Procedural Texture.
  56006. * 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.
  56007. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56008. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56009. * @param name Define the name of the texture
  56010. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56011. * @param size Define the size of the texture to create
  56012. * @param scene Define the scene the texture belongs to
  56013. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56014. * @param generateMipMaps Define if the texture should creates mip maps or not
  56015. */
  56016. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56017. private _loadJson;
  56018. /**
  56019. * Is the texture ready to be used ? (rendered at least once)
  56020. * @returns true if ready, otherwise, false.
  56021. */
  56022. isReady(): boolean;
  56023. /**
  56024. * Render the texture to its associated render target.
  56025. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56026. */
  56027. render(useCameraPostProcess?: boolean): void;
  56028. /**
  56029. * Update the list of dependant textures samplers in the shader.
  56030. */
  56031. updateTextures(): void;
  56032. /**
  56033. * Update the uniform values of the procedural texture in the shader.
  56034. */
  56035. updateShaderUniforms(): void;
  56036. /**
  56037. * Define if the texture animates or not.
  56038. */
  56039. animate: boolean;
  56040. }
  56041. }
  56042. declare module "babylonjs/Shaders/noise.fragment" {
  56043. /** @hidden */
  56044. export var noisePixelShader: {
  56045. name: string;
  56046. shader: string;
  56047. };
  56048. }
  56049. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  56050. import { Nullable } from "babylonjs/types";
  56051. import { Scene } from "babylonjs/scene";
  56052. import { Texture } from "babylonjs/Materials/Textures/texture";
  56053. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56054. import "babylonjs/Shaders/noise.fragment";
  56055. /**
  56056. * Class used to generate noise procedural textures
  56057. */
  56058. export class NoiseProceduralTexture extends ProceduralTexture {
  56059. private _time;
  56060. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56061. brightness: number;
  56062. /** Defines the number of octaves to process */
  56063. octaves: number;
  56064. /** Defines the level of persistence (0.8 by default) */
  56065. persistence: number;
  56066. /** Gets or sets animation speed factor (default is 1) */
  56067. animationSpeedFactor: number;
  56068. /**
  56069. * Creates a new NoiseProceduralTexture
  56070. * @param name defines the name fo the texture
  56071. * @param size defines the size of the texture (default is 256)
  56072. * @param scene defines the hosting scene
  56073. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56074. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56075. */
  56076. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56077. private _updateShaderUniforms;
  56078. protected _getDefines(): string;
  56079. /** Generate the current state of the procedural texture */
  56080. render(useCameraPostProcess?: boolean): void;
  56081. /**
  56082. * Serializes this noise procedural texture
  56083. * @returns a serialized noise procedural texture object
  56084. */
  56085. serialize(): any;
  56086. /**
  56087. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56088. * @param parsedTexture defines parsed texture data
  56089. * @param scene defines the current scene
  56090. * @param rootUrl defines the root URL containing noise procedural texture information
  56091. * @returns a parsed NoiseProceduralTexture
  56092. */
  56093. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56094. }
  56095. }
  56096. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  56097. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  56098. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  56099. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  56100. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  56101. }
  56102. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  56103. import { Nullable } from "babylonjs/types";
  56104. import { Scene } from "babylonjs/scene";
  56105. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  56106. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56107. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56108. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56109. /**
  56110. * Raw cube texture where the raw buffers are passed in
  56111. */
  56112. export class RawCubeTexture extends CubeTexture {
  56113. /**
  56114. * Creates a cube texture where the raw buffers are passed in.
  56115. * @param scene defines the scene the texture is attached to
  56116. * @param data defines the array of data to use to create each face
  56117. * @param size defines the size of the textures
  56118. * @param format defines the format of the data
  56119. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56120. * @param generateMipMaps defines if the engine should generate the mip levels
  56121. * @param invertY defines if data must be stored with Y axis inverted
  56122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56123. * @param compression defines the compression used (null by default)
  56124. */
  56125. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56126. /**
  56127. * Updates the raw cube texture.
  56128. * @param data defines the data to store
  56129. * @param format defines the data format
  56130. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56131. * @param invertY defines if data must be stored with Y axis inverted
  56132. * @param compression defines the compression used (null by default)
  56133. * @param level defines which level of the texture to update
  56134. */
  56135. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56136. /**
  56137. * Updates a raw cube texture with RGBD encoded data.
  56138. * @param data defines the array of data [mipmap][face] to use to create each face
  56139. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56140. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56141. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56142. * @returns a promsie that resolves when the operation is complete
  56143. */
  56144. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56145. /**
  56146. * Clones the raw cube texture.
  56147. * @return a new cube texture
  56148. */
  56149. clone(): CubeTexture;
  56150. /** @hidden */
  56151. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56152. }
  56153. }
  56154. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  56155. import { Scene } from "babylonjs/scene";
  56156. import { Texture } from "babylonjs/Materials/Textures/texture";
  56157. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56158. /**
  56159. * Class used to store 3D textures containing user data
  56160. */
  56161. export class RawTexture3D extends Texture {
  56162. /** Gets or sets the texture format to use */
  56163. format: number;
  56164. private _engine;
  56165. /**
  56166. * Create a new RawTexture3D
  56167. * @param data defines the data of the texture
  56168. * @param width defines the width of the texture
  56169. * @param height defines the height of the texture
  56170. * @param depth defines the depth of the texture
  56171. * @param format defines the texture format to use
  56172. * @param scene defines the hosting scene
  56173. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56174. * @param invertY defines if texture must be stored with Y axis inverted
  56175. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56176. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56177. */
  56178. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56179. /** Gets or sets the texture format to use */
  56180. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56181. /**
  56182. * Update the texture with new data
  56183. * @param data defines the data to store in the texture
  56184. */
  56185. update(data: ArrayBufferView): void;
  56186. }
  56187. }
  56188. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  56189. import { Scene } from "babylonjs/scene";
  56190. import { Texture } from "babylonjs/Materials/Textures/texture";
  56191. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56192. /**
  56193. * Class used to store 2D array textures containing user data
  56194. */
  56195. export class RawTexture2DArray extends Texture {
  56196. /** Gets or sets the texture format to use */
  56197. format: number;
  56198. private _engine;
  56199. /**
  56200. * Create a new RawTexture2DArray
  56201. * @param data defines the data of the texture
  56202. * @param width defines the width of the texture
  56203. * @param height defines the height of the texture
  56204. * @param depth defines the number of layers of the texture
  56205. * @param format defines the texture format to use
  56206. * @param scene defines the hosting scene
  56207. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56208. * @param invertY defines if texture must be stored with Y axis inverted
  56209. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56210. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56211. */
  56212. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56213. /** Gets or sets the texture format to use */
  56214. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56215. /**
  56216. * Update the texture with new data
  56217. * @param data defines the data to store in the texture
  56218. */
  56219. update(data: ArrayBufferView): void;
  56220. }
  56221. }
  56222. declare module "babylonjs/Materials/Textures/refractionTexture" {
  56223. import { Scene } from "babylonjs/scene";
  56224. import { Plane } from "babylonjs/Maths/math.plane";
  56225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56226. /**
  56227. * Creates a refraction texture used by refraction channel of the standard material.
  56228. * It is like a mirror but to see through a material.
  56229. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56230. */
  56231. export class RefractionTexture extends RenderTargetTexture {
  56232. /**
  56233. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56234. * 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.
  56235. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56236. */
  56237. refractionPlane: Plane;
  56238. /**
  56239. * Define how deep under the surface we should see.
  56240. */
  56241. depth: number;
  56242. /**
  56243. * Creates a refraction texture used by refraction channel of the standard material.
  56244. * It is like a mirror but to see through a material.
  56245. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56246. * @param name Define the texture name
  56247. * @param size Define the size of the underlying texture
  56248. * @param scene Define the scene the refraction belongs to
  56249. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56250. */
  56251. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56252. /**
  56253. * Clone the refraction texture.
  56254. * @returns the cloned texture
  56255. */
  56256. clone(): RefractionTexture;
  56257. /**
  56258. * Serialize the texture to a JSON representation you could use in Parse later on
  56259. * @returns the serialized JSON representation
  56260. */
  56261. serialize(): any;
  56262. }
  56263. }
  56264. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  56265. import { Nullable } from "babylonjs/types";
  56266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56267. import { Matrix } from "babylonjs/Maths/math.vector";
  56268. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  56269. import "babylonjs/Engines/Extensions/engine.videoTexture";
  56270. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  56271. import { Scene } from "babylonjs/scene";
  56272. /**
  56273. * Defines the options related to the creation of an HtmlElementTexture
  56274. */
  56275. export interface IHtmlElementTextureOptions {
  56276. /**
  56277. * Defines wether mip maps should be created or not.
  56278. */
  56279. generateMipMaps?: boolean;
  56280. /**
  56281. * Defines the sampling mode of the texture.
  56282. */
  56283. samplingMode?: number;
  56284. /**
  56285. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56286. */
  56287. engine: Nullable<ThinEngine>;
  56288. /**
  56289. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56290. */
  56291. scene: Nullable<Scene>;
  56292. }
  56293. /**
  56294. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56295. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56296. * is automatically managed.
  56297. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56298. * in your application.
  56299. *
  56300. * As the update is not automatic, you need to call them manually.
  56301. */
  56302. export class HtmlElementTexture extends BaseTexture {
  56303. /**
  56304. * The texture URL.
  56305. */
  56306. element: HTMLVideoElement | HTMLCanvasElement;
  56307. private static readonly DefaultOptions;
  56308. private _textureMatrix;
  56309. private _engine;
  56310. private _isVideo;
  56311. private _generateMipMaps;
  56312. private _samplingMode;
  56313. /**
  56314. * Instantiates a HtmlElementTexture from the following parameters.
  56315. *
  56316. * @param name Defines the name of the texture
  56317. * @param element Defines the video or canvas the texture is filled with
  56318. * @param options Defines the other none mandatory texture creation options
  56319. */
  56320. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56321. private _createInternalTexture;
  56322. /**
  56323. * Returns the texture matrix used in most of the material.
  56324. */
  56325. getTextureMatrix(): Matrix;
  56326. /**
  56327. * Updates the content of the texture.
  56328. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56329. */
  56330. update(invertY?: Nullable<boolean>): void;
  56331. }
  56332. }
  56333. declare module "babylonjs/Materials/Textures/index" {
  56334. export * from "babylonjs/Materials/Textures/baseTexture";
  56335. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  56336. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  56337. export * from "babylonjs/Materials/Textures/cubeTexture";
  56338. export * from "babylonjs/Materials/Textures/dynamicTexture";
  56339. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  56340. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  56341. export * from "babylonjs/Materials/Textures/internalTexture";
  56342. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  56343. export * from "babylonjs/Materials/Textures/Loaders/index";
  56344. export * from "babylonjs/Materials/Textures/mirrorTexture";
  56345. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  56346. export * from "babylonjs/Materials/Textures/Procedurals/index";
  56347. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  56348. export * from "babylonjs/Materials/Textures/rawTexture";
  56349. export * from "babylonjs/Materials/Textures/rawTexture3D";
  56350. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  56351. export * from "babylonjs/Materials/Textures/refractionTexture";
  56352. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  56353. export * from "babylonjs/Materials/Textures/texture";
  56354. export * from "babylonjs/Materials/Textures/videoTexture";
  56355. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  56356. }
  56357. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  56358. /**
  56359. * Enum used to define the target of a block
  56360. */
  56361. export enum NodeMaterialBlockTargets {
  56362. /** Vertex shader */
  56363. Vertex = 1,
  56364. /** Fragment shader */
  56365. Fragment = 2,
  56366. /** Neutral */
  56367. Neutral = 4,
  56368. /** Vertex and Fragment */
  56369. VertexAndFragment = 3
  56370. }
  56371. }
  56372. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  56373. /**
  56374. * Defines the kind of connection point for node based material
  56375. */
  56376. export enum NodeMaterialBlockConnectionPointTypes {
  56377. /** Float */
  56378. Float = 1,
  56379. /** Int */
  56380. Int = 2,
  56381. /** Vector2 */
  56382. Vector2 = 4,
  56383. /** Vector3 */
  56384. Vector3 = 8,
  56385. /** Vector4 */
  56386. Vector4 = 16,
  56387. /** Color3 */
  56388. Color3 = 32,
  56389. /** Color4 */
  56390. Color4 = 64,
  56391. /** Matrix */
  56392. Matrix = 128,
  56393. /** Detect type based on connection */
  56394. AutoDetect = 1024,
  56395. /** Output type that will be defined by input type */
  56396. BasedOnInput = 2048
  56397. }
  56398. }
  56399. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  56400. /**
  56401. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56402. */
  56403. export enum NodeMaterialBlockConnectionPointMode {
  56404. /** Value is an uniform */
  56405. Uniform = 0,
  56406. /** Value is a mesh attribute */
  56407. Attribute = 1,
  56408. /** Value is a varying between vertex and fragment shaders */
  56409. Varying = 2,
  56410. /** Mode is undefined */
  56411. Undefined = 3
  56412. }
  56413. }
  56414. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  56415. /**
  56416. * Enum used to define system values e.g. values automatically provided by the system
  56417. */
  56418. export enum NodeMaterialSystemValues {
  56419. /** World */
  56420. World = 1,
  56421. /** View */
  56422. View = 2,
  56423. /** Projection */
  56424. Projection = 3,
  56425. /** ViewProjection */
  56426. ViewProjection = 4,
  56427. /** WorldView */
  56428. WorldView = 5,
  56429. /** WorldViewProjection */
  56430. WorldViewProjection = 6,
  56431. /** CameraPosition */
  56432. CameraPosition = 7,
  56433. /** Fog Color */
  56434. FogColor = 8,
  56435. /** Delta time */
  56436. DeltaTime = 9
  56437. }
  56438. }
  56439. declare module "babylonjs/Materials/Node/Enums/index" {
  56440. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56441. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56442. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  56443. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56444. }
  56445. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  56446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56447. /**
  56448. * Root class for all node material optimizers
  56449. */
  56450. export class NodeMaterialOptimizer {
  56451. /**
  56452. * Function used to optimize a NodeMaterial graph
  56453. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56454. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56455. */
  56456. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56457. }
  56458. }
  56459. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  56460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56463. import { Scene } from "babylonjs/scene";
  56464. /**
  56465. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56466. */
  56467. export class TransformBlock extends NodeMaterialBlock {
  56468. /**
  56469. * Defines the value to use to complement W value to transform it to a Vector4
  56470. */
  56471. complementW: number;
  56472. /**
  56473. * Defines the value to use to complement z value to transform it to a Vector4
  56474. */
  56475. complementZ: number;
  56476. /**
  56477. * Creates a new TransformBlock
  56478. * @param name defines the block name
  56479. */
  56480. constructor(name: string);
  56481. /**
  56482. * Gets the current class name
  56483. * @returns the class name
  56484. */
  56485. getClassName(): string;
  56486. /**
  56487. * Gets the vector input
  56488. */
  56489. readonly vector: NodeMaterialConnectionPoint;
  56490. /**
  56491. * Gets the output component
  56492. */
  56493. readonly output: NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the matrix transform input
  56496. */
  56497. readonly transform: NodeMaterialConnectionPoint;
  56498. protected _buildBlock(state: NodeMaterialBuildState): this;
  56499. serialize(): any;
  56500. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56501. protected _dumpPropertiesCode(): string;
  56502. }
  56503. }
  56504. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  56505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56508. /**
  56509. * Block used to output the vertex position
  56510. */
  56511. export class VertexOutputBlock extends NodeMaterialBlock {
  56512. /**
  56513. * Creates a new VertexOutputBlock
  56514. * @param name defines the block name
  56515. */
  56516. constructor(name: string);
  56517. /**
  56518. * Gets the current class name
  56519. * @returns the class name
  56520. */
  56521. getClassName(): string;
  56522. /**
  56523. * Gets the vector input component
  56524. */
  56525. readonly vector: NodeMaterialConnectionPoint;
  56526. protected _buildBlock(state: NodeMaterialBuildState): this;
  56527. }
  56528. }
  56529. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56533. /**
  56534. * Block used to output the final color
  56535. */
  56536. export class FragmentOutputBlock extends NodeMaterialBlock {
  56537. /**
  56538. * Create a new FragmentOutputBlock
  56539. * @param name defines the block name
  56540. */
  56541. constructor(name: string);
  56542. /**
  56543. * Gets the current class name
  56544. * @returns the class name
  56545. */
  56546. getClassName(): string;
  56547. /**
  56548. * Gets the rgba input component
  56549. */
  56550. readonly rgba: NodeMaterialConnectionPoint;
  56551. /**
  56552. * Gets the rgb input component
  56553. */
  56554. readonly rgb: NodeMaterialConnectionPoint;
  56555. /**
  56556. * Gets the a input component
  56557. */
  56558. readonly a: NodeMaterialConnectionPoint;
  56559. protected _buildBlock(state: NodeMaterialBuildState): this;
  56560. }
  56561. }
  56562. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56568. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56569. import { Effect } from "babylonjs/Materials/effect";
  56570. import { Mesh } from "babylonjs/Meshes/mesh";
  56571. import { Nullable } from "babylonjs/types";
  56572. import { Scene } from "babylonjs/scene";
  56573. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56574. /**
  56575. * Block used to read a reflection texture from a sampler
  56576. */
  56577. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56578. private _define3DName;
  56579. private _defineCubicName;
  56580. private _defineExplicitName;
  56581. private _defineProjectionName;
  56582. private _defineLocalCubicName;
  56583. private _defineSphericalName;
  56584. private _definePlanarName;
  56585. private _defineEquirectangularName;
  56586. private _defineMirroredEquirectangularFixedName;
  56587. private _defineEquirectangularFixedName;
  56588. private _defineSkyboxName;
  56589. private _cubeSamplerName;
  56590. private _2DSamplerName;
  56591. private _positionUVWName;
  56592. private _directionWName;
  56593. private _reflectionCoordsName;
  56594. private _reflection2DCoordsName;
  56595. private _reflectionColorName;
  56596. private _reflectionMatrixName;
  56597. /**
  56598. * Gets or sets the texture associated with the node
  56599. */
  56600. texture: Nullable<BaseTexture>;
  56601. /**
  56602. * Create a new TextureBlock
  56603. * @param name defines the block name
  56604. */
  56605. constructor(name: string);
  56606. /**
  56607. * Gets the current class name
  56608. * @returns the class name
  56609. */
  56610. getClassName(): string;
  56611. /**
  56612. * Gets the world position input component
  56613. */
  56614. readonly position: NodeMaterialConnectionPoint;
  56615. /**
  56616. * Gets the world position input component
  56617. */
  56618. readonly worldPosition: NodeMaterialConnectionPoint;
  56619. /**
  56620. * Gets the world normal input component
  56621. */
  56622. readonly worldNormal: NodeMaterialConnectionPoint;
  56623. /**
  56624. * Gets the world input component
  56625. */
  56626. readonly world: NodeMaterialConnectionPoint;
  56627. /**
  56628. * Gets the camera (or eye) position component
  56629. */
  56630. readonly cameraPosition: NodeMaterialConnectionPoint;
  56631. /**
  56632. * Gets the view input component
  56633. */
  56634. readonly view: NodeMaterialConnectionPoint;
  56635. /**
  56636. * Gets the rgb output component
  56637. */
  56638. readonly rgb: NodeMaterialConnectionPoint;
  56639. /**
  56640. * Gets the r output component
  56641. */
  56642. readonly r: NodeMaterialConnectionPoint;
  56643. /**
  56644. * Gets the g output component
  56645. */
  56646. readonly g: NodeMaterialConnectionPoint;
  56647. /**
  56648. * Gets the b output component
  56649. */
  56650. readonly b: NodeMaterialConnectionPoint;
  56651. autoConfigure(material: NodeMaterial): void;
  56652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56653. isReady(): boolean;
  56654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56655. private _injectVertexCode;
  56656. private _writeOutput;
  56657. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56658. protected _dumpPropertiesCode(): string;
  56659. serialize(): any;
  56660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56661. }
  56662. }
  56663. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56665. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56666. import { Scene } from "babylonjs/scene";
  56667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56668. import { Matrix } from "babylonjs/Maths/math.vector";
  56669. import { Mesh } from "babylonjs/Meshes/mesh";
  56670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56671. import { Observable } from "babylonjs/Misc/observable";
  56672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56673. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56674. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56675. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56676. import { Nullable } from "babylonjs/types";
  56677. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56678. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56679. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56680. /**
  56681. * Interface used to configure the node material editor
  56682. */
  56683. export interface INodeMaterialEditorOptions {
  56684. /** Define the URl to load node editor script */
  56685. editorURL?: string;
  56686. }
  56687. /** @hidden */
  56688. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56689. /** BONES */
  56690. NUM_BONE_INFLUENCERS: number;
  56691. BonesPerMesh: number;
  56692. BONETEXTURE: boolean;
  56693. /** MORPH TARGETS */
  56694. MORPHTARGETS: boolean;
  56695. MORPHTARGETS_NORMAL: boolean;
  56696. MORPHTARGETS_TANGENT: boolean;
  56697. MORPHTARGETS_UV: boolean;
  56698. NUM_MORPH_INFLUENCERS: number;
  56699. /** IMAGE PROCESSING */
  56700. IMAGEPROCESSING: boolean;
  56701. VIGNETTE: boolean;
  56702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56703. VIGNETTEBLENDMODEOPAQUE: boolean;
  56704. TONEMAPPING: boolean;
  56705. TONEMAPPING_ACES: boolean;
  56706. CONTRAST: boolean;
  56707. EXPOSURE: boolean;
  56708. COLORCURVES: boolean;
  56709. COLORGRADING: boolean;
  56710. COLORGRADING3D: boolean;
  56711. SAMPLER3DGREENDEPTH: boolean;
  56712. SAMPLER3DBGRMAP: boolean;
  56713. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56714. /** MISC. */
  56715. BUMPDIRECTUV: number;
  56716. constructor();
  56717. setValue(name: string, value: boolean): void;
  56718. }
  56719. /**
  56720. * Class used to configure NodeMaterial
  56721. */
  56722. export interface INodeMaterialOptions {
  56723. /**
  56724. * Defines if blocks should emit comments
  56725. */
  56726. emitComments: boolean;
  56727. }
  56728. /**
  56729. * Class used to create a node based material built by assembling shader blocks
  56730. */
  56731. export class NodeMaterial extends PushMaterial {
  56732. private static _BuildIdGenerator;
  56733. private _options;
  56734. private _vertexCompilationState;
  56735. private _fragmentCompilationState;
  56736. private _sharedData;
  56737. private _buildId;
  56738. private _buildWasSuccessful;
  56739. private _cachedWorldViewMatrix;
  56740. private _cachedWorldViewProjectionMatrix;
  56741. private _optimizers;
  56742. private _animationFrame;
  56743. /** Define the URl to load node editor script */
  56744. static EditorURL: string;
  56745. private BJSNODEMATERIALEDITOR;
  56746. /** Get the inspector from bundle or global */
  56747. private _getGlobalNodeMaterialEditor;
  56748. /**
  56749. * Gets or sets data used by visual editor
  56750. * @see https://nme.babylonjs.com
  56751. */
  56752. editorData: any;
  56753. /**
  56754. * 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)
  56755. */
  56756. ignoreAlpha: boolean;
  56757. /**
  56758. * Defines the maximum number of lights that can be used in the material
  56759. */
  56760. maxSimultaneousLights: number;
  56761. /**
  56762. * Observable raised when the material is built
  56763. */
  56764. onBuildObservable: Observable<NodeMaterial>;
  56765. /**
  56766. * Gets or sets the root nodes of the material vertex shader
  56767. */
  56768. _vertexOutputNodes: NodeMaterialBlock[];
  56769. /**
  56770. * Gets or sets the root nodes of the material fragment (pixel) shader
  56771. */
  56772. _fragmentOutputNodes: NodeMaterialBlock[];
  56773. /** Gets or sets options to control the node material overall behavior */
  56774. options: INodeMaterialOptions;
  56775. /**
  56776. * Default configuration related to image processing available in the standard Material.
  56777. */
  56778. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56779. /**
  56780. * Gets the image processing configuration used either in this material.
  56781. */
  56782. /**
  56783. * Sets the Default image processing configuration used either in the this material.
  56784. *
  56785. * If sets to null, the scene one is in use.
  56786. */
  56787. imageProcessingConfiguration: ImageProcessingConfiguration;
  56788. /**
  56789. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56790. */
  56791. attachedBlocks: NodeMaterialBlock[];
  56792. /**
  56793. * Create a new node based material
  56794. * @param name defines the material name
  56795. * @param scene defines the hosting scene
  56796. * @param options defines creation option
  56797. */
  56798. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56799. /**
  56800. * Gets the current class name of the material e.g. "NodeMaterial"
  56801. * @returns the class name
  56802. */
  56803. getClassName(): string;
  56804. /**
  56805. * Keep track of the image processing observer to allow dispose and replace.
  56806. */
  56807. private _imageProcessingObserver;
  56808. /**
  56809. * Attaches a new image processing configuration to the Standard Material.
  56810. * @param configuration
  56811. */
  56812. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56813. /**
  56814. * Get a block by its name
  56815. * @param name defines the name of the block to retrieve
  56816. * @returns the required block or null if not found
  56817. */
  56818. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56819. /**
  56820. * Get a block by its name
  56821. * @param predicate defines the predicate used to find the good candidate
  56822. * @returns the required block or null if not found
  56823. */
  56824. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56825. /**
  56826. * Get an input block by its name
  56827. * @param predicate defines the predicate used to find the good candidate
  56828. * @returns the required input block or null if not found
  56829. */
  56830. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56831. /**
  56832. * Gets the list of input blocks attached to this material
  56833. * @returns an array of InputBlocks
  56834. */
  56835. getInputBlocks(): InputBlock[];
  56836. /**
  56837. * Adds a new optimizer to the list of optimizers
  56838. * @param optimizer defines the optimizers to add
  56839. * @returns the current material
  56840. */
  56841. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56842. /**
  56843. * Remove an optimizer from the list of optimizers
  56844. * @param optimizer defines the optimizers to remove
  56845. * @returns the current material
  56846. */
  56847. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56848. /**
  56849. * Add a new block to the list of output nodes
  56850. * @param node defines the node to add
  56851. * @returns the current material
  56852. */
  56853. addOutputNode(node: NodeMaterialBlock): this;
  56854. /**
  56855. * Remove a block from the list of root nodes
  56856. * @param node defines the node to remove
  56857. * @returns the current material
  56858. */
  56859. removeOutputNode(node: NodeMaterialBlock): this;
  56860. private _addVertexOutputNode;
  56861. private _removeVertexOutputNode;
  56862. private _addFragmentOutputNode;
  56863. private _removeFragmentOutputNode;
  56864. /**
  56865. * Specifies if the material will require alpha blending
  56866. * @returns a boolean specifying if alpha blending is needed
  56867. */
  56868. needAlphaBlending(): boolean;
  56869. /**
  56870. * Specifies if this material should be rendered in alpha test mode
  56871. * @returns a boolean specifying if an alpha test is needed.
  56872. */
  56873. needAlphaTesting(): boolean;
  56874. private _initializeBlock;
  56875. private _resetDualBlocks;
  56876. /**
  56877. * Remove a block from the current node material
  56878. * @param block defines the block to remove
  56879. */
  56880. removeBlock(block: NodeMaterialBlock): void;
  56881. /**
  56882. * Build the material and generates the inner effect
  56883. * @param verbose defines if the build should log activity
  56884. */
  56885. build(verbose?: boolean): void;
  56886. /**
  56887. * Runs an otpimization phase to try to improve the shader code
  56888. */
  56889. optimize(): void;
  56890. private _prepareDefinesForAttributes;
  56891. /**
  56892. * Get if the submesh is ready to be used and all its information available.
  56893. * Child classes can use it to update shaders
  56894. * @param mesh defines the mesh to check
  56895. * @param subMesh defines which submesh to check
  56896. * @param useInstances specifies that instances should be used
  56897. * @returns a boolean indicating that the submesh is ready or not
  56898. */
  56899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56900. /**
  56901. * Get a string representing the shaders built by the current node graph
  56902. */
  56903. readonly compiledShaders: string;
  56904. /**
  56905. * Binds the world matrix to the material
  56906. * @param world defines the world transformation matrix
  56907. */
  56908. bindOnlyWorldMatrix(world: Matrix): void;
  56909. /**
  56910. * Binds the submesh to this material by preparing the effect and shader to draw
  56911. * @param world defines the world transformation matrix
  56912. * @param mesh defines the mesh containing the submesh
  56913. * @param subMesh defines the submesh to bind the material to
  56914. */
  56915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56916. /**
  56917. * Gets the active textures from the material
  56918. * @returns an array of textures
  56919. */
  56920. getActiveTextures(): BaseTexture[];
  56921. /**
  56922. * Gets the list of texture blocks
  56923. * @returns an array of texture blocks
  56924. */
  56925. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56926. /**
  56927. * Specifies if the material uses a texture
  56928. * @param texture defines the texture to check against the material
  56929. * @returns a boolean specifying if the material uses the texture
  56930. */
  56931. hasTexture(texture: BaseTexture): boolean;
  56932. /**
  56933. * Disposes the material
  56934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56937. */
  56938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56939. /** Creates the node editor window. */
  56940. private _createNodeEditor;
  56941. /**
  56942. * Launch the node material editor
  56943. * @param config Define the configuration of the editor
  56944. * @return a promise fulfilled when the node editor is visible
  56945. */
  56946. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56947. /**
  56948. * Clear the current material
  56949. */
  56950. clear(): void;
  56951. /**
  56952. * Clear the current material and set it to a default state
  56953. */
  56954. setToDefault(): void;
  56955. /**
  56956. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56957. * @param url defines the url to load from
  56958. * @returns a promise that will fullfil when the material is fully loaded
  56959. */
  56960. loadAsync(url: string): Promise<void>;
  56961. private _gatherBlocks;
  56962. /**
  56963. * Generate a string containing the code declaration required to create an equivalent of this material
  56964. * @returns a string
  56965. */
  56966. generateCode(): string;
  56967. /**
  56968. * Serializes this material in a JSON representation
  56969. * @returns the serialized material object
  56970. */
  56971. serialize(): any;
  56972. private _restoreConnections;
  56973. /**
  56974. * Clear the current graph and load a new one from a serialization object
  56975. * @param source defines the JSON representation of the material
  56976. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56977. */
  56978. loadFromSerialization(source: any, rootUrl?: string): void;
  56979. /**
  56980. * Creates a node material from parsed material data
  56981. * @param source defines the JSON representation of the material
  56982. * @param scene defines the hosting scene
  56983. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56984. * @returns a new node material
  56985. */
  56986. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56987. /**
  56988. * Creates a new node material set to default basic configuration
  56989. * @param name defines the name of the material
  56990. * @param scene defines the hosting scene
  56991. * @returns a new NodeMaterial
  56992. */
  56993. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56994. }
  56995. }
  56996. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56999. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57002. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57003. import { Effect } from "babylonjs/Materials/effect";
  57004. import { Mesh } from "babylonjs/Meshes/mesh";
  57005. import { Nullable } from "babylonjs/types";
  57006. import { Texture } from "babylonjs/Materials/Textures/texture";
  57007. import { Scene } from "babylonjs/scene";
  57008. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57009. /**
  57010. * Block used to read a texture from a sampler
  57011. */
  57012. export class TextureBlock extends NodeMaterialBlock {
  57013. private _defineName;
  57014. private _linearDefineName;
  57015. private _tempTextureRead;
  57016. private _samplerName;
  57017. private _transformedUVName;
  57018. private _textureTransformName;
  57019. private _textureInfoName;
  57020. private _mainUVName;
  57021. private _mainUVDefineName;
  57022. /**
  57023. * Gets or sets the texture associated with the node
  57024. */
  57025. texture: Nullable<Texture>;
  57026. /**
  57027. * Create a new TextureBlock
  57028. * @param name defines the block name
  57029. */
  57030. constructor(name: string);
  57031. /**
  57032. * Gets the current class name
  57033. * @returns the class name
  57034. */
  57035. getClassName(): string;
  57036. /**
  57037. * Gets the uv input component
  57038. */
  57039. readonly uv: NodeMaterialConnectionPoint;
  57040. /**
  57041. * Gets the rgba output component
  57042. */
  57043. readonly rgba: NodeMaterialConnectionPoint;
  57044. /**
  57045. * Gets the rgb output component
  57046. */
  57047. readonly rgb: NodeMaterialConnectionPoint;
  57048. /**
  57049. * Gets the r output component
  57050. */
  57051. readonly r: NodeMaterialConnectionPoint;
  57052. /**
  57053. * Gets the g output component
  57054. */
  57055. readonly g: NodeMaterialConnectionPoint;
  57056. /**
  57057. * Gets the b output component
  57058. */
  57059. readonly b: NodeMaterialConnectionPoint;
  57060. /**
  57061. * Gets the a output component
  57062. */
  57063. readonly a: NodeMaterialConnectionPoint;
  57064. readonly target: NodeMaterialBlockTargets;
  57065. autoConfigure(material: NodeMaterial): void;
  57066. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57067. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57068. private _getTextureBase;
  57069. isReady(): boolean;
  57070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57071. private readonly _isMixed;
  57072. private _injectVertexCode;
  57073. private _writeTextureRead;
  57074. private _writeOutput;
  57075. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57076. protected _dumpPropertiesCode(): string;
  57077. serialize(): any;
  57078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57079. }
  57080. }
  57081. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  57082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57084. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57085. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57086. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57087. import { Scene } from "babylonjs/scene";
  57088. /**
  57089. * Class used to store shared data between 2 NodeMaterialBuildState
  57090. */
  57091. export class NodeMaterialBuildStateSharedData {
  57092. /**
  57093. * Gets the list of emitted varyings
  57094. */
  57095. temps: string[];
  57096. /**
  57097. * Gets the list of emitted varyings
  57098. */
  57099. varyings: string[];
  57100. /**
  57101. * Gets the varying declaration string
  57102. */
  57103. varyingDeclaration: string;
  57104. /**
  57105. * Input blocks
  57106. */
  57107. inputBlocks: InputBlock[];
  57108. /**
  57109. * Input blocks
  57110. */
  57111. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57112. /**
  57113. * Bindable blocks (Blocks that need to set data to the effect)
  57114. */
  57115. bindableBlocks: NodeMaterialBlock[];
  57116. /**
  57117. * List of blocks that can provide a compilation fallback
  57118. */
  57119. blocksWithFallbacks: NodeMaterialBlock[];
  57120. /**
  57121. * List of blocks that can provide a define update
  57122. */
  57123. blocksWithDefines: NodeMaterialBlock[];
  57124. /**
  57125. * List of blocks that can provide a repeatable content
  57126. */
  57127. repeatableContentBlocks: NodeMaterialBlock[];
  57128. /**
  57129. * List of blocks that can provide a dynamic list of uniforms
  57130. */
  57131. dynamicUniformBlocks: NodeMaterialBlock[];
  57132. /**
  57133. * List of blocks that can block the isReady function for the material
  57134. */
  57135. blockingBlocks: NodeMaterialBlock[];
  57136. /**
  57137. * Gets the list of animated inputs
  57138. */
  57139. animatedInputs: InputBlock[];
  57140. /**
  57141. * Build Id used to avoid multiple recompilations
  57142. */
  57143. buildId: number;
  57144. /** List of emitted variables */
  57145. variableNames: {
  57146. [key: string]: number;
  57147. };
  57148. /** List of emitted defines */
  57149. defineNames: {
  57150. [key: string]: number;
  57151. };
  57152. /** Should emit comments? */
  57153. emitComments: boolean;
  57154. /** Emit build activity */
  57155. verbose: boolean;
  57156. /** Gets or sets the hosting scene */
  57157. scene: Scene;
  57158. /**
  57159. * Gets the compilation hints emitted at compilation time
  57160. */
  57161. hints: {
  57162. needWorldViewMatrix: boolean;
  57163. needWorldViewProjectionMatrix: boolean;
  57164. needAlphaBlending: boolean;
  57165. needAlphaTesting: boolean;
  57166. };
  57167. /**
  57168. * List of compilation checks
  57169. */
  57170. checks: {
  57171. emitVertex: boolean;
  57172. emitFragment: boolean;
  57173. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57174. };
  57175. /** Creates a new shared data */
  57176. constructor();
  57177. /**
  57178. * Emits console errors and exceptions if there is a failing check
  57179. */
  57180. emitErrors(): void;
  57181. }
  57182. }
  57183. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  57184. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57185. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57186. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  57187. /**
  57188. * Class used to store node based material build state
  57189. */
  57190. export class NodeMaterialBuildState {
  57191. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57192. supportUniformBuffers: boolean;
  57193. /**
  57194. * Gets the list of emitted attributes
  57195. */
  57196. attributes: string[];
  57197. /**
  57198. * Gets the list of emitted uniforms
  57199. */
  57200. uniforms: string[];
  57201. /**
  57202. * Gets the list of emitted constants
  57203. */
  57204. constants: string[];
  57205. /**
  57206. * Gets the list of emitted samplers
  57207. */
  57208. samplers: string[];
  57209. /**
  57210. * Gets the list of emitted functions
  57211. */
  57212. functions: {
  57213. [key: string]: string;
  57214. };
  57215. /**
  57216. * Gets the list of emitted extensions
  57217. */
  57218. extensions: {
  57219. [key: string]: string;
  57220. };
  57221. /**
  57222. * Gets the target of the compilation state
  57223. */
  57224. target: NodeMaterialBlockTargets;
  57225. /**
  57226. * Gets the list of emitted counters
  57227. */
  57228. counters: {
  57229. [key: string]: number;
  57230. };
  57231. /**
  57232. * Shared data between multiple NodeMaterialBuildState instances
  57233. */
  57234. sharedData: NodeMaterialBuildStateSharedData;
  57235. /** @hidden */
  57236. _vertexState: NodeMaterialBuildState;
  57237. /** @hidden */
  57238. _attributeDeclaration: string;
  57239. /** @hidden */
  57240. _uniformDeclaration: string;
  57241. /** @hidden */
  57242. _constantDeclaration: string;
  57243. /** @hidden */
  57244. _samplerDeclaration: string;
  57245. /** @hidden */
  57246. _varyingTransfer: string;
  57247. private _repeatableContentAnchorIndex;
  57248. /** @hidden */
  57249. _builtCompilationString: string;
  57250. /**
  57251. * Gets the emitted compilation strings
  57252. */
  57253. compilationString: string;
  57254. /**
  57255. * Finalize the compilation strings
  57256. * @param state defines the current compilation state
  57257. */
  57258. finalize(state: NodeMaterialBuildState): void;
  57259. /** @hidden */
  57260. readonly _repeatableContentAnchor: string;
  57261. /** @hidden */
  57262. _getFreeVariableName(prefix: string): string;
  57263. /** @hidden */
  57264. _getFreeDefineName(prefix: string): string;
  57265. /** @hidden */
  57266. _excludeVariableName(name: string): void;
  57267. /** @hidden */
  57268. _emit2DSampler(name: string): void;
  57269. /** @hidden */
  57270. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57271. /** @hidden */
  57272. _emitExtension(name: string, extension: string): void;
  57273. /** @hidden */
  57274. _emitFunction(name: string, code: string, comments: string): void;
  57275. /** @hidden */
  57276. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57277. replaceStrings?: {
  57278. search: RegExp;
  57279. replace: string;
  57280. }[];
  57281. repeatKey?: string;
  57282. }): string;
  57283. /** @hidden */
  57284. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57285. repeatKey?: string;
  57286. removeAttributes?: boolean;
  57287. removeUniforms?: boolean;
  57288. removeVaryings?: boolean;
  57289. removeIfDef?: boolean;
  57290. replaceStrings?: {
  57291. search: RegExp;
  57292. replace: string;
  57293. }[];
  57294. }, storeKey?: string): void;
  57295. /** @hidden */
  57296. _registerTempVariable(name: string): boolean;
  57297. /** @hidden */
  57298. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57299. /** @hidden */
  57300. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57301. /** @hidden */
  57302. _emitFloat(value: number): string;
  57303. }
  57304. }
  57305. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  57306. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57308. import { Nullable } from "babylonjs/types";
  57309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57310. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57311. import { Effect } from "babylonjs/Materials/effect";
  57312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57313. import { Mesh } from "babylonjs/Meshes/mesh";
  57314. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57315. import { Scene } from "babylonjs/scene";
  57316. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57317. /**
  57318. * Defines a block that can be used inside a node based material
  57319. */
  57320. export class NodeMaterialBlock {
  57321. private _buildId;
  57322. private _buildTarget;
  57323. private _target;
  57324. private _isFinalMerger;
  57325. private _isInput;
  57326. protected _isUnique: boolean;
  57327. /** @hidden */
  57328. _codeVariableName: string;
  57329. /** @hidden */
  57330. _inputs: NodeMaterialConnectionPoint[];
  57331. /** @hidden */
  57332. _outputs: NodeMaterialConnectionPoint[];
  57333. /** @hidden */
  57334. _preparationId: number;
  57335. /**
  57336. * Gets or sets the name of the block
  57337. */
  57338. name: string;
  57339. /**
  57340. * Gets or sets the unique id of the node
  57341. */
  57342. uniqueId: number;
  57343. /**
  57344. * Gets or sets the comments associated with this block
  57345. */
  57346. comments: string;
  57347. /**
  57348. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57349. */
  57350. readonly isUnique: boolean;
  57351. /**
  57352. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57353. */
  57354. readonly isFinalMerger: boolean;
  57355. /**
  57356. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57357. */
  57358. readonly isInput: boolean;
  57359. /**
  57360. * Gets or sets the build Id
  57361. */
  57362. buildId: number;
  57363. /**
  57364. * Gets or sets the target of the block
  57365. */
  57366. target: NodeMaterialBlockTargets;
  57367. /**
  57368. * Gets the list of input points
  57369. */
  57370. readonly inputs: NodeMaterialConnectionPoint[];
  57371. /** Gets the list of output points */
  57372. readonly outputs: NodeMaterialConnectionPoint[];
  57373. /**
  57374. * Find an input by its name
  57375. * @param name defines the name of the input to look for
  57376. * @returns the input or null if not found
  57377. */
  57378. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57379. /**
  57380. * Find an output by its name
  57381. * @param name defines the name of the outputto look for
  57382. * @returns the output or null if not found
  57383. */
  57384. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57385. /**
  57386. * Creates a new NodeMaterialBlock
  57387. * @param name defines the block name
  57388. * @param target defines the target of that block (Vertex by default)
  57389. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57390. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57391. */
  57392. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57393. /**
  57394. * Initialize the block and prepare the context for build
  57395. * @param state defines the state that will be used for the build
  57396. */
  57397. initialize(state: NodeMaterialBuildState): void;
  57398. /**
  57399. * Bind data to effect. Will only be called for blocks with isBindable === true
  57400. * @param effect defines the effect to bind data to
  57401. * @param nodeMaterial defines the hosting NodeMaterial
  57402. * @param mesh defines the mesh that will be rendered
  57403. */
  57404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57405. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57406. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57407. protected _writeFloat(value: number): string;
  57408. /**
  57409. * Gets the current class name e.g. "NodeMaterialBlock"
  57410. * @returns the class name
  57411. */
  57412. getClassName(): string;
  57413. /**
  57414. * Register a new input. Must be called inside a block constructor
  57415. * @param name defines the connection point name
  57416. * @param type defines the connection point type
  57417. * @param isOptional defines a boolean indicating that this input can be omitted
  57418. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57419. * @returns the current block
  57420. */
  57421. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57422. /**
  57423. * Register a new output. Must be called inside a block constructor
  57424. * @param name defines the connection point name
  57425. * @param type defines the connection point type
  57426. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57427. * @returns the current block
  57428. */
  57429. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57430. /**
  57431. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57432. * @param forOutput defines an optional connection point to check compatibility with
  57433. * @returns the first available input or null
  57434. */
  57435. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57436. /**
  57437. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57438. * @param forBlock defines an optional block to check compatibility with
  57439. * @returns the first available input or null
  57440. */
  57441. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57442. /**
  57443. * Gets the sibling of the given output
  57444. * @param current defines the current output
  57445. * @returns the next output in the list or null
  57446. */
  57447. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57448. /**
  57449. * Connect current block with another block
  57450. * @param other defines the block to connect with
  57451. * @param options define the various options to help pick the right connections
  57452. * @returns the current block
  57453. */
  57454. connectTo(other: NodeMaterialBlock, options?: {
  57455. input?: string;
  57456. output?: string;
  57457. outputSwizzle?: string;
  57458. }): this | undefined;
  57459. protected _buildBlock(state: NodeMaterialBuildState): void;
  57460. /**
  57461. * Add uniforms, samplers and uniform buffers at compilation time
  57462. * @param state defines the state to update
  57463. * @param nodeMaterial defines the node material requesting the update
  57464. * @param defines defines the material defines to update
  57465. * @param uniformBuffers defines the list of uniform buffer names
  57466. */
  57467. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57468. /**
  57469. * Add potential fallbacks if shader compilation fails
  57470. * @param mesh defines the mesh to be rendered
  57471. * @param fallbacks defines the current prioritized list of fallbacks
  57472. */
  57473. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57474. /**
  57475. * Initialize defines for shader compilation
  57476. * @param mesh defines the mesh to be rendered
  57477. * @param nodeMaterial defines the node material requesting the update
  57478. * @param defines defines the material defines to update
  57479. * @param useInstances specifies that instances should be used
  57480. */
  57481. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57482. /**
  57483. * Update defines for shader compilation
  57484. * @param mesh defines the mesh to be rendered
  57485. * @param nodeMaterial defines the node material requesting the update
  57486. * @param defines defines the material defines to update
  57487. * @param useInstances specifies that instances should be used
  57488. */
  57489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57490. /**
  57491. * Lets the block try to connect some inputs automatically
  57492. * @param material defines the hosting NodeMaterial
  57493. */
  57494. autoConfigure(material: NodeMaterial): void;
  57495. /**
  57496. * Function called when a block is declared as repeatable content generator
  57497. * @param vertexShaderState defines the current compilation state for the vertex shader
  57498. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57499. * @param mesh defines the mesh to be rendered
  57500. * @param defines defines the material defines to update
  57501. */
  57502. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57503. /**
  57504. * Checks if the block is ready
  57505. * @param mesh defines the mesh to be rendered
  57506. * @param nodeMaterial defines the node material requesting the update
  57507. * @param defines defines the material defines to update
  57508. * @param useInstances specifies that instances should be used
  57509. * @returns true if the block is ready
  57510. */
  57511. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57512. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57513. private _processBuild;
  57514. /**
  57515. * Compile the current node and generate the shader code
  57516. * @param state defines the current compilation state (uniforms, samplers, current string)
  57517. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57518. * @returns true if already built
  57519. */
  57520. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57521. protected _inputRename(name: string): string;
  57522. protected _outputRename(name: string): string;
  57523. protected _dumpPropertiesCode(): string;
  57524. /** @hidden */
  57525. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57526. /** @hidden */
  57527. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57528. /**
  57529. * Clone the current block to a new identical block
  57530. * @param scene defines the hosting scene
  57531. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57532. * @returns a copy of the current block
  57533. */
  57534. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57535. /**
  57536. * Serializes this block in a JSON representation
  57537. * @returns the serialized block object
  57538. */
  57539. serialize(): any;
  57540. /** @hidden */
  57541. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57542. /**
  57543. * Release resources
  57544. */
  57545. dispose(): void;
  57546. }
  57547. }
  57548. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57549. /**
  57550. * Enum defining the type of animations supported by InputBlock
  57551. */
  57552. export enum AnimatedInputBlockTypes {
  57553. /** No animation */
  57554. None = 0,
  57555. /** Time based animation. Will only work for floats */
  57556. Time = 1
  57557. }
  57558. }
  57559. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57561. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57562. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57563. import { Nullable } from "babylonjs/types";
  57564. import { Effect } from "babylonjs/Materials/effect";
  57565. import { Matrix } from "babylonjs/Maths/math.vector";
  57566. import { Scene } from "babylonjs/scene";
  57567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57569. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57570. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57571. /**
  57572. * Block used to expose an input value
  57573. */
  57574. export class InputBlock extends NodeMaterialBlock {
  57575. private _mode;
  57576. private _associatedVariableName;
  57577. private _storedValue;
  57578. private _valueCallback;
  57579. private _type;
  57580. private _animationType;
  57581. /** Gets or set a value used to limit the range of float values */
  57582. min: number;
  57583. /** Gets or set a value used to limit the range of float values */
  57584. max: number;
  57585. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57586. matrixMode: number;
  57587. /** @hidden */
  57588. _systemValue: Nullable<NodeMaterialSystemValues>;
  57589. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57590. visibleInInspector: boolean;
  57591. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57592. isConstant: boolean;
  57593. /** Gets or sets the group to use to display this block in the Inspector */
  57594. groupInInspector: string;
  57595. /**
  57596. * Gets or sets the connection point type (default is float)
  57597. */
  57598. readonly type: NodeMaterialBlockConnectionPointTypes;
  57599. /**
  57600. * Creates a new InputBlock
  57601. * @param name defines the block name
  57602. * @param target defines the target of that block (Vertex by default)
  57603. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57604. */
  57605. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57606. /**
  57607. * Gets the output component
  57608. */
  57609. readonly output: NodeMaterialConnectionPoint;
  57610. /**
  57611. * Set the source of this connection point to a vertex attribute
  57612. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57613. * @returns the current connection point
  57614. */
  57615. setAsAttribute(attributeName?: string): InputBlock;
  57616. /**
  57617. * Set the source of this connection point to a system value
  57618. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57619. * @returns the current connection point
  57620. */
  57621. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57622. /**
  57623. * Gets or sets the value of that point.
  57624. * Please note that this value will be ignored if valueCallback is defined
  57625. */
  57626. value: any;
  57627. /**
  57628. * Gets or sets a callback used to get the value of that point.
  57629. * Please note that setting this value will force the connection point to ignore the value property
  57630. */
  57631. valueCallback: () => any;
  57632. /**
  57633. * Gets or sets the associated variable name in the shader
  57634. */
  57635. associatedVariableName: string;
  57636. /** Gets or sets the type of animation applied to the input */
  57637. animationType: AnimatedInputBlockTypes;
  57638. /**
  57639. * Gets a boolean indicating that this connection point not defined yet
  57640. */
  57641. readonly isUndefined: boolean;
  57642. /**
  57643. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57644. * In this case the connection point name must be the name of the uniform to use.
  57645. * Can only be set on inputs
  57646. */
  57647. isUniform: boolean;
  57648. /**
  57649. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57650. * In this case the connection point name must be the name of the attribute to use
  57651. * Can only be set on inputs
  57652. */
  57653. isAttribute: boolean;
  57654. /**
  57655. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57656. * Can only be set on exit points
  57657. */
  57658. isVarying: boolean;
  57659. /**
  57660. * Gets a boolean indicating that the current connection point is a system value
  57661. */
  57662. readonly isSystemValue: boolean;
  57663. /**
  57664. * Gets or sets the current well known value or null if not defined as a system value
  57665. */
  57666. systemValue: Nullable<NodeMaterialSystemValues>;
  57667. /**
  57668. * Gets the current class name
  57669. * @returns the class name
  57670. */
  57671. getClassName(): string;
  57672. /**
  57673. * Animate the input if animationType !== None
  57674. * @param scene defines the rendering scene
  57675. */
  57676. animate(scene: Scene): void;
  57677. private _emitDefine;
  57678. initialize(state: NodeMaterialBuildState): void;
  57679. /**
  57680. * Set the input block to its default value (based on its type)
  57681. */
  57682. setDefaultValue(): void;
  57683. private _emitConstant;
  57684. private _emit;
  57685. /** @hidden */
  57686. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57687. /** @hidden */
  57688. _transmit(effect: Effect, scene: Scene): void;
  57689. protected _buildBlock(state: NodeMaterialBuildState): void;
  57690. protected _dumpPropertiesCode(): string;
  57691. serialize(): any;
  57692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57693. }
  57694. }
  57695. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57696. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57697. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57698. import { Nullable } from "babylonjs/types";
  57699. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57700. import { Observable } from "babylonjs/Misc/observable";
  57701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57702. /**
  57703. * Enum used to define the compatibility state between two connection points
  57704. */
  57705. export enum NodeMaterialConnectionPointCompatibilityStates {
  57706. /** Points are compatibles */
  57707. Compatible = 0,
  57708. /** Points are incompatible because of their types */
  57709. TypeIncompatible = 1,
  57710. /** Points are incompatible because of their targets (vertex vs fragment) */
  57711. TargetIncompatible = 2
  57712. }
  57713. /**
  57714. * Defines the direction of a connection point
  57715. */
  57716. export enum NodeMaterialConnectionPointDirection {
  57717. /** Input */
  57718. Input = 0,
  57719. /** Output */
  57720. Output = 1
  57721. }
  57722. /**
  57723. * Defines a connection point for a block
  57724. */
  57725. export class NodeMaterialConnectionPoint {
  57726. /** @hidden */
  57727. _ownerBlock: NodeMaterialBlock;
  57728. /** @hidden */
  57729. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57730. private _endpoints;
  57731. private _associatedVariableName;
  57732. private _direction;
  57733. /** @hidden */
  57734. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57735. /** @hidden */
  57736. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57737. private _type;
  57738. /** @hidden */
  57739. _enforceAssociatedVariableName: boolean;
  57740. /** Gets the direction of the point */
  57741. readonly direction: NodeMaterialConnectionPointDirection;
  57742. /**
  57743. * Gets or sets the additional types supported by this connection point
  57744. */
  57745. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57746. /**
  57747. * Gets or sets the additional types excluded by this connection point
  57748. */
  57749. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57750. /**
  57751. * Observable triggered when this point is connected
  57752. */
  57753. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57754. /**
  57755. * Gets or sets the associated variable name in the shader
  57756. */
  57757. associatedVariableName: string;
  57758. /**
  57759. * Gets or sets the connection point type (default is float)
  57760. */
  57761. type: NodeMaterialBlockConnectionPointTypes;
  57762. /**
  57763. * Gets or sets the connection point name
  57764. */
  57765. name: string;
  57766. /**
  57767. * Gets or sets a boolean indicating that this connection point can be omitted
  57768. */
  57769. isOptional: boolean;
  57770. /**
  57771. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57772. */
  57773. define: string;
  57774. /** @hidden */
  57775. _prioritizeVertex: boolean;
  57776. private _target;
  57777. /** Gets or sets the target of that connection point */
  57778. target: NodeMaterialBlockTargets;
  57779. /**
  57780. * Gets a boolean indicating that the current point is connected
  57781. */
  57782. readonly isConnected: boolean;
  57783. /**
  57784. * Gets a boolean indicating that the current point is connected to an input block
  57785. */
  57786. readonly isConnectedToInputBlock: boolean;
  57787. /**
  57788. * Gets a the connected input block (if any)
  57789. */
  57790. readonly connectInputBlock: Nullable<InputBlock>;
  57791. /** Get the other side of the connection (if any) */
  57792. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57793. /** Get the block that owns this connection point */
  57794. readonly ownerBlock: NodeMaterialBlock;
  57795. /** Get the block connected on the other side of this connection (if any) */
  57796. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57797. /** Get the block connected on the endpoints of this connection (if any) */
  57798. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57799. /** Gets the list of connected endpoints */
  57800. readonly endpoints: NodeMaterialConnectionPoint[];
  57801. /** Gets a boolean indicating if that output point is connected to at least one input */
  57802. readonly hasEndpoints: boolean;
  57803. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57804. readonly isConnectedInVertexShader: boolean;
  57805. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57806. readonly isConnectedInFragmentShader: boolean;
  57807. /**
  57808. * Creates a new connection point
  57809. * @param name defines the connection point name
  57810. * @param ownerBlock defines the block hosting this connection point
  57811. * @param direction defines the direction of the connection point
  57812. */
  57813. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  57814. /**
  57815. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57816. * @returns the class name
  57817. */
  57818. getClassName(): string;
  57819. /**
  57820. * Gets a boolean indicating if the current point can be connected to another point
  57821. * @param connectionPoint defines the other connection point
  57822. * @returns a boolean
  57823. */
  57824. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57825. /**
  57826. * Gets a number indicating if the current point can be connected to another point
  57827. * @param connectionPoint defines the other connection point
  57828. * @returns a number defining the compatibility state
  57829. */
  57830. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57831. /**
  57832. * Connect this point to another connection point
  57833. * @param connectionPoint defines the other connection point
  57834. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57835. * @returns the current connection point
  57836. */
  57837. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57838. /**
  57839. * Disconnect this point from one of his endpoint
  57840. * @param endpoint defines the other connection point
  57841. * @returns the current connection point
  57842. */
  57843. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57844. /**
  57845. * Serializes this point in a JSON representation
  57846. * @returns the serialized point object
  57847. */
  57848. serialize(): any;
  57849. /**
  57850. * Release resources
  57851. */
  57852. dispose(): void;
  57853. }
  57854. }
  57855. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57859. import { Mesh } from "babylonjs/Meshes/mesh";
  57860. import { Effect } from "babylonjs/Materials/effect";
  57861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57862. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57863. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57864. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57865. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57866. /**
  57867. * Block used to add support for vertex skinning (bones)
  57868. */
  57869. export class BonesBlock extends NodeMaterialBlock {
  57870. /**
  57871. * Creates a new BonesBlock
  57872. * @param name defines the block name
  57873. */
  57874. constructor(name: string);
  57875. /**
  57876. * Initialize the block and prepare the context for build
  57877. * @param state defines the state that will be used for the build
  57878. */
  57879. initialize(state: NodeMaterialBuildState): void;
  57880. /**
  57881. * Gets the current class name
  57882. * @returns the class name
  57883. */
  57884. getClassName(): string;
  57885. /**
  57886. * Gets the matrix indices input component
  57887. */
  57888. readonly matricesIndices: NodeMaterialConnectionPoint;
  57889. /**
  57890. * Gets the matrix weights input component
  57891. */
  57892. readonly matricesWeights: NodeMaterialConnectionPoint;
  57893. /**
  57894. * Gets the extra matrix indices input component
  57895. */
  57896. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57897. /**
  57898. * Gets the extra matrix weights input component
  57899. */
  57900. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57901. /**
  57902. * Gets the world input component
  57903. */
  57904. readonly world: NodeMaterialConnectionPoint;
  57905. /**
  57906. * Gets the output component
  57907. */
  57908. readonly output: NodeMaterialConnectionPoint;
  57909. autoConfigure(material: NodeMaterial): void;
  57910. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57912. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57913. protected _buildBlock(state: NodeMaterialBuildState): this;
  57914. }
  57915. }
  57916. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57918. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57921. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57922. /**
  57923. * Block used to add support for instances
  57924. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57925. */
  57926. export class InstancesBlock extends NodeMaterialBlock {
  57927. /**
  57928. * Creates a new InstancesBlock
  57929. * @param name defines the block name
  57930. */
  57931. constructor(name: string);
  57932. /**
  57933. * Gets the current class name
  57934. * @returns the class name
  57935. */
  57936. getClassName(): string;
  57937. /**
  57938. * Gets the first world row input component
  57939. */
  57940. readonly world0: NodeMaterialConnectionPoint;
  57941. /**
  57942. * Gets the second world row input component
  57943. */
  57944. readonly world1: NodeMaterialConnectionPoint;
  57945. /**
  57946. * Gets the third world row input component
  57947. */
  57948. readonly world2: NodeMaterialConnectionPoint;
  57949. /**
  57950. * Gets the forth world row input component
  57951. */
  57952. readonly world3: NodeMaterialConnectionPoint;
  57953. /**
  57954. * Gets the world input component
  57955. */
  57956. readonly world: NodeMaterialConnectionPoint;
  57957. /**
  57958. * Gets the output component
  57959. */
  57960. readonly output: NodeMaterialConnectionPoint;
  57961. autoConfigure(material: NodeMaterial): void;
  57962. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57963. protected _buildBlock(state: NodeMaterialBuildState): this;
  57964. }
  57965. }
  57966. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57971. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57972. import { Effect } from "babylonjs/Materials/effect";
  57973. import { Mesh } from "babylonjs/Meshes/mesh";
  57974. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57975. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57976. /**
  57977. * Block used to add morph targets support to vertex shader
  57978. */
  57979. export class MorphTargetsBlock extends NodeMaterialBlock {
  57980. private _repeatableContentAnchor;
  57981. private _repeatebleContentGenerated;
  57982. /**
  57983. * Create a new MorphTargetsBlock
  57984. * @param name defines the block name
  57985. */
  57986. constructor(name: string);
  57987. /**
  57988. * Gets the current class name
  57989. * @returns the class name
  57990. */
  57991. getClassName(): string;
  57992. /**
  57993. * Gets the position input component
  57994. */
  57995. readonly position: NodeMaterialConnectionPoint;
  57996. /**
  57997. * Gets the normal input component
  57998. */
  57999. readonly normal: NodeMaterialConnectionPoint;
  58000. /**
  58001. * Gets the tangent input component
  58002. */
  58003. readonly tangent: NodeMaterialConnectionPoint;
  58004. /**
  58005. * Gets the tangent input component
  58006. */
  58007. readonly uv: NodeMaterialConnectionPoint;
  58008. /**
  58009. * Gets the position output component
  58010. */
  58011. readonly positionOutput: NodeMaterialConnectionPoint;
  58012. /**
  58013. * Gets the normal output component
  58014. */
  58015. readonly normalOutput: NodeMaterialConnectionPoint;
  58016. /**
  58017. * Gets the tangent output component
  58018. */
  58019. readonly tangentOutput: NodeMaterialConnectionPoint;
  58020. /**
  58021. * Gets the tangent output component
  58022. */
  58023. readonly uvOutput: NodeMaterialConnectionPoint;
  58024. initialize(state: NodeMaterialBuildState): void;
  58025. autoConfigure(material: NodeMaterial): void;
  58026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58027. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58028. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58029. protected _buildBlock(state: NodeMaterialBuildState): this;
  58030. }
  58031. }
  58032. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  58033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58036. import { Nullable } from "babylonjs/types";
  58037. import { Scene } from "babylonjs/scene";
  58038. import { Effect } from "babylonjs/Materials/effect";
  58039. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58040. import { Mesh } from "babylonjs/Meshes/mesh";
  58041. import { Light } from "babylonjs/Lights/light";
  58042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58043. /**
  58044. * Block used to get data information from a light
  58045. */
  58046. export class LightInformationBlock extends NodeMaterialBlock {
  58047. private _lightDataUniformName;
  58048. private _lightColorUniformName;
  58049. private _lightTypeDefineName;
  58050. /**
  58051. * Gets or sets the light associated with this block
  58052. */
  58053. light: Nullable<Light>;
  58054. /**
  58055. * Creates a new LightInformationBlock
  58056. * @param name defines the block name
  58057. */
  58058. constructor(name: string);
  58059. /**
  58060. * Gets the current class name
  58061. * @returns the class name
  58062. */
  58063. getClassName(): string;
  58064. /**
  58065. * Gets the world position input component
  58066. */
  58067. readonly worldPosition: NodeMaterialConnectionPoint;
  58068. /**
  58069. * Gets the direction output component
  58070. */
  58071. readonly direction: NodeMaterialConnectionPoint;
  58072. /**
  58073. * Gets the direction output component
  58074. */
  58075. readonly color: NodeMaterialConnectionPoint;
  58076. /**
  58077. * Gets the direction output component
  58078. */
  58079. readonly intensity: NodeMaterialConnectionPoint;
  58080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58082. protected _buildBlock(state: NodeMaterialBuildState): this;
  58083. serialize(): any;
  58084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58085. }
  58086. }
  58087. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  58088. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  58089. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  58090. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  58091. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  58092. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  58093. }
  58094. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  58095. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58096. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58097. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58099. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58100. import { Effect } from "babylonjs/Materials/effect";
  58101. import { Mesh } from "babylonjs/Meshes/mesh";
  58102. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58103. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58104. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58105. /**
  58106. * Block used to add image processing support to fragment shader
  58107. */
  58108. export class ImageProcessingBlock extends NodeMaterialBlock {
  58109. /**
  58110. * Create a new ImageProcessingBlock
  58111. * @param name defines the block name
  58112. */
  58113. constructor(name: string);
  58114. /**
  58115. * Gets the current class name
  58116. * @returns the class name
  58117. */
  58118. getClassName(): string;
  58119. /**
  58120. * Gets the color input component
  58121. */
  58122. readonly color: NodeMaterialConnectionPoint;
  58123. /**
  58124. * Gets the output component
  58125. */
  58126. readonly output: NodeMaterialConnectionPoint;
  58127. /**
  58128. * Initialize the block and prepare the context for build
  58129. * @param state defines the state that will be used for the build
  58130. */
  58131. initialize(state: NodeMaterialBuildState): void;
  58132. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58133. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58134. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58135. protected _buildBlock(state: NodeMaterialBuildState): this;
  58136. }
  58137. }
  58138. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  58139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58142. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58144. import { Effect } from "babylonjs/Materials/effect";
  58145. import { Mesh } from "babylonjs/Meshes/mesh";
  58146. import { Scene } from "babylonjs/scene";
  58147. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58148. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58149. /**
  58150. * Block used to pertub normals based on a normal map
  58151. */
  58152. export class PerturbNormalBlock extends NodeMaterialBlock {
  58153. private _tangentSpaceParameterName;
  58154. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58155. invertX: boolean;
  58156. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58157. invertY: boolean;
  58158. /**
  58159. * Create a new PerturbNormalBlock
  58160. * @param name defines the block name
  58161. */
  58162. constructor(name: string);
  58163. /**
  58164. * Gets the current class name
  58165. * @returns the class name
  58166. */
  58167. getClassName(): string;
  58168. /**
  58169. * Gets the world position input component
  58170. */
  58171. readonly worldPosition: NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the world normal input component
  58174. */
  58175. readonly worldNormal: NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the uv input component
  58178. */
  58179. readonly uv: NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the normal map color input component
  58182. */
  58183. readonly normalMapColor: NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the strength input component
  58186. */
  58187. readonly strength: NodeMaterialConnectionPoint;
  58188. /**
  58189. * Gets the output component
  58190. */
  58191. readonly output: NodeMaterialConnectionPoint;
  58192. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58194. autoConfigure(material: NodeMaterial): void;
  58195. protected _buildBlock(state: NodeMaterialBuildState): this;
  58196. protected _dumpPropertiesCode(): string;
  58197. serialize(): any;
  58198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58199. }
  58200. }
  58201. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  58202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58205. /**
  58206. * Block used to discard a pixel if a value is smaller than a cutoff
  58207. */
  58208. export class DiscardBlock extends NodeMaterialBlock {
  58209. /**
  58210. * Create a new DiscardBlock
  58211. * @param name defines the block name
  58212. */
  58213. constructor(name: string);
  58214. /**
  58215. * Gets the current class name
  58216. * @returns the class name
  58217. */
  58218. getClassName(): string;
  58219. /**
  58220. * Gets the color input component
  58221. */
  58222. readonly value: NodeMaterialConnectionPoint;
  58223. /**
  58224. * Gets the cutoff input component
  58225. */
  58226. readonly cutoff: NodeMaterialConnectionPoint;
  58227. protected _buildBlock(state: NodeMaterialBuildState): this;
  58228. }
  58229. }
  58230. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  58231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58234. /**
  58235. * Block used to test if the fragment shader is front facing
  58236. */
  58237. export class FrontFacingBlock extends NodeMaterialBlock {
  58238. /**
  58239. * Creates a new FrontFacingBlock
  58240. * @param name defines the block name
  58241. */
  58242. constructor(name: string);
  58243. /**
  58244. * Gets the current class name
  58245. * @returns the class name
  58246. */
  58247. getClassName(): string;
  58248. /**
  58249. * Gets the output component
  58250. */
  58251. readonly output: NodeMaterialConnectionPoint;
  58252. protected _buildBlock(state: NodeMaterialBuildState): this;
  58253. }
  58254. }
  58255. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  58256. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58257. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58258. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58259. /**
  58260. * Block used to get the derivative value on x and y of a given input
  58261. */
  58262. export class DerivativeBlock extends NodeMaterialBlock {
  58263. /**
  58264. * Create a new DerivativeBlock
  58265. * @param name defines the block name
  58266. */
  58267. constructor(name: string);
  58268. /**
  58269. * Gets the current class name
  58270. * @returns the class name
  58271. */
  58272. getClassName(): string;
  58273. /**
  58274. * Gets the input component
  58275. */
  58276. readonly input: NodeMaterialConnectionPoint;
  58277. /**
  58278. * Gets the derivative output on x
  58279. */
  58280. readonly dx: NodeMaterialConnectionPoint;
  58281. /**
  58282. * Gets the derivative output on y
  58283. */
  58284. readonly dy: NodeMaterialConnectionPoint;
  58285. protected _buildBlock(state: NodeMaterialBuildState): this;
  58286. }
  58287. }
  58288. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  58289. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  58290. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  58291. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  58292. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  58293. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  58294. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  58295. }
  58296. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  58297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58299. import { Mesh } from "babylonjs/Meshes/mesh";
  58300. import { Effect } from "babylonjs/Materials/effect";
  58301. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58303. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58304. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58305. /**
  58306. * Block used to add support for scene fog
  58307. */
  58308. export class FogBlock extends NodeMaterialBlock {
  58309. private _fogDistanceName;
  58310. private _fogParameters;
  58311. /**
  58312. * Create a new FogBlock
  58313. * @param name defines the block name
  58314. */
  58315. constructor(name: string);
  58316. /**
  58317. * Gets the current class name
  58318. * @returns the class name
  58319. */
  58320. getClassName(): string;
  58321. /**
  58322. * Gets the world position input component
  58323. */
  58324. readonly worldPosition: NodeMaterialConnectionPoint;
  58325. /**
  58326. * Gets the view input component
  58327. */
  58328. readonly view: NodeMaterialConnectionPoint;
  58329. /**
  58330. * Gets the color input component
  58331. */
  58332. readonly input: NodeMaterialConnectionPoint;
  58333. /**
  58334. * Gets the fog color input component
  58335. */
  58336. readonly fogColor: NodeMaterialConnectionPoint;
  58337. /**
  58338. * Gets the output component
  58339. */
  58340. readonly output: NodeMaterialConnectionPoint;
  58341. autoConfigure(material: NodeMaterial): void;
  58342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58344. protected _buildBlock(state: NodeMaterialBuildState): this;
  58345. }
  58346. }
  58347. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  58348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58352. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58353. import { Effect } from "babylonjs/Materials/effect";
  58354. import { Mesh } from "babylonjs/Meshes/mesh";
  58355. import { Light } from "babylonjs/Lights/light";
  58356. import { Nullable } from "babylonjs/types";
  58357. import { Scene } from "babylonjs/scene";
  58358. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58359. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58360. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58362. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  58363. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58364. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58365. /**
  58366. * Block used to add light in the fragment shader
  58367. */
  58368. export class LightBlock extends NodeMaterialBlock {
  58369. private _lightId;
  58370. /**
  58371. * Gets or sets the light associated with this block
  58372. */
  58373. light: Nullable<Light>;
  58374. /**
  58375. * Create a new LightBlock
  58376. * @param name defines the block name
  58377. */
  58378. constructor(name: string);
  58379. /**
  58380. * Gets the current class name
  58381. * @returns the class name
  58382. */
  58383. getClassName(): string;
  58384. /**
  58385. * Gets the world position input component
  58386. */
  58387. readonly worldPosition: NodeMaterialConnectionPoint;
  58388. /**
  58389. * Gets the world normal input component
  58390. */
  58391. readonly worldNormal: NodeMaterialConnectionPoint;
  58392. /**
  58393. * Gets the camera (or eye) position component
  58394. */
  58395. readonly cameraPosition: NodeMaterialConnectionPoint;
  58396. /**
  58397. * Gets the glossiness component
  58398. */
  58399. readonly glossiness: NodeMaterialConnectionPoint;
  58400. /**
  58401. * Gets the glossinness power component
  58402. */
  58403. readonly glossPower: NodeMaterialConnectionPoint;
  58404. /**
  58405. * Gets the diffuse color component
  58406. */
  58407. readonly diffuseColor: NodeMaterialConnectionPoint;
  58408. /**
  58409. * Gets the specular color component
  58410. */
  58411. readonly specularColor: NodeMaterialConnectionPoint;
  58412. /**
  58413. * Gets the diffuse output component
  58414. */
  58415. readonly diffuseOutput: NodeMaterialConnectionPoint;
  58416. /**
  58417. * Gets the specular output component
  58418. */
  58419. readonly specularOutput: NodeMaterialConnectionPoint;
  58420. autoConfigure(material: NodeMaterial): void;
  58421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58422. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58423. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58424. private _injectVertexCode;
  58425. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58426. serialize(): any;
  58427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58428. }
  58429. }
  58430. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  58431. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  58432. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  58433. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58434. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58435. }
  58436. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  58437. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58438. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58439. }
  58440. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  58441. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58442. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58443. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58444. /**
  58445. * Block used to multiply 2 values
  58446. */
  58447. export class MultiplyBlock extends NodeMaterialBlock {
  58448. /**
  58449. * Creates a new MultiplyBlock
  58450. * @param name defines the block name
  58451. */
  58452. constructor(name: string);
  58453. /**
  58454. * Gets the current class name
  58455. * @returns the class name
  58456. */
  58457. getClassName(): string;
  58458. /**
  58459. * Gets the left operand input component
  58460. */
  58461. readonly left: NodeMaterialConnectionPoint;
  58462. /**
  58463. * Gets the right operand input component
  58464. */
  58465. readonly right: NodeMaterialConnectionPoint;
  58466. /**
  58467. * Gets the output component
  58468. */
  58469. readonly output: NodeMaterialConnectionPoint;
  58470. protected _buildBlock(state: NodeMaterialBuildState): this;
  58471. }
  58472. }
  58473. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  58474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58477. /**
  58478. * Block used to add 2 vectors
  58479. */
  58480. export class AddBlock extends NodeMaterialBlock {
  58481. /**
  58482. * Creates a new AddBlock
  58483. * @param name defines the block name
  58484. */
  58485. constructor(name: string);
  58486. /**
  58487. * Gets the current class name
  58488. * @returns the class name
  58489. */
  58490. getClassName(): string;
  58491. /**
  58492. * Gets the left operand input component
  58493. */
  58494. readonly left: NodeMaterialConnectionPoint;
  58495. /**
  58496. * Gets the right operand input component
  58497. */
  58498. readonly right: NodeMaterialConnectionPoint;
  58499. /**
  58500. * Gets the output component
  58501. */
  58502. readonly output: NodeMaterialConnectionPoint;
  58503. protected _buildBlock(state: NodeMaterialBuildState): this;
  58504. }
  58505. }
  58506. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  58507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58510. /**
  58511. * Block used to scale a vector by a float
  58512. */
  58513. export class ScaleBlock extends NodeMaterialBlock {
  58514. /**
  58515. * Creates a new ScaleBlock
  58516. * @param name defines the block name
  58517. */
  58518. constructor(name: string);
  58519. /**
  58520. * Gets the current class name
  58521. * @returns the class name
  58522. */
  58523. getClassName(): string;
  58524. /**
  58525. * Gets the input component
  58526. */
  58527. readonly input: NodeMaterialConnectionPoint;
  58528. /**
  58529. * Gets the factor input component
  58530. */
  58531. readonly factor: NodeMaterialConnectionPoint;
  58532. /**
  58533. * Gets the output component
  58534. */
  58535. readonly output: NodeMaterialConnectionPoint;
  58536. protected _buildBlock(state: NodeMaterialBuildState): this;
  58537. }
  58538. }
  58539. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  58540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58543. import { Scene } from "babylonjs/scene";
  58544. /**
  58545. * Block used to clamp a float
  58546. */
  58547. export class ClampBlock extends NodeMaterialBlock {
  58548. /** Gets or sets the minimum range */
  58549. minimum: number;
  58550. /** Gets or sets the maximum range */
  58551. maximum: number;
  58552. /**
  58553. * Creates a new ClampBlock
  58554. * @param name defines the block name
  58555. */
  58556. constructor(name: string);
  58557. /**
  58558. * Gets the current class name
  58559. * @returns the class name
  58560. */
  58561. getClassName(): string;
  58562. /**
  58563. * Gets the value input component
  58564. */
  58565. readonly value: NodeMaterialConnectionPoint;
  58566. /**
  58567. * Gets the output component
  58568. */
  58569. readonly output: NodeMaterialConnectionPoint;
  58570. protected _buildBlock(state: NodeMaterialBuildState): this;
  58571. protected _dumpPropertiesCode(): string;
  58572. serialize(): any;
  58573. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58574. }
  58575. }
  58576. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58580. /**
  58581. * Block used to apply a cross product between 2 vectors
  58582. */
  58583. export class CrossBlock extends NodeMaterialBlock {
  58584. /**
  58585. * Creates a new CrossBlock
  58586. * @param name defines the block name
  58587. */
  58588. constructor(name: string);
  58589. /**
  58590. * Gets the current class name
  58591. * @returns the class name
  58592. */
  58593. getClassName(): string;
  58594. /**
  58595. * Gets the left operand input component
  58596. */
  58597. readonly left: NodeMaterialConnectionPoint;
  58598. /**
  58599. * Gets the right operand input component
  58600. */
  58601. readonly right: NodeMaterialConnectionPoint;
  58602. /**
  58603. * Gets the output component
  58604. */
  58605. readonly output: NodeMaterialConnectionPoint;
  58606. protected _buildBlock(state: NodeMaterialBuildState): this;
  58607. }
  58608. }
  58609. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58613. /**
  58614. * Block used to apply a dot product between 2 vectors
  58615. */
  58616. export class DotBlock extends NodeMaterialBlock {
  58617. /**
  58618. * Creates a new DotBlock
  58619. * @param name defines the block name
  58620. */
  58621. constructor(name: string);
  58622. /**
  58623. * Gets the current class name
  58624. * @returns the class name
  58625. */
  58626. getClassName(): string;
  58627. /**
  58628. * Gets the left operand input component
  58629. */
  58630. readonly left: NodeMaterialConnectionPoint;
  58631. /**
  58632. * Gets the right operand input component
  58633. */
  58634. readonly right: NodeMaterialConnectionPoint;
  58635. /**
  58636. * Gets the output component
  58637. */
  58638. readonly output: NodeMaterialConnectionPoint;
  58639. protected _buildBlock(state: NodeMaterialBuildState): this;
  58640. }
  58641. }
  58642. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58646. import { Vector2 } from "babylonjs/Maths/math.vector";
  58647. import { Scene } from "babylonjs/scene";
  58648. /**
  58649. * Block used to remap a float from a range to a new one
  58650. */
  58651. export class RemapBlock extends NodeMaterialBlock {
  58652. /**
  58653. * Gets or sets the source range
  58654. */
  58655. sourceRange: Vector2;
  58656. /**
  58657. * Gets or sets the target range
  58658. */
  58659. targetRange: Vector2;
  58660. /**
  58661. * Creates a new RemapBlock
  58662. * @param name defines the block name
  58663. */
  58664. constructor(name: string);
  58665. /**
  58666. * Gets the current class name
  58667. * @returns the class name
  58668. */
  58669. getClassName(): string;
  58670. /**
  58671. * Gets the input component
  58672. */
  58673. readonly input: NodeMaterialConnectionPoint;
  58674. /**
  58675. * Gets the source min input component
  58676. */
  58677. readonly sourceMin: NodeMaterialConnectionPoint;
  58678. /**
  58679. * Gets the source max input component
  58680. */
  58681. readonly sourceMax: NodeMaterialConnectionPoint;
  58682. /**
  58683. * Gets the target min input component
  58684. */
  58685. readonly targetMin: NodeMaterialConnectionPoint;
  58686. /**
  58687. * Gets the target max input component
  58688. */
  58689. readonly targetMax: NodeMaterialConnectionPoint;
  58690. /**
  58691. * Gets the output component
  58692. */
  58693. readonly output: NodeMaterialConnectionPoint;
  58694. protected _buildBlock(state: NodeMaterialBuildState): this;
  58695. protected _dumpPropertiesCode(): string;
  58696. serialize(): any;
  58697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58698. }
  58699. }
  58700. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58704. /**
  58705. * Block used to normalize a vector
  58706. */
  58707. export class NormalizeBlock extends NodeMaterialBlock {
  58708. /**
  58709. * Creates a new NormalizeBlock
  58710. * @param name defines the block name
  58711. */
  58712. constructor(name: string);
  58713. /**
  58714. * Gets the current class name
  58715. * @returns the class name
  58716. */
  58717. getClassName(): string;
  58718. /**
  58719. * Gets the input component
  58720. */
  58721. readonly input: NodeMaterialConnectionPoint;
  58722. /**
  58723. * Gets the output component
  58724. */
  58725. readonly output: NodeMaterialConnectionPoint;
  58726. protected _buildBlock(state: NodeMaterialBuildState): this;
  58727. }
  58728. }
  58729. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58733. import { Scene } from "babylonjs/scene";
  58734. /**
  58735. * Operations supported by the Trigonometry block
  58736. */
  58737. export enum TrigonometryBlockOperations {
  58738. /** Cos */
  58739. Cos = 0,
  58740. /** Sin */
  58741. Sin = 1,
  58742. /** Abs */
  58743. Abs = 2,
  58744. /** Exp */
  58745. Exp = 3,
  58746. /** Exp2 */
  58747. Exp2 = 4,
  58748. /** Round */
  58749. Round = 5,
  58750. /** Floor */
  58751. Floor = 6,
  58752. /** Ceiling */
  58753. Ceiling = 7,
  58754. /** Square root */
  58755. Sqrt = 8,
  58756. /** Log */
  58757. Log = 9,
  58758. /** Tangent */
  58759. Tan = 10,
  58760. /** Arc tangent */
  58761. ArcTan = 11,
  58762. /** Arc cosinus */
  58763. ArcCos = 12,
  58764. /** Arc sinus */
  58765. ArcSin = 13,
  58766. /** Fraction */
  58767. Fract = 14,
  58768. /** Sign */
  58769. Sign = 15,
  58770. /** To radians (from degrees) */
  58771. Radians = 16,
  58772. /** To degrees (from radians) */
  58773. Degrees = 17
  58774. }
  58775. /**
  58776. * Block used to apply trigonometry operation to floats
  58777. */
  58778. export class TrigonometryBlock extends NodeMaterialBlock {
  58779. /**
  58780. * Gets or sets the operation applied by the block
  58781. */
  58782. operation: TrigonometryBlockOperations;
  58783. /**
  58784. * Creates a new TrigonometryBlock
  58785. * @param name defines the block name
  58786. */
  58787. constructor(name: string);
  58788. /**
  58789. * Gets the current class name
  58790. * @returns the class name
  58791. */
  58792. getClassName(): string;
  58793. /**
  58794. * Gets the input component
  58795. */
  58796. readonly input: NodeMaterialConnectionPoint;
  58797. /**
  58798. * Gets the output component
  58799. */
  58800. readonly output: NodeMaterialConnectionPoint;
  58801. protected _buildBlock(state: NodeMaterialBuildState): this;
  58802. serialize(): any;
  58803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58804. protected _dumpPropertiesCode(): string;
  58805. }
  58806. }
  58807. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58811. /**
  58812. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58813. */
  58814. export class ColorMergerBlock extends NodeMaterialBlock {
  58815. /**
  58816. * Create a new ColorMergerBlock
  58817. * @param name defines the block name
  58818. */
  58819. constructor(name: string);
  58820. /**
  58821. * Gets the current class name
  58822. * @returns the class name
  58823. */
  58824. getClassName(): string;
  58825. /**
  58826. * Gets the rgb component (input)
  58827. */
  58828. readonly rgbIn: NodeMaterialConnectionPoint;
  58829. /**
  58830. * Gets the r component (input)
  58831. */
  58832. readonly r: NodeMaterialConnectionPoint;
  58833. /**
  58834. * Gets the g component (input)
  58835. */
  58836. readonly g: NodeMaterialConnectionPoint;
  58837. /**
  58838. * Gets the b component (input)
  58839. */
  58840. readonly b: NodeMaterialConnectionPoint;
  58841. /**
  58842. * Gets the a component (input)
  58843. */
  58844. readonly a: NodeMaterialConnectionPoint;
  58845. /**
  58846. * Gets the rgba component (output)
  58847. */
  58848. readonly rgba: NodeMaterialConnectionPoint;
  58849. /**
  58850. * Gets the rgb component (output)
  58851. */
  58852. readonly rgbOut: NodeMaterialConnectionPoint;
  58853. /**
  58854. * Gets the rgb component (output)
  58855. * @deprecated Please use rgbOut instead.
  58856. */
  58857. readonly rgb: NodeMaterialConnectionPoint;
  58858. protected _buildBlock(state: NodeMaterialBuildState): this;
  58859. }
  58860. }
  58861. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58865. /**
  58866. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58867. */
  58868. export class VectorMergerBlock extends NodeMaterialBlock {
  58869. /**
  58870. * Create a new VectorMergerBlock
  58871. * @param name defines the block name
  58872. */
  58873. constructor(name: string);
  58874. /**
  58875. * Gets the current class name
  58876. * @returns the class name
  58877. */
  58878. getClassName(): string;
  58879. /**
  58880. * Gets the xyz component (input)
  58881. */
  58882. readonly xyzIn: NodeMaterialConnectionPoint;
  58883. /**
  58884. * Gets the xy component (input)
  58885. */
  58886. readonly xyIn: NodeMaterialConnectionPoint;
  58887. /**
  58888. * Gets the x component (input)
  58889. */
  58890. readonly x: NodeMaterialConnectionPoint;
  58891. /**
  58892. * Gets the y component (input)
  58893. */
  58894. readonly y: NodeMaterialConnectionPoint;
  58895. /**
  58896. * Gets the z component (input)
  58897. */
  58898. readonly z: NodeMaterialConnectionPoint;
  58899. /**
  58900. * Gets the w component (input)
  58901. */
  58902. readonly w: NodeMaterialConnectionPoint;
  58903. /**
  58904. * Gets the xyzw component (output)
  58905. */
  58906. readonly xyzw: NodeMaterialConnectionPoint;
  58907. /**
  58908. * Gets the xyz component (output)
  58909. */
  58910. readonly xyzOut: NodeMaterialConnectionPoint;
  58911. /**
  58912. * Gets the xy component (output)
  58913. */
  58914. readonly xyOut: NodeMaterialConnectionPoint;
  58915. /**
  58916. * Gets the xy component (output)
  58917. * @deprecated Please use xyOut instead.
  58918. */
  58919. readonly xy: NodeMaterialConnectionPoint;
  58920. /**
  58921. * Gets the xyz component (output)
  58922. * @deprecated Please use xyzOut instead.
  58923. */
  58924. readonly xyz: NodeMaterialConnectionPoint;
  58925. protected _buildBlock(state: NodeMaterialBuildState): this;
  58926. }
  58927. }
  58928. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  58929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58932. /**
  58933. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  58934. */
  58935. export class ColorSplitterBlock extends NodeMaterialBlock {
  58936. /**
  58937. * Create a new ColorSplitterBlock
  58938. * @param name defines the block name
  58939. */
  58940. constructor(name: string);
  58941. /**
  58942. * Gets the current class name
  58943. * @returns the class name
  58944. */
  58945. getClassName(): string;
  58946. /**
  58947. * Gets the rgba component (input)
  58948. */
  58949. readonly rgba: NodeMaterialConnectionPoint;
  58950. /**
  58951. * Gets the rgb component (input)
  58952. */
  58953. readonly rgbIn: NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the rgb component (output)
  58956. */
  58957. readonly rgbOut: NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the r component (output)
  58960. */
  58961. readonly r: NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the g component (output)
  58964. */
  58965. readonly g: NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the b component (output)
  58968. */
  58969. readonly b: NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the a component (output)
  58972. */
  58973. readonly a: NodeMaterialConnectionPoint;
  58974. protected _inputRename(name: string): string;
  58975. protected _outputRename(name: string): string;
  58976. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58977. }
  58978. }
  58979. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58981. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58982. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58983. /**
  58984. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58985. */
  58986. export class VectorSplitterBlock extends NodeMaterialBlock {
  58987. /**
  58988. * Create a new VectorSplitterBlock
  58989. * @param name defines the block name
  58990. */
  58991. constructor(name: string);
  58992. /**
  58993. * Gets the current class name
  58994. * @returns the class name
  58995. */
  58996. getClassName(): string;
  58997. /**
  58998. * Gets the xyzw component (input)
  58999. */
  59000. readonly xyzw: NodeMaterialConnectionPoint;
  59001. /**
  59002. * Gets the xyz component (input)
  59003. */
  59004. readonly xyzIn: NodeMaterialConnectionPoint;
  59005. /**
  59006. * Gets the xy component (input)
  59007. */
  59008. readonly xyIn: NodeMaterialConnectionPoint;
  59009. /**
  59010. * Gets the xyz component (output)
  59011. */
  59012. readonly xyzOut: NodeMaterialConnectionPoint;
  59013. /**
  59014. * Gets the xy component (output)
  59015. */
  59016. readonly xyOut: NodeMaterialConnectionPoint;
  59017. /**
  59018. * Gets the x component (output)
  59019. */
  59020. readonly x: NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the y component (output)
  59023. */
  59024. readonly y: NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the z component (output)
  59027. */
  59028. readonly z: NodeMaterialConnectionPoint;
  59029. /**
  59030. * Gets the w component (output)
  59031. */
  59032. readonly w: NodeMaterialConnectionPoint;
  59033. protected _inputRename(name: string): string;
  59034. protected _outputRename(name: string): string;
  59035. protected _buildBlock(state: NodeMaterialBuildState): this;
  59036. }
  59037. }
  59038. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  59039. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59040. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59041. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59042. /**
  59043. * Block used to lerp between 2 values
  59044. */
  59045. export class LerpBlock extends NodeMaterialBlock {
  59046. /**
  59047. * Creates a new LerpBlock
  59048. * @param name defines the block name
  59049. */
  59050. constructor(name: string);
  59051. /**
  59052. * Gets the current class name
  59053. * @returns the class name
  59054. */
  59055. getClassName(): string;
  59056. /**
  59057. * Gets the left operand input component
  59058. */
  59059. readonly left: NodeMaterialConnectionPoint;
  59060. /**
  59061. * Gets the right operand input component
  59062. */
  59063. readonly right: NodeMaterialConnectionPoint;
  59064. /**
  59065. * Gets the gradient operand input component
  59066. */
  59067. readonly gradient: NodeMaterialConnectionPoint;
  59068. /**
  59069. * Gets the output component
  59070. */
  59071. readonly output: NodeMaterialConnectionPoint;
  59072. protected _buildBlock(state: NodeMaterialBuildState): this;
  59073. }
  59074. }
  59075. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  59076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59079. /**
  59080. * Block used to divide 2 vectors
  59081. */
  59082. export class DivideBlock extends NodeMaterialBlock {
  59083. /**
  59084. * Creates a new DivideBlock
  59085. * @param name defines the block name
  59086. */
  59087. constructor(name: string);
  59088. /**
  59089. * Gets the current class name
  59090. * @returns the class name
  59091. */
  59092. getClassName(): string;
  59093. /**
  59094. * Gets the left operand input component
  59095. */
  59096. readonly left: NodeMaterialConnectionPoint;
  59097. /**
  59098. * Gets the right operand input component
  59099. */
  59100. readonly right: NodeMaterialConnectionPoint;
  59101. /**
  59102. * Gets the output component
  59103. */
  59104. readonly output: NodeMaterialConnectionPoint;
  59105. protected _buildBlock(state: NodeMaterialBuildState): this;
  59106. }
  59107. }
  59108. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  59109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59112. /**
  59113. * Block used to subtract 2 vectors
  59114. */
  59115. export class SubtractBlock extends NodeMaterialBlock {
  59116. /**
  59117. * Creates a new SubtractBlock
  59118. * @param name defines the block name
  59119. */
  59120. constructor(name: string);
  59121. /**
  59122. * Gets the current class name
  59123. * @returns the class name
  59124. */
  59125. getClassName(): string;
  59126. /**
  59127. * Gets the left operand input component
  59128. */
  59129. readonly left: NodeMaterialConnectionPoint;
  59130. /**
  59131. * Gets the right operand input component
  59132. */
  59133. readonly right: NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the output component
  59136. */
  59137. readonly output: NodeMaterialConnectionPoint;
  59138. protected _buildBlock(state: NodeMaterialBuildState): this;
  59139. }
  59140. }
  59141. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  59142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59145. /**
  59146. * Block used to step a value
  59147. */
  59148. export class StepBlock extends NodeMaterialBlock {
  59149. /**
  59150. * Creates a new StepBlock
  59151. * @param name defines the block name
  59152. */
  59153. constructor(name: string);
  59154. /**
  59155. * Gets the current class name
  59156. * @returns the class name
  59157. */
  59158. getClassName(): string;
  59159. /**
  59160. * Gets the value operand input component
  59161. */
  59162. readonly value: NodeMaterialConnectionPoint;
  59163. /**
  59164. * Gets the edge operand input component
  59165. */
  59166. readonly edge: NodeMaterialConnectionPoint;
  59167. /**
  59168. * Gets the output component
  59169. */
  59170. readonly output: NodeMaterialConnectionPoint;
  59171. protected _buildBlock(state: NodeMaterialBuildState): this;
  59172. }
  59173. }
  59174. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  59175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59178. /**
  59179. * Block used to get the opposite (1 - x) of a value
  59180. */
  59181. export class OneMinusBlock extends NodeMaterialBlock {
  59182. /**
  59183. * Creates a new OneMinusBlock
  59184. * @param name defines the block name
  59185. */
  59186. constructor(name: string);
  59187. /**
  59188. * Gets the current class name
  59189. * @returns the class name
  59190. */
  59191. getClassName(): string;
  59192. /**
  59193. * Gets the input component
  59194. */
  59195. readonly input: NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the output component
  59198. */
  59199. readonly output: NodeMaterialConnectionPoint;
  59200. protected _buildBlock(state: NodeMaterialBuildState): this;
  59201. }
  59202. }
  59203. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  59204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59207. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59208. /**
  59209. * Block used to get the view direction
  59210. */
  59211. export class ViewDirectionBlock extends NodeMaterialBlock {
  59212. /**
  59213. * Creates a new ViewDirectionBlock
  59214. * @param name defines the block name
  59215. */
  59216. constructor(name: string);
  59217. /**
  59218. * Gets the current class name
  59219. * @returns the class name
  59220. */
  59221. getClassName(): string;
  59222. /**
  59223. * Gets the world position component
  59224. */
  59225. readonly worldPosition: NodeMaterialConnectionPoint;
  59226. /**
  59227. * Gets the camera position component
  59228. */
  59229. readonly cameraPosition: NodeMaterialConnectionPoint;
  59230. /**
  59231. * Gets the output component
  59232. */
  59233. readonly output: NodeMaterialConnectionPoint;
  59234. autoConfigure(material: NodeMaterial): void;
  59235. protected _buildBlock(state: NodeMaterialBuildState): this;
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  59239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59242. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59243. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  59244. /**
  59245. * Block used to compute fresnel value
  59246. */
  59247. export class FresnelBlock extends NodeMaterialBlock {
  59248. /**
  59249. * Create a new FresnelBlock
  59250. * @param name defines the block name
  59251. */
  59252. constructor(name: string);
  59253. /**
  59254. * Gets the current class name
  59255. * @returns the class name
  59256. */
  59257. getClassName(): string;
  59258. /**
  59259. * Gets the world normal input component
  59260. */
  59261. readonly worldNormal: NodeMaterialConnectionPoint;
  59262. /**
  59263. * Gets the view direction input component
  59264. */
  59265. readonly viewDirection: NodeMaterialConnectionPoint;
  59266. /**
  59267. * Gets the bias input component
  59268. */
  59269. readonly bias: NodeMaterialConnectionPoint;
  59270. /**
  59271. * Gets the camera (or eye) position component
  59272. */
  59273. readonly power: NodeMaterialConnectionPoint;
  59274. /**
  59275. * Gets the fresnel output component
  59276. */
  59277. readonly fresnel: NodeMaterialConnectionPoint;
  59278. autoConfigure(material: NodeMaterial): void;
  59279. protected _buildBlock(state: NodeMaterialBuildState): this;
  59280. }
  59281. }
  59282. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  59283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59286. /**
  59287. * Block used to get the max of 2 values
  59288. */
  59289. export class MaxBlock extends NodeMaterialBlock {
  59290. /**
  59291. * Creates a new MaxBlock
  59292. * @param name defines the block name
  59293. */
  59294. constructor(name: string);
  59295. /**
  59296. * Gets the current class name
  59297. * @returns the class name
  59298. */
  59299. getClassName(): string;
  59300. /**
  59301. * Gets the left operand input component
  59302. */
  59303. readonly left: NodeMaterialConnectionPoint;
  59304. /**
  59305. * Gets the right operand input component
  59306. */
  59307. readonly right: NodeMaterialConnectionPoint;
  59308. /**
  59309. * Gets the output component
  59310. */
  59311. readonly output: NodeMaterialConnectionPoint;
  59312. protected _buildBlock(state: NodeMaterialBuildState): this;
  59313. }
  59314. }
  59315. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  59316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59319. /**
  59320. * Block used to get the min of 2 values
  59321. */
  59322. export class MinBlock extends NodeMaterialBlock {
  59323. /**
  59324. * Creates a new MinBlock
  59325. * @param name defines the block name
  59326. */
  59327. constructor(name: string);
  59328. /**
  59329. * Gets the current class name
  59330. * @returns the class name
  59331. */
  59332. getClassName(): string;
  59333. /**
  59334. * Gets the left operand input component
  59335. */
  59336. readonly left: NodeMaterialConnectionPoint;
  59337. /**
  59338. * Gets the right operand input component
  59339. */
  59340. readonly right: NodeMaterialConnectionPoint;
  59341. /**
  59342. * Gets the output component
  59343. */
  59344. readonly output: NodeMaterialConnectionPoint;
  59345. protected _buildBlock(state: NodeMaterialBuildState): this;
  59346. }
  59347. }
  59348. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  59349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59352. /**
  59353. * Block used to get the distance between 2 values
  59354. */
  59355. export class DistanceBlock extends NodeMaterialBlock {
  59356. /**
  59357. * Creates a new DistanceBlock
  59358. * @param name defines the block name
  59359. */
  59360. constructor(name: string);
  59361. /**
  59362. * Gets the current class name
  59363. * @returns the class name
  59364. */
  59365. getClassName(): string;
  59366. /**
  59367. * Gets the left operand input component
  59368. */
  59369. readonly left: NodeMaterialConnectionPoint;
  59370. /**
  59371. * Gets the right operand input component
  59372. */
  59373. readonly right: NodeMaterialConnectionPoint;
  59374. /**
  59375. * Gets the output component
  59376. */
  59377. readonly output: NodeMaterialConnectionPoint;
  59378. protected _buildBlock(state: NodeMaterialBuildState): this;
  59379. }
  59380. }
  59381. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  59382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59385. /**
  59386. * Block used to get the length of a vector
  59387. */
  59388. export class LengthBlock extends NodeMaterialBlock {
  59389. /**
  59390. * Creates a new LengthBlock
  59391. * @param name defines the block name
  59392. */
  59393. constructor(name: string);
  59394. /**
  59395. * Gets the current class name
  59396. * @returns the class name
  59397. */
  59398. getClassName(): string;
  59399. /**
  59400. * Gets the value input component
  59401. */
  59402. readonly value: NodeMaterialConnectionPoint;
  59403. /**
  59404. * Gets the output component
  59405. */
  59406. readonly output: NodeMaterialConnectionPoint;
  59407. protected _buildBlock(state: NodeMaterialBuildState): this;
  59408. }
  59409. }
  59410. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  59411. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59413. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59414. /**
  59415. * Block used to get negative version of a value (i.e. x * -1)
  59416. */
  59417. export class NegateBlock extends NodeMaterialBlock {
  59418. /**
  59419. * Creates a new NegateBlock
  59420. * @param name defines the block name
  59421. */
  59422. constructor(name: string);
  59423. /**
  59424. * Gets the current class name
  59425. * @returns the class name
  59426. */
  59427. getClassName(): string;
  59428. /**
  59429. * Gets the value input component
  59430. */
  59431. readonly value: NodeMaterialConnectionPoint;
  59432. /**
  59433. * Gets the output component
  59434. */
  59435. readonly output: NodeMaterialConnectionPoint;
  59436. protected _buildBlock(state: NodeMaterialBuildState): this;
  59437. }
  59438. }
  59439. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  59440. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59441. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59442. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59443. /**
  59444. * Block used to get the value of the first parameter raised to the power of the second
  59445. */
  59446. export class PowBlock extends NodeMaterialBlock {
  59447. /**
  59448. * Creates a new PowBlock
  59449. * @param name defines the block name
  59450. */
  59451. constructor(name: string);
  59452. /**
  59453. * Gets the current class name
  59454. * @returns the class name
  59455. */
  59456. getClassName(): string;
  59457. /**
  59458. * Gets the value operand input component
  59459. */
  59460. readonly value: NodeMaterialConnectionPoint;
  59461. /**
  59462. * Gets the power operand input component
  59463. */
  59464. readonly power: NodeMaterialConnectionPoint;
  59465. /**
  59466. * Gets the output component
  59467. */
  59468. readonly output: NodeMaterialConnectionPoint;
  59469. protected _buildBlock(state: NodeMaterialBuildState): this;
  59470. }
  59471. }
  59472. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  59473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59476. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59477. /**
  59478. * Block used to get a random number
  59479. */
  59480. export class RandomNumberBlock extends NodeMaterialBlock {
  59481. /**
  59482. * Creates a new RandomNumberBlock
  59483. * @param name defines the block name
  59484. */
  59485. constructor(name: string);
  59486. /**
  59487. * Gets the current class name
  59488. * @returns the class name
  59489. */
  59490. getClassName(): string;
  59491. /**
  59492. * Gets the seed input component
  59493. */
  59494. readonly seed: NodeMaterialConnectionPoint;
  59495. /**
  59496. * Gets the output component
  59497. */
  59498. readonly output: NodeMaterialConnectionPoint;
  59499. protected _buildBlock(state: NodeMaterialBuildState): this;
  59500. }
  59501. }
  59502. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  59503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59506. /**
  59507. * Block used to compute arc tangent of 2 values
  59508. */
  59509. export class ArcTan2Block extends NodeMaterialBlock {
  59510. /**
  59511. * Creates a new ArcTan2Block
  59512. * @param name defines the block name
  59513. */
  59514. constructor(name: string);
  59515. /**
  59516. * Gets the current class name
  59517. * @returns the class name
  59518. */
  59519. getClassName(): string;
  59520. /**
  59521. * Gets the x operand input component
  59522. */
  59523. readonly x: NodeMaterialConnectionPoint;
  59524. /**
  59525. * Gets the y operand input component
  59526. */
  59527. readonly y: NodeMaterialConnectionPoint;
  59528. /**
  59529. * Gets the output component
  59530. */
  59531. readonly output: NodeMaterialConnectionPoint;
  59532. protected _buildBlock(state: NodeMaterialBuildState): this;
  59533. }
  59534. }
  59535. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  59536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59539. /**
  59540. * Block used to smooth step a value
  59541. */
  59542. export class SmoothStepBlock extends NodeMaterialBlock {
  59543. /**
  59544. * Creates a new SmoothStepBlock
  59545. * @param name defines the block name
  59546. */
  59547. constructor(name: string);
  59548. /**
  59549. * Gets the current class name
  59550. * @returns the class name
  59551. */
  59552. getClassName(): string;
  59553. /**
  59554. * Gets the value operand input component
  59555. */
  59556. readonly value: NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the first edge operand input component
  59559. */
  59560. readonly edge0: NodeMaterialConnectionPoint;
  59561. /**
  59562. * Gets the second edge operand input component
  59563. */
  59564. readonly edge1: NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the output component
  59567. */
  59568. readonly output: NodeMaterialConnectionPoint;
  59569. protected _buildBlock(state: NodeMaterialBuildState): this;
  59570. }
  59571. }
  59572. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  59573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59576. /**
  59577. * Block used to get the reciprocal (1 / x) of a value
  59578. */
  59579. export class ReciprocalBlock extends NodeMaterialBlock {
  59580. /**
  59581. * Creates a new ReciprocalBlock
  59582. * @param name defines the block name
  59583. */
  59584. constructor(name: string);
  59585. /**
  59586. * Gets the current class name
  59587. * @returns the class name
  59588. */
  59589. getClassName(): string;
  59590. /**
  59591. * Gets the input component
  59592. */
  59593. readonly input: NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the output component
  59596. */
  59597. readonly output: NodeMaterialConnectionPoint;
  59598. protected _buildBlock(state: NodeMaterialBuildState): this;
  59599. }
  59600. }
  59601. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59605. /**
  59606. * Block used to replace a color by another one
  59607. */
  59608. export class ReplaceColorBlock extends NodeMaterialBlock {
  59609. /**
  59610. * Creates a new ReplaceColorBlock
  59611. * @param name defines the block name
  59612. */
  59613. constructor(name: string);
  59614. /**
  59615. * Gets the current class name
  59616. * @returns the class name
  59617. */
  59618. getClassName(): string;
  59619. /**
  59620. * Gets the value input component
  59621. */
  59622. readonly value: NodeMaterialConnectionPoint;
  59623. /**
  59624. * Gets the reference input component
  59625. */
  59626. readonly reference: NodeMaterialConnectionPoint;
  59627. /**
  59628. * Gets the distance input component
  59629. */
  59630. readonly distance: NodeMaterialConnectionPoint;
  59631. /**
  59632. * Gets the replacement input component
  59633. */
  59634. readonly replacement: NodeMaterialConnectionPoint;
  59635. /**
  59636. * Gets the output component
  59637. */
  59638. readonly output: NodeMaterialConnectionPoint;
  59639. protected _buildBlock(state: NodeMaterialBuildState): this;
  59640. }
  59641. }
  59642. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59646. /**
  59647. * Block used to posterize a value
  59648. * @see https://en.wikipedia.org/wiki/Posterization
  59649. */
  59650. export class PosterizeBlock extends NodeMaterialBlock {
  59651. /**
  59652. * Creates a new PosterizeBlock
  59653. * @param name defines the block name
  59654. */
  59655. constructor(name: string);
  59656. /**
  59657. * Gets the current class name
  59658. * @returns the class name
  59659. */
  59660. getClassName(): string;
  59661. /**
  59662. * Gets the value input component
  59663. */
  59664. readonly value: NodeMaterialConnectionPoint;
  59665. /**
  59666. * Gets the steps input component
  59667. */
  59668. readonly steps: NodeMaterialConnectionPoint;
  59669. /**
  59670. * Gets the output component
  59671. */
  59672. readonly output: NodeMaterialConnectionPoint;
  59673. protected _buildBlock(state: NodeMaterialBuildState): this;
  59674. }
  59675. }
  59676. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59680. import { Scene } from "babylonjs/scene";
  59681. /**
  59682. * Operations supported by the Wave block
  59683. */
  59684. export enum WaveBlockKind {
  59685. /** SawTooth */
  59686. SawTooth = 0,
  59687. /** Square */
  59688. Square = 1,
  59689. /** Triangle */
  59690. Triangle = 2
  59691. }
  59692. /**
  59693. * Block used to apply wave operation to floats
  59694. */
  59695. export class WaveBlock extends NodeMaterialBlock {
  59696. /**
  59697. * Gets or sets the kibnd of wave to be applied by the block
  59698. */
  59699. kind: WaveBlockKind;
  59700. /**
  59701. * Creates a new WaveBlock
  59702. * @param name defines the block name
  59703. */
  59704. constructor(name: string);
  59705. /**
  59706. * Gets the current class name
  59707. * @returns the class name
  59708. */
  59709. getClassName(): string;
  59710. /**
  59711. * Gets the input component
  59712. */
  59713. readonly input: NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the output component
  59716. */
  59717. readonly output: NodeMaterialConnectionPoint;
  59718. protected _buildBlock(state: NodeMaterialBuildState): this;
  59719. serialize(): any;
  59720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59721. }
  59722. }
  59723. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59727. import { Color3 } from "babylonjs/Maths/math.color";
  59728. import { Scene } from "babylonjs/scene";
  59729. /**
  59730. * Class used to store a color step for the GradientBlock
  59731. */
  59732. export class GradientBlockColorStep {
  59733. /**
  59734. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59735. */
  59736. step: number;
  59737. /**
  59738. * Gets or sets the color associated with this step
  59739. */
  59740. color: Color3;
  59741. /**
  59742. * Creates a new GradientBlockColorStep
  59743. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59744. * @param color defines the color associated with this step
  59745. */
  59746. constructor(
  59747. /**
  59748. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59749. */
  59750. step: number,
  59751. /**
  59752. * Gets or sets the color associated with this step
  59753. */
  59754. color: Color3);
  59755. }
  59756. /**
  59757. * Block used to return a color from a gradient based on an input value between 0 and 1
  59758. */
  59759. export class GradientBlock extends NodeMaterialBlock {
  59760. /**
  59761. * Gets or sets the list of color steps
  59762. */
  59763. colorSteps: GradientBlockColorStep[];
  59764. /**
  59765. * Creates a new GradientBlock
  59766. * @param name defines the block name
  59767. */
  59768. constructor(name: string);
  59769. /**
  59770. * Gets the current class name
  59771. * @returns the class name
  59772. */
  59773. getClassName(): string;
  59774. /**
  59775. * Gets the gradient input component
  59776. */
  59777. readonly gradient: NodeMaterialConnectionPoint;
  59778. /**
  59779. * Gets the output component
  59780. */
  59781. readonly output: NodeMaterialConnectionPoint;
  59782. private _writeColorConstant;
  59783. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59784. serialize(): any;
  59785. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59786. protected _dumpPropertiesCode(): string;
  59787. }
  59788. }
  59789. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59793. /**
  59794. * Block used to normalize lerp between 2 values
  59795. */
  59796. export class NLerpBlock extends NodeMaterialBlock {
  59797. /**
  59798. * Creates a new NLerpBlock
  59799. * @param name defines the block name
  59800. */
  59801. constructor(name: string);
  59802. /**
  59803. * Gets the current class name
  59804. * @returns the class name
  59805. */
  59806. getClassName(): string;
  59807. /**
  59808. * Gets the left operand input component
  59809. */
  59810. readonly left: NodeMaterialConnectionPoint;
  59811. /**
  59812. * Gets the right operand input component
  59813. */
  59814. readonly right: NodeMaterialConnectionPoint;
  59815. /**
  59816. * Gets the gradient operand input component
  59817. */
  59818. readonly gradient: NodeMaterialConnectionPoint;
  59819. /**
  59820. * Gets the output component
  59821. */
  59822. readonly output: NodeMaterialConnectionPoint;
  59823. protected _buildBlock(state: NodeMaterialBuildState): this;
  59824. }
  59825. }
  59826. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59830. import { Scene } from "babylonjs/scene";
  59831. /**
  59832. * block used to Generate a Worley Noise 3D Noise Pattern
  59833. */
  59834. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59835. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59836. manhattanDistance: boolean;
  59837. /**
  59838. * Creates a new WorleyNoise3DBlock
  59839. * @param name defines the block name
  59840. */
  59841. constructor(name: string);
  59842. /**
  59843. * Gets the current class name
  59844. * @returns the class name
  59845. */
  59846. getClassName(): string;
  59847. /**
  59848. * Gets the seed input component
  59849. */
  59850. readonly seed: NodeMaterialConnectionPoint;
  59851. /**
  59852. * Gets the jitter input component
  59853. */
  59854. readonly jitter: NodeMaterialConnectionPoint;
  59855. /**
  59856. * Gets the output component
  59857. */
  59858. readonly output: NodeMaterialConnectionPoint;
  59859. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59860. /**
  59861. * Exposes the properties to the UI?
  59862. */
  59863. protected _dumpPropertiesCode(): string;
  59864. /**
  59865. * Exposes the properties to the Seralize?
  59866. */
  59867. serialize(): any;
  59868. /**
  59869. * Exposes the properties to the deseralize?
  59870. */
  59871. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59872. }
  59873. }
  59874. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59875. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59878. /**
  59879. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59880. */
  59881. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59882. /**
  59883. * Creates a new SimplexPerlin3DBlock
  59884. * @param name defines the block name
  59885. */
  59886. constructor(name: string);
  59887. /**
  59888. * Gets the current class name
  59889. * @returns the class name
  59890. */
  59891. getClassName(): string;
  59892. /**
  59893. * Gets the seed operand input component
  59894. */
  59895. readonly seed: NodeMaterialConnectionPoint;
  59896. /**
  59897. * Gets the output component
  59898. */
  59899. readonly output: NodeMaterialConnectionPoint;
  59900. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59901. }
  59902. }
  59903. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59907. /**
  59908. * Block used to blend normals
  59909. */
  59910. export class NormalBlendBlock extends NodeMaterialBlock {
  59911. /**
  59912. * Creates a new NormalBlendBlock
  59913. * @param name defines the block name
  59914. */
  59915. constructor(name: string);
  59916. /**
  59917. * Gets the current class name
  59918. * @returns the class name
  59919. */
  59920. getClassName(): string;
  59921. /**
  59922. * Gets the first input component
  59923. */
  59924. readonly normalMap0: NodeMaterialConnectionPoint;
  59925. /**
  59926. * Gets the second input component
  59927. */
  59928. readonly normalMap1: NodeMaterialConnectionPoint;
  59929. /**
  59930. * Gets the output component
  59931. */
  59932. readonly output: NodeMaterialConnectionPoint;
  59933. protected _buildBlock(state: NodeMaterialBuildState): this;
  59934. }
  59935. }
  59936. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59940. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59941. /**
  59942. * Block used to rotate a 2d vector by a given angle
  59943. */
  59944. export class Rotate2dBlock extends NodeMaterialBlock {
  59945. /**
  59946. * Creates a new Rotate2dBlock
  59947. * @param name defines the block name
  59948. */
  59949. constructor(name: string);
  59950. /**
  59951. * Gets the current class name
  59952. * @returns the class name
  59953. */
  59954. getClassName(): string;
  59955. /**
  59956. * Gets the input vector
  59957. */
  59958. readonly input: NodeMaterialConnectionPoint;
  59959. /**
  59960. * Gets the input angle
  59961. */
  59962. readonly angle: NodeMaterialConnectionPoint;
  59963. /**
  59964. * Gets the output component
  59965. */
  59966. readonly output: NodeMaterialConnectionPoint;
  59967. autoConfigure(material: NodeMaterial): void;
  59968. protected _buildBlock(state: NodeMaterialBuildState): this;
  59969. }
  59970. }
  59971. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  59972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59975. /**
  59976. * Block used to get the reflected vector from a direction and a normal
  59977. */
  59978. export class ReflectBlock extends NodeMaterialBlock {
  59979. /**
  59980. * Creates a new ReflectBlock
  59981. * @param name defines the block name
  59982. */
  59983. constructor(name: string);
  59984. /**
  59985. * Gets the current class name
  59986. * @returns the class name
  59987. */
  59988. getClassName(): string;
  59989. /**
  59990. * Gets the incident component
  59991. */
  59992. readonly incident: NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the normal component
  59995. */
  59996. readonly normal: NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the output component
  59999. */
  60000. readonly output: NodeMaterialConnectionPoint;
  60001. protected _buildBlock(state: NodeMaterialBuildState): this;
  60002. }
  60003. }
  60004. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  60005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60008. /**
  60009. * Block used to get the refracted vector from a direction and a normal
  60010. */
  60011. export class RefractBlock extends NodeMaterialBlock {
  60012. /**
  60013. * Creates a new RefractBlock
  60014. * @param name defines the block name
  60015. */
  60016. constructor(name: string);
  60017. /**
  60018. * Gets the current class name
  60019. * @returns the class name
  60020. */
  60021. getClassName(): string;
  60022. /**
  60023. * Gets the incident component
  60024. */
  60025. readonly incident: NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the normal component
  60028. */
  60029. readonly normal: NodeMaterialConnectionPoint;
  60030. /**
  60031. * Gets the index of refraction component
  60032. */
  60033. readonly ior: NodeMaterialConnectionPoint;
  60034. /**
  60035. * Gets the output component
  60036. */
  60037. readonly output: NodeMaterialConnectionPoint;
  60038. protected _buildBlock(state: NodeMaterialBuildState): this;
  60039. }
  60040. }
  60041. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  60042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60045. /**
  60046. * Block used to desaturate a color
  60047. */
  60048. export class DesaturateBlock extends NodeMaterialBlock {
  60049. /**
  60050. * Creates a new DesaturateBlock
  60051. * @param name defines the block name
  60052. */
  60053. constructor(name: string);
  60054. /**
  60055. * Gets the current class name
  60056. * @returns the class name
  60057. */
  60058. getClassName(): string;
  60059. /**
  60060. * Gets the color operand input component
  60061. */
  60062. readonly color: NodeMaterialConnectionPoint;
  60063. /**
  60064. * Gets the level operand input component
  60065. */
  60066. readonly level: NodeMaterialConnectionPoint;
  60067. /**
  60068. * Gets the output component
  60069. */
  60070. readonly output: NodeMaterialConnectionPoint;
  60071. protected _buildBlock(state: NodeMaterialBuildState): this;
  60072. }
  60073. }
  60074. declare module "babylonjs/Materials/Node/Blocks/index" {
  60075. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  60076. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  60077. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  60078. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  60079. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  60080. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  60081. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  60082. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  60083. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  60084. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  60085. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  60086. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  60087. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  60088. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  60089. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  60090. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  60091. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  60092. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  60093. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  60094. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  60095. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  60096. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  60097. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  60098. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  60099. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  60100. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  60101. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  60102. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  60103. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  60104. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  60105. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  60106. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  60107. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  60108. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  60109. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  60110. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  60111. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  60112. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  60113. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  60114. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  60115. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  60116. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  60117. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  60118. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  60119. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  60120. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  60121. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  60122. }
  60123. declare module "babylonjs/Materials/Node/Optimizers/index" {
  60124. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60125. }
  60126. declare module "babylonjs/Materials/Node/index" {
  60127. export * from "babylonjs/Materials/Node/Enums/index";
  60128. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60129. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  60130. export * from "babylonjs/Materials/Node/nodeMaterial";
  60131. export * from "babylonjs/Materials/Node/Blocks/index";
  60132. export * from "babylonjs/Materials/Node/Optimizers/index";
  60133. }
  60134. declare module "babylonjs/Materials/effectRenderer" {
  60135. import { Nullable } from "babylonjs/types";
  60136. import { Texture } from "babylonjs/Materials/Textures/texture";
  60137. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60138. import { Viewport } from "babylonjs/Maths/math.viewport";
  60139. import { Observable } from "babylonjs/Misc/observable";
  60140. import { Effect } from "babylonjs/Materials/effect";
  60141. import "babylonjs/Engines/Extensions/engine.renderTarget";
  60142. import "babylonjs/Shaders/postprocess.vertex";
  60143. /**
  60144. * Effect Render Options
  60145. */
  60146. export interface IEffectRendererOptions {
  60147. /**
  60148. * Defines the vertices positions.
  60149. */
  60150. positions?: number[];
  60151. /**
  60152. * Defines the indices.
  60153. */
  60154. indices?: number[];
  60155. }
  60156. /**
  60157. * Helper class to render one or more effects
  60158. */
  60159. export class EffectRenderer {
  60160. private engine;
  60161. private static _DefaultOptions;
  60162. private _vertexBuffers;
  60163. private _indexBuffer;
  60164. private _ringBufferIndex;
  60165. private _ringScreenBuffer;
  60166. private _fullscreenViewport;
  60167. private _getNextFrameBuffer;
  60168. /**
  60169. * Creates an effect renderer
  60170. * @param engine the engine to use for rendering
  60171. * @param options defines the options of the effect renderer
  60172. */
  60173. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60174. /**
  60175. * Sets the current viewport in normalized coordinates 0-1
  60176. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60177. */
  60178. setViewport(viewport?: Viewport): void;
  60179. /**
  60180. * Binds the embedded attributes buffer to the effect.
  60181. * @param effect Defines the effect to bind the attributes for
  60182. */
  60183. bindBuffers(effect: Effect): void;
  60184. /**
  60185. * Sets the current effect wrapper to use during draw.
  60186. * The effect needs to be ready before calling this api.
  60187. * This also sets the default full screen position attribute.
  60188. * @param effectWrapper Defines the effect to draw with
  60189. */
  60190. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60191. /**
  60192. * Draws a full screen quad.
  60193. */
  60194. draw(): void;
  60195. /**
  60196. * renders one or more effects to a specified texture
  60197. * @param effectWrappers list of effects to renderer
  60198. * @param outputTexture texture to draw to, if null it will render to the screen
  60199. */
  60200. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60201. /**
  60202. * Disposes of the effect renderer
  60203. */
  60204. dispose(): void;
  60205. }
  60206. /**
  60207. * Options to create an EffectWrapper
  60208. */
  60209. interface EffectWrapperCreationOptions {
  60210. /**
  60211. * Engine to use to create the effect
  60212. */
  60213. engine: ThinEngine;
  60214. /**
  60215. * Fragment shader for the effect
  60216. */
  60217. fragmentShader: string;
  60218. /**
  60219. * Vertex shader for the effect
  60220. */
  60221. vertexShader?: string;
  60222. /**
  60223. * Attributes to use in the shader
  60224. */
  60225. attributeNames?: Array<string>;
  60226. /**
  60227. * Uniforms to use in the shader
  60228. */
  60229. uniformNames?: Array<string>;
  60230. /**
  60231. * Texture sampler names to use in the shader
  60232. */
  60233. samplerNames?: Array<string>;
  60234. /**
  60235. * The friendly name of the effect displayed in Spector.
  60236. */
  60237. name?: string;
  60238. }
  60239. /**
  60240. * Wraps an effect to be used for rendering
  60241. */
  60242. export class EffectWrapper {
  60243. /**
  60244. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60245. */
  60246. onApplyObservable: Observable<{}>;
  60247. /**
  60248. * The underlying effect
  60249. */
  60250. effect: Effect;
  60251. /**
  60252. * Creates an effect to be renderer
  60253. * @param creationOptions options to create the effect
  60254. */
  60255. constructor(creationOptions: EffectWrapperCreationOptions);
  60256. /**
  60257. * Disposes of the effect wrapper
  60258. */
  60259. dispose(): void;
  60260. }
  60261. }
  60262. declare module "babylonjs/Materials/index" {
  60263. export * from "babylonjs/Materials/Background/index";
  60264. export * from "babylonjs/Materials/colorCurves";
  60265. export * from "babylonjs/Materials/iEffectFallbacks";
  60266. export * from "babylonjs/Materials/effectFallbacks";
  60267. export * from "babylonjs/Materials/effect";
  60268. export * from "babylonjs/Materials/fresnelParameters";
  60269. export * from "babylonjs/Materials/imageProcessingConfiguration";
  60270. export * from "babylonjs/Materials/material";
  60271. export * from "babylonjs/Materials/materialDefines";
  60272. export * from "babylonjs/Materials/materialHelper";
  60273. export * from "babylonjs/Materials/multiMaterial";
  60274. export * from "babylonjs/Materials/PBR/index";
  60275. export * from "babylonjs/Materials/pushMaterial";
  60276. export * from "babylonjs/Materials/shaderMaterial";
  60277. export * from "babylonjs/Materials/standardMaterial";
  60278. export * from "babylonjs/Materials/Textures/index";
  60279. export * from "babylonjs/Materials/uniformBuffer";
  60280. export * from "babylonjs/Materials/materialFlags";
  60281. export * from "babylonjs/Materials/Node/index";
  60282. export * from "babylonjs/Materials/effectRenderer";
  60283. }
  60284. declare module "babylonjs/Maths/index" {
  60285. export * from "babylonjs/Maths/math.scalar";
  60286. export * from "babylonjs/Maths/math";
  60287. export * from "babylonjs/Maths/sphericalPolynomial";
  60288. }
  60289. declare module "babylonjs/Misc/workerPool" {
  60290. import { IDisposable } from "babylonjs/scene";
  60291. /**
  60292. * Helper class to push actions to a pool of workers.
  60293. */
  60294. export class WorkerPool implements IDisposable {
  60295. private _workerInfos;
  60296. private _pendingActions;
  60297. /**
  60298. * Constructor
  60299. * @param workers Array of workers to use for actions
  60300. */
  60301. constructor(workers: Array<Worker>);
  60302. /**
  60303. * Terminates all workers and clears any pending actions.
  60304. */
  60305. dispose(): void;
  60306. /**
  60307. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60308. * pended until a worker has completed its action.
  60309. * @param action The action to perform. Call onComplete when the action is complete.
  60310. */
  60311. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60312. private _execute;
  60313. }
  60314. }
  60315. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  60316. import { IDisposable } from "babylonjs/scene";
  60317. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60318. /**
  60319. * Configuration for Draco compression
  60320. */
  60321. export interface IDracoCompressionConfiguration {
  60322. /**
  60323. * Configuration for the decoder.
  60324. */
  60325. decoder: {
  60326. /**
  60327. * The url to the WebAssembly module.
  60328. */
  60329. wasmUrl?: string;
  60330. /**
  60331. * The url to the WebAssembly binary.
  60332. */
  60333. wasmBinaryUrl?: string;
  60334. /**
  60335. * The url to the fallback JavaScript module.
  60336. */
  60337. fallbackUrl?: string;
  60338. };
  60339. }
  60340. /**
  60341. * Draco compression (https://google.github.io/draco/)
  60342. *
  60343. * This class wraps the Draco module.
  60344. *
  60345. * **Encoder**
  60346. *
  60347. * The encoder is not currently implemented.
  60348. *
  60349. * **Decoder**
  60350. *
  60351. * 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.
  60352. *
  60353. * To update the configuration, use the following code:
  60354. * ```javascript
  60355. * DracoCompression.Configuration = {
  60356. * decoder: {
  60357. * wasmUrl: "<url to the WebAssembly library>",
  60358. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60359. * fallbackUrl: "<url to the fallback JavaScript library>",
  60360. * }
  60361. * };
  60362. * ```
  60363. *
  60364. * 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.
  60365. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60366. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60367. *
  60368. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60369. * ```javascript
  60370. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60371. * ```
  60372. *
  60373. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60374. */
  60375. export class DracoCompression implements IDisposable {
  60376. private _workerPoolPromise?;
  60377. private _decoderModulePromise?;
  60378. /**
  60379. * The configuration. Defaults to the following urls:
  60380. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60381. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60382. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60383. */
  60384. static Configuration: IDracoCompressionConfiguration;
  60385. /**
  60386. * Returns true if the decoder configuration is available.
  60387. */
  60388. static readonly DecoderAvailable: boolean;
  60389. /**
  60390. * Default number of workers to create when creating the draco compression object.
  60391. */
  60392. static DefaultNumWorkers: number;
  60393. private static GetDefaultNumWorkers;
  60394. private static _Default;
  60395. /**
  60396. * Default instance for the draco compression object.
  60397. */
  60398. static readonly Default: DracoCompression;
  60399. /**
  60400. * Constructor
  60401. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60402. */
  60403. constructor(numWorkers?: number);
  60404. /**
  60405. * Stop all async operations and release resources.
  60406. */
  60407. dispose(): void;
  60408. /**
  60409. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60410. * @returns a promise that resolves when ready
  60411. */
  60412. whenReadyAsync(): Promise<void>;
  60413. /**
  60414. * Decode Draco compressed mesh data to vertex data.
  60415. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60416. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60417. * @returns A promise that resolves with the decoded vertex data
  60418. */
  60419. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60420. [kind: string]: number;
  60421. }): Promise<VertexData>;
  60422. }
  60423. }
  60424. declare module "babylonjs/Meshes/Compression/index" {
  60425. export * from "babylonjs/Meshes/Compression/dracoCompression";
  60426. }
  60427. declare module "babylonjs/Meshes/csg" {
  60428. import { Nullable } from "babylonjs/types";
  60429. import { Scene } from "babylonjs/scene";
  60430. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60431. import { Mesh } from "babylonjs/Meshes/mesh";
  60432. import { Material } from "babylonjs/Materials/material";
  60433. /**
  60434. * Class for building Constructive Solid Geometry
  60435. */
  60436. export class CSG {
  60437. private polygons;
  60438. /**
  60439. * The world matrix
  60440. */
  60441. matrix: Matrix;
  60442. /**
  60443. * Stores the position
  60444. */
  60445. position: Vector3;
  60446. /**
  60447. * Stores the rotation
  60448. */
  60449. rotation: Vector3;
  60450. /**
  60451. * Stores the rotation quaternion
  60452. */
  60453. rotationQuaternion: Nullable<Quaternion>;
  60454. /**
  60455. * Stores the scaling vector
  60456. */
  60457. scaling: Vector3;
  60458. /**
  60459. * Convert the Mesh to CSG
  60460. * @param mesh The Mesh to convert to CSG
  60461. * @returns A new CSG from the Mesh
  60462. */
  60463. static FromMesh(mesh: Mesh): CSG;
  60464. /**
  60465. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60466. * @param polygons Polygons used to construct a CSG solid
  60467. */
  60468. private static FromPolygons;
  60469. /**
  60470. * Clones, or makes a deep copy, of the CSG
  60471. * @returns A new CSG
  60472. */
  60473. clone(): CSG;
  60474. /**
  60475. * Unions this CSG with another CSG
  60476. * @param csg The CSG to union against this CSG
  60477. * @returns The unioned CSG
  60478. */
  60479. union(csg: CSG): CSG;
  60480. /**
  60481. * Unions this CSG with another CSG in place
  60482. * @param csg The CSG to union against this CSG
  60483. */
  60484. unionInPlace(csg: CSG): void;
  60485. /**
  60486. * Subtracts this CSG with another CSG
  60487. * @param csg The CSG to subtract against this CSG
  60488. * @returns A new CSG
  60489. */
  60490. subtract(csg: CSG): CSG;
  60491. /**
  60492. * Subtracts this CSG with another CSG in place
  60493. * @param csg The CSG to subtact against this CSG
  60494. */
  60495. subtractInPlace(csg: CSG): void;
  60496. /**
  60497. * Intersect this CSG with another CSG
  60498. * @param csg The CSG to intersect against this CSG
  60499. * @returns A new CSG
  60500. */
  60501. intersect(csg: CSG): CSG;
  60502. /**
  60503. * Intersects this CSG with another CSG in place
  60504. * @param csg The CSG to intersect against this CSG
  60505. */
  60506. intersectInPlace(csg: CSG): void;
  60507. /**
  60508. * Return a new CSG solid with solid and empty space switched. This solid is
  60509. * not modified.
  60510. * @returns A new CSG solid with solid and empty space switched
  60511. */
  60512. inverse(): CSG;
  60513. /**
  60514. * Inverses the CSG in place
  60515. */
  60516. inverseInPlace(): void;
  60517. /**
  60518. * This is used to keep meshes transformations so they can be restored
  60519. * when we build back a Babylon Mesh
  60520. * NB : All CSG operations are performed in world coordinates
  60521. * @param csg The CSG to copy the transform attributes from
  60522. * @returns This CSG
  60523. */
  60524. copyTransformAttributes(csg: CSG): CSG;
  60525. /**
  60526. * Build Raw mesh from CSG
  60527. * Coordinates here are in world space
  60528. * @param name The name of the mesh geometry
  60529. * @param scene The Scene
  60530. * @param keepSubMeshes Specifies if the submeshes should be kept
  60531. * @returns A new Mesh
  60532. */
  60533. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60534. /**
  60535. * Build Mesh from CSG taking material and transforms into account
  60536. * @param name The name of the Mesh
  60537. * @param material The material of the Mesh
  60538. * @param scene The Scene
  60539. * @param keepSubMeshes Specifies if submeshes should be kept
  60540. * @returns The new Mesh
  60541. */
  60542. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60543. }
  60544. }
  60545. declare module "babylonjs/Meshes/trailMesh" {
  60546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60547. import { Mesh } from "babylonjs/Meshes/mesh";
  60548. import { Scene } from "babylonjs/scene";
  60549. /**
  60550. * Class used to create a trail following a mesh
  60551. */
  60552. export class TrailMesh extends Mesh {
  60553. private _generator;
  60554. private _autoStart;
  60555. private _running;
  60556. private _diameter;
  60557. private _length;
  60558. private _sectionPolygonPointsCount;
  60559. private _sectionVectors;
  60560. private _sectionNormalVectors;
  60561. private _beforeRenderObserver;
  60562. /**
  60563. * @constructor
  60564. * @param name The value used by scene.getMeshByName() to do a lookup.
  60565. * @param generator The mesh to generate a trail.
  60566. * @param scene The scene to add this mesh to.
  60567. * @param diameter Diameter of trailing mesh. Default is 1.
  60568. * @param length Length of trailing mesh. Default is 60.
  60569. * @param autoStart Automatically start trailing mesh. Default true.
  60570. */
  60571. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60572. /**
  60573. * "TrailMesh"
  60574. * @returns "TrailMesh"
  60575. */
  60576. getClassName(): string;
  60577. private _createMesh;
  60578. /**
  60579. * Start trailing mesh.
  60580. */
  60581. start(): void;
  60582. /**
  60583. * Stop trailing mesh.
  60584. */
  60585. stop(): void;
  60586. /**
  60587. * Update trailing mesh geometry.
  60588. */
  60589. update(): void;
  60590. /**
  60591. * Returns a new TrailMesh object.
  60592. * @param name is a string, the name given to the new mesh
  60593. * @param newGenerator use new generator object for cloned trail mesh
  60594. * @returns a new mesh
  60595. */
  60596. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60597. /**
  60598. * Serializes this trail mesh
  60599. * @param serializationObject object to write serialization to
  60600. */
  60601. serialize(serializationObject: any): void;
  60602. /**
  60603. * Parses a serialized trail mesh
  60604. * @param parsedMesh the serialized mesh
  60605. * @param scene the scene to create the trail mesh in
  60606. * @returns the created trail mesh
  60607. */
  60608. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60609. }
  60610. }
  60611. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  60612. import { Nullable } from "babylonjs/types";
  60613. import { Scene } from "babylonjs/scene";
  60614. import { Vector4 } from "babylonjs/Maths/math.vector";
  60615. import { Color4 } from "babylonjs/Maths/math.color";
  60616. import { Mesh } from "babylonjs/Meshes/mesh";
  60617. /**
  60618. * Class containing static functions to help procedurally build meshes
  60619. */
  60620. export class TiledBoxBuilder {
  60621. /**
  60622. * Creates a box mesh
  60623. * 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)
  60624. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60628. * @param name defines the name of the mesh
  60629. * @param options defines the options used to create the mesh
  60630. * @param scene defines the hosting scene
  60631. * @returns the box mesh
  60632. */
  60633. static CreateTiledBox(name: string, options: {
  60634. pattern?: number;
  60635. width?: number;
  60636. height?: number;
  60637. depth?: number;
  60638. tileSize?: number;
  60639. tileWidth?: number;
  60640. tileHeight?: number;
  60641. alignHorizontal?: number;
  60642. alignVertical?: number;
  60643. faceUV?: Vector4[];
  60644. faceColors?: Color4[];
  60645. sideOrientation?: number;
  60646. updatable?: boolean;
  60647. }, scene?: Nullable<Scene>): Mesh;
  60648. }
  60649. }
  60650. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  60651. import { Vector4 } from "babylonjs/Maths/math.vector";
  60652. import { Mesh } from "babylonjs/Meshes/mesh";
  60653. /**
  60654. * Class containing static functions to help procedurally build meshes
  60655. */
  60656. export class TorusKnotBuilder {
  60657. /**
  60658. * Creates a torus knot mesh
  60659. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60660. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60661. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60662. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60664. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60666. * @param name defines the name of the mesh
  60667. * @param options defines the options used to create the mesh
  60668. * @param scene defines the hosting scene
  60669. * @returns the torus knot mesh
  60670. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60671. */
  60672. static CreateTorusKnot(name: string, options: {
  60673. radius?: number;
  60674. tube?: number;
  60675. radialSegments?: number;
  60676. tubularSegments?: number;
  60677. p?: number;
  60678. q?: number;
  60679. updatable?: boolean;
  60680. sideOrientation?: number;
  60681. frontUVs?: Vector4;
  60682. backUVs?: Vector4;
  60683. }, scene: any): Mesh;
  60684. }
  60685. }
  60686. declare module "babylonjs/Meshes/polygonMesh" {
  60687. import { Scene } from "babylonjs/scene";
  60688. import { Vector2 } from "babylonjs/Maths/math.vector";
  60689. import { Mesh } from "babylonjs/Meshes/mesh";
  60690. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  60691. import { Path2 } from "babylonjs/Maths/math.path";
  60692. /**
  60693. * Polygon
  60694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60695. */
  60696. export class Polygon {
  60697. /**
  60698. * Creates a rectangle
  60699. * @param xmin bottom X coord
  60700. * @param ymin bottom Y coord
  60701. * @param xmax top X coord
  60702. * @param ymax top Y coord
  60703. * @returns points that make the resulting rectation
  60704. */
  60705. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60706. /**
  60707. * Creates a circle
  60708. * @param radius radius of circle
  60709. * @param cx scale in x
  60710. * @param cy scale in y
  60711. * @param numberOfSides number of sides that make up the circle
  60712. * @returns points that make the resulting circle
  60713. */
  60714. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60715. /**
  60716. * Creates a polygon from input string
  60717. * @param input Input polygon data
  60718. * @returns the parsed points
  60719. */
  60720. static Parse(input: string): Vector2[];
  60721. /**
  60722. * Starts building a polygon from x and y coordinates
  60723. * @param x x coordinate
  60724. * @param y y coordinate
  60725. * @returns the started path2
  60726. */
  60727. static StartingAt(x: number, y: number): Path2;
  60728. }
  60729. /**
  60730. * Builds a polygon
  60731. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60732. */
  60733. export class PolygonMeshBuilder {
  60734. private _points;
  60735. private _outlinepoints;
  60736. private _holes;
  60737. private _name;
  60738. private _scene;
  60739. private _epoints;
  60740. private _eholes;
  60741. private _addToepoint;
  60742. /**
  60743. * Babylon reference to the earcut plugin.
  60744. */
  60745. bjsEarcut: any;
  60746. /**
  60747. * Creates a PolygonMeshBuilder
  60748. * @param name name of the builder
  60749. * @param contours Path of the polygon
  60750. * @param scene scene to add to when creating the mesh
  60751. * @param earcutInjection can be used to inject your own earcut reference
  60752. */
  60753. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60754. /**
  60755. * Adds a whole within the polygon
  60756. * @param hole Array of points defining the hole
  60757. * @returns this
  60758. */
  60759. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60760. /**
  60761. * Creates the polygon
  60762. * @param updatable If the mesh should be updatable
  60763. * @param depth The depth of the mesh created
  60764. * @returns the created mesh
  60765. */
  60766. build(updatable?: boolean, depth?: number): Mesh;
  60767. /**
  60768. * Creates the polygon
  60769. * @param depth The depth of the mesh created
  60770. * @returns the created VertexData
  60771. */
  60772. buildVertexData(depth?: number): VertexData;
  60773. /**
  60774. * Adds a side to the polygon
  60775. * @param positions points that make the polygon
  60776. * @param normals normals of the polygon
  60777. * @param uvs uvs of the polygon
  60778. * @param indices indices of the polygon
  60779. * @param bounds bounds of the polygon
  60780. * @param points points of the polygon
  60781. * @param depth depth of the polygon
  60782. * @param flip flip of the polygon
  60783. */
  60784. private addSide;
  60785. }
  60786. }
  60787. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60788. import { Scene } from "babylonjs/scene";
  60789. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60790. import { Color4 } from "babylonjs/Maths/math.color";
  60791. import { Mesh } from "babylonjs/Meshes/mesh";
  60792. import { Nullable } from "babylonjs/types";
  60793. /**
  60794. * Class containing static functions to help procedurally build meshes
  60795. */
  60796. export class PolygonBuilder {
  60797. /**
  60798. * Creates a polygon mesh
  60799. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60800. * * 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
  60801. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60804. * * Remember you can only change the shape positions, not their number when updating a polygon
  60805. * @param name defines the name of the mesh
  60806. * @param options defines the options used to create the mesh
  60807. * @param scene defines the hosting scene
  60808. * @param earcutInjection can be used to inject your own earcut reference
  60809. * @returns the polygon mesh
  60810. */
  60811. static CreatePolygon(name: string, options: {
  60812. shape: Vector3[];
  60813. holes?: Vector3[][];
  60814. depth?: number;
  60815. faceUV?: Vector4[];
  60816. faceColors?: Color4[];
  60817. updatable?: boolean;
  60818. sideOrientation?: number;
  60819. frontUVs?: Vector4;
  60820. backUVs?: Vector4;
  60821. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60822. /**
  60823. * Creates an extruded polygon mesh, with depth in the Y direction.
  60824. * * 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)
  60825. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60826. * @param name defines the name of the mesh
  60827. * @param options defines the options used to create the mesh
  60828. * @param scene defines the hosting scene
  60829. * @param earcutInjection can be used to inject your own earcut reference
  60830. * @returns the polygon mesh
  60831. */
  60832. static ExtrudePolygon(name: string, options: {
  60833. shape: Vector3[];
  60834. holes?: Vector3[][];
  60835. depth?: number;
  60836. faceUV?: Vector4[];
  60837. faceColors?: Color4[];
  60838. updatable?: boolean;
  60839. sideOrientation?: number;
  60840. frontUVs?: Vector4;
  60841. backUVs?: Vector4;
  60842. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60843. }
  60844. }
  60845. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60846. import { Scene } from "babylonjs/scene";
  60847. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60848. import { Mesh } from "babylonjs/Meshes/mesh";
  60849. import { Nullable } from "babylonjs/types";
  60850. /**
  60851. * Class containing static functions to help procedurally build meshes
  60852. */
  60853. export class LatheBuilder {
  60854. /**
  60855. * Creates lathe mesh.
  60856. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60857. * * 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
  60858. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60859. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60860. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60861. * * 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
  60862. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60863. * * 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
  60864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60868. * @param name defines the name of the mesh
  60869. * @param options defines the options used to create the mesh
  60870. * @param scene defines the hosting scene
  60871. * @returns the lathe mesh
  60872. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60873. */
  60874. static CreateLathe(name: string, options: {
  60875. shape: Vector3[];
  60876. radius?: number;
  60877. tessellation?: number;
  60878. clip?: number;
  60879. arc?: number;
  60880. closed?: boolean;
  60881. updatable?: boolean;
  60882. sideOrientation?: number;
  60883. frontUVs?: Vector4;
  60884. backUVs?: Vector4;
  60885. cap?: number;
  60886. invertUV?: boolean;
  60887. }, scene?: Nullable<Scene>): Mesh;
  60888. }
  60889. }
  60890. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60891. import { Nullable } from "babylonjs/types";
  60892. import { Scene } from "babylonjs/scene";
  60893. import { Vector4 } from "babylonjs/Maths/math.vector";
  60894. import { Mesh } from "babylonjs/Meshes/mesh";
  60895. /**
  60896. * Class containing static functions to help procedurally build meshes
  60897. */
  60898. export class TiledPlaneBuilder {
  60899. /**
  60900. * Creates a tiled plane mesh
  60901. * * The parameter `pattern` will, depending on value, do nothing or
  60902. * * * flip (reflect about central vertical) alternate tiles across and up
  60903. * * * flip every tile on alternate rows
  60904. * * * rotate (180 degs) alternate tiles across and up
  60905. * * * rotate every tile on alternate rows
  60906. * * * flip and rotate alternate tiles across and up
  60907. * * * flip and rotate every tile on alternate rows
  60908. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60909. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60911. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60912. * * 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)
  60913. * * 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)
  60914. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60915. * @param name defines the name of the mesh
  60916. * @param options defines the options used to create the mesh
  60917. * @param scene defines the hosting scene
  60918. * @returns the box mesh
  60919. */
  60920. static CreateTiledPlane(name: string, options: {
  60921. pattern?: number;
  60922. tileSize?: number;
  60923. tileWidth?: number;
  60924. tileHeight?: number;
  60925. size?: number;
  60926. width?: number;
  60927. height?: number;
  60928. alignHorizontal?: number;
  60929. alignVertical?: number;
  60930. sideOrientation?: number;
  60931. frontUVs?: Vector4;
  60932. backUVs?: Vector4;
  60933. updatable?: boolean;
  60934. }, scene?: Nullable<Scene>): Mesh;
  60935. }
  60936. }
  60937. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  60938. import { Nullable } from "babylonjs/types";
  60939. import { Scene } from "babylonjs/scene";
  60940. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60941. import { Mesh } from "babylonjs/Meshes/mesh";
  60942. /**
  60943. * Class containing static functions to help procedurally build meshes
  60944. */
  60945. export class TubeBuilder {
  60946. /**
  60947. * Creates a tube mesh.
  60948. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60949. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60950. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60951. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60952. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60953. * * 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)
  60954. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60955. * * 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
  60956. * * 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
  60957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60961. * @param name defines the name of the mesh
  60962. * @param options defines the options used to create the mesh
  60963. * @param scene defines the hosting scene
  60964. * @returns the tube mesh
  60965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60966. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60967. */
  60968. static CreateTube(name: string, options: {
  60969. path: Vector3[];
  60970. radius?: number;
  60971. tessellation?: number;
  60972. radiusFunction?: {
  60973. (i: number, distance: number): number;
  60974. };
  60975. cap?: number;
  60976. arc?: number;
  60977. updatable?: boolean;
  60978. sideOrientation?: number;
  60979. frontUVs?: Vector4;
  60980. backUVs?: Vector4;
  60981. instance?: Mesh;
  60982. invertUV?: boolean;
  60983. }, scene?: Nullable<Scene>): Mesh;
  60984. }
  60985. }
  60986. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60987. import { Scene } from "babylonjs/scene";
  60988. import { Vector4 } from "babylonjs/Maths/math.vector";
  60989. import { Mesh } from "babylonjs/Meshes/mesh";
  60990. import { Nullable } from "babylonjs/types";
  60991. /**
  60992. * Class containing static functions to help procedurally build meshes
  60993. */
  60994. export class IcoSphereBuilder {
  60995. /**
  60996. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60997. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60998. * * 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`)
  60999. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61000. * * 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
  61001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61004. * @param name defines the name of the mesh
  61005. * @param options defines the options used to create the mesh
  61006. * @param scene defines the hosting scene
  61007. * @returns the icosahedron mesh
  61008. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61009. */
  61010. static CreateIcoSphere(name: string, options: {
  61011. radius?: number;
  61012. radiusX?: number;
  61013. radiusY?: number;
  61014. radiusZ?: number;
  61015. flat?: boolean;
  61016. subdivisions?: number;
  61017. sideOrientation?: number;
  61018. frontUVs?: Vector4;
  61019. backUVs?: Vector4;
  61020. updatable?: boolean;
  61021. }, scene?: Nullable<Scene>): Mesh;
  61022. }
  61023. }
  61024. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  61025. import { Vector3 } from "babylonjs/Maths/math.vector";
  61026. import { Mesh } from "babylonjs/Meshes/mesh";
  61027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61028. /**
  61029. * Class containing static functions to help procedurally build meshes
  61030. */
  61031. export class DecalBuilder {
  61032. /**
  61033. * Creates a decal mesh.
  61034. * 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
  61035. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61036. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61037. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61038. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61039. * @param name defines the name of the mesh
  61040. * @param sourceMesh defines the mesh where the decal must be applied
  61041. * @param options defines the options used to create the mesh
  61042. * @param scene defines the hosting scene
  61043. * @returns the decal mesh
  61044. * @see https://doc.babylonjs.com/how_to/decals
  61045. */
  61046. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61047. position?: Vector3;
  61048. normal?: Vector3;
  61049. size?: Vector3;
  61050. angle?: number;
  61051. }): Mesh;
  61052. }
  61053. }
  61054. declare module "babylonjs/Meshes/meshBuilder" {
  61055. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  61056. import { Nullable } from "babylonjs/types";
  61057. import { Scene } from "babylonjs/scene";
  61058. import { Mesh } from "babylonjs/Meshes/mesh";
  61059. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  61060. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  61061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61062. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61063. import { Plane } from "babylonjs/Maths/math.plane";
  61064. /**
  61065. * Class containing static functions to help procedurally build meshes
  61066. */
  61067. export class MeshBuilder {
  61068. /**
  61069. * Creates a box mesh
  61070. * * The parameter `size` sets the size (float) of each box side (default 1)
  61071. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61072. * * 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)
  61073. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61077. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61078. * @param name defines the name of the mesh
  61079. * @param options defines the options used to create the mesh
  61080. * @param scene defines the hosting scene
  61081. * @returns the box mesh
  61082. */
  61083. static CreateBox(name: string, options: {
  61084. size?: number;
  61085. width?: number;
  61086. height?: number;
  61087. depth?: number;
  61088. faceUV?: Vector4[];
  61089. faceColors?: Color4[];
  61090. sideOrientation?: number;
  61091. frontUVs?: Vector4;
  61092. backUVs?: Vector4;
  61093. updatable?: boolean;
  61094. }, scene?: Nullable<Scene>): Mesh;
  61095. /**
  61096. * Creates a tiled box mesh
  61097. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61099. * @param name defines the name of the mesh
  61100. * @param options defines the options used to create the mesh
  61101. * @param scene defines the hosting scene
  61102. * @returns the tiled box mesh
  61103. */
  61104. static CreateTiledBox(name: string, options: {
  61105. pattern?: number;
  61106. size?: number;
  61107. width?: number;
  61108. height?: number;
  61109. depth: number;
  61110. tileSize?: number;
  61111. tileWidth?: number;
  61112. tileHeight?: number;
  61113. faceUV?: Vector4[];
  61114. faceColors?: Color4[];
  61115. alignHorizontal?: number;
  61116. alignVertical?: number;
  61117. sideOrientation?: number;
  61118. updatable?: boolean;
  61119. }, scene?: Nullable<Scene>): Mesh;
  61120. /**
  61121. * Creates a sphere mesh
  61122. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61123. * * 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`)
  61124. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61125. * * 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
  61126. * * 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)
  61127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61130. * @param name defines the name of the mesh
  61131. * @param options defines the options used to create the mesh
  61132. * @param scene defines the hosting scene
  61133. * @returns the sphere mesh
  61134. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61135. */
  61136. static CreateSphere(name: string, options: {
  61137. segments?: number;
  61138. diameter?: number;
  61139. diameterX?: number;
  61140. diameterY?: number;
  61141. diameterZ?: number;
  61142. arc?: number;
  61143. slice?: number;
  61144. sideOrientation?: number;
  61145. frontUVs?: Vector4;
  61146. backUVs?: Vector4;
  61147. updatable?: boolean;
  61148. }, scene?: Nullable<Scene>): Mesh;
  61149. /**
  61150. * Creates a plane polygonal mesh. By default, this is a disc
  61151. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61152. * * 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
  61153. * * 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
  61154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61157. * @param name defines the name of the mesh
  61158. * @param options defines the options used to create the mesh
  61159. * @param scene defines the hosting scene
  61160. * @returns the plane polygonal mesh
  61161. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61162. */
  61163. static CreateDisc(name: string, options: {
  61164. radius?: number;
  61165. tessellation?: number;
  61166. arc?: number;
  61167. updatable?: boolean;
  61168. sideOrientation?: number;
  61169. frontUVs?: Vector4;
  61170. backUVs?: Vector4;
  61171. }, scene?: Nullable<Scene>): Mesh;
  61172. /**
  61173. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61174. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61175. * * 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`)
  61176. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61177. * * 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
  61178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61181. * @param name defines the name of the mesh
  61182. * @param options defines the options used to create the mesh
  61183. * @param scene defines the hosting scene
  61184. * @returns the icosahedron mesh
  61185. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61186. */
  61187. static CreateIcoSphere(name: string, options: {
  61188. radius?: number;
  61189. radiusX?: number;
  61190. radiusY?: number;
  61191. radiusZ?: number;
  61192. flat?: boolean;
  61193. subdivisions?: number;
  61194. sideOrientation?: number;
  61195. frontUVs?: Vector4;
  61196. backUVs?: Vector4;
  61197. updatable?: boolean;
  61198. }, scene?: Nullable<Scene>): Mesh;
  61199. /**
  61200. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61201. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61202. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61203. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61204. * * 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
  61205. * * 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
  61206. * * 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
  61207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61209. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61210. * * 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
  61211. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61212. * * 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
  61213. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61215. * @param name defines the name of the mesh
  61216. * @param options defines the options used to create the mesh
  61217. * @param scene defines the hosting scene
  61218. * @returns the ribbon mesh
  61219. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61220. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61221. */
  61222. static CreateRibbon(name: string, options: {
  61223. pathArray: Vector3[][];
  61224. closeArray?: boolean;
  61225. closePath?: boolean;
  61226. offset?: number;
  61227. updatable?: boolean;
  61228. sideOrientation?: number;
  61229. frontUVs?: Vector4;
  61230. backUVs?: Vector4;
  61231. instance?: Mesh;
  61232. invertUV?: boolean;
  61233. uvs?: Vector2[];
  61234. colors?: Color4[];
  61235. }, scene?: Nullable<Scene>): Mesh;
  61236. /**
  61237. * Creates a cylinder or a cone mesh
  61238. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61239. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61240. * * 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.
  61241. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61242. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61243. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61244. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61245. * * 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).
  61246. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61247. * * 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).
  61248. * * 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
  61249. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61250. * * 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
  61251. * * 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.
  61252. * * If `enclose` is false, a ring surface is one element.
  61253. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61254. * * 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
  61255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61258. * @param name defines the name of the mesh
  61259. * @param options defines the options used to create the mesh
  61260. * @param scene defines the hosting scene
  61261. * @returns the cylinder mesh
  61262. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61263. */
  61264. static CreateCylinder(name: string, options: {
  61265. height?: number;
  61266. diameterTop?: number;
  61267. diameterBottom?: number;
  61268. diameter?: number;
  61269. tessellation?: number;
  61270. subdivisions?: number;
  61271. arc?: number;
  61272. faceColors?: Color4[];
  61273. faceUV?: Vector4[];
  61274. updatable?: boolean;
  61275. hasRings?: boolean;
  61276. enclose?: boolean;
  61277. cap?: number;
  61278. sideOrientation?: number;
  61279. frontUVs?: Vector4;
  61280. backUVs?: Vector4;
  61281. }, scene?: Nullable<Scene>): Mesh;
  61282. /**
  61283. * Creates a torus mesh
  61284. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61285. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61286. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61290. * @param name defines the name of the mesh
  61291. * @param options defines the options used to create the mesh
  61292. * @param scene defines the hosting scene
  61293. * @returns the torus mesh
  61294. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61295. */
  61296. static CreateTorus(name: string, options: {
  61297. diameter?: number;
  61298. thickness?: number;
  61299. tessellation?: number;
  61300. updatable?: boolean;
  61301. sideOrientation?: number;
  61302. frontUVs?: Vector4;
  61303. backUVs?: Vector4;
  61304. }, scene?: Nullable<Scene>): Mesh;
  61305. /**
  61306. * Creates a torus knot mesh
  61307. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61308. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61309. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61310. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61314. * @param name defines the name of the mesh
  61315. * @param options defines the options used to create the mesh
  61316. * @param scene defines the hosting scene
  61317. * @returns the torus knot mesh
  61318. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61319. */
  61320. static CreateTorusKnot(name: string, options: {
  61321. radius?: number;
  61322. tube?: number;
  61323. radialSegments?: number;
  61324. tubularSegments?: number;
  61325. p?: number;
  61326. q?: number;
  61327. updatable?: boolean;
  61328. sideOrientation?: number;
  61329. frontUVs?: Vector4;
  61330. backUVs?: Vector4;
  61331. }, scene?: Nullable<Scene>): Mesh;
  61332. /**
  61333. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61334. * * 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
  61335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61336. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61337. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61338. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61339. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61340. * * 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
  61341. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61344. * @param name defines the name of the new line system
  61345. * @param options defines the options used to create the line system
  61346. * @param scene defines the hosting scene
  61347. * @returns a new line system mesh
  61348. */
  61349. static CreateLineSystem(name: string, options: {
  61350. lines: Vector3[][];
  61351. updatable?: boolean;
  61352. instance?: Nullable<LinesMesh>;
  61353. colors?: Nullable<Color4[][]>;
  61354. useVertexAlpha?: boolean;
  61355. }, scene: Nullable<Scene>): LinesMesh;
  61356. /**
  61357. * Creates a line mesh
  61358. * 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
  61359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61360. * * The parameter `points` is an array successive Vector3
  61361. * * 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
  61362. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61363. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61364. * * When updating an instance, remember that only point positions can change, not the number of points
  61365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61366. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61367. * @param name defines the name of the new line system
  61368. * @param options defines the options used to create the line system
  61369. * @param scene defines the hosting scene
  61370. * @returns a new line mesh
  61371. */
  61372. static CreateLines(name: string, options: {
  61373. points: Vector3[];
  61374. updatable?: boolean;
  61375. instance?: Nullable<LinesMesh>;
  61376. colors?: Color4[];
  61377. useVertexAlpha?: boolean;
  61378. }, scene?: Nullable<Scene>): LinesMesh;
  61379. /**
  61380. * Creates a dashed line mesh
  61381. * * 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
  61382. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61383. * * The parameter `points` is an array successive Vector3
  61384. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61385. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61386. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61387. * * 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
  61388. * * When updating an instance, remember that only point positions can change, not the number of points
  61389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61390. * @param name defines the name of the mesh
  61391. * @param options defines the options used to create the mesh
  61392. * @param scene defines the hosting scene
  61393. * @returns the dashed line mesh
  61394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61395. */
  61396. static CreateDashedLines(name: string, options: {
  61397. points: Vector3[];
  61398. dashSize?: number;
  61399. gapSize?: number;
  61400. dashNb?: number;
  61401. updatable?: boolean;
  61402. instance?: LinesMesh;
  61403. }, scene?: Nullable<Scene>): LinesMesh;
  61404. /**
  61405. * 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.
  61406. * * 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.
  61407. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61408. * * 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.
  61409. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61410. * * 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
  61411. * * 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
  61412. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61415. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61417. * @param name defines the name of the mesh
  61418. * @param options defines the options used to create the mesh
  61419. * @param scene defines the hosting scene
  61420. * @returns the extruded shape mesh
  61421. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61423. */
  61424. static ExtrudeShape(name: string, options: {
  61425. shape: Vector3[];
  61426. path: Vector3[];
  61427. scale?: number;
  61428. rotation?: number;
  61429. cap?: number;
  61430. updatable?: boolean;
  61431. sideOrientation?: number;
  61432. frontUVs?: Vector4;
  61433. backUVs?: Vector4;
  61434. instance?: Mesh;
  61435. invertUV?: boolean;
  61436. }, scene?: Nullable<Scene>): Mesh;
  61437. /**
  61438. * Creates an custom extruded shape mesh.
  61439. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61440. * * 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.
  61441. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61442. * * 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
  61443. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61444. * * 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
  61445. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61446. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61447. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61448. * * 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
  61449. * * 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
  61450. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61451. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61452. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61453. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61455. * @param name defines the name of the mesh
  61456. * @param options defines the options used to create the mesh
  61457. * @param scene defines the hosting scene
  61458. * @returns the custom extruded shape mesh
  61459. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61460. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61462. */
  61463. static ExtrudeShapeCustom(name: string, options: {
  61464. shape: Vector3[];
  61465. path: Vector3[];
  61466. scaleFunction?: any;
  61467. rotationFunction?: any;
  61468. ribbonCloseArray?: boolean;
  61469. ribbonClosePath?: boolean;
  61470. cap?: number;
  61471. updatable?: boolean;
  61472. sideOrientation?: number;
  61473. frontUVs?: Vector4;
  61474. backUVs?: Vector4;
  61475. instance?: Mesh;
  61476. invertUV?: boolean;
  61477. }, scene?: Nullable<Scene>): Mesh;
  61478. /**
  61479. * Creates lathe mesh.
  61480. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61481. * * 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
  61482. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61483. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61484. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61485. * * 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
  61486. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61487. * * 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
  61488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61492. * @param name defines the name of the mesh
  61493. * @param options defines the options used to create the mesh
  61494. * @param scene defines the hosting scene
  61495. * @returns the lathe mesh
  61496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61497. */
  61498. static CreateLathe(name: string, options: {
  61499. shape: Vector3[];
  61500. radius?: number;
  61501. tessellation?: number;
  61502. clip?: number;
  61503. arc?: number;
  61504. closed?: boolean;
  61505. updatable?: boolean;
  61506. sideOrientation?: number;
  61507. frontUVs?: Vector4;
  61508. backUVs?: Vector4;
  61509. cap?: number;
  61510. invertUV?: boolean;
  61511. }, scene?: Nullable<Scene>): Mesh;
  61512. /**
  61513. * Creates a tiled plane mesh
  61514. * * You can set a limited pattern arrangement with the tiles
  61515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61518. * @param name defines the name of the mesh
  61519. * @param options defines the options used to create the mesh
  61520. * @param scene defines the hosting scene
  61521. * @returns the plane mesh
  61522. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61523. */
  61524. static CreateTiledPlane(name: string, options: {
  61525. pattern?: number;
  61526. tileSize?: number;
  61527. tileWidth?: number;
  61528. tileHeight?: number;
  61529. size?: number;
  61530. width?: number;
  61531. height?: number;
  61532. alignHorizontal?: number;
  61533. alignVertical?: number;
  61534. sideOrientation?: number;
  61535. frontUVs?: Vector4;
  61536. backUVs?: Vector4;
  61537. updatable?: boolean;
  61538. }, scene?: Nullable<Scene>): Mesh;
  61539. /**
  61540. * Creates a plane mesh
  61541. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61542. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61543. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61547. * @param name defines the name of the mesh
  61548. * @param options defines the options used to create the mesh
  61549. * @param scene defines the hosting scene
  61550. * @returns the plane mesh
  61551. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61552. */
  61553. static CreatePlane(name: string, options: {
  61554. size?: number;
  61555. width?: number;
  61556. height?: number;
  61557. sideOrientation?: number;
  61558. frontUVs?: Vector4;
  61559. backUVs?: Vector4;
  61560. updatable?: boolean;
  61561. sourcePlane?: Plane;
  61562. }, scene?: Nullable<Scene>): Mesh;
  61563. /**
  61564. * Creates a ground mesh
  61565. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61566. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61568. * @param name defines the name of the mesh
  61569. * @param options defines the options used to create the mesh
  61570. * @param scene defines the hosting scene
  61571. * @returns the ground mesh
  61572. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61573. */
  61574. static CreateGround(name: string, options: {
  61575. width?: number;
  61576. height?: number;
  61577. subdivisions?: number;
  61578. subdivisionsX?: number;
  61579. subdivisionsY?: number;
  61580. updatable?: boolean;
  61581. }, scene?: Nullable<Scene>): Mesh;
  61582. /**
  61583. * Creates a tiled ground mesh
  61584. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61585. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61586. * * 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
  61587. * * 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
  61588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61589. * @param name defines the name of the mesh
  61590. * @param options defines the options used to create the mesh
  61591. * @param scene defines the hosting scene
  61592. * @returns the tiled ground mesh
  61593. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61594. */
  61595. static CreateTiledGround(name: string, options: {
  61596. xmin: number;
  61597. zmin: number;
  61598. xmax: number;
  61599. zmax: number;
  61600. subdivisions?: {
  61601. w: number;
  61602. h: number;
  61603. };
  61604. precision?: {
  61605. w: number;
  61606. h: number;
  61607. };
  61608. updatable?: boolean;
  61609. }, scene?: Nullable<Scene>): Mesh;
  61610. /**
  61611. * Creates a ground mesh from a height map
  61612. * * The parameter `url` sets the URL of the height map image resource.
  61613. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61614. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61615. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61616. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61617. * * 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.
  61618. * * 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).
  61619. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61621. * @param name defines the name of the mesh
  61622. * @param url defines the url to the height map
  61623. * @param options defines the options used to create the mesh
  61624. * @param scene defines the hosting scene
  61625. * @returns the ground mesh
  61626. * @see https://doc.babylonjs.com/babylon101/height_map
  61627. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61628. */
  61629. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61630. width?: number;
  61631. height?: number;
  61632. subdivisions?: number;
  61633. minHeight?: number;
  61634. maxHeight?: number;
  61635. colorFilter?: Color3;
  61636. alphaFilter?: number;
  61637. updatable?: boolean;
  61638. onReady?: (mesh: GroundMesh) => void;
  61639. }, scene?: Nullable<Scene>): GroundMesh;
  61640. /**
  61641. * Creates a polygon mesh
  61642. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61643. * * 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
  61644. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  61647. * * Remember you can only change the shape positions, not their number when updating a polygon
  61648. * @param name defines the name of the mesh
  61649. * @param options defines the options used to create the mesh
  61650. * @param scene defines the hosting scene
  61651. * @param earcutInjection can be used to inject your own earcut reference
  61652. * @returns the polygon mesh
  61653. */
  61654. static CreatePolygon(name: string, options: {
  61655. shape: Vector3[];
  61656. holes?: Vector3[][];
  61657. depth?: number;
  61658. faceUV?: Vector4[];
  61659. faceColors?: Color4[];
  61660. updatable?: boolean;
  61661. sideOrientation?: number;
  61662. frontUVs?: Vector4;
  61663. backUVs?: Vector4;
  61664. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61665. /**
  61666. * Creates an extruded polygon mesh, with depth in the Y direction.
  61667. * * 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)
  61668. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61669. * @param name defines the name of the mesh
  61670. * @param options defines the options used to create the mesh
  61671. * @param scene defines the hosting scene
  61672. * @param earcutInjection can be used to inject your own earcut reference
  61673. * @returns the polygon mesh
  61674. */
  61675. static ExtrudePolygon(name: string, options: {
  61676. shape: Vector3[];
  61677. holes?: Vector3[][];
  61678. depth?: number;
  61679. faceUV?: Vector4[];
  61680. faceColors?: Color4[];
  61681. updatable?: boolean;
  61682. sideOrientation?: number;
  61683. frontUVs?: Vector4;
  61684. backUVs?: Vector4;
  61685. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61686. /**
  61687. * Creates a tube mesh.
  61688. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61689. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61690. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61691. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61692. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61693. * * 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)
  61694. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61695. * * 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
  61696. * * 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
  61697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61699. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61701. * @param name defines the name of the mesh
  61702. * @param options defines the options used to create the mesh
  61703. * @param scene defines the hosting scene
  61704. * @returns the tube mesh
  61705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61706. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61707. */
  61708. static CreateTube(name: string, options: {
  61709. path: Vector3[];
  61710. radius?: number;
  61711. tessellation?: number;
  61712. radiusFunction?: {
  61713. (i: number, distance: number): number;
  61714. };
  61715. cap?: number;
  61716. arc?: number;
  61717. updatable?: boolean;
  61718. sideOrientation?: number;
  61719. frontUVs?: Vector4;
  61720. backUVs?: Vector4;
  61721. instance?: Mesh;
  61722. invertUV?: boolean;
  61723. }, scene?: Nullable<Scene>): Mesh;
  61724. /**
  61725. * Creates a polyhedron mesh
  61726. * * 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
  61727. * * The parameter `size` (positive float, default 1) sets the polygon size
  61728. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61729. * * 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`
  61730. * * 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
  61731. * * 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)`)
  61732. * * 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
  61733. * * 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
  61734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61737. * @param name defines the name of the mesh
  61738. * @param options defines the options used to create the mesh
  61739. * @param scene defines the hosting scene
  61740. * @returns the polyhedron mesh
  61741. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61742. */
  61743. static CreatePolyhedron(name: string, options: {
  61744. type?: number;
  61745. size?: number;
  61746. sizeX?: number;
  61747. sizeY?: number;
  61748. sizeZ?: number;
  61749. custom?: any;
  61750. faceUV?: Vector4[];
  61751. faceColors?: Color4[];
  61752. flat?: boolean;
  61753. updatable?: boolean;
  61754. sideOrientation?: number;
  61755. frontUVs?: Vector4;
  61756. backUVs?: Vector4;
  61757. }, scene?: Nullable<Scene>): Mesh;
  61758. /**
  61759. * Creates a decal mesh.
  61760. * 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
  61761. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61762. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61763. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61764. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61765. * @param name defines the name of the mesh
  61766. * @param sourceMesh defines the mesh where the decal must be applied
  61767. * @param options defines the options used to create the mesh
  61768. * @param scene defines the hosting scene
  61769. * @returns the decal mesh
  61770. * @see https://doc.babylonjs.com/how_to/decals
  61771. */
  61772. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61773. position?: Vector3;
  61774. normal?: Vector3;
  61775. size?: Vector3;
  61776. angle?: number;
  61777. }): Mesh;
  61778. }
  61779. }
  61780. declare module "babylonjs/Meshes/meshSimplification" {
  61781. import { Mesh } from "babylonjs/Meshes/mesh";
  61782. /**
  61783. * A simplifier interface for future simplification implementations
  61784. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61785. */
  61786. export interface ISimplifier {
  61787. /**
  61788. * Simplification of a given mesh according to the given settings.
  61789. * Since this requires computation, it is assumed that the function runs async.
  61790. * @param settings The settings of the simplification, including quality and distance
  61791. * @param successCallback A callback that will be called after the mesh was simplified.
  61792. * @param errorCallback in case of an error, this callback will be called. optional.
  61793. */
  61794. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61795. }
  61796. /**
  61797. * Expected simplification settings.
  61798. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61799. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61800. */
  61801. export interface ISimplificationSettings {
  61802. /**
  61803. * Gets or sets the expected quality
  61804. */
  61805. quality: number;
  61806. /**
  61807. * Gets or sets the distance when this optimized version should be used
  61808. */
  61809. distance: number;
  61810. /**
  61811. * Gets an already optimized mesh
  61812. */
  61813. optimizeMesh?: boolean;
  61814. }
  61815. /**
  61816. * Class used to specify simplification options
  61817. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61818. */
  61819. export class SimplificationSettings implements ISimplificationSettings {
  61820. /** expected quality */
  61821. quality: number;
  61822. /** distance when this optimized version should be used */
  61823. distance: number;
  61824. /** already optimized mesh */
  61825. optimizeMesh?: boolean | undefined;
  61826. /**
  61827. * Creates a SimplificationSettings
  61828. * @param quality expected quality
  61829. * @param distance distance when this optimized version should be used
  61830. * @param optimizeMesh already optimized mesh
  61831. */
  61832. constructor(
  61833. /** expected quality */
  61834. quality: number,
  61835. /** distance when this optimized version should be used */
  61836. distance: number,
  61837. /** already optimized mesh */
  61838. optimizeMesh?: boolean | undefined);
  61839. }
  61840. /**
  61841. * Interface used to define a simplification task
  61842. */
  61843. export interface ISimplificationTask {
  61844. /**
  61845. * Array of settings
  61846. */
  61847. settings: Array<ISimplificationSettings>;
  61848. /**
  61849. * Simplification type
  61850. */
  61851. simplificationType: SimplificationType;
  61852. /**
  61853. * Mesh to simplify
  61854. */
  61855. mesh: Mesh;
  61856. /**
  61857. * Callback called on success
  61858. */
  61859. successCallback?: () => void;
  61860. /**
  61861. * Defines if parallel processing can be used
  61862. */
  61863. parallelProcessing: boolean;
  61864. }
  61865. /**
  61866. * Queue used to order the simplification tasks
  61867. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61868. */
  61869. export class SimplificationQueue {
  61870. private _simplificationArray;
  61871. /**
  61872. * Gets a boolean indicating that the process is still running
  61873. */
  61874. running: boolean;
  61875. /**
  61876. * Creates a new queue
  61877. */
  61878. constructor();
  61879. /**
  61880. * Adds a new simplification task
  61881. * @param task defines a task to add
  61882. */
  61883. addTask(task: ISimplificationTask): void;
  61884. /**
  61885. * Execute next task
  61886. */
  61887. executeNext(): void;
  61888. /**
  61889. * Execute a simplification task
  61890. * @param task defines the task to run
  61891. */
  61892. runSimplification(task: ISimplificationTask): void;
  61893. private getSimplifier;
  61894. }
  61895. /**
  61896. * The implemented types of simplification
  61897. * At the moment only Quadratic Error Decimation is implemented
  61898. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61899. */
  61900. export enum SimplificationType {
  61901. /** Quadratic error decimation */
  61902. QUADRATIC = 0
  61903. }
  61904. }
  61905. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61906. import { Scene } from "babylonjs/scene";
  61907. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61908. import { ISceneComponent } from "babylonjs/sceneComponent";
  61909. module "babylonjs/scene" {
  61910. interface Scene {
  61911. /** @hidden (Backing field) */
  61912. _simplificationQueue: SimplificationQueue;
  61913. /**
  61914. * Gets or sets the simplification queue attached to the scene
  61915. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61916. */
  61917. simplificationQueue: SimplificationQueue;
  61918. }
  61919. }
  61920. module "babylonjs/Meshes/mesh" {
  61921. interface Mesh {
  61922. /**
  61923. * Simplify the mesh according to the given array of settings.
  61924. * Function will return immediately and will simplify async
  61925. * @param settings a collection of simplification settings
  61926. * @param parallelProcessing should all levels calculate parallel or one after the other
  61927. * @param simplificationType the type of simplification to run
  61928. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61929. * @returns the current mesh
  61930. */
  61931. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61932. }
  61933. }
  61934. /**
  61935. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61936. * created in a scene
  61937. */
  61938. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61939. /**
  61940. * The component name helpfull to identify the component in the list of scene components.
  61941. */
  61942. readonly name: string;
  61943. /**
  61944. * The scene the component belongs to.
  61945. */
  61946. scene: Scene;
  61947. /**
  61948. * Creates a new instance of the component for the given scene
  61949. * @param scene Defines the scene to register the component in
  61950. */
  61951. constructor(scene: Scene);
  61952. /**
  61953. * Registers the component in a given scene
  61954. */
  61955. register(): void;
  61956. /**
  61957. * Rebuilds the elements related to this component in case of
  61958. * context lost for instance.
  61959. */
  61960. rebuild(): void;
  61961. /**
  61962. * Disposes the component and the associated ressources
  61963. */
  61964. dispose(): void;
  61965. private _beforeCameraUpdate;
  61966. }
  61967. }
  61968. declare module "babylonjs/Meshes/Builders/index" {
  61969. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61970. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61971. export * from "babylonjs/Meshes/Builders/discBuilder";
  61972. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61973. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61974. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61975. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61976. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61977. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61978. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61979. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61980. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61981. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61982. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61983. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61984. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61985. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61986. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61987. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61988. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61989. }
  61990. declare module "babylonjs/Meshes/index" {
  61991. export * from "babylonjs/Meshes/abstractMesh";
  61992. export * from "babylonjs/Meshes/buffer";
  61993. export * from "babylonjs/Meshes/Compression/index";
  61994. export * from "babylonjs/Meshes/csg";
  61995. export * from "babylonjs/Meshes/geometry";
  61996. export * from "babylonjs/Meshes/groundMesh";
  61997. export * from "babylonjs/Meshes/trailMesh";
  61998. export * from "babylonjs/Meshes/instancedMesh";
  61999. export * from "babylonjs/Meshes/linesMesh";
  62000. export * from "babylonjs/Meshes/mesh";
  62001. export * from "babylonjs/Meshes/mesh.vertexData";
  62002. export * from "babylonjs/Meshes/meshBuilder";
  62003. export * from "babylonjs/Meshes/meshSimplification";
  62004. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  62005. export * from "babylonjs/Meshes/polygonMesh";
  62006. export * from "babylonjs/Meshes/subMesh";
  62007. export * from "babylonjs/Meshes/meshLODLevel";
  62008. export * from "babylonjs/Meshes/transformNode";
  62009. export * from "babylonjs/Meshes/Builders/index";
  62010. export * from "babylonjs/Meshes/dataBuffer";
  62011. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  62012. }
  62013. declare module "babylonjs/Morph/index" {
  62014. export * from "babylonjs/Morph/morphTarget";
  62015. export * from "babylonjs/Morph/morphTargetManager";
  62016. }
  62017. declare module "babylonjs/Navigation/INavigationEngine" {
  62018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62019. import { Vector3 } from "babylonjs/Maths/math";
  62020. import { Mesh } from "babylonjs/Meshes/mesh";
  62021. import { Scene } from "babylonjs/scene";
  62022. /**
  62023. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62024. */
  62025. export interface INavigationEnginePlugin {
  62026. /**
  62027. * plugin name
  62028. */
  62029. name: string;
  62030. /**
  62031. * Creates a navigation mesh
  62032. * @param meshes array of all the geometry used to compute the navigatio mesh
  62033. * @param parameters bunch of parameters used to filter geometry
  62034. */
  62035. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62036. /**
  62037. * Create a navigation mesh debug mesh
  62038. * @param scene is where the mesh will be added
  62039. * @returns debug display mesh
  62040. */
  62041. createDebugNavMesh(scene: Scene): Mesh;
  62042. /**
  62043. * Get a navigation mesh constrained position, closest to the parameter position
  62044. * @param position world position
  62045. * @returns the closest point to position constrained by the navigation mesh
  62046. */
  62047. getClosestPoint(position: Vector3): Vector3;
  62048. /**
  62049. * Get a navigation mesh constrained position, within a particular radius
  62050. * @param position world position
  62051. * @param maxRadius the maximum distance to the constrained world position
  62052. * @returns the closest point to position constrained by the navigation mesh
  62053. */
  62054. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62055. /**
  62056. * Compute the final position from a segment made of destination-position
  62057. * @param position world position
  62058. * @param destination world position
  62059. * @returns the resulting point along the navmesh
  62060. */
  62061. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62062. /**
  62063. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62064. * @param start world position
  62065. * @param end world position
  62066. * @returns array containing world position composing the path
  62067. */
  62068. computePath(start: Vector3, end: Vector3): Vector3[];
  62069. /**
  62070. * If this plugin is supported
  62071. * @returns true if plugin is supported
  62072. */
  62073. isSupported(): boolean;
  62074. /**
  62075. * Create a new Crowd so you can add agents
  62076. * @param maxAgents the maximum agent count in the crowd
  62077. * @param maxAgentRadius the maximum radius an agent can have
  62078. * @param scene to attach the crowd to
  62079. * @returns the crowd you can add agents to
  62080. */
  62081. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62082. /**
  62083. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62084. * The queries will try to find a solution within those bounds
  62085. * default is (1,1,1)
  62086. * @param extent x,y,z value that define the extent around the queries point of reference
  62087. */
  62088. setDefaultQueryExtent(extent: Vector3): void;
  62089. /**
  62090. * Get the Bounding box extent specified by setDefaultQueryExtent
  62091. * @returns the box extent values
  62092. */
  62093. getDefaultQueryExtent(): Vector3;
  62094. /**
  62095. * Release all resources
  62096. */
  62097. dispose(): void;
  62098. }
  62099. /**
  62100. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62101. */
  62102. export interface ICrowd {
  62103. /**
  62104. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62105. * You can attach anything to that node. The node position is updated in the scene update tick.
  62106. * @param pos world position that will be constrained by the navigation mesh
  62107. * @param parameters agent parameters
  62108. * @param transform hooked to the agent that will be update by the scene
  62109. * @returns agent index
  62110. */
  62111. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62112. /**
  62113. * Returns the agent position in world space
  62114. * @param index agent index returned by addAgent
  62115. * @returns world space position
  62116. */
  62117. getAgentPosition(index: number): Vector3;
  62118. /**
  62119. * Gets the agent velocity in world space
  62120. * @param index agent index returned by addAgent
  62121. * @returns world space velocity
  62122. */
  62123. getAgentVelocity(index: number): Vector3;
  62124. /**
  62125. * remove a particular agent previously created
  62126. * @param index agent index returned by addAgent
  62127. */
  62128. removeAgent(index: number): void;
  62129. /**
  62130. * get the list of all agents attached to this crowd
  62131. * @returns list of agent indices
  62132. */
  62133. getAgents(): number[];
  62134. /**
  62135. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62136. * @param deltaTime in seconds
  62137. */
  62138. update(deltaTime: number): void;
  62139. /**
  62140. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62141. * @param index agent index returned by addAgent
  62142. * @param destination targeted world position
  62143. */
  62144. agentGoto(index: number, destination: Vector3): void;
  62145. /**
  62146. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62147. * The queries will try to find a solution within those bounds
  62148. * default is (1,1,1)
  62149. * @param extent x,y,z value that define the extent around the queries point of reference
  62150. */
  62151. setDefaultQueryExtent(extent: Vector3): void;
  62152. /**
  62153. * Get the Bounding box extent specified by setDefaultQueryExtent
  62154. * @returns the box extent values
  62155. */
  62156. getDefaultQueryExtent(): Vector3;
  62157. /**
  62158. * Release all resources
  62159. */
  62160. dispose(): void;
  62161. }
  62162. /**
  62163. * Configures an agent
  62164. */
  62165. export interface IAgentParameters {
  62166. /**
  62167. * Agent radius. [Limit: >= 0]
  62168. */
  62169. radius: number;
  62170. /**
  62171. * Agent height. [Limit: > 0]
  62172. */
  62173. height: number;
  62174. /**
  62175. * Maximum allowed acceleration. [Limit: >= 0]
  62176. */
  62177. maxAcceleration: number;
  62178. /**
  62179. * Maximum allowed speed. [Limit: >= 0]
  62180. */
  62181. maxSpeed: number;
  62182. /**
  62183. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62184. */
  62185. collisionQueryRange: number;
  62186. /**
  62187. * The path visibility optimization range. [Limit: > 0]
  62188. */
  62189. pathOptimizationRange: number;
  62190. /**
  62191. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62192. */
  62193. separationWeight: number;
  62194. }
  62195. /**
  62196. * Configures the navigation mesh creation
  62197. */
  62198. export interface INavMeshParameters {
  62199. /**
  62200. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62201. */
  62202. cs: number;
  62203. /**
  62204. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62205. */
  62206. ch: number;
  62207. /**
  62208. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62209. */
  62210. walkableSlopeAngle: number;
  62211. /**
  62212. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62213. * be considered walkable. [Limit: >= 3] [Units: vx]
  62214. */
  62215. walkableHeight: number;
  62216. /**
  62217. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62218. */
  62219. walkableClimb: number;
  62220. /**
  62221. * The distance to erode/shrink the walkable area of the heightfield away from
  62222. * obstructions. [Limit: >=0] [Units: vx]
  62223. */
  62224. walkableRadius: number;
  62225. /**
  62226. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62227. */
  62228. maxEdgeLen: number;
  62229. /**
  62230. * The maximum distance a simplfied contour's border edges should deviate
  62231. * the original raw contour. [Limit: >=0] [Units: vx]
  62232. */
  62233. maxSimplificationError: number;
  62234. /**
  62235. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62236. */
  62237. minRegionArea: number;
  62238. /**
  62239. * Any regions with a span count smaller than this value will, if possible,
  62240. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62241. */
  62242. mergeRegionArea: number;
  62243. /**
  62244. * The maximum number of vertices allowed for polygons generated during the
  62245. * contour to polygon conversion process. [Limit: >= 3]
  62246. */
  62247. maxVertsPerPoly: number;
  62248. /**
  62249. * Sets the sampling distance to use when generating the detail mesh.
  62250. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62251. */
  62252. detailSampleDist: number;
  62253. /**
  62254. * The maximum distance the detail mesh surface should deviate from heightfield
  62255. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62256. */
  62257. detailSampleMaxError: number;
  62258. }
  62259. }
  62260. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  62261. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  62262. import { Mesh } from "babylonjs/Meshes/mesh";
  62263. import { Scene } from "babylonjs/scene";
  62264. import { Vector3 } from "babylonjs/Maths/math";
  62265. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62266. /**
  62267. * RecastJS navigation plugin
  62268. */
  62269. export class RecastJSPlugin implements INavigationEnginePlugin {
  62270. /**
  62271. * Reference to the Recast library
  62272. */
  62273. bjsRECAST: any;
  62274. /**
  62275. * plugin name
  62276. */
  62277. name: string;
  62278. /**
  62279. * the first navmesh created. We might extend this to support multiple navmeshes
  62280. */
  62281. navMesh: any;
  62282. /**
  62283. * Initializes the recastJS plugin
  62284. * @param recastInjection can be used to inject your own recast reference
  62285. */
  62286. constructor(recastInjection?: any);
  62287. /**
  62288. * Creates a navigation mesh
  62289. * @param meshes array of all the geometry used to compute the navigatio mesh
  62290. * @param parameters bunch of parameters used to filter geometry
  62291. */
  62292. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62293. /**
  62294. * Create a navigation mesh debug mesh
  62295. * @param scene is where the mesh will be added
  62296. * @returns debug display mesh
  62297. */
  62298. createDebugNavMesh(scene: Scene): Mesh;
  62299. /**
  62300. * Get a navigation mesh constrained position, closest to the parameter position
  62301. * @param position world position
  62302. * @returns the closest point to position constrained by the navigation mesh
  62303. */
  62304. getClosestPoint(position: Vector3): Vector3;
  62305. /**
  62306. * Get a navigation mesh constrained position, within a particular radius
  62307. * @param position world position
  62308. * @param maxRadius the maximum distance to the constrained world position
  62309. * @returns the closest point to position constrained by the navigation mesh
  62310. */
  62311. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62312. /**
  62313. * Compute the final position from a segment made of destination-position
  62314. * @param position world position
  62315. * @param destination world position
  62316. * @returns the resulting point along the navmesh
  62317. */
  62318. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62319. /**
  62320. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62321. * @param start world position
  62322. * @param end world position
  62323. * @returns array containing world position composing the path
  62324. */
  62325. computePath(start: Vector3, end: Vector3): Vector3[];
  62326. /**
  62327. * Create a new Crowd so you can add agents
  62328. * @param maxAgents the maximum agent count in the crowd
  62329. * @param maxAgentRadius the maximum radius an agent can have
  62330. * @param scene to attach the crowd to
  62331. * @returns the crowd you can add agents to
  62332. */
  62333. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62334. /**
  62335. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62336. * The queries will try to find a solution within those bounds
  62337. * default is (1,1,1)
  62338. * @param extent x,y,z value that define the extent around the queries point of reference
  62339. */
  62340. setDefaultQueryExtent(extent: Vector3): void;
  62341. /**
  62342. * Get the Bounding box extent specified by setDefaultQueryExtent
  62343. * @returns the box extent values
  62344. */
  62345. getDefaultQueryExtent(): Vector3;
  62346. /**
  62347. * Disposes
  62348. */
  62349. dispose(): void;
  62350. /**
  62351. * If this plugin is supported
  62352. * @returns true if plugin is supported
  62353. */
  62354. isSupported(): boolean;
  62355. }
  62356. /**
  62357. * Recast detour crowd implementation
  62358. */
  62359. export class RecastJSCrowd implements ICrowd {
  62360. /**
  62361. * Recast/detour plugin
  62362. */
  62363. bjsRECASTPlugin: RecastJSPlugin;
  62364. /**
  62365. * Link to the detour crowd
  62366. */
  62367. recastCrowd: any;
  62368. /**
  62369. * One transform per agent
  62370. */
  62371. transforms: TransformNode[];
  62372. /**
  62373. * All agents created
  62374. */
  62375. agents: number[];
  62376. /**
  62377. * Link to the scene is kept to unregister the crowd from the scene
  62378. */
  62379. private _scene;
  62380. /**
  62381. * Observer for crowd updates
  62382. */
  62383. private _onBeforeAnimationsObserver;
  62384. /**
  62385. * Constructor
  62386. * @param plugin recastJS plugin
  62387. * @param maxAgents the maximum agent count in the crowd
  62388. * @param maxAgentRadius the maximum radius an agent can have
  62389. * @param scene to attach the crowd to
  62390. * @returns the crowd you can add agents to
  62391. */
  62392. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62393. /**
  62394. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62395. * You can attach anything to that node. The node position is updated in the scene update tick.
  62396. * @param pos world position that will be constrained by the navigation mesh
  62397. * @param parameters agent parameters
  62398. * @param transform hooked to the agent that will be update by the scene
  62399. * @returns agent index
  62400. */
  62401. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62402. /**
  62403. * Returns the agent position in world space
  62404. * @param index agent index returned by addAgent
  62405. * @returns world space position
  62406. */
  62407. getAgentPosition(index: number): Vector3;
  62408. /**
  62409. * Returns the agent velocity in world space
  62410. * @param index agent index returned by addAgent
  62411. * @returns world space velocity
  62412. */
  62413. getAgentVelocity(index: number): Vector3;
  62414. /**
  62415. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62416. * @param index agent index returned by addAgent
  62417. * @param destination targeted world position
  62418. */
  62419. agentGoto(index: number, destination: Vector3): void;
  62420. /**
  62421. * remove a particular agent previously created
  62422. * @param index agent index returned by addAgent
  62423. */
  62424. removeAgent(index: number): void;
  62425. /**
  62426. * get the list of all agents attached to this crowd
  62427. * @returns list of agent indices
  62428. */
  62429. getAgents(): number[];
  62430. /**
  62431. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62432. * @param deltaTime in seconds
  62433. */
  62434. update(deltaTime: number): void;
  62435. /**
  62436. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62437. * The queries will try to find a solution within those bounds
  62438. * default is (1,1,1)
  62439. * @param extent x,y,z value that define the extent around the queries point of reference
  62440. */
  62441. setDefaultQueryExtent(extent: Vector3): void;
  62442. /**
  62443. * Get the Bounding box extent specified by setDefaultQueryExtent
  62444. * @returns the box extent values
  62445. */
  62446. getDefaultQueryExtent(): Vector3;
  62447. /**
  62448. * Release all resources
  62449. */
  62450. dispose(): void;
  62451. }
  62452. }
  62453. declare module "babylonjs/Navigation/Plugins/index" {
  62454. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  62455. }
  62456. declare module "babylonjs/Navigation/index" {
  62457. export * from "babylonjs/Navigation/INavigationEngine";
  62458. export * from "babylonjs/Navigation/Plugins/index";
  62459. }
  62460. declare module "babylonjs/Offline/database" {
  62461. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  62462. /**
  62463. * Class used to enable access to IndexedDB
  62464. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62465. */
  62466. export class Database implements IOfflineProvider {
  62467. private _callbackManifestChecked;
  62468. private _currentSceneUrl;
  62469. private _db;
  62470. private _enableSceneOffline;
  62471. private _enableTexturesOffline;
  62472. private _manifestVersionFound;
  62473. private _mustUpdateRessources;
  62474. private _hasReachedQuota;
  62475. private _isSupported;
  62476. private _idbFactory;
  62477. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62478. private static IsUASupportingBlobStorage;
  62479. /**
  62480. * Gets a boolean indicating if Database storate is enabled (off by default)
  62481. */
  62482. static IDBStorageEnabled: boolean;
  62483. /**
  62484. * Gets a boolean indicating if scene must be saved in the database
  62485. */
  62486. readonly enableSceneOffline: boolean;
  62487. /**
  62488. * Gets a boolean indicating if textures must be saved in the database
  62489. */
  62490. readonly enableTexturesOffline: boolean;
  62491. /**
  62492. * Creates a new Database
  62493. * @param urlToScene defines the url to load the scene
  62494. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62495. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62496. */
  62497. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62498. private static _ParseURL;
  62499. private static _ReturnFullUrlLocation;
  62500. private _checkManifestFile;
  62501. /**
  62502. * Open the database and make it available
  62503. * @param successCallback defines the callback to call on success
  62504. * @param errorCallback defines the callback to call on error
  62505. */
  62506. open(successCallback: () => void, errorCallback: () => void): void;
  62507. /**
  62508. * Loads an image from the database
  62509. * @param url defines the url to load from
  62510. * @param image defines the target DOM image
  62511. */
  62512. loadImage(url: string, image: HTMLImageElement): void;
  62513. private _loadImageFromDBAsync;
  62514. private _saveImageIntoDBAsync;
  62515. private _checkVersionFromDB;
  62516. private _loadVersionFromDBAsync;
  62517. private _saveVersionIntoDBAsync;
  62518. /**
  62519. * Loads a file from database
  62520. * @param url defines the URL to load from
  62521. * @param sceneLoaded defines a callback to call on success
  62522. * @param progressCallBack defines a callback to call when progress changed
  62523. * @param errorCallback defines a callback to call on error
  62524. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62525. */
  62526. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62527. private _loadFileAsync;
  62528. private _saveFileAsync;
  62529. /**
  62530. * Validates if xhr data is correct
  62531. * @param xhr defines the request to validate
  62532. * @param dataType defines the expected data type
  62533. * @returns true if data is correct
  62534. */
  62535. private static _ValidateXHRData;
  62536. }
  62537. }
  62538. declare module "babylonjs/Offline/index" {
  62539. export * from "babylonjs/Offline/database";
  62540. export * from "babylonjs/Offline/IOfflineProvider";
  62541. }
  62542. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  62543. /** @hidden */
  62544. export var gpuUpdateParticlesPixelShader: {
  62545. name: string;
  62546. shader: string;
  62547. };
  62548. }
  62549. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  62550. /** @hidden */
  62551. export var gpuUpdateParticlesVertexShader: {
  62552. name: string;
  62553. shader: string;
  62554. };
  62555. }
  62556. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  62557. /** @hidden */
  62558. export var clipPlaneFragmentDeclaration2: {
  62559. name: string;
  62560. shader: string;
  62561. };
  62562. }
  62563. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  62564. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  62565. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  62566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62567. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  62568. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  62569. /** @hidden */
  62570. export var gpuRenderParticlesPixelShader: {
  62571. name: string;
  62572. shader: string;
  62573. };
  62574. }
  62575. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  62576. /** @hidden */
  62577. export var clipPlaneVertexDeclaration2: {
  62578. name: string;
  62579. shader: string;
  62580. };
  62581. }
  62582. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  62583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  62584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  62585. /** @hidden */
  62586. export var gpuRenderParticlesVertexShader: {
  62587. name: string;
  62588. shader: string;
  62589. };
  62590. }
  62591. declare module "babylonjs/Particles/gpuParticleSystem" {
  62592. import { Nullable } from "babylonjs/types";
  62593. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  62594. import { Observable } from "babylonjs/Misc/observable";
  62595. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62596. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62597. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  62598. import { Scene, IDisposable } from "babylonjs/scene";
  62599. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  62600. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62601. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  62602. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  62603. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  62604. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  62605. /**
  62606. * This represents a GPU particle system in Babylon
  62607. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62608. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62609. */
  62610. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62611. /**
  62612. * The layer mask we are rendering the particles through.
  62613. */
  62614. layerMask: number;
  62615. private _capacity;
  62616. private _activeCount;
  62617. private _currentActiveCount;
  62618. private _accumulatedCount;
  62619. private _renderEffect;
  62620. private _updateEffect;
  62621. private _buffer0;
  62622. private _buffer1;
  62623. private _spriteBuffer;
  62624. private _updateVAO;
  62625. private _renderVAO;
  62626. private _targetIndex;
  62627. private _sourceBuffer;
  62628. private _targetBuffer;
  62629. private _engine;
  62630. private _currentRenderId;
  62631. private _started;
  62632. private _stopped;
  62633. private _timeDelta;
  62634. private _randomTexture;
  62635. private _randomTexture2;
  62636. private _attributesStrideSize;
  62637. private _updateEffectOptions;
  62638. private _randomTextureSize;
  62639. private _actualFrame;
  62640. private readonly _rawTextureWidth;
  62641. /**
  62642. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62643. */
  62644. static readonly IsSupported: boolean;
  62645. /**
  62646. * An event triggered when the system is disposed.
  62647. */
  62648. onDisposeObservable: Observable<GPUParticleSystem>;
  62649. /**
  62650. * Gets the maximum number of particles active at the same time.
  62651. * @returns The max number of active particles.
  62652. */
  62653. getCapacity(): number;
  62654. /**
  62655. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62656. * to override the particles.
  62657. */
  62658. forceDepthWrite: boolean;
  62659. /**
  62660. * Gets or set the number of active particles
  62661. */
  62662. activeParticleCount: number;
  62663. private _preWarmDone;
  62664. /**
  62665. * Is this system ready to be used/rendered
  62666. * @return true if the system is ready
  62667. */
  62668. isReady(): boolean;
  62669. /**
  62670. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62671. * @returns True if it has been started, otherwise false.
  62672. */
  62673. isStarted(): boolean;
  62674. /**
  62675. * Starts the particle system and begins to emit
  62676. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62677. */
  62678. start(delay?: number): void;
  62679. /**
  62680. * Stops the particle system.
  62681. */
  62682. stop(): void;
  62683. /**
  62684. * Remove all active particles
  62685. */
  62686. reset(): void;
  62687. /**
  62688. * Returns the string "GPUParticleSystem"
  62689. * @returns a string containing the class name
  62690. */
  62691. getClassName(): string;
  62692. private _colorGradientsTexture;
  62693. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62694. /**
  62695. * Adds a new color gradient
  62696. * @param gradient defines the gradient to use (between 0 and 1)
  62697. * @param color1 defines the color to affect to the specified gradient
  62698. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62699. * @returns the current particle system
  62700. */
  62701. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62702. /**
  62703. * Remove a specific color gradient
  62704. * @param gradient defines the gradient to remove
  62705. * @returns the current particle system
  62706. */
  62707. removeColorGradient(gradient: number): GPUParticleSystem;
  62708. private _angularSpeedGradientsTexture;
  62709. private _sizeGradientsTexture;
  62710. private _velocityGradientsTexture;
  62711. private _limitVelocityGradientsTexture;
  62712. private _dragGradientsTexture;
  62713. private _addFactorGradient;
  62714. /**
  62715. * Adds a new size gradient
  62716. * @param gradient defines the gradient to use (between 0 and 1)
  62717. * @param factor defines the size factor to affect to the specified gradient
  62718. * @returns the current particle system
  62719. */
  62720. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62721. /**
  62722. * Remove a specific size gradient
  62723. * @param gradient defines the gradient to remove
  62724. * @returns the current particle system
  62725. */
  62726. removeSizeGradient(gradient: number): GPUParticleSystem;
  62727. /**
  62728. * Adds a new angular speed gradient
  62729. * @param gradient defines the gradient to use (between 0 and 1)
  62730. * @param factor defines the angular speed to affect to the specified gradient
  62731. * @returns the current particle system
  62732. */
  62733. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62734. /**
  62735. * Remove a specific angular speed gradient
  62736. * @param gradient defines the gradient to remove
  62737. * @returns the current particle system
  62738. */
  62739. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62740. /**
  62741. * Adds a new velocity gradient
  62742. * @param gradient defines the gradient to use (between 0 and 1)
  62743. * @param factor defines the velocity to affect to the specified gradient
  62744. * @returns the current particle system
  62745. */
  62746. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62747. /**
  62748. * Remove a specific velocity gradient
  62749. * @param gradient defines the gradient to remove
  62750. * @returns the current particle system
  62751. */
  62752. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62753. /**
  62754. * Adds a new limit velocity gradient
  62755. * @param gradient defines the gradient to use (between 0 and 1)
  62756. * @param factor defines the limit velocity value to affect to the specified gradient
  62757. * @returns the current particle system
  62758. */
  62759. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62760. /**
  62761. * Remove a specific limit velocity gradient
  62762. * @param gradient defines the gradient to remove
  62763. * @returns the current particle system
  62764. */
  62765. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62766. /**
  62767. * Adds a new drag gradient
  62768. * @param gradient defines the gradient to use (between 0 and 1)
  62769. * @param factor defines the drag value to affect to the specified gradient
  62770. * @returns the current particle system
  62771. */
  62772. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62773. /**
  62774. * Remove a specific drag gradient
  62775. * @param gradient defines the gradient to remove
  62776. * @returns the current particle system
  62777. */
  62778. removeDragGradient(gradient: number): GPUParticleSystem;
  62779. /**
  62780. * Not supported by GPUParticleSystem
  62781. * @param gradient defines the gradient to use (between 0 and 1)
  62782. * @param factor defines the emit rate value to affect to the specified gradient
  62783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62784. * @returns the current particle system
  62785. */
  62786. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62787. /**
  62788. * Not supported by GPUParticleSystem
  62789. * @param gradient defines the gradient to remove
  62790. * @returns the current particle system
  62791. */
  62792. removeEmitRateGradient(gradient: number): IParticleSystem;
  62793. /**
  62794. * Not supported by GPUParticleSystem
  62795. * @param gradient defines the gradient to use (between 0 and 1)
  62796. * @param factor defines the start size value to affect to the specified gradient
  62797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62798. * @returns the current particle system
  62799. */
  62800. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62801. /**
  62802. * Not supported by GPUParticleSystem
  62803. * @param gradient defines the gradient to remove
  62804. * @returns the current particle system
  62805. */
  62806. removeStartSizeGradient(gradient: number): IParticleSystem;
  62807. /**
  62808. * Not supported by GPUParticleSystem
  62809. * @param gradient defines the gradient to use (between 0 and 1)
  62810. * @param min defines the color remap minimal range
  62811. * @param max defines the color remap maximal range
  62812. * @returns the current particle system
  62813. */
  62814. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62815. /**
  62816. * Not supported by GPUParticleSystem
  62817. * @param gradient defines the gradient to remove
  62818. * @returns the current particle system
  62819. */
  62820. removeColorRemapGradient(): IParticleSystem;
  62821. /**
  62822. * Not supported by GPUParticleSystem
  62823. * @param gradient defines the gradient to use (between 0 and 1)
  62824. * @param min defines the alpha remap minimal range
  62825. * @param max defines the alpha remap maximal range
  62826. * @returns the current particle system
  62827. */
  62828. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62829. /**
  62830. * Not supported by GPUParticleSystem
  62831. * @param gradient defines the gradient to remove
  62832. * @returns the current particle system
  62833. */
  62834. removeAlphaRemapGradient(): IParticleSystem;
  62835. /**
  62836. * Not supported by GPUParticleSystem
  62837. * @param gradient defines the gradient to use (between 0 and 1)
  62838. * @param color defines the color to affect to the specified gradient
  62839. * @returns the current particle system
  62840. */
  62841. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62842. /**
  62843. * Not supported by GPUParticleSystem
  62844. * @param gradient defines the gradient to remove
  62845. * @returns the current particle system
  62846. */
  62847. removeRampGradient(): IParticleSystem;
  62848. /**
  62849. * Not supported by GPUParticleSystem
  62850. * @returns the list of ramp gradients
  62851. */
  62852. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62853. /**
  62854. * Not supported by GPUParticleSystem
  62855. * Gets or sets a boolean indicating that ramp gradients must be used
  62856. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62857. */
  62858. useRampGradients: boolean;
  62859. /**
  62860. * Not supported by GPUParticleSystem
  62861. * @param gradient defines the gradient to use (between 0 and 1)
  62862. * @param factor defines the life time factor to affect to the specified gradient
  62863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62864. * @returns the current particle system
  62865. */
  62866. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62867. /**
  62868. * Not supported by GPUParticleSystem
  62869. * @param gradient defines the gradient to remove
  62870. * @returns the current particle system
  62871. */
  62872. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62873. /**
  62874. * Instantiates a GPU particle system.
  62875. * 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.
  62876. * @param name The name of the particle system
  62877. * @param options The options used to create the system
  62878. * @param scene The scene the particle system belongs to
  62879. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62880. */
  62881. constructor(name: string, options: Partial<{
  62882. capacity: number;
  62883. randomTextureSize: number;
  62884. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62885. protected _reset(): void;
  62886. private _createUpdateVAO;
  62887. private _createRenderVAO;
  62888. private _initialize;
  62889. /** @hidden */
  62890. _recreateUpdateEffect(): void;
  62891. /** @hidden */
  62892. _recreateRenderEffect(): void;
  62893. /**
  62894. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62895. * @param preWarm defines if we are in the pre-warmimg phase
  62896. */
  62897. animate(preWarm?: boolean): void;
  62898. private _createFactorGradientTexture;
  62899. private _createSizeGradientTexture;
  62900. private _createAngularSpeedGradientTexture;
  62901. private _createVelocityGradientTexture;
  62902. private _createLimitVelocityGradientTexture;
  62903. private _createDragGradientTexture;
  62904. private _createColorGradientTexture;
  62905. /**
  62906. * Renders the particle system in its current state
  62907. * @param preWarm defines if the system should only update the particles but not render them
  62908. * @returns the current number of particles
  62909. */
  62910. render(preWarm?: boolean): number;
  62911. /**
  62912. * Rebuilds the particle system
  62913. */
  62914. rebuild(): void;
  62915. private _releaseBuffers;
  62916. private _releaseVAOs;
  62917. /**
  62918. * Disposes the particle system and free the associated resources
  62919. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62920. */
  62921. dispose(disposeTexture?: boolean): void;
  62922. /**
  62923. * Clones the particle system.
  62924. * @param name The name of the cloned object
  62925. * @param newEmitter The new emitter to use
  62926. * @returns the cloned particle system
  62927. */
  62928. clone(name: string, newEmitter: any): GPUParticleSystem;
  62929. /**
  62930. * Serializes the particle system to a JSON object.
  62931. * @returns the JSON object
  62932. */
  62933. serialize(): any;
  62934. /**
  62935. * Parses a JSON object to create a GPU particle system.
  62936. * @param parsedParticleSystem The JSON object to parse
  62937. * @param scene The scene to create the particle system in
  62938. * @param rootUrl The root url to use to load external dependencies like texture
  62939. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62940. * @returns the parsed GPU particle system
  62941. */
  62942. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62943. }
  62944. }
  62945. declare module "babylonjs/Particles/particleSystemSet" {
  62946. import { Nullable } from "babylonjs/types";
  62947. import { Color3 } from "babylonjs/Maths/math.color";
  62948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62950. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62951. import { Scene, IDisposable } from "babylonjs/scene";
  62952. /**
  62953. * Represents a set of particle systems working together to create a specific effect
  62954. */
  62955. export class ParticleSystemSet implements IDisposable {
  62956. /**
  62957. * Gets or sets base Assets URL
  62958. */
  62959. static BaseAssetsUrl: string;
  62960. private _emitterCreationOptions;
  62961. private _emitterNode;
  62962. /**
  62963. * Gets the particle system list
  62964. */
  62965. systems: IParticleSystem[];
  62966. /**
  62967. * Gets the emitter node used with this set
  62968. */
  62969. readonly emitterNode: Nullable<TransformNode>;
  62970. /**
  62971. * Creates a new emitter mesh as a sphere
  62972. * @param options defines the options used to create the sphere
  62973. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62974. * @param scene defines the hosting scene
  62975. */
  62976. setEmitterAsSphere(options: {
  62977. diameter: number;
  62978. segments: number;
  62979. color: Color3;
  62980. }, renderingGroupId: number, scene: Scene): void;
  62981. /**
  62982. * Starts all particle systems of the set
  62983. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62984. */
  62985. start(emitter?: AbstractMesh): void;
  62986. /**
  62987. * Release all associated resources
  62988. */
  62989. dispose(): void;
  62990. /**
  62991. * Serialize the set into a JSON compatible object
  62992. * @returns a JSON compatible representation of the set
  62993. */
  62994. serialize(): any;
  62995. /**
  62996. * Parse a new ParticleSystemSet from a serialized source
  62997. * @param data defines a JSON compatible representation of the set
  62998. * @param scene defines the hosting scene
  62999. * @param gpu defines if we want GPU particles or CPU particles
  63000. * @returns a new ParticleSystemSet
  63001. */
  63002. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63003. }
  63004. }
  63005. declare module "babylonjs/Particles/particleHelper" {
  63006. import { Nullable } from "babylonjs/types";
  63007. import { Scene } from "babylonjs/scene";
  63008. import { Vector3 } from "babylonjs/Maths/math.vector";
  63009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63010. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63011. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  63012. /**
  63013. * This class is made for on one-liner static method to help creating particle system set.
  63014. */
  63015. export class ParticleHelper {
  63016. /**
  63017. * Gets or sets base Assets URL
  63018. */
  63019. static BaseAssetsUrl: string;
  63020. /**
  63021. * Create a default particle system that you can tweak
  63022. * @param emitter defines the emitter to use
  63023. * @param capacity defines the system capacity (default is 500 particles)
  63024. * @param scene defines the hosting scene
  63025. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63026. * @returns the new Particle system
  63027. */
  63028. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63029. /**
  63030. * This is the main static method (one-liner) of this helper to create different particle systems
  63031. * @param type This string represents the type to the particle system to create
  63032. * @param scene The scene where the particle system should live
  63033. * @param gpu If the system will use gpu
  63034. * @returns the ParticleSystemSet created
  63035. */
  63036. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63037. /**
  63038. * Static function used to export a particle system to a ParticleSystemSet variable.
  63039. * Please note that the emitter shape is not exported
  63040. * @param systems defines the particle systems to export
  63041. * @returns the created particle system set
  63042. */
  63043. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63044. }
  63045. }
  63046. declare module "babylonjs/Particles/particleSystemComponent" {
  63047. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63048. import { Effect } from "babylonjs/Materials/effect";
  63049. import "babylonjs/Shaders/particles.vertex";
  63050. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63051. module "babylonjs/Engines/engine" {
  63052. interface Engine {
  63053. /**
  63054. * Create an effect to use with particle systems.
  63055. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63056. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63057. * @param uniformsNames defines a list of attribute names
  63058. * @param samplers defines an array of string used to represent textures
  63059. * @param defines defines the string containing the defines to use to compile the shaders
  63060. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63061. * @param onCompiled defines a function to call when the effect creation is successful
  63062. * @param onError defines a function to call when the effect creation has failed
  63063. * @returns the new Effect
  63064. */
  63065. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63066. }
  63067. }
  63068. module "babylonjs/Meshes/mesh" {
  63069. interface Mesh {
  63070. /**
  63071. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63072. * @returns an array of IParticleSystem
  63073. */
  63074. getEmittedParticleSystems(): IParticleSystem[];
  63075. /**
  63076. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63077. * @returns an array of IParticleSystem
  63078. */
  63079. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63080. }
  63081. }
  63082. /**
  63083. * @hidden
  63084. */
  63085. export var _IDoNeedToBeInTheBuild: number;
  63086. }
  63087. declare module "babylonjs/Particles/pointsCloudSystem" {
  63088. import { Color4 } from "babylonjs/Maths/math";
  63089. import { Mesh } from "babylonjs/Meshes/mesh";
  63090. import { Scene, IDisposable } from "babylonjs/scene";
  63091. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  63092. /** Defines the 4 color options */
  63093. export enum PointColor {
  63094. /** color value */
  63095. Color = 2,
  63096. /** uv value */
  63097. UV = 1,
  63098. /** random value */
  63099. Random = 0,
  63100. /** stated value */
  63101. Stated = 3
  63102. }
  63103. /**
  63104. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63105. * 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.
  63106. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63107. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63108. *
  63109. * Full documentation here : TO BE ENTERED
  63110. */
  63111. export class PointsCloudSystem implements IDisposable {
  63112. /**
  63113. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63114. * Example : var p = SPS.particles[i];
  63115. */
  63116. particles: CloudPoint[];
  63117. /**
  63118. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63119. */
  63120. nbParticles: number;
  63121. /**
  63122. * This a counter for your own usage. It's not set by any SPS functions.
  63123. */
  63124. counter: number;
  63125. /**
  63126. * The PCS name. This name is also given to the underlying mesh.
  63127. */
  63128. name: string;
  63129. /**
  63130. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63131. */
  63132. mesh: Mesh;
  63133. /**
  63134. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63135. * Please read :
  63136. */
  63137. vars: any;
  63138. /**
  63139. * @hidden
  63140. */
  63141. _size: number;
  63142. private _scene;
  63143. private _promises;
  63144. private _positions;
  63145. private _indices;
  63146. private _normals;
  63147. private _colors;
  63148. private _uvs;
  63149. private _indices32;
  63150. private _positions32;
  63151. private _colors32;
  63152. private _uvs32;
  63153. private _updatable;
  63154. private _isVisibilityBoxLocked;
  63155. private _alwaysVisible;
  63156. private _groups;
  63157. private _groupCounter;
  63158. private _computeParticleColor;
  63159. private _computeParticleTexture;
  63160. private _computeParticleRotation;
  63161. private _computeBoundingBox;
  63162. private _isReady;
  63163. /**
  63164. * Creates a PCS (Points Cloud System) object
  63165. * @param name (String) is the PCS name, this will be the underlying mesh name
  63166. * @param pointSize (number) is the size for each point
  63167. * @param scene (Scene) is the scene in which the PCS is added
  63168. * @param options defines the options of the PCS e.g.
  63169. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63170. */
  63171. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63172. updatable?: boolean;
  63173. });
  63174. /**
  63175. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63176. * If no points were added to the PCS, the returned mesh is just a single point.
  63177. * @returns a promise for the created mesh
  63178. */
  63179. buildMeshAsync(): Promise<Mesh>;
  63180. /**
  63181. * @hidden
  63182. */
  63183. private _buildMesh;
  63184. private _addParticle;
  63185. private _randomUnitVector;
  63186. private _getColorIndicesForCoord;
  63187. private _setPointsColorOrUV;
  63188. private _colorFromTexture;
  63189. private _calculateDensity;
  63190. /**
  63191. * Adds points to the PCS in random positions within a unit sphere
  63192. * @param nb (positive integer) the number of particles to be created from this model
  63193. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63194. * @returns the number of groups in the system
  63195. */
  63196. addPoints(nb: number, pointFunction?: any): number;
  63197. /**
  63198. * Adds points to the PCS from the surface of the model shape
  63199. * @param mesh is any Mesh object that will be used as a surface model for the points
  63200. * @param nb (positive integer) the number of particles to be created from this model
  63201. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63202. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63203. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63204. * @returns the number of groups in the system
  63205. */
  63206. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63207. /**
  63208. * Adds points to the PCS inside the model shape
  63209. * @param mesh is any Mesh object that will be used as a surface model for the points
  63210. * @param nb (positive integer) the number of particles to be created from this model
  63211. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63212. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63213. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63214. * @returns the number of groups in the system
  63215. */
  63216. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63217. /**
  63218. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63219. * This method calls `updateParticle()` for each particle of the SPS.
  63220. * For an animated SPS, it is usually called within the render loop.
  63221. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63222. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63223. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63224. * @returns the PCS.
  63225. */
  63226. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63227. /**
  63228. * Disposes the PCS.
  63229. */
  63230. dispose(): void;
  63231. /**
  63232. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63233. * doc :
  63234. * @returns the PCS.
  63235. */
  63236. refreshVisibleSize(): PointsCloudSystem;
  63237. /**
  63238. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63239. * @param size the size (float) of the visibility box
  63240. * note : this doesn't lock the PCS mesh bounding box.
  63241. * doc :
  63242. */
  63243. setVisibilityBox(size: number): void;
  63244. /**
  63245. * Gets whether the PCS is always visible or not
  63246. * doc :
  63247. */
  63248. /**
  63249. * Sets the PCS as always visible or not
  63250. * doc :
  63251. */
  63252. isAlwaysVisible: boolean;
  63253. /**
  63254. * Tells to `setParticles()` to compute the particle rotations or not
  63255. * Default value : false. The PCS is faster when it's set to false
  63256. * Note : particle rotations are only applied to parent particles
  63257. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63258. */
  63259. computeParticleRotation: boolean;
  63260. /**
  63261. * Tells to `setParticles()` to compute the particle colors or not.
  63262. * Default value : true. The PCS is faster when it's set to false.
  63263. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63264. */
  63265. /**
  63266. * Gets if `setParticles()` computes the particle colors or not.
  63267. * Default value : false. The PCS is faster when it's set to false.
  63268. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63269. */
  63270. computeParticleColor: boolean;
  63271. /**
  63272. * Gets if `setParticles()` computes the particle textures or not.
  63273. * Default value : false. The PCS is faster when it's set to false.
  63274. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63275. */
  63276. computeParticleTexture: boolean;
  63277. /**
  63278. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63279. */
  63280. /**
  63281. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63282. */
  63283. computeBoundingBox: boolean;
  63284. /**
  63285. * This function does nothing. It may be overwritten to set all the particle first values.
  63286. * The PCS doesn't call this function, you may have to call it by your own.
  63287. * doc :
  63288. */
  63289. initParticles(): void;
  63290. /**
  63291. * This function does nothing. It may be overwritten to recycle a particle
  63292. * The PCS doesn't call this function, you can to call it
  63293. * doc :
  63294. * @param particle The particle to recycle
  63295. * @returns the recycled particle
  63296. */
  63297. recycleParticle(particle: CloudPoint): CloudPoint;
  63298. /**
  63299. * Updates a particle : this function should be overwritten by the user.
  63300. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63301. * doc :
  63302. * @example : just set a particle position or velocity and recycle conditions
  63303. * @param particle The particle to update
  63304. * @returns the updated particle
  63305. */
  63306. updateParticle(particle: CloudPoint): CloudPoint;
  63307. /**
  63308. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63309. * This does nothing and may be overwritten by the user.
  63310. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63311. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63312. * @param update the boolean update value actually passed to setParticles()
  63313. */
  63314. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63315. /**
  63316. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63317. * This will be passed three parameters.
  63318. * This does nothing and may be overwritten by the user.
  63319. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63320. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63321. * @param update the boolean update value actually passed to setParticles()
  63322. */
  63323. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63324. }
  63325. }
  63326. declare module "babylonjs/Particles/cloudPoint" {
  63327. import { Nullable } from "babylonjs/types";
  63328. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  63329. import { Mesh } from "babylonjs/Meshes/mesh";
  63330. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63331. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  63332. /**
  63333. * Represents one particle of a points cloud system.
  63334. */
  63335. export class CloudPoint {
  63336. /**
  63337. * particle global index
  63338. */
  63339. idx: number;
  63340. /**
  63341. * The color of the particle
  63342. */
  63343. color: Nullable<Color4>;
  63344. /**
  63345. * The world space position of the particle.
  63346. */
  63347. position: Vector3;
  63348. /**
  63349. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63350. */
  63351. rotation: Vector3;
  63352. /**
  63353. * The world space rotation quaternion of the particle.
  63354. */
  63355. rotationQuaternion: Nullable<Quaternion>;
  63356. /**
  63357. * The uv of the particle.
  63358. */
  63359. uv: Nullable<Vector2>;
  63360. /**
  63361. * The current speed of the particle.
  63362. */
  63363. velocity: Vector3;
  63364. /**
  63365. * The pivot point in the particle local space.
  63366. */
  63367. pivot: Vector3;
  63368. /**
  63369. * Must the particle be translated from its pivot point in its local space ?
  63370. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63371. * Default : false
  63372. */
  63373. translateFromPivot: boolean;
  63374. /**
  63375. * Index of this particle in the global "positions" array (Internal use)
  63376. * @hidden
  63377. */
  63378. _pos: number;
  63379. /**
  63380. * @hidden Index of this particle in the global "indices" array (Internal use)
  63381. */
  63382. _ind: number;
  63383. /**
  63384. * Group this particle belongs to
  63385. */
  63386. _group: PointsGroup;
  63387. /**
  63388. * Group id of this particle
  63389. */
  63390. groupId: number;
  63391. /**
  63392. * Index of the particle in its group id (Internal use)
  63393. */
  63394. idxInGroup: number;
  63395. /**
  63396. * @hidden Particle BoundingInfo object (Internal use)
  63397. */
  63398. _boundingInfo: BoundingInfo;
  63399. /**
  63400. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63401. */
  63402. _pcs: PointsCloudSystem;
  63403. /**
  63404. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63405. */
  63406. _stillInvisible: boolean;
  63407. /**
  63408. * @hidden Last computed particle rotation matrix
  63409. */
  63410. _rotationMatrix: number[];
  63411. /**
  63412. * Parent particle Id, if any.
  63413. * Default null.
  63414. */
  63415. parentId: Nullable<number>;
  63416. /**
  63417. * @hidden Internal global position in the PCS.
  63418. */
  63419. _globalPosition: Vector3;
  63420. /**
  63421. * Creates a Point Cloud object.
  63422. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63423. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63424. * @param group (PointsGroup) is the group the particle belongs to
  63425. * @param groupId (integer) is the group identifier in the PCS.
  63426. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63427. * @param pcs defines the PCS it is associated to
  63428. */
  63429. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63430. /**
  63431. * get point size
  63432. */
  63433. /**
  63434. * Set point size
  63435. */
  63436. size: Vector3;
  63437. /**
  63438. * Legacy support, changed quaternion to rotationQuaternion
  63439. */
  63440. /**
  63441. * Legacy support, changed quaternion to rotationQuaternion
  63442. */
  63443. quaternion: Nullable<Quaternion>;
  63444. /**
  63445. * Returns a boolean. True if the particle intersects a mesh, else false
  63446. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63447. * @param target is the object (point or mesh) what the intersection is computed against
  63448. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63449. * @returns true if it intersects
  63450. */
  63451. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63452. /**
  63453. * get the rotation matrix of the particle
  63454. * @hidden
  63455. */
  63456. getRotationMatrix(m: Matrix): void;
  63457. }
  63458. /**
  63459. * Represents a group of points in a points cloud system
  63460. * * PCS internal tool, don't use it manually.
  63461. */
  63462. export class PointsGroup {
  63463. /**
  63464. * The group id
  63465. * @hidden
  63466. */
  63467. groupID: number;
  63468. /**
  63469. * image data for group (internal use)
  63470. * @hidden
  63471. */
  63472. _groupImageData: Nullable<ArrayBufferView>;
  63473. /**
  63474. * Image Width (internal use)
  63475. * @hidden
  63476. */
  63477. _groupImgWidth: number;
  63478. /**
  63479. * Image Height (internal use)
  63480. * @hidden
  63481. */
  63482. _groupImgHeight: number;
  63483. /**
  63484. * Custom position function (internal use)
  63485. * @hidden
  63486. */
  63487. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63488. /**
  63489. * density per facet for surface points
  63490. * @hidden
  63491. */
  63492. _groupDensity: number[];
  63493. /**
  63494. * Only when points are colored by texture carries pointer to texture list array
  63495. * @hidden
  63496. */
  63497. _textureNb: number;
  63498. /**
  63499. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63500. * PCS internal tool, don't use it manually.
  63501. * @hidden
  63502. */
  63503. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63504. }
  63505. }
  63506. declare module "babylonjs/Particles/index" {
  63507. export * from "babylonjs/Particles/baseParticleSystem";
  63508. export * from "babylonjs/Particles/EmitterTypes/index";
  63509. export * from "babylonjs/Particles/gpuParticleSystem";
  63510. export * from "babylonjs/Particles/IParticleSystem";
  63511. export * from "babylonjs/Particles/particle";
  63512. export * from "babylonjs/Particles/particleHelper";
  63513. export * from "babylonjs/Particles/particleSystem";
  63514. export * from "babylonjs/Particles/particleSystemComponent";
  63515. export * from "babylonjs/Particles/particleSystemSet";
  63516. export * from "babylonjs/Particles/solidParticle";
  63517. export * from "babylonjs/Particles/solidParticleSystem";
  63518. export * from "babylonjs/Particles/cloudPoint";
  63519. export * from "babylonjs/Particles/pointsCloudSystem";
  63520. export * from "babylonjs/Particles/subEmitter";
  63521. }
  63522. declare module "babylonjs/Physics/physicsEngineComponent" {
  63523. import { Nullable } from "babylonjs/types";
  63524. import { Observable, Observer } from "babylonjs/Misc/observable";
  63525. import { Vector3 } from "babylonjs/Maths/math.vector";
  63526. import { Mesh } from "babylonjs/Meshes/mesh";
  63527. import { ISceneComponent } from "babylonjs/sceneComponent";
  63528. import { Scene } from "babylonjs/scene";
  63529. import { Node } from "babylonjs/node";
  63530. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63531. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63532. module "babylonjs/scene" {
  63533. interface Scene {
  63534. /** @hidden (Backing field) */
  63535. _physicsEngine: Nullable<IPhysicsEngine>;
  63536. /** @hidden */
  63537. _physicsTimeAccumulator: number;
  63538. /**
  63539. * Gets the current physics engine
  63540. * @returns a IPhysicsEngine or null if none attached
  63541. */
  63542. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63543. /**
  63544. * Enables physics to the current scene
  63545. * @param gravity defines the scene's gravity for the physics engine
  63546. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63547. * @return a boolean indicating if the physics engine was initialized
  63548. */
  63549. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63550. /**
  63551. * Disables and disposes the physics engine associated with the scene
  63552. */
  63553. disablePhysicsEngine(): void;
  63554. /**
  63555. * Gets a boolean indicating if there is an active physics engine
  63556. * @returns a boolean indicating if there is an active physics engine
  63557. */
  63558. isPhysicsEnabled(): boolean;
  63559. /**
  63560. * Deletes a physics compound impostor
  63561. * @param compound defines the compound to delete
  63562. */
  63563. deleteCompoundImpostor(compound: any): void;
  63564. /**
  63565. * An event triggered when physic simulation is about to be run
  63566. */
  63567. onBeforePhysicsObservable: Observable<Scene>;
  63568. /**
  63569. * An event triggered when physic simulation has been done
  63570. */
  63571. onAfterPhysicsObservable: Observable<Scene>;
  63572. }
  63573. }
  63574. module "babylonjs/Meshes/abstractMesh" {
  63575. interface AbstractMesh {
  63576. /** @hidden */
  63577. _physicsImpostor: Nullable<PhysicsImpostor>;
  63578. /**
  63579. * Gets or sets impostor used for physic simulation
  63580. * @see http://doc.babylonjs.com/features/physics_engine
  63581. */
  63582. physicsImpostor: Nullable<PhysicsImpostor>;
  63583. /**
  63584. * Gets the current physics impostor
  63585. * @see http://doc.babylonjs.com/features/physics_engine
  63586. * @returns a physics impostor or null
  63587. */
  63588. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63589. /** Apply a physic impulse to the mesh
  63590. * @param force defines the force to apply
  63591. * @param contactPoint defines where to apply the force
  63592. * @returns the current mesh
  63593. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63594. */
  63595. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63596. /**
  63597. * Creates a physic joint between two meshes
  63598. * @param otherMesh defines the other mesh to use
  63599. * @param pivot1 defines the pivot to use on this mesh
  63600. * @param pivot2 defines the pivot to use on the other mesh
  63601. * @param options defines additional options (can be plugin dependent)
  63602. * @returns the current mesh
  63603. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63604. */
  63605. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63606. /** @hidden */
  63607. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63608. }
  63609. }
  63610. /**
  63611. * Defines the physics engine scene component responsible to manage a physics engine
  63612. */
  63613. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63614. /**
  63615. * The component name helpful to identify the component in the list of scene components.
  63616. */
  63617. readonly name: string;
  63618. /**
  63619. * The scene the component belongs to.
  63620. */
  63621. scene: Scene;
  63622. /**
  63623. * Creates a new instance of the component for the given scene
  63624. * @param scene Defines the scene to register the component in
  63625. */
  63626. constructor(scene: Scene);
  63627. /**
  63628. * Registers the component in a given scene
  63629. */
  63630. register(): void;
  63631. /**
  63632. * Rebuilds the elements related to this component in case of
  63633. * context lost for instance.
  63634. */
  63635. rebuild(): void;
  63636. /**
  63637. * Disposes the component and the associated ressources
  63638. */
  63639. dispose(): void;
  63640. }
  63641. }
  63642. declare module "babylonjs/Physics/physicsHelper" {
  63643. import { Nullable } from "babylonjs/types";
  63644. import { Vector3 } from "babylonjs/Maths/math.vector";
  63645. import { Mesh } from "babylonjs/Meshes/mesh";
  63646. import { Scene } from "babylonjs/scene";
  63647. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63648. /**
  63649. * A helper for physics simulations
  63650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63651. */
  63652. export class PhysicsHelper {
  63653. private _scene;
  63654. private _physicsEngine;
  63655. /**
  63656. * Initializes the Physics helper
  63657. * @param scene Babylon.js scene
  63658. */
  63659. constructor(scene: Scene);
  63660. /**
  63661. * Applies a radial explosion impulse
  63662. * @param origin the origin of the explosion
  63663. * @param radiusOrEventOptions the radius or the options of radial explosion
  63664. * @param strength the explosion strength
  63665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63666. * @returns A physics radial explosion event, or null
  63667. */
  63668. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63669. /**
  63670. * Applies a radial explosion force
  63671. * @param origin the origin of the explosion
  63672. * @param radiusOrEventOptions the radius or the options of radial explosion
  63673. * @param strength the explosion strength
  63674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63675. * @returns A physics radial explosion event, or null
  63676. */
  63677. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63678. /**
  63679. * Creates a gravitational field
  63680. * @param origin the origin of the explosion
  63681. * @param radiusOrEventOptions the radius or the options of radial explosion
  63682. * @param strength the explosion strength
  63683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63684. * @returns A physics gravitational field event, or null
  63685. */
  63686. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63687. /**
  63688. * Creates a physics updraft event
  63689. * @param origin the origin of the updraft
  63690. * @param radiusOrEventOptions the radius or the options of the updraft
  63691. * @param strength the strength of the updraft
  63692. * @param height the height of the updraft
  63693. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63694. * @returns A physics updraft event, or null
  63695. */
  63696. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63697. /**
  63698. * Creates a physics vortex event
  63699. * @param origin the of the vortex
  63700. * @param radiusOrEventOptions the radius or the options of the vortex
  63701. * @param strength the strength of the vortex
  63702. * @param height the height of the vortex
  63703. * @returns a Physics vortex event, or null
  63704. * A physics vortex event or null
  63705. */
  63706. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63707. }
  63708. /**
  63709. * Represents a physics radial explosion event
  63710. */
  63711. class PhysicsRadialExplosionEvent {
  63712. private _scene;
  63713. private _options;
  63714. private _sphere;
  63715. private _dataFetched;
  63716. /**
  63717. * Initializes a radial explosioin event
  63718. * @param _scene BabylonJS scene
  63719. * @param _options The options for the vortex event
  63720. */
  63721. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63722. /**
  63723. * Returns the data related to the radial explosion event (sphere).
  63724. * @returns The radial explosion event data
  63725. */
  63726. getData(): PhysicsRadialExplosionEventData;
  63727. /**
  63728. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63729. * @param impostor A physics imposter
  63730. * @param origin the origin of the explosion
  63731. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63732. */
  63733. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63734. /**
  63735. * Triggers affecterd impostors callbacks
  63736. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63737. */
  63738. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63739. /**
  63740. * Disposes the sphere.
  63741. * @param force Specifies if the sphere should be disposed by force
  63742. */
  63743. dispose(force?: boolean): void;
  63744. /*** Helpers ***/
  63745. private _prepareSphere;
  63746. private _intersectsWithSphere;
  63747. }
  63748. /**
  63749. * Represents a gravitational field event
  63750. */
  63751. class PhysicsGravitationalFieldEvent {
  63752. private _physicsHelper;
  63753. private _scene;
  63754. private _origin;
  63755. private _options;
  63756. private _tickCallback;
  63757. private _sphere;
  63758. private _dataFetched;
  63759. /**
  63760. * Initializes the physics gravitational field event
  63761. * @param _physicsHelper A physics helper
  63762. * @param _scene BabylonJS scene
  63763. * @param _origin The origin position of the gravitational field event
  63764. * @param _options The options for the vortex event
  63765. */
  63766. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63767. /**
  63768. * Returns the data related to the gravitational field event (sphere).
  63769. * @returns A gravitational field event
  63770. */
  63771. getData(): PhysicsGravitationalFieldEventData;
  63772. /**
  63773. * Enables the gravitational field.
  63774. */
  63775. enable(): void;
  63776. /**
  63777. * Disables the gravitational field.
  63778. */
  63779. disable(): void;
  63780. /**
  63781. * Disposes the sphere.
  63782. * @param force The force to dispose from the gravitational field event
  63783. */
  63784. dispose(force?: boolean): void;
  63785. private _tick;
  63786. }
  63787. /**
  63788. * Represents a physics updraft event
  63789. */
  63790. class PhysicsUpdraftEvent {
  63791. private _scene;
  63792. private _origin;
  63793. private _options;
  63794. private _physicsEngine;
  63795. private _originTop;
  63796. private _originDirection;
  63797. private _tickCallback;
  63798. private _cylinder;
  63799. private _cylinderPosition;
  63800. private _dataFetched;
  63801. /**
  63802. * Initializes the physics updraft event
  63803. * @param _scene BabylonJS scene
  63804. * @param _origin The origin position of the updraft
  63805. * @param _options The options for the updraft event
  63806. */
  63807. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63808. /**
  63809. * Returns the data related to the updraft event (cylinder).
  63810. * @returns A physics updraft event
  63811. */
  63812. getData(): PhysicsUpdraftEventData;
  63813. /**
  63814. * Enables the updraft.
  63815. */
  63816. enable(): void;
  63817. /**
  63818. * Disables the updraft.
  63819. */
  63820. disable(): void;
  63821. /**
  63822. * Disposes the cylinder.
  63823. * @param force Specifies if the updraft should be disposed by force
  63824. */
  63825. dispose(force?: boolean): void;
  63826. private getImpostorHitData;
  63827. private _tick;
  63828. /*** Helpers ***/
  63829. private _prepareCylinder;
  63830. private _intersectsWithCylinder;
  63831. }
  63832. /**
  63833. * Represents a physics vortex event
  63834. */
  63835. class PhysicsVortexEvent {
  63836. private _scene;
  63837. private _origin;
  63838. private _options;
  63839. private _physicsEngine;
  63840. private _originTop;
  63841. private _tickCallback;
  63842. private _cylinder;
  63843. private _cylinderPosition;
  63844. private _dataFetched;
  63845. /**
  63846. * Initializes the physics vortex event
  63847. * @param _scene The BabylonJS scene
  63848. * @param _origin The origin position of the vortex
  63849. * @param _options The options for the vortex event
  63850. */
  63851. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63852. /**
  63853. * Returns the data related to the vortex event (cylinder).
  63854. * @returns The physics vortex event data
  63855. */
  63856. getData(): PhysicsVortexEventData;
  63857. /**
  63858. * Enables the vortex.
  63859. */
  63860. enable(): void;
  63861. /**
  63862. * Disables the cortex.
  63863. */
  63864. disable(): void;
  63865. /**
  63866. * Disposes the sphere.
  63867. * @param force
  63868. */
  63869. dispose(force?: boolean): void;
  63870. private getImpostorHitData;
  63871. private _tick;
  63872. /*** Helpers ***/
  63873. private _prepareCylinder;
  63874. private _intersectsWithCylinder;
  63875. }
  63876. /**
  63877. * Options fot the radial explosion event
  63878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63879. */
  63880. export class PhysicsRadialExplosionEventOptions {
  63881. /**
  63882. * The radius of the sphere for the radial explosion.
  63883. */
  63884. radius: number;
  63885. /**
  63886. * The strenth of the explosion.
  63887. */
  63888. strength: number;
  63889. /**
  63890. * The strenght of the force in correspondence to the distance of the affected object
  63891. */
  63892. falloff: PhysicsRadialImpulseFalloff;
  63893. /**
  63894. * Sphere options for the radial explosion.
  63895. */
  63896. sphere: {
  63897. segments: number;
  63898. diameter: number;
  63899. };
  63900. /**
  63901. * Sphere options for the radial explosion.
  63902. */
  63903. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63904. }
  63905. /**
  63906. * Options fot the updraft event
  63907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63908. */
  63909. export class PhysicsUpdraftEventOptions {
  63910. /**
  63911. * The radius of the cylinder for the vortex
  63912. */
  63913. radius: number;
  63914. /**
  63915. * The strenth of the updraft.
  63916. */
  63917. strength: number;
  63918. /**
  63919. * The height of the cylinder for the updraft.
  63920. */
  63921. height: number;
  63922. /**
  63923. * The mode for the the updraft.
  63924. */
  63925. updraftMode: PhysicsUpdraftMode;
  63926. }
  63927. /**
  63928. * Options fot the vortex event
  63929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63930. */
  63931. export class PhysicsVortexEventOptions {
  63932. /**
  63933. * The radius of the cylinder for the vortex
  63934. */
  63935. radius: number;
  63936. /**
  63937. * The strenth of the vortex.
  63938. */
  63939. strength: number;
  63940. /**
  63941. * The height of the cylinder for the vortex.
  63942. */
  63943. height: number;
  63944. /**
  63945. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63946. */
  63947. centripetalForceThreshold: number;
  63948. /**
  63949. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63950. */
  63951. centripetalForceMultiplier: number;
  63952. /**
  63953. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63954. */
  63955. centrifugalForceMultiplier: number;
  63956. /**
  63957. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63958. */
  63959. updraftForceMultiplier: number;
  63960. }
  63961. /**
  63962. * The strenght of the force in correspondence to the distance of the affected object
  63963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63964. */
  63965. export enum PhysicsRadialImpulseFalloff {
  63966. /** Defines that impulse is constant in strength across it's whole radius */
  63967. Constant = 0,
  63968. /** Defines that impulse gets weaker if it's further from the origin */
  63969. Linear = 1
  63970. }
  63971. /**
  63972. * The strength of the force in correspondence to the distance of the affected object
  63973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63974. */
  63975. export enum PhysicsUpdraftMode {
  63976. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63977. Center = 0,
  63978. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63979. Perpendicular = 1
  63980. }
  63981. /**
  63982. * Interface for a physics hit data
  63983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63984. */
  63985. export interface PhysicsHitData {
  63986. /**
  63987. * The force applied at the contact point
  63988. */
  63989. force: Vector3;
  63990. /**
  63991. * The contact point
  63992. */
  63993. contactPoint: Vector3;
  63994. /**
  63995. * The distance from the origin to the contact point
  63996. */
  63997. distanceFromOrigin: number;
  63998. }
  63999. /**
  64000. * Interface for radial explosion event data
  64001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64002. */
  64003. export interface PhysicsRadialExplosionEventData {
  64004. /**
  64005. * A sphere used for the radial explosion event
  64006. */
  64007. sphere: Mesh;
  64008. }
  64009. /**
  64010. * Interface for gravitational field event data
  64011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64012. */
  64013. export interface PhysicsGravitationalFieldEventData {
  64014. /**
  64015. * A sphere mesh used for the gravitational field event
  64016. */
  64017. sphere: Mesh;
  64018. }
  64019. /**
  64020. * Interface for updraft event data
  64021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64022. */
  64023. export interface PhysicsUpdraftEventData {
  64024. /**
  64025. * A cylinder used for the updraft event
  64026. */
  64027. cylinder: Mesh;
  64028. }
  64029. /**
  64030. * Interface for vortex event data
  64031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64032. */
  64033. export interface PhysicsVortexEventData {
  64034. /**
  64035. * A cylinder used for the vortex event
  64036. */
  64037. cylinder: Mesh;
  64038. }
  64039. /**
  64040. * Interface for an affected physics impostor
  64041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64042. */
  64043. export interface PhysicsAffectedImpostorWithData {
  64044. /**
  64045. * The impostor affected by the effect
  64046. */
  64047. impostor: PhysicsImpostor;
  64048. /**
  64049. * The data about the hit/horce from the explosion
  64050. */
  64051. hitData: PhysicsHitData;
  64052. }
  64053. }
  64054. declare module "babylonjs/Physics/Plugins/index" {
  64055. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  64056. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  64057. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  64058. }
  64059. declare module "babylonjs/Physics/index" {
  64060. export * from "babylonjs/Physics/IPhysicsEngine";
  64061. export * from "babylonjs/Physics/physicsEngine";
  64062. export * from "babylonjs/Physics/physicsEngineComponent";
  64063. export * from "babylonjs/Physics/physicsHelper";
  64064. export * from "babylonjs/Physics/physicsImpostor";
  64065. export * from "babylonjs/Physics/physicsJoint";
  64066. export * from "babylonjs/Physics/Plugins/index";
  64067. }
  64068. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  64069. /** @hidden */
  64070. export var blackAndWhitePixelShader: {
  64071. name: string;
  64072. shader: string;
  64073. };
  64074. }
  64075. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  64076. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64077. import { Camera } from "babylonjs/Cameras/camera";
  64078. import { Engine } from "babylonjs/Engines/engine";
  64079. import "babylonjs/Shaders/blackAndWhite.fragment";
  64080. /**
  64081. * Post process used to render in black and white
  64082. */
  64083. export class BlackAndWhitePostProcess extends PostProcess {
  64084. /**
  64085. * Linear about to convert he result to black and white (default: 1)
  64086. */
  64087. degree: number;
  64088. /**
  64089. * Creates a black and white post process
  64090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64091. * @param name The name of the effect.
  64092. * @param options The required width/height ratio to downsize to before computing the render pass.
  64093. * @param camera The camera to apply the render pass to.
  64094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64095. * @param engine The engine which the post process will be applied. (default: current engine)
  64096. * @param reusable If the post process can be reused on the same frame. (default: false)
  64097. */
  64098. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64099. }
  64100. }
  64101. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  64102. import { Nullable } from "babylonjs/types";
  64103. import { Camera } from "babylonjs/Cameras/camera";
  64104. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64105. import { Engine } from "babylonjs/Engines/engine";
  64106. /**
  64107. * This represents a set of one or more post processes in Babylon.
  64108. * A post process can be used to apply a shader to a texture after it is rendered.
  64109. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64110. */
  64111. export class PostProcessRenderEffect {
  64112. private _postProcesses;
  64113. private _getPostProcesses;
  64114. private _singleInstance;
  64115. private _cameras;
  64116. private _indicesForCamera;
  64117. /**
  64118. * Name of the effect
  64119. * @hidden
  64120. */
  64121. _name: string;
  64122. /**
  64123. * Instantiates a post process render effect.
  64124. * A post process can be used to apply a shader to a texture after it is rendered.
  64125. * @param engine The engine the effect is tied to
  64126. * @param name The name of the effect
  64127. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64128. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64129. */
  64130. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64131. /**
  64132. * Checks if all the post processes in the effect are supported.
  64133. */
  64134. readonly isSupported: boolean;
  64135. /**
  64136. * Updates the current state of the effect
  64137. * @hidden
  64138. */
  64139. _update(): void;
  64140. /**
  64141. * Attaches the effect on cameras
  64142. * @param cameras The camera to attach to.
  64143. * @hidden
  64144. */
  64145. _attachCameras(cameras: Camera): void;
  64146. /**
  64147. * Attaches the effect on cameras
  64148. * @param cameras The camera to attach to.
  64149. * @hidden
  64150. */
  64151. _attachCameras(cameras: Camera[]): void;
  64152. /**
  64153. * Detaches the effect on cameras
  64154. * @param cameras The camera to detatch from.
  64155. * @hidden
  64156. */
  64157. _detachCameras(cameras: Camera): void;
  64158. /**
  64159. * Detatches the effect on cameras
  64160. * @param cameras The camera to detatch from.
  64161. * @hidden
  64162. */
  64163. _detachCameras(cameras: Camera[]): void;
  64164. /**
  64165. * Enables the effect on given cameras
  64166. * @param cameras The camera to enable.
  64167. * @hidden
  64168. */
  64169. _enable(cameras: Camera): void;
  64170. /**
  64171. * Enables the effect on given cameras
  64172. * @param cameras The camera to enable.
  64173. * @hidden
  64174. */
  64175. _enable(cameras: Nullable<Camera[]>): void;
  64176. /**
  64177. * Disables the effect on the given cameras
  64178. * @param cameras The camera to disable.
  64179. * @hidden
  64180. */
  64181. _disable(cameras: Camera): void;
  64182. /**
  64183. * Disables the effect on the given cameras
  64184. * @param cameras The camera to disable.
  64185. * @hidden
  64186. */
  64187. _disable(cameras: Nullable<Camera[]>): void;
  64188. /**
  64189. * Gets a list of the post processes contained in the effect.
  64190. * @param camera The camera to get the post processes on.
  64191. * @returns The list of the post processes in the effect.
  64192. */
  64193. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64194. }
  64195. }
  64196. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  64197. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64198. /** @hidden */
  64199. export var extractHighlightsPixelShader: {
  64200. name: string;
  64201. shader: string;
  64202. };
  64203. }
  64204. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  64205. import { Nullable } from "babylonjs/types";
  64206. import { Camera } from "babylonjs/Cameras/camera";
  64207. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64208. import { Engine } from "babylonjs/Engines/engine";
  64209. import "babylonjs/Shaders/extractHighlights.fragment";
  64210. /**
  64211. * 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.
  64212. */
  64213. export class ExtractHighlightsPostProcess extends PostProcess {
  64214. /**
  64215. * The luminance threshold, pixels below this value will be set to black.
  64216. */
  64217. threshold: number;
  64218. /** @hidden */
  64219. _exposure: number;
  64220. /**
  64221. * Post process which has the input texture to be used when performing highlight extraction
  64222. * @hidden
  64223. */
  64224. _inputPostProcess: Nullable<PostProcess>;
  64225. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64226. }
  64227. }
  64228. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  64229. /** @hidden */
  64230. export var bloomMergePixelShader: {
  64231. name: string;
  64232. shader: string;
  64233. };
  64234. }
  64235. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  64236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64237. import { Nullable } from "babylonjs/types";
  64238. import { Engine } from "babylonjs/Engines/engine";
  64239. import { Camera } from "babylonjs/Cameras/camera";
  64240. import "babylonjs/Shaders/bloomMerge.fragment";
  64241. /**
  64242. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64243. */
  64244. export class BloomMergePostProcess extends PostProcess {
  64245. /** Weight of the bloom to be added to the original input. */
  64246. weight: number;
  64247. /**
  64248. * Creates a new instance of @see BloomMergePostProcess
  64249. * @param name The name of the effect.
  64250. * @param originalFromInput Post process which's input will be used for the merge.
  64251. * @param blurred Blurred highlights post process which's output will be used.
  64252. * @param weight Weight of the bloom to be added to the original input.
  64253. * @param options The required width/height ratio to downsize to before computing the render pass.
  64254. * @param camera The camera to apply the render pass to.
  64255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64256. * @param engine The engine which the post process will be applied. (default: current engine)
  64257. * @param reusable If the post process can be reused on the same frame. (default: false)
  64258. * @param textureType Type of textures used when performing the post process. (default: 0)
  64259. * @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)
  64260. */
  64261. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64262. /** Weight of the bloom to be added to the original input. */
  64263. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64264. }
  64265. }
  64266. declare module "babylonjs/PostProcesses/bloomEffect" {
  64267. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64268. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64269. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64270. import { Camera } from "babylonjs/Cameras/camera";
  64271. import { Scene } from "babylonjs/scene";
  64272. /**
  64273. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64274. */
  64275. export class BloomEffect extends PostProcessRenderEffect {
  64276. private bloomScale;
  64277. /**
  64278. * @hidden Internal
  64279. */
  64280. _effects: Array<PostProcess>;
  64281. /**
  64282. * @hidden Internal
  64283. */
  64284. _downscale: ExtractHighlightsPostProcess;
  64285. private _blurX;
  64286. private _blurY;
  64287. private _merge;
  64288. /**
  64289. * The luminance threshold to find bright areas of the image to bloom.
  64290. */
  64291. threshold: number;
  64292. /**
  64293. * The strength of the bloom.
  64294. */
  64295. weight: number;
  64296. /**
  64297. * Specifies the size of the bloom blur kernel, relative to the final output size
  64298. */
  64299. kernel: number;
  64300. /**
  64301. * Creates a new instance of @see BloomEffect
  64302. * @param scene The scene the effect belongs to.
  64303. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64304. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64305. * @param bloomWeight The the strength of bloom.
  64306. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64307. * @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)
  64308. */
  64309. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64310. /**
  64311. * Disposes each of the internal effects for a given camera.
  64312. * @param camera The camera to dispose the effect on.
  64313. */
  64314. disposeEffects(camera: Camera): void;
  64315. /**
  64316. * @hidden Internal
  64317. */
  64318. _updateEffects(): void;
  64319. /**
  64320. * Internal
  64321. * @returns if all the contained post processes are ready.
  64322. * @hidden
  64323. */
  64324. _isReady(): boolean;
  64325. }
  64326. }
  64327. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  64328. /** @hidden */
  64329. export var chromaticAberrationPixelShader: {
  64330. name: string;
  64331. shader: string;
  64332. };
  64333. }
  64334. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  64335. import { Vector2 } from "babylonjs/Maths/math.vector";
  64336. import { Nullable } from "babylonjs/types";
  64337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64338. import { Camera } from "babylonjs/Cameras/camera";
  64339. import { Engine } from "babylonjs/Engines/engine";
  64340. import "babylonjs/Shaders/chromaticAberration.fragment";
  64341. /**
  64342. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64343. */
  64344. export class ChromaticAberrationPostProcess extends PostProcess {
  64345. /**
  64346. * The amount of seperation of rgb channels (default: 30)
  64347. */
  64348. aberrationAmount: number;
  64349. /**
  64350. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64351. */
  64352. radialIntensity: number;
  64353. /**
  64354. * 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))
  64355. */
  64356. direction: Vector2;
  64357. /**
  64358. * 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))
  64359. */
  64360. centerPosition: Vector2;
  64361. /**
  64362. * Creates a new instance ChromaticAberrationPostProcess
  64363. * @param name The name of the effect.
  64364. * @param screenWidth The width of the screen to apply the effect on.
  64365. * @param screenHeight The height of the screen to apply the effect on.
  64366. * @param options The required width/height ratio to downsize to before computing the render pass.
  64367. * @param camera The camera to apply the render pass to.
  64368. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64369. * @param engine The engine which the post process will be applied. (default: current engine)
  64370. * @param reusable If the post process can be reused on the same frame. (default: false)
  64371. * @param textureType Type of textures used when performing the post process. (default: 0)
  64372. * @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)
  64373. */
  64374. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64375. }
  64376. }
  64377. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  64378. /** @hidden */
  64379. export var circleOfConfusionPixelShader: {
  64380. name: string;
  64381. shader: string;
  64382. };
  64383. }
  64384. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  64385. import { Nullable } from "babylonjs/types";
  64386. import { Engine } from "babylonjs/Engines/engine";
  64387. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64389. import { Camera } from "babylonjs/Cameras/camera";
  64390. import "babylonjs/Shaders/circleOfConfusion.fragment";
  64391. /**
  64392. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64393. */
  64394. export class CircleOfConfusionPostProcess extends PostProcess {
  64395. /**
  64396. * 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.
  64397. */
  64398. lensSize: number;
  64399. /**
  64400. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64401. */
  64402. fStop: number;
  64403. /**
  64404. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64405. */
  64406. focusDistance: number;
  64407. /**
  64408. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64409. */
  64410. focalLength: number;
  64411. private _depthTexture;
  64412. /**
  64413. * Creates a new instance CircleOfConfusionPostProcess
  64414. * @param name The name of the effect.
  64415. * @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.
  64416. * @param options The required width/height ratio to downsize to before computing the render pass.
  64417. * @param camera The camera to apply the render pass to.
  64418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64419. * @param engine The engine which the post process will be applied. (default: current engine)
  64420. * @param reusable If the post process can be reused on the same frame. (default: false)
  64421. * @param textureType Type of textures used when performing the post process. (default: 0)
  64422. * @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)
  64423. */
  64424. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64425. /**
  64426. * 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.
  64427. */
  64428. depthTexture: RenderTargetTexture;
  64429. }
  64430. }
  64431. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  64432. /** @hidden */
  64433. export var colorCorrectionPixelShader: {
  64434. name: string;
  64435. shader: string;
  64436. };
  64437. }
  64438. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  64439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64440. import { Engine } from "babylonjs/Engines/engine";
  64441. import { Camera } from "babylonjs/Cameras/camera";
  64442. import "babylonjs/Shaders/colorCorrection.fragment";
  64443. /**
  64444. *
  64445. * This post-process allows the modification of rendered colors by using
  64446. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64447. *
  64448. * The object needs to be provided an url to a texture containing the color
  64449. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64450. * Use an image editing software to tweak the LUT to match your needs.
  64451. *
  64452. * For an example of a color LUT, see here:
  64453. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64454. * For explanations on color grading, see here:
  64455. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64456. *
  64457. */
  64458. export class ColorCorrectionPostProcess extends PostProcess {
  64459. private _colorTableTexture;
  64460. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64461. }
  64462. }
  64463. declare module "babylonjs/Shaders/convolution.fragment" {
  64464. /** @hidden */
  64465. export var convolutionPixelShader: {
  64466. name: string;
  64467. shader: string;
  64468. };
  64469. }
  64470. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  64471. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64472. import { Nullable } from "babylonjs/types";
  64473. import { Camera } from "babylonjs/Cameras/camera";
  64474. import { Engine } from "babylonjs/Engines/engine";
  64475. import "babylonjs/Shaders/convolution.fragment";
  64476. /**
  64477. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64478. * input texture to perform effects such as edge detection or sharpening
  64479. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64480. */
  64481. export class ConvolutionPostProcess extends PostProcess {
  64482. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64483. kernel: number[];
  64484. /**
  64485. * Creates a new instance ConvolutionPostProcess
  64486. * @param name The name of the effect.
  64487. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64488. * @param options The required width/height ratio to downsize to before computing the render pass.
  64489. * @param camera The camera to apply the render pass to.
  64490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64491. * @param engine The engine which the post process will be applied. (default: current engine)
  64492. * @param reusable If the post process can be reused on the same frame. (default: false)
  64493. * @param textureType Type of textures used when performing the post process. (default: 0)
  64494. */
  64495. constructor(name: string,
  64496. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64497. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64498. /**
  64499. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64500. */
  64501. static EdgeDetect0Kernel: number[];
  64502. /**
  64503. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64504. */
  64505. static EdgeDetect1Kernel: number[];
  64506. /**
  64507. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64508. */
  64509. static EdgeDetect2Kernel: number[];
  64510. /**
  64511. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64512. */
  64513. static SharpenKernel: number[];
  64514. /**
  64515. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64516. */
  64517. static EmbossKernel: number[];
  64518. /**
  64519. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64520. */
  64521. static GaussianKernel: number[];
  64522. }
  64523. }
  64524. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  64525. import { Nullable } from "babylonjs/types";
  64526. import { Vector2 } from "babylonjs/Maths/math.vector";
  64527. import { Camera } from "babylonjs/Cameras/camera";
  64528. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64529. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64530. import { Engine } from "babylonjs/Engines/engine";
  64531. import { Scene } from "babylonjs/scene";
  64532. /**
  64533. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64534. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64535. * based on samples that have a large difference in distance than the center pixel.
  64536. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64537. */
  64538. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64539. direction: Vector2;
  64540. /**
  64541. * Creates a new instance CircleOfConfusionPostProcess
  64542. * @param name The name of the effect.
  64543. * @param scene The scene the effect belongs to.
  64544. * @param direction The direction the blur should be applied.
  64545. * @param kernel The size of the kernel used to blur.
  64546. * @param options The required width/height ratio to downsize to before computing the render pass.
  64547. * @param camera The camera to apply the render pass to.
  64548. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64549. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64551. * @param engine The engine which the post process will be applied. (default: current engine)
  64552. * @param reusable If the post process can be reused on the same frame. (default: false)
  64553. * @param textureType Type of textures used when performing the post process. (default: 0)
  64554. * @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)
  64555. */
  64556. 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);
  64557. }
  64558. }
  64559. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  64560. /** @hidden */
  64561. export var depthOfFieldMergePixelShader: {
  64562. name: string;
  64563. shader: string;
  64564. };
  64565. }
  64566. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  64567. import { Nullable } from "babylonjs/types";
  64568. import { Camera } from "babylonjs/Cameras/camera";
  64569. import { Effect } from "babylonjs/Materials/effect";
  64570. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64571. import { Engine } from "babylonjs/Engines/engine";
  64572. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  64573. /**
  64574. * Options to be set when merging outputs from the default pipeline.
  64575. */
  64576. export class DepthOfFieldMergePostProcessOptions {
  64577. /**
  64578. * The original image to merge on top of
  64579. */
  64580. originalFromInput: PostProcess;
  64581. /**
  64582. * Parameters to perform the merge of the depth of field effect
  64583. */
  64584. depthOfField?: {
  64585. circleOfConfusion: PostProcess;
  64586. blurSteps: Array<PostProcess>;
  64587. };
  64588. /**
  64589. * Parameters to perform the merge of bloom effect
  64590. */
  64591. bloom?: {
  64592. blurred: PostProcess;
  64593. weight: number;
  64594. };
  64595. }
  64596. /**
  64597. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64598. */
  64599. export class DepthOfFieldMergePostProcess extends PostProcess {
  64600. private blurSteps;
  64601. /**
  64602. * Creates a new instance of DepthOfFieldMergePostProcess
  64603. * @param name The name of the effect.
  64604. * @param originalFromInput Post process which's input will be used for the merge.
  64605. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64606. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64607. * @param options The required width/height ratio to downsize to before computing the render pass.
  64608. * @param camera The camera to apply the render pass to.
  64609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64610. * @param engine The engine which the post process will be applied. (default: current engine)
  64611. * @param reusable If the post process can be reused on the same frame. (default: false)
  64612. * @param textureType Type of textures used when performing the post process. (default: 0)
  64613. * @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)
  64614. */
  64615. 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);
  64616. /**
  64617. * Updates the effect with the current post process compile time values and recompiles the shader.
  64618. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64619. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64620. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64621. * @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
  64622. * @param onCompiled Called when the shader has been compiled.
  64623. * @param onError Called if there is an error when compiling a shader.
  64624. */
  64625. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64626. }
  64627. }
  64628. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  64629. import { Nullable } from "babylonjs/types";
  64630. import { Camera } from "babylonjs/Cameras/camera";
  64631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64632. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64633. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64634. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64635. import { Scene } from "babylonjs/scene";
  64636. /**
  64637. * Specifies the level of max blur that should be applied when using the depth of field effect
  64638. */
  64639. export enum DepthOfFieldEffectBlurLevel {
  64640. /**
  64641. * Subtle blur
  64642. */
  64643. Low = 0,
  64644. /**
  64645. * Medium blur
  64646. */
  64647. Medium = 1,
  64648. /**
  64649. * Large blur
  64650. */
  64651. High = 2
  64652. }
  64653. /**
  64654. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64655. */
  64656. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64657. private _circleOfConfusion;
  64658. /**
  64659. * @hidden Internal, blurs from high to low
  64660. */
  64661. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64662. private _depthOfFieldBlurY;
  64663. private _dofMerge;
  64664. /**
  64665. * @hidden Internal post processes in depth of field effect
  64666. */
  64667. _effects: Array<PostProcess>;
  64668. /**
  64669. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64670. */
  64671. focalLength: number;
  64672. /**
  64673. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64674. */
  64675. fStop: number;
  64676. /**
  64677. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64678. */
  64679. focusDistance: number;
  64680. /**
  64681. * 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.
  64682. */
  64683. lensSize: number;
  64684. /**
  64685. * Creates a new instance DepthOfFieldEffect
  64686. * @param scene The scene the effect belongs to.
  64687. * @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.
  64688. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64689. * @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)
  64690. */
  64691. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64692. /**
  64693. * Get the current class name of the current effet
  64694. * @returns "DepthOfFieldEffect"
  64695. */
  64696. getClassName(): string;
  64697. /**
  64698. * 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.
  64699. */
  64700. depthTexture: RenderTargetTexture;
  64701. /**
  64702. * Disposes each of the internal effects for a given camera.
  64703. * @param camera The camera to dispose the effect on.
  64704. */
  64705. disposeEffects(camera: Camera): void;
  64706. /**
  64707. * @hidden Internal
  64708. */
  64709. _updateEffects(): void;
  64710. /**
  64711. * Internal
  64712. * @returns if all the contained post processes are ready.
  64713. * @hidden
  64714. */
  64715. _isReady(): boolean;
  64716. }
  64717. }
  64718. declare module "babylonjs/Shaders/displayPass.fragment" {
  64719. /** @hidden */
  64720. export var displayPassPixelShader: {
  64721. name: string;
  64722. shader: string;
  64723. };
  64724. }
  64725. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64726. import { Nullable } from "babylonjs/types";
  64727. import { Camera } from "babylonjs/Cameras/camera";
  64728. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64729. import { Engine } from "babylonjs/Engines/engine";
  64730. import "babylonjs/Shaders/displayPass.fragment";
  64731. /**
  64732. * DisplayPassPostProcess which produces an output the same as it's input
  64733. */
  64734. export class DisplayPassPostProcess extends PostProcess {
  64735. /**
  64736. * Creates the DisplayPassPostProcess
  64737. * @param name The name of the effect.
  64738. * @param options The required width/height ratio to downsize to before computing the render pass.
  64739. * @param camera The camera to apply the render pass to.
  64740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64741. * @param engine The engine which the post process will be applied. (default: current engine)
  64742. * @param reusable If the post process can be reused on the same frame. (default: false)
  64743. */
  64744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64745. }
  64746. }
  64747. declare module "babylonjs/Shaders/filter.fragment" {
  64748. /** @hidden */
  64749. export var filterPixelShader: {
  64750. name: string;
  64751. shader: string;
  64752. };
  64753. }
  64754. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64755. import { Nullable } from "babylonjs/types";
  64756. import { Matrix } from "babylonjs/Maths/math.vector";
  64757. import { Camera } from "babylonjs/Cameras/camera";
  64758. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64759. import { Engine } from "babylonjs/Engines/engine";
  64760. import "babylonjs/Shaders/filter.fragment";
  64761. /**
  64762. * Applies a kernel filter to the image
  64763. */
  64764. export class FilterPostProcess extends PostProcess {
  64765. /** The matrix to be applied to the image */
  64766. kernelMatrix: Matrix;
  64767. /**
  64768. *
  64769. * @param name The name of the effect.
  64770. * @param kernelMatrix The matrix to be applied to the image
  64771. * @param options The required width/height ratio to downsize to before computing the render pass.
  64772. * @param camera The camera to apply the render pass to.
  64773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64774. * @param engine The engine which the post process will be applied. (default: current engine)
  64775. * @param reusable If the post process can be reused on the same frame. (default: false)
  64776. */
  64777. constructor(name: string,
  64778. /** The matrix to be applied to the image */
  64779. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64780. }
  64781. }
  64782. declare module "babylonjs/Shaders/fxaa.fragment" {
  64783. /** @hidden */
  64784. export var fxaaPixelShader: {
  64785. name: string;
  64786. shader: string;
  64787. };
  64788. }
  64789. declare module "babylonjs/Shaders/fxaa.vertex" {
  64790. /** @hidden */
  64791. export var fxaaVertexShader: {
  64792. name: string;
  64793. shader: string;
  64794. };
  64795. }
  64796. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64797. import { Nullable } from "babylonjs/types";
  64798. import { Camera } from "babylonjs/Cameras/camera";
  64799. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64800. import { Engine } from "babylonjs/Engines/engine";
  64801. import "babylonjs/Shaders/fxaa.fragment";
  64802. import "babylonjs/Shaders/fxaa.vertex";
  64803. /**
  64804. * Fxaa post process
  64805. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64806. */
  64807. export class FxaaPostProcess extends PostProcess {
  64808. /** @hidden */
  64809. texelWidth: number;
  64810. /** @hidden */
  64811. texelHeight: number;
  64812. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64813. private _getDefines;
  64814. }
  64815. }
  64816. declare module "babylonjs/Shaders/grain.fragment" {
  64817. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64818. /** @hidden */
  64819. export var grainPixelShader: {
  64820. name: string;
  64821. shader: string;
  64822. };
  64823. }
  64824. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64825. import { Nullable } from "babylonjs/types";
  64826. import { Camera } from "babylonjs/Cameras/camera";
  64827. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64828. import { Engine } from "babylonjs/Engines/engine";
  64829. import "babylonjs/Shaders/grain.fragment";
  64830. /**
  64831. * The GrainPostProcess adds noise to the image at mid luminance levels
  64832. */
  64833. export class GrainPostProcess extends PostProcess {
  64834. /**
  64835. * The intensity of the grain added (default: 30)
  64836. */
  64837. intensity: number;
  64838. /**
  64839. * If the grain should be randomized on every frame
  64840. */
  64841. animated: boolean;
  64842. /**
  64843. * Creates a new instance of @see GrainPostProcess
  64844. * @param name The name of the effect.
  64845. * @param options The required width/height ratio to downsize to before computing the render pass.
  64846. * @param camera The camera to apply the render pass to.
  64847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64848. * @param engine The engine which the post process will be applied. (default: current engine)
  64849. * @param reusable If the post process can be reused on the same frame. (default: false)
  64850. * @param textureType Type of textures used when performing the post process. (default: 0)
  64851. * @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)
  64852. */
  64853. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64854. }
  64855. }
  64856. declare module "babylonjs/Shaders/highlights.fragment" {
  64857. /** @hidden */
  64858. export var highlightsPixelShader: {
  64859. name: string;
  64860. shader: string;
  64861. };
  64862. }
  64863. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64864. import { Nullable } from "babylonjs/types";
  64865. import { Camera } from "babylonjs/Cameras/camera";
  64866. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64867. import { Engine } from "babylonjs/Engines/engine";
  64868. import "babylonjs/Shaders/highlights.fragment";
  64869. /**
  64870. * Extracts highlights from the image
  64871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64872. */
  64873. export class HighlightsPostProcess extends PostProcess {
  64874. /**
  64875. * Extracts highlights from the image
  64876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64877. * @param name The name of the effect.
  64878. * @param options The required width/height ratio to downsize to before computing the render pass.
  64879. * @param camera The camera to apply the render pass to.
  64880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64881. * @param engine The engine which the post process will be applied. (default: current engine)
  64882. * @param reusable If the post process can be reused on the same frame. (default: false)
  64883. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64884. */
  64885. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64886. }
  64887. }
  64888. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64889. /** @hidden */
  64890. export var mrtFragmentDeclaration: {
  64891. name: string;
  64892. shader: string;
  64893. };
  64894. }
  64895. declare module "babylonjs/Shaders/geometry.fragment" {
  64896. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64897. /** @hidden */
  64898. export var geometryPixelShader: {
  64899. name: string;
  64900. shader: string;
  64901. };
  64902. }
  64903. declare module "babylonjs/Shaders/geometry.vertex" {
  64904. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64905. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64907. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64909. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64910. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64911. /** @hidden */
  64912. export var geometryVertexShader: {
  64913. name: string;
  64914. shader: string;
  64915. };
  64916. }
  64917. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64918. import { Matrix } from "babylonjs/Maths/math.vector";
  64919. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64920. import { Mesh } from "babylonjs/Meshes/mesh";
  64921. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64922. import { Effect } from "babylonjs/Materials/effect";
  64923. import { Scene } from "babylonjs/scene";
  64924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64925. import "babylonjs/Shaders/geometry.fragment";
  64926. import "babylonjs/Shaders/geometry.vertex";
  64927. /** @hidden */
  64928. interface ISavedTransformationMatrix {
  64929. world: Matrix;
  64930. viewProjection: Matrix;
  64931. }
  64932. /**
  64933. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64934. */
  64935. export class GeometryBufferRenderer {
  64936. /**
  64937. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64938. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64939. */
  64940. static readonly POSITION_TEXTURE_TYPE: number;
  64941. /**
  64942. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64943. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64944. */
  64945. static readonly VELOCITY_TEXTURE_TYPE: number;
  64946. /**
  64947. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64948. * in order to compute objects velocities when enableVelocity is set to "true"
  64949. * @hidden
  64950. */
  64951. _previousTransformationMatrices: {
  64952. [index: number]: ISavedTransformationMatrix;
  64953. };
  64954. /**
  64955. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64956. * in order to compute objects velocities when enableVelocity is set to "true"
  64957. * @hidden
  64958. */
  64959. _previousBonesTransformationMatrices: {
  64960. [index: number]: Float32Array;
  64961. };
  64962. /**
  64963. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64964. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64965. */
  64966. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64967. private _scene;
  64968. private _multiRenderTarget;
  64969. private _ratio;
  64970. private _enablePosition;
  64971. private _enableVelocity;
  64972. private _positionIndex;
  64973. private _velocityIndex;
  64974. protected _effect: Effect;
  64975. protected _cachedDefines: string;
  64976. /**
  64977. * Set the render list (meshes to be rendered) used in the G buffer.
  64978. */
  64979. renderList: Mesh[];
  64980. /**
  64981. * Gets wether or not G buffer are supported by the running hardware.
  64982. * This requires draw buffer supports
  64983. */
  64984. readonly isSupported: boolean;
  64985. /**
  64986. * Returns the index of the given texture type in the G-Buffer textures array
  64987. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64988. * @returns the index of the given texture type in the G-Buffer textures array
  64989. */
  64990. getTextureIndex(textureType: number): number;
  64991. /**
  64992. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64993. */
  64994. /**
  64995. * Sets whether or not objects positions are enabled for the G buffer.
  64996. */
  64997. enablePosition: boolean;
  64998. /**
  64999. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65000. */
  65001. /**
  65002. * Sets wether or not objects velocities are enabled for the G buffer.
  65003. */
  65004. enableVelocity: boolean;
  65005. /**
  65006. * Gets the scene associated with the buffer.
  65007. */
  65008. readonly scene: Scene;
  65009. /**
  65010. * Gets the ratio used by the buffer during its creation.
  65011. * How big is the buffer related to the main canvas.
  65012. */
  65013. readonly ratio: number;
  65014. /** @hidden */
  65015. static _SceneComponentInitialization: (scene: Scene) => void;
  65016. /**
  65017. * Creates a new G Buffer for the scene
  65018. * @param scene The scene the buffer belongs to
  65019. * @param ratio How big is the buffer related to the main canvas.
  65020. */
  65021. constructor(scene: Scene, ratio?: number);
  65022. /**
  65023. * Checks wether everything is ready to render a submesh to the G buffer.
  65024. * @param subMesh the submesh to check readiness for
  65025. * @param useInstances is the mesh drawn using instance or not
  65026. * @returns true if ready otherwise false
  65027. */
  65028. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65029. /**
  65030. * Gets the current underlying G Buffer.
  65031. * @returns the buffer
  65032. */
  65033. getGBuffer(): MultiRenderTarget;
  65034. /**
  65035. * Gets the number of samples used to render the buffer (anti aliasing).
  65036. */
  65037. /**
  65038. * Sets the number of samples used to render the buffer (anti aliasing).
  65039. */
  65040. samples: number;
  65041. /**
  65042. * Disposes the renderer and frees up associated resources.
  65043. */
  65044. dispose(): void;
  65045. protected _createRenderTargets(): void;
  65046. private _copyBonesTransformationMatrices;
  65047. }
  65048. }
  65049. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  65050. import { Nullable } from "babylonjs/types";
  65051. import { Scene } from "babylonjs/scene";
  65052. import { ISceneComponent } from "babylonjs/sceneComponent";
  65053. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  65054. module "babylonjs/scene" {
  65055. interface Scene {
  65056. /** @hidden (Backing field) */
  65057. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65058. /**
  65059. * Gets or Sets the current geometry buffer associated to the scene.
  65060. */
  65061. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65062. /**
  65063. * Enables a GeometryBufferRender and associates it with the scene
  65064. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65065. * @returns the GeometryBufferRenderer
  65066. */
  65067. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65068. /**
  65069. * Disables the GeometryBufferRender associated with the scene
  65070. */
  65071. disableGeometryBufferRenderer(): void;
  65072. }
  65073. }
  65074. /**
  65075. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65076. * in several rendering techniques.
  65077. */
  65078. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65079. /**
  65080. * The component name helpful to identify the component in the list of scene components.
  65081. */
  65082. readonly name: string;
  65083. /**
  65084. * The scene the component belongs to.
  65085. */
  65086. scene: Scene;
  65087. /**
  65088. * Creates a new instance of the component for the given scene
  65089. * @param scene Defines the scene to register the component in
  65090. */
  65091. constructor(scene: Scene);
  65092. /**
  65093. * Registers the component in a given scene
  65094. */
  65095. register(): void;
  65096. /**
  65097. * Rebuilds the elements related to this component in case of
  65098. * context lost for instance.
  65099. */
  65100. rebuild(): void;
  65101. /**
  65102. * Disposes the component and the associated ressources
  65103. */
  65104. dispose(): void;
  65105. private _gatherRenderTargets;
  65106. }
  65107. }
  65108. declare module "babylonjs/Shaders/motionBlur.fragment" {
  65109. /** @hidden */
  65110. export var motionBlurPixelShader: {
  65111. name: string;
  65112. shader: string;
  65113. };
  65114. }
  65115. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  65116. import { Nullable } from "babylonjs/types";
  65117. import { Camera } from "babylonjs/Cameras/camera";
  65118. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65119. import { Scene } from "babylonjs/scene";
  65120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65121. import "babylonjs/Animations/animatable";
  65122. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  65123. import "babylonjs/Shaders/motionBlur.fragment";
  65124. import { Engine } from "babylonjs/Engines/engine";
  65125. /**
  65126. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65127. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65128. * As an example, all you have to do is to create the post-process:
  65129. * var mb = new BABYLON.MotionBlurPostProcess(
  65130. * 'mb', // The name of the effect.
  65131. * scene, // The scene containing the objects to blur according to their velocity.
  65132. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65133. * camera // The camera to apply the render pass to.
  65134. * );
  65135. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65136. */
  65137. export class MotionBlurPostProcess extends PostProcess {
  65138. /**
  65139. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65140. */
  65141. motionStrength: number;
  65142. /**
  65143. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65144. */
  65145. /**
  65146. * Sets the number of iterations to be used for motion blur quality
  65147. */
  65148. motionBlurSamples: number;
  65149. private _motionBlurSamples;
  65150. private _geometryBufferRenderer;
  65151. /**
  65152. * Creates a new instance MotionBlurPostProcess
  65153. * @param name The name of the effect.
  65154. * @param scene The scene containing the objects to blur according to their velocity.
  65155. * @param options The required width/height ratio to downsize to before computing the render pass.
  65156. * @param camera The camera to apply the render pass to.
  65157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65158. * @param engine The engine which the post process will be applied. (default: current engine)
  65159. * @param reusable If the post process can be reused on the same frame. (default: false)
  65160. * @param textureType Type of textures used when performing the post process. (default: 0)
  65161. * @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)
  65162. */
  65163. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65164. /**
  65165. * Excludes the given skinned mesh from computing bones velocities.
  65166. * 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.
  65167. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65168. */
  65169. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65170. /**
  65171. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65172. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65173. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65174. */
  65175. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65176. /**
  65177. * Disposes the post process.
  65178. * @param camera The camera to dispose the post process on.
  65179. */
  65180. dispose(camera?: Camera): void;
  65181. }
  65182. }
  65183. declare module "babylonjs/Shaders/refraction.fragment" {
  65184. /** @hidden */
  65185. export var refractionPixelShader: {
  65186. name: string;
  65187. shader: string;
  65188. };
  65189. }
  65190. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  65191. import { Color3 } from "babylonjs/Maths/math.color";
  65192. import { Camera } from "babylonjs/Cameras/camera";
  65193. import { Texture } from "babylonjs/Materials/Textures/texture";
  65194. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65195. import { Engine } from "babylonjs/Engines/engine";
  65196. import "babylonjs/Shaders/refraction.fragment";
  65197. /**
  65198. * Post process which applies a refractin texture
  65199. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65200. */
  65201. export class RefractionPostProcess extends PostProcess {
  65202. /** the base color of the refraction (used to taint the rendering) */
  65203. color: Color3;
  65204. /** simulated refraction depth */
  65205. depth: number;
  65206. /** the coefficient of the base color (0 to remove base color tainting) */
  65207. colorLevel: number;
  65208. private _refTexture;
  65209. private _ownRefractionTexture;
  65210. /**
  65211. * Gets or sets the refraction texture
  65212. * Please note that you are responsible for disposing the texture if you set it manually
  65213. */
  65214. refractionTexture: Texture;
  65215. /**
  65216. * Initializes the RefractionPostProcess
  65217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65218. * @param name The name of the effect.
  65219. * @param refractionTextureUrl Url of the refraction texture to use
  65220. * @param color the base color of the refraction (used to taint the rendering)
  65221. * @param depth simulated refraction depth
  65222. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65223. * @param camera The camera to apply the render pass to.
  65224. * @param options The required width/height ratio to downsize to before computing the render pass.
  65225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65226. * @param engine The engine which the post process will be applied. (default: current engine)
  65227. * @param reusable If the post process can be reused on the same frame. (default: false)
  65228. */
  65229. constructor(name: string, refractionTextureUrl: string,
  65230. /** the base color of the refraction (used to taint the rendering) */
  65231. color: Color3,
  65232. /** simulated refraction depth */
  65233. depth: number,
  65234. /** the coefficient of the base color (0 to remove base color tainting) */
  65235. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65236. /**
  65237. * Disposes of the post process
  65238. * @param camera Camera to dispose post process on
  65239. */
  65240. dispose(camera: Camera): void;
  65241. }
  65242. }
  65243. declare module "babylonjs/Shaders/sharpen.fragment" {
  65244. /** @hidden */
  65245. export var sharpenPixelShader: {
  65246. name: string;
  65247. shader: string;
  65248. };
  65249. }
  65250. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  65251. import { Nullable } from "babylonjs/types";
  65252. import { Camera } from "babylonjs/Cameras/camera";
  65253. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65254. import "babylonjs/Shaders/sharpen.fragment";
  65255. import { Engine } from "babylonjs/Engines/engine";
  65256. /**
  65257. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65258. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65259. */
  65260. export class SharpenPostProcess extends PostProcess {
  65261. /**
  65262. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65263. */
  65264. colorAmount: number;
  65265. /**
  65266. * How much sharpness should be applied (default: 0.3)
  65267. */
  65268. edgeAmount: number;
  65269. /**
  65270. * Creates a new instance ConvolutionPostProcess
  65271. * @param name The name of the effect.
  65272. * @param options The required width/height ratio to downsize to before computing the render pass.
  65273. * @param camera The camera to apply the render pass to.
  65274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65275. * @param engine The engine which the post process will be applied. (default: current engine)
  65276. * @param reusable If the post process can be reused on the same frame. (default: false)
  65277. * @param textureType Type of textures used when performing the post process. (default: 0)
  65278. * @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)
  65279. */
  65280. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65281. }
  65282. }
  65283. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  65284. import { Nullable } from "babylonjs/types";
  65285. import { Camera } from "babylonjs/Cameras/camera";
  65286. import { Engine } from "babylonjs/Engines/engine";
  65287. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65288. import { IInspectable } from "babylonjs/Misc/iInspectable";
  65289. /**
  65290. * PostProcessRenderPipeline
  65291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65292. */
  65293. export class PostProcessRenderPipeline {
  65294. private engine;
  65295. private _renderEffects;
  65296. private _renderEffectsForIsolatedPass;
  65297. /**
  65298. * List of inspectable custom properties (used by the Inspector)
  65299. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65300. */
  65301. inspectableCustomProperties: IInspectable[];
  65302. /**
  65303. * @hidden
  65304. */
  65305. protected _cameras: Camera[];
  65306. /** @hidden */
  65307. _name: string;
  65308. /**
  65309. * Gets pipeline name
  65310. */
  65311. readonly name: string;
  65312. /** Gets the list of attached cameras */
  65313. readonly cameras: Camera[];
  65314. /**
  65315. * Initializes a PostProcessRenderPipeline
  65316. * @param engine engine to add the pipeline to
  65317. * @param name name of the pipeline
  65318. */
  65319. constructor(engine: Engine, name: string);
  65320. /**
  65321. * Gets the class name
  65322. * @returns "PostProcessRenderPipeline"
  65323. */
  65324. getClassName(): string;
  65325. /**
  65326. * If all the render effects in the pipeline are supported
  65327. */
  65328. readonly isSupported: boolean;
  65329. /**
  65330. * Adds an effect to the pipeline
  65331. * @param renderEffect the effect to add
  65332. */
  65333. addEffect(renderEffect: PostProcessRenderEffect): void;
  65334. /** @hidden */
  65335. _rebuild(): void;
  65336. /** @hidden */
  65337. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65338. /** @hidden */
  65339. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65340. /** @hidden */
  65341. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65342. /** @hidden */
  65343. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65344. /** @hidden */
  65345. _attachCameras(cameras: Camera, unique: boolean): void;
  65346. /** @hidden */
  65347. _attachCameras(cameras: Camera[], unique: boolean): void;
  65348. /** @hidden */
  65349. _detachCameras(cameras: Camera): void;
  65350. /** @hidden */
  65351. _detachCameras(cameras: Nullable<Camera[]>): void;
  65352. /** @hidden */
  65353. _update(): void;
  65354. /** @hidden */
  65355. _reset(): void;
  65356. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65357. /**
  65358. * Disposes of the pipeline
  65359. */
  65360. dispose(): void;
  65361. }
  65362. }
  65363. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  65364. import { Camera } from "babylonjs/Cameras/camera";
  65365. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65366. /**
  65367. * PostProcessRenderPipelineManager class
  65368. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65369. */
  65370. export class PostProcessRenderPipelineManager {
  65371. private _renderPipelines;
  65372. /**
  65373. * Initializes a PostProcessRenderPipelineManager
  65374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65375. */
  65376. constructor();
  65377. /**
  65378. * Gets the list of supported render pipelines
  65379. */
  65380. readonly supportedPipelines: PostProcessRenderPipeline[];
  65381. /**
  65382. * Adds a pipeline to the manager
  65383. * @param renderPipeline The pipeline to add
  65384. */
  65385. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65386. /**
  65387. * Attaches a camera to the pipeline
  65388. * @param renderPipelineName The name of the pipeline to attach to
  65389. * @param cameras the camera to attach
  65390. * @param unique if the camera can be attached multiple times to the pipeline
  65391. */
  65392. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65393. /**
  65394. * Detaches a camera from the pipeline
  65395. * @param renderPipelineName The name of the pipeline to detach from
  65396. * @param cameras the camera to detach
  65397. */
  65398. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65399. /**
  65400. * Enables an effect by name on a pipeline
  65401. * @param renderPipelineName the name of the pipeline to enable the effect in
  65402. * @param renderEffectName the name of the effect to enable
  65403. * @param cameras the cameras that the effect should be enabled on
  65404. */
  65405. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65406. /**
  65407. * Disables an effect by name on a pipeline
  65408. * @param renderPipelineName the name of the pipeline to disable the effect in
  65409. * @param renderEffectName the name of the effect to disable
  65410. * @param cameras the cameras that the effect should be disabled on
  65411. */
  65412. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65413. /**
  65414. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65415. */
  65416. update(): void;
  65417. /** @hidden */
  65418. _rebuild(): void;
  65419. /**
  65420. * Disposes of the manager and pipelines
  65421. */
  65422. dispose(): void;
  65423. }
  65424. }
  65425. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  65426. import { ISceneComponent } from "babylonjs/sceneComponent";
  65427. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65428. import { Scene } from "babylonjs/scene";
  65429. module "babylonjs/scene" {
  65430. interface Scene {
  65431. /** @hidden (Backing field) */
  65432. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65433. /**
  65434. * Gets the postprocess render pipeline manager
  65435. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65436. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65437. */
  65438. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65439. }
  65440. }
  65441. /**
  65442. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65443. */
  65444. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65445. /**
  65446. * The component name helpfull to identify the component in the list of scene components.
  65447. */
  65448. readonly name: string;
  65449. /**
  65450. * The scene the component belongs to.
  65451. */
  65452. scene: Scene;
  65453. /**
  65454. * Creates a new instance of the component for the given scene
  65455. * @param scene Defines the scene to register the component in
  65456. */
  65457. constructor(scene: Scene);
  65458. /**
  65459. * Registers the component in a given scene
  65460. */
  65461. register(): void;
  65462. /**
  65463. * Rebuilds the elements related to this component in case of
  65464. * context lost for instance.
  65465. */
  65466. rebuild(): void;
  65467. /**
  65468. * Disposes the component and the associated ressources
  65469. */
  65470. dispose(): void;
  65471. private _gatherRenderTargets;
  65472. }
  65473. }
  65474. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  65475. import { Nullable } from "babylonjs/types";
  65476. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65477. import { Camera } from "babylonjs/Cameras/camera";
  65478. import { IDisposable } from "babylonjs/scene";
  65479. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  65480. import { Scene } from "babylonjs/scene";
  65481. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  65482. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  65483. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  65484. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  65485. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65486. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65487. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  65488. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65489. import { Animation } from "babylonjs/Animations/animation";
  65490. /**
  65491. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65492. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65493. */
  65494. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65495. private _scene;
  65496. private _camerasToBeAttached;
  65497. /**
  65498. * ID of the sharpen post process,
  65499. */
  65500. private readonly SharpenPostProcessId;
  65501. /**
  65502. * @ignore
  65503. * ID of the image processing post process;
  65504. */
  65505. readonly ImageProcessingPostProcessId: string;
  65506. /**
  65507. * @ignore
  65508. * ID of the Fast Approximate Anti-Aliasing post process;
  65509. */
  65510. readonly FxaaPostProcessId: string;
  65511. /**
  65512. * ID of the chromatic aberration post process,
  65513. */
  65514. private readonly ChromaticAberrationPostProcessId;
  65515. /**
  65516. * ID of the grain post process
  65517. */
  65518. private readonly GrainPostProcessId;
  65519. /**
  65520. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65521. */
  65522. sharpen: SharpenPostProcess;
  65523. private _sharpenEffect;
  65524. private bloom;
  65525. /**
  65526. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65527. */
  65528. depthOfField: DepthOfFieldEffect;
  65529. /**
  65530. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65531. */
  65532. fxaa: FxaaPostProcess;
  65533. /**
  65534. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65535. */
  65536. imageProcessing: ImageProcessingPostProcess;
  65537. /**
  65538. * Chromatic aberration post process which will shift rgb colors in the image
  65539. */
  65540. chromaticAberration: ChromaticAberrationPostProcess;
  65541. private _chromaticAberrationEffect;
  65542. /**
  65543. * Grain post process which add noise to the image
  65544. */
  65545. grain: GrainPostProcess;
  65546. private _grainEffect;
  65547. /**
  65548. * Glow post process which adds a glow to emissive areas of the image
  65549. */
  65550. private _glowLayer;
  65551. /**
  65552. * Animations which can be used to tweak settings over a period of time
  65553. */
  65554. animations: Animation[];
  65555. private _imageProcessingConfigurationObserver;
  65556. private _sharpenEnabled;
  65557. private _bloomEnabled;
  65558. private _depthOfFieldEnabled;
  65559. private _depthOfFieldBlurLevel;
  65560. private _fxaaEnabled;
  65561. private _imageProcessingEnabled;
  65562. private _defaultPipelineTextureType;
  65563. private _bloomScale;
  65564. private _chromaticAberrationEnabled;
  65565. private _grainEnabled;
  65566. private _buildAllowed;
  65567. /**
  65568. * Gets active scene
  65569. */
  65570. readonly scene: Scene;
  65571. /**
  65572. * Enable or disable the sharpen process from the pipeline
  65573. */
  65574. sharpenEnabled: boolean;
  65575. private _resizeObserver;
  65576. private _hardwareScaleLevel;
  65577. private _bloomKernel;
  65578. /**
  65579. * Specifies the size of the bloom blur kernel, relative to the final output size
  65580. */
  65581. bloomKernel: number;
  65582. /**
  65583. * Specifies the weight of the bloom in the final rendering
  65584. */
  65585. private _bloomWeight;
  65586. /**
  65587. * Specifies the luma threshold for the area that will be blurred by the bloom
  65588. */
  65589. private _bloomThreshold;
  65590. private _hdr;
  65591. /**
  65592. * The strength of the bloom.
  65593. */
  65594. bloomWeight: number;
  65595. /**
  65596. * The strength of the bloom.
  65597. */
  65598. bloomThreshold: number;
  65599. /**
  65600. * The scale of the bloom, lower value will provide better performance.
  65601. */
  65602. bloomScale: number;
  65603. /**
  65604. * Enable or disable the bloom from the pipeline
  65605. */
  65606. bloomEnabled: boolean;
  65607. private _rebuildBloom;
  65608. /**
  65609. * If the depth of field is enabled.
  65610. */
  65611. depthOfFieldEnabled: boolean;
  65612. /**
  65613. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65614. */
  65615. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  65616. /**
  65617. * If the anti aliasing is enabled.
  65618. */
  65619. fxaaEnabled: boolean;
  65620. private _samples;
  65621. /**
  65622. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65623. */
  65624. samples: number;
  65625. /**
  65626. * If image processing is enabled.
  65627. */
  65628. imageProcessingEnabled: boolean;
  65629. /**
  65630. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65631. */
  65632. glowLayerEnabled: boolean;
  65633. /**
  65634. * Gets the glow layer (or null if not defined)
  65635. */
  65636. readonly glowLayer: Nullable<GlowLayer>;
  65637. /**
  65638. * Enable or disable the chromaticAberration process from the pipeline
  65639. */
  65640. chromaticAberrationEnabled: boolean;
  65641. /**
  65642. * Enable or disable the grain process from the pipeline
  65643. */
  65644. grainEnabled: boolean;
  65645. /**
  65646. * @constructor
  65647. * @param name - The rendering pipeline name (default: "")
  65648. * @param hdr - If high dynamic range textures should be used (default: true)
  65649. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65650. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65651. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65652. */
  65653. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65654. /**
  65655. * Get the class name
  65656. * @returns "DefaultRenderingPipeline"
  65657. */
  65658. getClassName(): string;
  65659. /**
  65660. * Force the compilation of the entire pipeline.
  65661. */
  65662. prepare(): void;
  65663. private _hasCleared;
  65664. private _prevPostProcess;
  65665. private _prevPrevPostProcess;
  65666. private _setAutoClearAndTextureSharing;
  65667. private _depthOfFieldSceneObserver;
  65668. private _buildPipeline;
  65669. private _disposePostProcesses;
  65670. /**
  65671. * Adds a camera to the pipeline
  65672. * @param camera the camera to be added
  65673. */
  65674. addCamera(camera: Camera): void;
  65675. /**
  65676. * Removes a camera from the pipeline
  65677. * @param camera the camera to remove
  65678. */
  65679. removeCamera(camera: Camera): void;
  65680. /**
  65681. * Dispose of the pipeline and stop all post processes
  65682. */
  65683. dispose(): void;
  65684. /**
  65685. * Serialize the rendering pipeline (Used when exporting)
  65686. * @returns the serialized object
  65687. */
  65688. serialize(): any;
  65689. /**
  65690. * Parse the serialized pipeline
  65691. * @param source Source pipeline.
  65692. * @param scene The scene to load the pipeline to.
  65693. * @param rootUrl The URL of the serialized pipeline.
  65694. * @returns An instantiated pipeline from the serialized object.
  65695. */
  65696. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65697. }
  65698. }
  65699. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  65700. /** @hidden */
  65701. export var lensHighlightsPixelShader: {
  65702. name: string;
  65703. shader: string;
  65704. };
  65705. }
  65706. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65707. /** @hidden */
  65708. export var depthOfFieldPixelShader: {
  65709. name: string;
  65710. shader: string;
  65711. };
  65712. }
  65713. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65714. import { Camera } from "babylonjs/Cameras/camera";
  65715. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65716. import { Scene } from "babylonjs/scene";
  65717. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65718. import "babylonjs/Shaders/chromaticAberration.fragment";
  65719. import "babylonjs/Shaders/lensHighlights.fragment";
  65720. import "babylonjs/Shaders/depthOfField.fragment";
  65721. /**
  65722. * BABYLON.JS Chromatic Aberration GLSL Shader
  65723. * Author: Olivier Guyot
  65724. * Separates very slightly R, G and B colors on the edges of the screen
  65725. * Inspired by Francois Tarlier & Martins Upitis
  65726. */
  65727. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65728. /**
  65729. * @ignore
  65730. * The chromatic aberration PostProcess id in the pipeline
  65731. */
  65732. LensChromaticAberrationEffect: string;
  65733. /**
  65734. * @ignore
  65735. * The highlights enhancing PostProcess id in the pipeline
  65736. */
  65737. HighlightsEnhancingEffect: string;
  65738. /**
  65739. * @ignore
  65740. * The depth-of-field PostProcess id in the pipeline
  65741. */
  65742. LensDepthOfFieldEffect: string;
  65743. private _scene;
  65744. private _depthTexture;
  65745. private _grainTexture;
  65746. private _chromaticAberrationPostProcess;
  65747. private _highlightsPostProcess;
  65748. private _depthOfFieldPostProcess;
  65749. private _edgeBlur;
  65750. private _grainAmount;
  65751. private _chromaticAberration;
  65752. private _distortion;
  65753. private _highlightsGain;
  65754. private _highlightsThreshold;
  65755. private _dofDistance;
  65756. private _dofAperture;
  65757. private _dofDarken;
  65758. private _dofPentagon;
  65759. private _blurNoise;
  65760. /**
  65761. * @constructor
  65762. *
  65763. * Effect parameters are as follow:
  65764. * {
  65765. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65766. * edge_blur: number; // from 0 to x (1 for realism)
  65767. * distortion: number; // from 0 to x (1 for realism)
  65768. * grain_amount: number; // from 0 to 1
  65769. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65770. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65771. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65772. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65773. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65774. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65775. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65776. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65777. * }
  65778. * Note: if an effect parameter is unset, effect is disabled
  65779. *
  65780. * @param name The rendering pipeline name
  65781. * @param parameters - An object containing all parameters (see above)
  65782. * @param scene The scene linked to this pipeline
  65783. * @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)
  65784. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65785. */
  65786. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65787. /**
  65788. * Get the class name
  65789. * @returns "LensRenderingPipeline"
  65790. */
  65791. getClassName(): string;
  65792. /**
  65793. * Gets associated scene
  65794. */
  65795. readonly scene: Scene;
  65796. /**
  65797. * Gets or sets the edge blur
  65798. */
  65799. edgeBlur: number;
  65800. /**
  65801. * Gets or sets the grain amount
  65802. */
  65803. grainAmount: number;
  65804. /**
  65805. * Gets or sets the chromatic aberration amount
  65806. */
  65807. chromaticAberration: number;
  65808. /**
  65809. * Gets or sets the depth of field aperture
  65810. */
  65811. dofAperture: number;
  65812. /**
  65813. * Gets or sets the edge distortion
  65814. */
  65815. edgeDistortion: number;
  65816. /**
  65817. * Gets or sets the depth of field distortion
  65818. */
  65819. dofDistortion: number;
  65820. /**
  65821. * Gets or sets the darken out of focus amount
  65822. */
  65823. darkenOutOfFocus: number;
  65824. /**
  65825. * Gets or sets a boolean indicating if blur noise is enabled
  65826. */
  65827. blurNoise: boolean;
  65828. /**
  65829. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65830. */
  65831. pentagonBokeh: boolean;
  65832. /**
  65833. * Gets or sets the highlight grain amount
  65834. */
  65835. highlightsGain: number;
  65836. /**
  65837. * Gets or sets the highlight threshold
  65838. */
  65839. highlightsThreshold: number;
  65840. /**
  65841. * Sets the amount of blur at the edges
  65842. * @param amount blur amount
  65843. */
  65844. setEdgeBlur(amount: number): void;
  65845. /**
  65846. * Sets edge blur to 0
  65847. */
  65848. disableEdgeBlur(): void;
  65849. /**
  65850. * Sets the amout of grain
  65851. * @param amount Amount of grain
  65852. */
  65853. setGrainAmount(amount: number): void;
  65854. /**
  65855. * Set grain amount to 0
  65856. */
  65857. disableGrain(): void;
  65858. /**
  65859. * Sets the chromatic aberration amount
  65860. * @param amount amount of chromatic aberration
  65861. */
  65862. setChromaticAberration(amount: number): void;
  65863. /**
  65864. * Sets chromatic aberration amount to 0
  65865. */
  65866. disableChromaticAberration(): void;
  65867. /**
  65868. * Sets the EdgeDistortion amount
  65869. * @param amount amount of EdgeDistortion
  65870. */
  65871. setEdgeDistortion(amount: number): void;
  65872. /**
  65873. * Sets edge distortion to 0
  65874. */
  65875. disableEdgeDistortion(): void;
  65876. /**
  65877. * Sets the FocusDistance amount
  65878. * @param amount amount of FocusDistance
  65879. */
  65880. setFocusDistance(amount: number): void;
  65881. /**
  65882. * Disables depth of field
  65883. */
  65884. disableDepthOfField(): void;
  65885. /**
  65886. * Sets the Aperture amount
  65887. * @param amount amount of Aperture
  65888. */
  65889. setAperture(amount: number): void;
  65890. /**
  65891. * Sets the DarkenOutOfFocus amount
  65892. * @param amount amount of DarkenOutOfFocus
  65893. */
  65894. setDarkenOutOfFocus(amount: number): void;
  65895. private _pentagonBokehIsEnabled;
  65896. /**
  65897. * Creates a pentagon bokeh effect
  65898. */
  65899. enablePentagonBokeh(): void;
  65900. /**
  65901. * Disables the pentagon bokeh effect
  65902. */
  65903. disablePentagonBokeh(): void;
  65904. /**
  65905. * Enables noise blur
  65906. */
  65907. enableNoiseBlur(): void;
  65908. /**
  65909. * Disables noise blur
  65910. */
  65911. disableNoiseBlur(): void;
  65912. /**
  65913. * Sets the HighlightsGain amount
  65914. * @param amount amount of HighlightsGain
  65915. */
  65916. setHighlightsGain(amount: number): void;
  65917. /**
  65918. * Sets the HighlightsThreshold amount
  65919. * @param amount amount of HighlightsThreshold
  65920. */
  65921. setHighlightsThreshold(amount: number): void;
  65922. /**
  65923. * Disables highlights
  65924. */
  65925. disableHighlights(): void;
  65926. /**
  65927. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65928. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65929. */
  65930. dispose(disableDepthRender?: boolean): void;
  65931. private _createChromaticAberrationPostProcess;
  65932. private _createHighlightsPostProcess;
  65933. private _createDepthOfFieldPostProcess;
  65934. private _createGrainTexture;
  65935. }
  65936. }
  65937. declare module "babylonjs/Shaders/ssao2.fragment" {
  65938. /** @hidden */
  65939. export var ssao2PixelShader: {
  65940. name: string;
  65941. shader: string;
  65942. };
  65943. }
  65944. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65945. /** @hidden */
  65946. export var ssaoCombinePixelShader: {
  65947. name: string;
  65948. shader: string;
  65949. };
  65950. }
  65951. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65952. import { Camera } from "babylonjs/Cameras/camera";
  65953. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65954. import { Scene } from "babylonjs/scene";
  65955. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65956. import "babylonjs/Shaders/ssao2.fragment";
  65957. import "babylonjs/Shaders/ssaoCombine.fragment";
  65958. /**
  65959. * Render pipeline to produce ssao effect
  65960. */
  65961. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65962. /**
  65963. * @ignore
  65964. * The PassPostProcess id in the pipeline that contains the original scene color
  65965. */
  65966. SSAOOriginalSceneColorEffect: string;
  65967. /**
  65968. * @ignore
  65969. * The SSAO PostProcess id in the pipeline
  65970. */
  65971. SSAORenderEffect: string;
  65972. /**
  65973. * @ignore
  65974. * The horizontal blur PostProcess id in the pipeline
  65975. */
  65976. SSAOBlurHRenderEffect: string;
  65977. /**
  65978. * @ignore
  65979. * The vertical blur PostProcess id in the pipeline
  65980. */
  65981. SSAOBlurVRenderEffect: string;
  65982. /**
  65983. * @ignore
  65984. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65985. */
  65986. SSAOCombineRenderEffect: string;
  65987. /**
  65988. * The output strength of the SSAO post-process. Default value is 1.0.
  65989. */
  65990. totalStrength: number;
  65991. /**
  65992. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65993. */
  65994. maxZ: number;
  65995. /**
  65996. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65997. */
  65998. minZAspect: number;
  65999. private _samples;
  66000. /**
  66001. * Number of samples used for the SSAO calculations. Default value is 8
  66002. */
  66003. samples: number;
  66004. private _textureSamples;
  66005. /**
  66006. * Number of samples to use for antialiasing
  66007. */
  66008. textureSamples: number;
  66009. /**
  66010. * Ratio object used for SSAO ratio and blur ratio
  66011. */
  66012. private _ratio;
  66013. /**
  66014. * Dynamically generated sphere sampler.
  66015. */
  66016. private _sampleSphere;
  66017. /**
  66018. * Blur filter offsets
  66019. */
  66020. private _samplerOffsets;
  66021. private _expensiveBlur;
  66022. /**
  66023. * If bilateral blur should be used
  66024. */
  66025. expensiveBlur: boolean;
  66026. /**
  66027. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66028. */
  66029. radius: number;
  66030. /**
  66031. * The base color of the SSAO post-process
  66032. * The final result is "base + ssao" between [0, 1]
  66033. */
  66034. base: number;
  66035. /**
  66036. * Support test.
  66037. */
  66038. static readonly IsSupported: boolean;
  66039. private _scene;
  66040. private _depthTexture;
  66041. private _normalTexture;
  66042. private _randomTexture;
  66043. private _originalColorPostProcess;
  66044. private _ssaoPostProcess;
  66045. private _blurHPostProcess;
  66046. private _blurVPostProcess;
  66047. private _ssaoCombinePostProcess;
  66048. /**
  66049. * Gets active scene
  66050. */
  66051. readonly scene: Scene;
  66052. /**
  66053. * @constructor
  66054. * @param name The rendering pipeline name
  66055. * @param scene The scene linked to this pipeline
  66056. * @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 }
  66057. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66058. */
  66059. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66060. /**
  66061. * Get the class name
  66062. * @returns "SSAO2RenderingPipeline"
  66063. */
  66064. getClassName(): string;
  66065. /**
  66066. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66067. */
  66068. dispose(disableGeometryBufferRenderer?: boolean): void;
  66069. private _createBlurPostProcess;
  66070. /** @hidden */
  66071. _rebuild(): void;
  66072. private _bits;
  66073. private _radicalInverse_VdC;
  66074. private _hammersley;
  66075. private _hemisphereSample_uniform;
  66076. private _generateHemisphere;
  66077. private _createSSAOPostProcess;
  66078. private _createSSAOCombinePostProcess;
  66079. private _createRandomTexture;
  66080. /**
  66081. * Serialize the rendering pipeline (Used when exporting)
  66082. * @returns the serialized object
  66083. */
  66084. serialize(): any;
  66085. /**
  66086. * Parse the serialized pipeline
  66087. * @param source Source pipeline.
  66088. * @param scene The scene to load the pipeline to.
  66089. * @param rootUrl The URL of the serialized pipeline.
  66090. * @returns An instantiated pipeline from the serialized object.
  66091. */
  66092. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66093. }
  66094. }
  66095. declare module "babylonjs/Shaders/ssao.fragment" {
  66096. /** @hidden */
  66097. export var ssaoPixelShader: {
  66098. name: string;
  66099. shader: string;
  66100. };
  66101. }
  66102. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  66103. import { Camera } from "babylonjs/Cameras/camera";
  66104. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66105. import { Scene } from "babylonjs/scene";
  66106. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66107. import "babylonjs/Shaders/ssao.fragment";
  66108. import "babylonjs/Shaders/ssaoCombine.fragment";
  66109. /**
  66110. * Render pipeline to produce ssao effect
  66111. */
  66112. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66113. /**
  66114. * @ignore
  66115. * The PassPostProcess id in the pipeline that contains the original scene color
  66116. */
  66117. SSAOOriginalSceneColorEffect: string;
  66118. /**
  66119. * @ignore
  66120. * The SSAO PostProcess id in the pipeline
  66121. */
  66122. SSAORenderEffect: string;
  66123. /**
  66124. * @ignore
  66125. * The horizontal blur PostProcess id in the pipeline
  66126. */
  66127. SSAOBlurHRenderEffect: string;
  66128. /**
  66129. * @ignore
  66130. * The vertical blur PostProcess id in the pipeline
  66131. */
  66132. SSAOBlurVRenderEffect: string;
  66133. /**
  66134. * @ignore
  66135. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66136. */
  66137. SSAOCombineRenderEffect: string;
  66138. /**
  66139. * The output strength of the SSAO post-process. Default value is 1.0.
  66140. */
  66141. totalStrength: number;
  66142. /**
  66143. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66144. */
  66145. radius: number;
  66146. /**
  66147. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66148. * Must not be equal to fallOff and superior to fallOff.
  66149. * Default value is 0.0075
  66150. */
  66151. area: number;
  66152. /**
  66153. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66154. * Must not be equal to area and inferior to area.
  66155. * Default value is 0.000001
  66156. */
  66157. fallOff: number;
  66158. /**
  66159. * The base color of the SSAO post-process
  66160. * The final result is "base + ssao" between [0, 1]
  66161. */
  66162. base: number;
  66163. private _scene;
  66164. private _depthTexture;
  66165. private _randomTexture;
  66166. private _originalColorPostProcess;
  66167. private _ssaoPostProcess;
  66168. private _blurHPostProcess;
  66169. private _blurVPostProcess;
  66170. private _ssaoCombinePostProcess;
  66171. private _firstUpdate;
  66172. /**
  66173. * Gets active scene
  66174. */
  66175. readonly scene: Scene;
  66176. /**
  66177. * @constructor
  66178. * @param name - The rendering pipeline name
  66179. * @param scene - The scene linked to this pipeline
  66180. * @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 }
  66181. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66182. */
  66183. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66184. /**
  66185. * Get the class name
  66186. * @returns "SSAORenderingPipeline"
  66187. */
  66188. getClassName(): string;
  66189. /**
  66190. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66191. */
  66192. dispose(disableDepthRender?: boolean): void;
  66193. private _createBlurPostProcess;
  66194. /** @hidden */
  66195. _rebuild(): void;
  66196. private _createSSAOPostProcess;
  66197. private _createSSAOCombinePostProcess;
  66198. private _createRandomTexture;
  66199. }
  66200. }
  66201. declare module "babylonjs/Shaders/standard.fragment" {
  66202. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66203. /** @hidden */
  66204. export var standardPixelShader: {
  66205. name: string;
  66206. shader: string;
  66207. };
  66208. }
  66209. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  66210. import { Nullable } from "babylonjs/types";
  66211. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66212. import { Camera } from "babylonjs/Cameras/camera";
  66213. import { Texture } from "babylonjs/Materials/Textures/texture";
  66214. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66215. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66216. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66217. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66218. import { IDisposable } from "babylonjs/scene";
  66219. import { SpotLight } from "babylonjs/Lights/spotLight";
  66220. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  66221. import { Scene } from "babylonjs/scene";
  66222. import { Animation } from "babylonjs/Animations/animation";
  66223. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66224. import "babylonjs/Shaders/standard.fragment";
  66225. /**
  66226. * Standard rendering pipeline
  66227. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66228. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66229. */
  66230. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66231. /**
  66232. * Public members
  66233. */
  66234. /**
  66235. * Post-process which contains the original scene color before the pipeline applies all the effects
  66236. */
  66237. originalPostProcess: Nullable<PostProcess>;
  66238. /**
  66239. * Post-process used to down scale an image x4
  66240. */
  66241. downSampleX4PostProcess: Nullable<PostProcess>;
  66242. /**
  66243. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66244. */
  66245. brightPassPostProcess: Nullable<PostProcess>;
  66246. /**
  66247. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66248. */
  66249. blurHPostProcesses: PostProcess[];
  66250. /**
  66251. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66252. */
  66253. blurVPostProcesses: PostProcess[];
  66254. /**
  66255. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66256. */
  66257. textureAdderPostProcess: Nullable<PostProcess>;
  66258. /**
  66259. * Post-process used to create volumetric lighting effect
  66260. */
  66261. volumetricLightPostProcess: Nullable<PostProcess>;
  66262. /**
  66263. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66264. */
  66265. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66266. /**
  66267. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66268. */
  66269. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66270. /**
  66271. * Post-process used to merge the volumetric light effect and the real scene color
  66272. */
  66273. volumetricLightMergePostProces: Nullable<PostProcess>;
  66274. /**
  66275. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66276. */
  66277. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66278. /**
  66279. * Base post-process used to calculate the average luminance of the final image for HDR
  66280. */
  66281. luminancePostProcess: Nullable<PostProcess>;
  66282. /**
  66283. * Post-processes used to create down sample post-processes in order to get
  66284. * the average luminance of the final image for HDR
  66285. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66286. */
  66287. luminanceDownSamplePostProcesses: PostProcess[];
  66288. /**
  66289. * Post-process used to create a HDR effect (light adaptation)
  66290. */
  66291. hdrPostProcess: Nullable<PostProcess>;
  66292. /**
  66293. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66294. */
  66295. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66296. /**
  66297. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66298. */
  66299. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66300. /**
  66301. * Post-process used to merge the final HDR post-process and the real scene color
  66302. */
  66303. hdrFinalPostProcess: Nullable<PostProcess>;
  66304. /**
  66305. * Post-process used to create a lens flare effect
  66306. */
  66307. lensFlarePostProcess: Nullable<PostProcess>;
  66308. /**
  66309. * Post-process that merges the result of the lens flare post-process and the real scene color
  66310. */
  66311. lensFlareComposePostProcess: Nullable<PostProcess>;
  66312. /**
  66313. * Post-process used to create a motion blur effect
  66314. */
  66315. motionBlurPostProcess: Nullable<PostProcess>;
  66316. /**
  66317. * Post-process used to create a depth of field effect
  66318. */
  66319. depthOfFieldPostProcess: Nullable<PostProcess>;
  66320. /**
  66321. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66322. */
  66323. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66324. /**
  66325. * Represents the brightness threshold in order to configure the illuminated surfaces
  66326. */
  66327. brightThreshold: number;
  66328. /**
  66329. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66330. */
  66331. blurWidth: number;
  66332. /**
  66333. * Sets if the blur for highlighted surfaces must be only horizontal
  66334. */
  66335. horizontalBlur: boolean;
  66336. /**
  66337. * Gets the overall exposure used by the pipeline
  66338. */
  66339. /**
  66340. * Sets the overall exposure used by the pipeline
  66341. */
  66342. exposure: number;
  66343. /**
  66344. * Texture used typically to simulate "dirty" on camera lens
  66345. */
  66346. lensTexture: Nullable<Texture>;
  66347. /**
  66348. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66349. */
  66350. volumetricLightCoefficient: number;
  66351. /**
  66352. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66353. */
  66354. volumetricLightPower: number;
  66355. /**
  66356. * Used the set the blur intensity to smooth the volumetric lights
  66357. */
  66358. volumetricLightBlurScale: number;
  66359. /**
  66360. * Light (spot or directional) used to generate the volumetric lights rays
  66361. * The source light must have a shadow generate so the pipeline can get its
  66362. * depth map
  66363. */
  66364. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66365. /**
  66366. * For eye adaptation, represents the minimum luminance the eye can see
  66367. */
  66368. hdrMinimumLuminance: number;
  66369. /**
  66370. * For eye adaptation, represents the decrease luminance speed
  66371. */
  66372. hdrDecreaseRate: number;
  66373. /**
  66374. * For eye adaptation, represents the increase luminance speed
  66375. */
  66376. hdrIncreaseRate: number;
  66377. /**
  66378. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66379. */
  66380. /**
  66381. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66382. */
  66383. hdrAutoExposure: boolean;
  66384. /**
  66385. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66386. */
  66387. lensColorTexture: Nullable<Texture>;
  66388. /**
  66389. * The overall strengh for the lens flare effect
  66390. */
  66391. lensFlareStrength: number;
  66392. /**
  66393. * Dispersion coefficient for lens flare ghosts
  66394. */
  66395. lensFlareGhostDispersal: number;
  66396. /**
  66397. * Main lens flare halo width
  66398. */
  66399. lensFlareHaloWidth: number;
  66400. /**
  66401. * Based on the lens distortion effect, defines how much the lens flare result
  66402. * is distorted
  66403. */
  66404. lensFlareDistortionStrength: number;
  66405. /**
  66406. * Configures the blur intensity used for for lens flare (halo)
  66407. */
  66408. lensFlareBlurWidth: number;
  66409. /**
  66410. * Lens star texture must be used to simulate rays on the flares and is available
  66411. * in the documentation
  66412. */
  66413. lensStarTexture: Nullable<Texture>;
  66414. /**
  66415. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66416. * flare effect by taking account of the dirt texture
  66417. */
  66418. lensFlareDirtTexture: Nullable<Texture>;
  66419. /**
  66420. * Represents the focal length for the depth of field effect
  66421. */
  66422. depthOfFieldDistance: number;
  66423. /**
  66424. * Represents the blur intensity for the blurred part of the depth of field effect
  66425. */
  66426. depthOfFieldBlurWidth: number;
  66427. /**
  66428. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66429. */
  66430. /**
  66431. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66432. */
  66433. motionStrength: number;
  66434. /**
  66435. * Gets wether or not the motion blur post-process is object based or screen based.
  66436. */
  66437. /**
  66438. * Sets wether or not the motion blur post-process should be object based or screen based
  66439. */
  66440. objectBasedMotionBlur: boolean;
  66441. /**
  66442. * List of animations for the pipeline (IAnimatable implementation)
  66443. */
  66444. animations: Animation[];
  66445. /**
  66446. * Private members
  66447. */
  66448. private _scene;
  66449. private _currentDepthOfFieldSource;
  66450. private _basePostProcess;
  66451. private _fixedExposure;
  66452. private _currentExposure;
  66453. private _hdrAutoExposure;
  66454. private _hdrCurrentLuminance;
  66455. private _motionStrength;
  66456. private _isObjectBasedMotionBlur;
  66457. private _floatTextureType;
  66458. private _camerasToBeAttached;
  66459. private _ratio;
  66460. private _bloomEnabled;
  66461. private _depthOfFieldEnabled;
  66462. private _vlsEnabled;
  66463. private _lensFlareEnabled;
  66464. private _hdrEnabled;
  66465. private _motionBlurEnabled;
  66466. private _fxaaEnabled;
  66467. private _motionBlurSamples;
  66468. private _volumetricLightStepsCount;
  66469. private _samples;
  66470. /**
  66471. * @ignore
  66472. * Specifies if the bloom pipeline is enabled
  66473. */
  66474. BloomEnabled: boolean;
  66475. /**
  66476. * @ignore
  66477. * Specifies if the depth of field pipeline is enabed
  66478. */
  66479. DepthOfFieldEnabled: boolean;
  66480. /**
  66481. * @ignore
  66482. * Specifies if the lens flare pipeline is enabed
  66483. */
  66484. LensFlareEnabled: boolean;
  66485. /**
  66486. * @ignore
  66487. * Specifies if the HDR pipeline is enabled
  66488. */
  66489. HDREnabled: boolean;
  66490. /**
  66491. * @ignore
  66492. * Specifies if the volumetric lights scattering effect is enabled
  66493. */
  66494. VLSEnabled: boolean;
  66495. /**
  66496. * @ignore
  66497. * Specifies if the motion blur effect is enabled
  66498. */
  66499. MotionBlurEnabled: boolean;
  66500. /**
  66501. * Specifies if anti-aliasing is enabled
  66502. */
  66503. fxaaEnabled: boolean;
  66504. /**
  66505. * Specifies the number of steps used to calculate the volumetric lights
  66506. * Typically in interval [50, 200]
  66507. */
  66508. volumetricLightStepsCount: number;
  66509. /**
  66510. * Specifies the number of samples used for the motion blur effect
  66511. * Typically in interval [16, 64]
  66512. */
  66513. motionBlurSamples: number;
  66514. /**
  66515. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66516. */
  66517. samples: number;
  66518. /**
  66519. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66520. * @constructor
  66521. * @param name The rendering pipeline name
  66522. * @param scene The scene linked to this pipeline
  66523. * @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)
  66524. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66525. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66526. */
  66527. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66528. private _buildPipeline;
  66529. private _createDownSampleX4PostProcess;
  66530. private _createBrightPassPostProcess;
  66531. private _createBlurPostProcesses;
  66532. private _createTextureAdderPostProcess;
  66533. private _createVolumetricLightPostProcess;
  66534. private _createLuminancePostProcesses;
  66535. private _createHdrPostProcess;
  66536. private _createLensFlarePostProcess;
  66537. private _createDepthOfFieldPostProcess;
  66538. private _createMotionBlurPostProcess;
  66539. private _getDepthTexture;
  66540. private _disposePostProcesses;
  66541. /**
  66542. * Dispose of the pipeline and stop all post processes
  66543. */
  66544. dispose(): void;
  66545. /**
  66546. * Serialize the rendering pipeline (Used when exporting)
  66547. * @returns the serialized object
  66548. */
  66549. serialize(): any;
  66550. /**
  66551. * Parse the serialized pipeline
  66552. * @param source Source pipeline.
  66553. * @param scene The scene to load the pipeline to.
  66554. * @param rootUrl The URL of the serialized pipeline.
  66555. * @returns An instantiated pipeline from the serialized object.
  66556. */
  66557. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66558. /**
  66559. * Luminance steps
  66560. */
  66561. static LuminanceSteps: number;
  66562. }
  66563. }
  66564. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  66565. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  66566. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  66567. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  66568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  66569. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  66570. }
  66571. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  66572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  66573. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66574. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66575. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66576. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66577. }
  66578. declare module "babylonjs/Shaders/tonemap.fragment" {
  66579. /** @hidden */
  66580. export var tonemapPixelShader: {
  66581. name: string;
  66582. shader: string;
  66583. };
  66584. }
  66585. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  66586. import { Camera } from "babylonjs/Cameras/camera";
  66587. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66588. import "babylonjs/Shaders/tonemap.fragment";
  66589. import { Engine } from "babylonjs/Engines/engine";
  66590. /** Defines operator used for tonemapping */
  66591. export enum TonemappingOperator {
  66592. /** Hable */
  66593. Hable = 0,
  66594. /** Reinhard */
  66595. Reinhard = 1,
  66596. /** HejiDawson */
  66597. HejiDawson = 2,
  66598. /** Photographic */
  66599. Photographic = 3
  66600. }
  66601. /**
  66602. * Defines a post process to apply tone mapping
  66603. */
  66604. export class TonemapPostProcess extends PostProcess {
  66605. private _operator;
  66606. /** Defines the required exposure adjustement */
  66607. exposureAdjustment: number;
  66608. /**
  66609. * Creates a new TonemapPostProcess
  66610. * @param name defines the name of the postprocess
  66611. * @param _operator defines the operator to use
  66612. * @param exposureAdjustment defines the required exposure adjustement
  66613. * @param camera defines the camera to use (can be null)
  66614. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66615. * @param engine defines the hosting engine (can be ignore if camera is set)
  66616. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66617. */
  66618. constructor(name: string, _operator: TonemappingOperator,
  66619. /** Defines the required exposure adjustement */
  66620. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66621. }
  66622. }
  66623. declare module "babylonjs/Shaders/depth.vertex" {
  66624. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66625. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66626. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66627. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66629. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66630. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66631. /** @hidden */
  66632. export var depthVertexShader: {
  66633. name: string;
  66634. shader: string;
  66635. };
  66636. }
  66637. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  66638. /** @hidden */
  66639. export var volumetricLightScatteringPixelShader: {
  66640. name: string;
  66641. shader: string;
  66642. };
  66643. }
  66644. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  66645. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66647. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66648. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66649. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66650. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66651. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66652. /** @hidden */
  66653. export var volumetricLightScatteringPassVertexShader: {
  66654. name: string;
  66655. shader: string;
  66656. };
  66657. }
  66658. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  66659. /** @hidden */
  66660. export var volumetricLightScatteringPassPixelShader: {
  66661. name: string;
  66662. shader: string;
  66663. };
  66664. }
  66665. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  66666. import { Vector3 } from "babylonjs/Maths/math.vector";
  66667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66668. import { Mesh } from "babylonjs/Meshes/mesh";
  66669. import { Camera } from "babylonjs/Cameras/camera";
  66670. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66671. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66672. import { Scene } from "babylonjs/scene";
  66673. import "babylonjs/Meshes/Builders/planeBuilder";
  66674. import "babylonjs/Shaders/depth.vertex";
  66675. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  66676. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  66677. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  66678. import { Engine } from "babylonjs/Engines/engine";
  66679. /**
  66680. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66681. */
  66682. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66683. private _volumetricLightScatteringPass;
  66684. private _volumetricLightScatteringRTT;
  66685. private _viewPort;
  66686. private _screenCoordinates;
  66687. private _cachedDefines;
  66688. /**
  66689. * If not undefined, the mesh position is computed from the attached node position
  66690. */
  66691. attachedNode: {
  66692. position: Vector3;
  66693. };
  66694. /**
  66695. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66696. */
  66697. customMeshPosition: Vector3;
  66698. /**
  66699. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66700. */
  66701. useCustomMeshPosition: boolean;
  66702. /**
  66703. * If the post-process should inverse the light scattering direction
  66704. */
  66705. invert: boolean;
  66706. /**
  66707. * The internal mesh used by the post-process
  66708. */
  66709. mesh: Mesh;
  66710. /**
  66711. * @hidden
  66712. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66713. */
  66714. useDiffuseColor: boolean;
  66715. /**
  66716. * Array containing the excluded meshes not rendered in the internal pass
  66717. */
  66718. excludedMeshes: AbstractMesh[];
  66719. /**
  66720. * Controls the overall intensity of the post-process
  66721. */
  66722. exposure: number;
  66723. /**
  66724. * Dissipates each sample's contribution in range [0, 1]
  66725. */
  66726. decay: number;
  66727. /**
  66728. * Controls the overall intensity of each sample
  66729. */
  66730. weight: number;
  66731. /**
  66732. * Controls the density of each sample
  66733. */
  66734. density: number;
  66735. /**
  66736. * @constructor
  66737. * @param name The post-process name
  66738. * @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)
  66739. * @param camera The camera that the post-process will be attached to
  66740. * @param mesh The mesh used to create the light scattering
  66741. * @param samples The post-process quality, default 100
  66742. * @param samplingModeThe post-process filtering mode
  66743. * @param engine The babylon engine
  66744. * @param reusable If the post-process is reusable
  66745. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66746. */
  66747. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66748. /**
  66749. * Returns the string "VolumetricLightScatteringPostProcess"
  66750. * @returns "VolumetricLightScatteringPostProcess"
  66751. */
  66752. getClassName(): string;
  66753. private _isReady;
  66754. /**
  66755. * Sets the new light position for light scattering effect
  66756. * @param position The new custom light position
  66757. */
  66758. setCustomMeshPosition(position: Vector3): void;
  66759. /**
  66760. * Returns the light position for light scattering effect
  66761. * @return Vector3 The custom light position
  66762. */
  66763. getCustomMeshPosition(): Vector3;
  66764. /**
  66765. * Disposes the internal assets and detaches the post-process from the camera
  66766. */
  66767. dispose(camera: Camera): void;
  66768. /**
  66769. * Returns the render target texture used by the post-process
  66770. * @return the render target texture used by the post-process
  66771. */
  66772. getPass(): RenderTargetTexture;
  66773. private _meshExcluded;
  66774. private _createPass;
  66775. private _updateMeshScreenCoordinates;
  66776. /**
  66777. * Creates a default mesh for the Volumeric Light Scattering post-process
  66778. * @param name The mesh name
  66779. * @param scene The scene where to create the mesh
  66780. * @return the default mesh
  66781. */
  66782. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66783. }
  66784. }
  66785. declare module "babylonjs/PostProcesses/index" {
  66786. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66787. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66788. export * from "babylonjs/PostProcesses/bloomEffect";
  66789. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66790. export * from "babylonjs/PostProcesses/blurPostProcess";
  66791. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66792. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66793. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66794. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66795. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66796. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66797. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66798. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66799. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66800. export * from "babylonjs/PostProcesses/filterPostProcess";
  66801. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66802. export * from "babylonjs/PostProcesses/grainPostProcess";
  66803. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66804. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66805. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66806. export * from "babylonjs/PostProcesses/passPostProcess";
  66807. export * from "babylonjs/PostProcesses/postProcess";
  66808. export * from "babylonjs/PostProcesses/postProcessManager";
  66809. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66810. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66811. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66812. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66813. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66814. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66815. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66816. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66817. }
  66818. declare module "babylonjs/Probes/index" {
  66819. export * from "babylonjs/Probes/reflectionProbe";
  66820. }
  66821. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66822. import { Scene } from "babylonjs/scene";
  66823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66824. import { SmartArray } from "babylonjs/Misc/smartArray";
  66825. import { ISceneComponent } from "babylonjs/sceneComponent";
  66826. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66827. import "babylonjs/Meshes/Builders/boxBuilder";
  66828. import "babylonjs/Shaders/color.fragment";
  66829. import "babylonjs/Shaders/color.vertex";
  66830. import { Color3 } from "babylonjs/Maths/math.color";
  66831. module "babylonjs/scene" {
  66832. interface Scene {
  66833. /** @hidden (Backing field) */
  66834. _boundingBoxRenderer: BoundingBoxRenderer;
  66835. /** @hidden (Backing field) */
  66836. _forceShowBoundingBoxes: boolean;
  66837. /**
  66838. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66839. */
  66840. forceShowBoundingBoxes: boolean;
  66841. /**
  66842. * Gets the bounding box renderer associated with the scene
  66843. * @returns a BoundingBoxRenderer
  66844. */
  66845. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66846. }
  66847. }
  66848. module "babylonjs/Meshes/abstractMesh" {
  66849. interface AbstractMesh {
  66850. /** @hidden (Backing field) */
  66851. _showBoundingBox: boolean;
  66852. /**
  66853. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66854. */
  66855. showBoundingBox: boolean;
  66856. }
  66857. }
  66858. /**
  66859. * Component responsible of rendering the bounding box of the meshes in a scene.
  66860. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66861. */
  66862. export class BoundingBoxRenderer implements ISceneComponent {
  66863. /**
  66864. * The component name helpfull to identify the component in the list of scene components.
  66865. */
  66866. readonly name: string;
  66867. /**
  66868. * The scene the component belongs to.
  66869. */
  66870. scene: Scene;
  66871. /**
  66872. * Color of the bounding box lines placed in front of an object
  66873. */
  66874. frontColor: Color3;
  66875. /**
  66876. * Color of the bounding box lines placed behind an object
  66877. */
  66878. backColor: Color3;
  66879. /**
  66880. * Defines if the renderer should show the back lines or not
  66881. */
  66882. showBackLines: boolean;
  66883. /**
  66884. * @hidden
  66885. */
  66886. renderList: SmartArray<BoundingBox>;
  66887. private _colorShader;
  66888. private _vertexBuffers;
  66889. private _indexBuffer;
  66890. private _fillIndexBuffer;
  66891. private _fillIndexData;
  66892. /**
  66893. * Instantiates a new bounding box renderer in a scene.
  66894. * @param scene the scene the renderer renders in
  66895. */
  66896. constructor(scene: Scene);
  66897. /**
  66898. * Registers the component in a given scene
  66899. */
  66900. register(): void;
  66901. private _evaluateSubMesh;
  66902. private _activeMesh;
  66903. private _prepareRessources;
  66904. private _createIndexBuffer;
  66905. /**
  66906. * Rebuilds the elements related to this component in case of
  66907. * context lost for instance.
  66908. */
  66909. rebuild(): void;
  66910. /**
  66911. * @hidden
  66912. */
  66913. reset(): void;
  66914. /**
  66915. * Render the bounding boxes of a specific rendering group
  66916. * @param renderingGroupId defines the rendering group to render
  66917. */
  66918. render(renderingGroupId: number): void;
  66919. /**
  66920. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66921. * @param mesh Define the mesh to render the occlusion bounding box for
  66922. */
  66923. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66924. /**
  66925. * Dispose and release the resources attached to this renderer.
  66926. */
  66927. dispose(): void;
  66928. }
  66929. }
  66930. declare module "babylonjs/Shaders/depth.fragment" {
  66931. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66932. /** @hidden */
  66933. export var depthPixelShader: {
  66934. name: string;
  66935. shader: string;
  66936. };
  66937. }
  66938. declare module "babylonjs/Rendering/depthRenderer" {
  66939. import { Nullable } from "babylonjs/types";
  66940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66941. import { Scene } from "babylonjs/scene";
  66942. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66943. import { Camera } from "babylonjs/Cameras/camera";
  66944. import "babylonjs/Shaders/depth.fragment";
  66945. import "babylonjs/Shaders/depth.vertex";
  66946. /**
  66947. * This represents a depth renderer in Babylon.
  66948. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66949. */
  66950. export class DepthRenderer {
  66951. private _scene;
  66952. private _depthMap;
  66953. private _effect;
  66954. private readonly _storeNonLinearDepth;
  66955. private readonly _clearColor;
  66956. /** Get if the depth renderer is using packed depth or not */
  66957. readonly isPacked: boolean;
  66958. private _cachedDefines;
  66959. private _camera;
  66960. /**
  66961. * Specifiess that the depth renderer will only be used within
  66962. * the camera it is created for.
  66963. * This can help forcing its rendering during the camera processing.
  66964. */
  66965. useOnlyInActiveCamera: boolean;
  66966. /** @hidden */
  66967. static _SceneComponentInitialization: (scene: Scene) => void;
  66968. /**
  66969. * Instantiates a depth renderer
  66970. * @param scene The scene the renderer belongs to
  66971. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66972. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66973. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66974. */
  66975. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66976. /**
  66977. * Creates the depth rendering effect and checks if the effect is ready.
  66978. * @param subMesh The submesh to be used to render the depth map of
  66979. * @param useInstances If multiple world instances should be used
  66980. * @returns if the depth renderer is ready to render the depth map
  66981. */
  66982. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66983. /**
  66984. * Gets the texture which the depth map will be written to.
  66985. * @returns The depth map texture
  66986. */
  66987. getDepthMap(): RenderTargetTexture;
  66988. /**
  66989. * Disposes of the depth renderer.
  66990. */
  66991. dispose(): void;
  66992. }
  66993. }
  66994. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66995. import { Nullable } from "babylonjs/types";
  66996. import { Scene } from "babylonjs/scene";
  66997. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66998. import { Camera } from "babylonjs/Cameras/camera";
  66999. import { ISceneComponent } from "babylonjs/sceneComponent";
  67000. module "babylonjs/scene" {
  67001. interface Scene {
  67002. /** @hidden (Backing field) */
  67003. _depthRenderer: {
  67004. [id: string]: DepthRenderer;
  67005. };
  67006. /**
  67007. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67008. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67009. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67010. * @returns the created depth renderer
  67011. */
  67012. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67013. /**
  67014. * Disables a depth renderer for a given camera
  67015. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67016. */
  67017. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67018. }
  67019. }
  67020. /**
  67021. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67022. * in several rendering techniques.
  67023. */
  67024. export class DepthRendererSceneComponent implements ISceneComponent {
  67025. /**
  67026. * The component name helpfull to identify the component in the list of scene components.
  67027. */
  67028. readonly name: string;
  67029. /**
  67030. * The scene the component belongs to.
  67031. */
  67032. scene: Scene;
  67033. /**
  67034. * Creates a new instance of the component for the given scene
  67035. * @param scene Defines the scene to register the component in
  67036. */
  67037. constructor(scene: Scene);
  67038. /**
  67039. * Registers the component in a given scene
  67040. */
  67041. register(): void;
  67042. /**
  67043. * Rebuilds the elements related to this component in case of
  67044. * context lost for instance.
  67045. */
  67046. rebuild(): void;
  67047. /**
  67048. * Disposes the component and the associated ressources
  67049. */
  67050. dispose(): void;
  67051. private _gatherRenderTargets;
  67052. private _gatherActiveCameraRenderTargets;
  67053. }
  67054. }
  67055. declare module "babylonjs/Shaders/outline.fragment" {
  67056. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  67057. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  67058. /** @hidden */
  67059. export var outlinePixelShader: {
  67060. name: string;
  67061. shader: string;
  67062. };
  67063. }
  67064. declare module "babylonjs/Shaders/outline.vertex" {
  67065. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67066. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67067. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67068. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67069. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  67070. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67071. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67072. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67073. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  67074. /** @hidden */
  67075. export var outlineVertexShader: {
  67076. name: string;
  67077. shader: string;
  67078. };
  67079. }
  67080. declare module "babylonjs/Rendering/outlineRenderer" {
  67081. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67082. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  67083. import { Scene } from "babylonjs/scene";
  67084. import { ISceneComponent } from "babylonjs/sceneComponent";
  67085. import "babylonjs/Shaders/outline.fragment";
  67086. import "babylonjs/Shaders/outline.vertex";
  67087. module "babylonjs/scene" {
  67088. interface Scene {
  67089. /** @hidden */
  67090. _outlineRenderer: OutlineRenderer;
  67091. /**
  67092. * Gets the outline renderer associated with the scene
  67093. * @returns a OutlineRenderer
  67094. */
  67095. getOutlineRenderer(): OutlineRenderer;
  67096. }
  67097. }
  67098. module "babylonjs/Meshes/abstractMesh" {
  67099. interface AbstractMesh {
  67100. /** @hidden (Backing field) */
  67101. _renderOutline: boolean;
  67102. /**
  67103. * Gets or sets a boolean indicating if the outline must be rendered as well
  67104. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67105. */
  67106. renderOutline: boolean;
  67107. /** @hidden (Backing field) */
  67108. _renderOverlay: boolean;
  67109. /**
  67110. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67111. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67112. */
  67113. renderOverlay: boolean;
  67114. }
  67115. }
  67116. /**
  67117. * This class is responsible to draw bothe outline/overlay of meshes.
  67118. * It should not be used directly but through the available method on mesh.
  67119. */
  67120. export class OutlineRenderer implements ISceneComponent {
  67121. /**
  67122. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67123. */
  67124. private static _StencilReference;
  67125. /**
  67126. * The name of the component. Each component must have a unique name.
  67127. */
  67128. name: string;
  67129. /**
  67130. * The scene the component belongs to.
  67131. */
  67132. scene: Scene;
  67133. /**
  67134. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67135. */
  67136. zOffset: number;
  67137. private _engine;
  67138. private _effect;
  67139. private _cachedDefines;
  67140. private _savedDepthWrite;
  67141. /**
  67142. * Instantiates a new outline renderer. (There could be only one per scene).
  67143. * @param scene Defines the scene it belongs to
  67144. */
  67145. constructor(scene: Scene);
  67146. /**
  67147. * Register the component to one instance of a scene.
  67148. */
  67149. register(): void;
  67150. /**
  67151. * Rebuilds the elements related to this component in case of
  67152. * context lost for instance.
  67153. */
  67154. rebuild(): void;
  67155. /**
  67156. * Disposes the component and the associated ressources.
  67157. */
  67158. dispose(): void;
  67159. /**
  67160. * Renders the outline in the canvas.
  67161. * @param subMesh Defines the sumesh to render
  67162. * @param batch Defines the batch of meshes in case of instances
  67163. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67164. */
  67165. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67166. /**
  67167. * Returns whether or not the outline renderer is ready for a given submesh.
  67168. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67169. * @param subMesh Defines the submesh to check readyness for
  67170. * @param useInstances Defines wheter wee are trying to render instances or not
  67171. * @returns true if ready otherwise false
  67172. */
  67173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67174. private _beforeRenderingMesh;
  67175. private _afterRenderingMesh;
  67176. }
  67177. }
  67178. declare module "babylonjs/Rendering/index" {
  67179. export * from "babylonjs/Rendering/boundingBoxRenderer";
  67180. export * from "babylonjs/Rendering/depthRenderer";
  67181. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  67182. export * from "babylonjs/Rendering/edgesRenderer";
  67183. export * from "babylonjs/Rendering/geometryBufferRenderer";
  67184. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67185. export * from "babylonjs/Rendering/outlineRenderer";
  67186. export * from "babylonjs/Rendering/renderingGroup";
  67187. export * from "babylonjs/Rendering/renderingManager";
  67188. export * from "babylonjs/Rendering/utilityLayerRenderer";
  67189. }
  67190. declare module "babylonjs/Sprites/ISprites" {
  67191. /**
  67192. * Defines the basic options interface of a Sprite Frame Source Size.
  67193. */
  67194. export interface ISpriteJSONSpriteSourceSize {
  67195. /**
  67196. * number of the original width of the Frame
  67197. */
  67198. w: number;
  67199. /**
  67200. * number of the original height of the Frame
  67201. */
  67202. h: number;
  67203. }
  67204. /**
  67205. * Defines the basic options interface of a Sprite Frame Data.
  67206. */
  67207. export interface ISpriteJSONSpriteFrameData {
  67208. /**
  67209. * number of the x offset of the Frame
  67210. */
  67211. x: number;
  67212. /**
  67213. * number of the y offset of the Frame
  67214. */
  67215. y: number;
  67216. /**
  67217. * number of the width of the Frame
  67218. */
  67219. w: number;
  67220. /**
  67221. * number of the height of the Frame
  67222. */
  67223. h: number;
  67224. }
  67225. /**
  67226. * Defines the basic options interface of a JSON Sprite.
  67227. */
  67228. export interface ISpriteJSONSprite {
  67229. /**
  67230. * string name of the Frame
  67231. */
  67232. filename: string;
  67233. /**
  67234. * ISpriteJSONSpriteFrame basic object of the frame data
  67235. */
  67236. frame: ISpriteJSONSpriteFrameData;
  67237. /**
  67238. * boolean to flag is the frame was rotated.
  67239. */
  67240. rotated: boolean;
  67241. /**
  67242. * boolean to flag is the frame was trimmed.
  67243. */
  67244. trimmed: boolean;
  67245. /**
  67246. * ISpriteJSONSpriteFrame basic object of the source data
  67247. */
  67248. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67249. /**
  67250. * ISpriteJSONSpriteFrame basic object of the source data
  67251. */
  67252. sourceSize: ISpriteJSONSpriteSourceSize;
  67253. }
  67254. /**
  67255. * Defines the basic options interface of a JSON atlas.
  67256. */
  67257. export interface ISpriteJSONAtlas {
  67258. /**
  67259. * Array of objects that contain the frame data.
  67260. */
  67261. frames: Array<ISpriteJSONSprite>;
  67262. /**
  67263. * object basic object containing the sprite meta data.
  67264. */
  67265. meta?: object;
  67266. }
  67267. }
  67268. declare module "babylonjs/Shaders/spriteMap.fragment" {
  67269. /** @hidden */
  67270. export var spriteMapPixelShader: {
  67271. name: string;
  67272. shader: string;
  67273. };
  67274. }
  67275. declare module "babylonjs/Shaders/spriteMap.vertex" {
  67276. /** @hidden */
  67277. export var spriteMapVertexShader: {
  67278. name: string;
  67279. shader: string;
  67280. };
  67281. }
  67282. declare module "babylonjs/Sprites/spriteMap" {
  67283. import { IDisposable, Scene } from "babylonjs/scene";
  67284. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  67285. import { Texture } from "babylonjs/Materials/Textures/texture";
  67286. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  67287. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  67288. import "babylonjs/Meshes/Builders/planeBuilder";
  67289. import "babylonjs/Shaders/spriteMap.fragment";
  67290. import "babylonjs/Shaders/spriteMap.vertex";
  67291. /**
  67292. * Defines the basic options interface of a SpriteMap
  67293. */
  67294. export interface ISpriteMapOptions {
  67295. /**
  67296. * Vector2 of the number of cells in the grid.
  67297. */
  67298. stageSize?: Vector2;
  67299. /**
  67300. * Vector2 of the size of the output plane in World Units.
  67301. */
  67302. outputSize?: Vector2;
  67303. /**
  67304. * Vector3 of the position of the output plane in World Units.
  67305. */
  67306. outputPosition?: Vector3;
  67307. /**
  67308. * Vector3 of the rotation of the output plane.
  67309. */
  67310. outputRotation?: Vector3;
  67311. /**
  67312. * number of layers that the system will reserve in resources.
  67313. */
  67314. layerCount?: number;
  67315. /**
  67316. * number of max animation frames a single cell will reserve in resources.
  67317. */
  67318. maxAnimationFrames?: number;
  67319. /**
  67320. * number cell index of the base tile when the system compiles.
  67321. */
  67322. baseTile?: number;
  67323. /**
  67324. * boolean flip the sprite after its been repositioned by the framing data.
  67325. */
  67326. flipU?: boolean;
  67327. /**
  67328. * Vector3 scalar of the global RGB values of the SpriteMap.
  67329. */
  67330. colorMultiply?: Vector3;
  67331. }
  67332. /**
  67333. * Defines the IDisposable interface in order to be cleanable from resources.
  67334. */
  67335. export interface ISpriteMap extends IDisposable {
  67336. /**
  67337. * String name of the SpriteMap.
  67338. */
  67339. name: string;
  67340. /**
  67341. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67342. */
  67343. atlasJSON: ISpriteJSONAtlas;
  67344. /**
  67345. * Texture of the SpriteMap.
  67346. */
  67347. spriteSheet: Texture;
  67348. /**
  67349. * The parameters to initialize the SpriteMap with.
  67350. */
  67351. options: ISpriteMapOptions;
  67352. }
  67353. /**
  67354. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67355. */
  67356. export class SpriteMap implements ISpriteMap {
  67357. /** The Name of the spriteMap */
  67358. name: string;
  67359. /** The JSON file with the frame and meta data */
  67360. atlasJSON: ISpriteJSONAtlas;
  67361. /** The systems Sprite Sheet Texture */
  67362. spriteSheet: Texture;
  67363. /** Arguments passed with the Constructor */
  67364. options: ISpriteMapOptions;
  67365. /** Public Sprite Storage array, parsed from atlasJSON */
  67366. sprites: Array<ISpriteJSONSprite>;
  67367. /** Returns the Number of Sprites in the System */
  67368. readonly spriteCount: number;
  67369. /** Returns the Position of Output Plane*/
  67370. /** Returns the Position of Output Plane*/
  67371. position: Vector3;
  67372. /** Returns the Rotation of Output Plane*/
  67373. /** Returns the Rotation of Output Plane*/
  67374. rotation: Vector3;
  67375. /** Sets the AnimationMap*/
  67376. /** Sets the AnimationMap*/
  67377. animationMap: RawTexture;
  67378. /** Scene that the SpriteMap was created in */
  67379. private _scene;
  67380. /** Texture Buffer of Float32 that holds tile frame data*/
  67381. private _frameMap;
  67382. /** Texture Buffers of Float32 that holds tileMap data*/
  67383. private _tileMaps;
  67384. /** Texture Buffer of Float32 that holds Animation Data*/
  67385. private _animationMap;
  67386. /** Custom ShaderMaterial Central to the System*/
  67387. private _material;
  67388. /** Custom ShaderMaterial Central to the System*/
  67389. private _output;
  67390. /** Systems Time Ticker*/
  67391. private _time;
  67392. /**
  67393. * Creates a new SpriteMap
  67394. * @param name defines the SpriteMaps Name
  67395. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67396. * @param spriteSheet is the Texture that the Sprites are on.
  67397. * @param options a basic deployment configuration
  67398. * @param scene The Scene that the map is deployed on
  67399. */
  67400. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67401. /**
  67402. * Returns tileID location
  67403. * @returns Vector2 the cell position ID
  67404. */
  67405. getTileID(): Vector2;
  67406. /**
  67407. * Gets the UV location of the mouse over the SpriteMap.
  67408. * @returns Vector2 the UV position of the mouse interaction
  67409. */
  67410. getMousePosition(): Vector2;
  67411. /**
  67412. * Creates the "frame" texture Buffer
  67413. * -------------------------------------
  67414. * Structure of frames
  67415. * "filename": "Falling-Water-2.png",
  67416. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67417. * "rotated": true,
  67418. * "trimmed": true,
  67419. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67420. * "sourceSize": {"w":32,"h":32}
  67421. * @returns RawTexture of the frameMap
  67422. */
  67423. private _createFrameBuffer;
  67424. /**
  67425. * Creates the tileMap texture Buffer
  67426. * @param buffer normally and array of numbers, or a false to generate from scratch
  67427. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67428. * @returns RawTexture of the tileMap
  67429. */
  67430. private _createTileBuffer;
  67431. /**
  67432. * Modifies the data of the tileMaps
  67433. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67434. * @param pos is the iVector2 Coordinates of the Tile
  67435. * @param tile The SpriteIndex of the new Tile
  67436. */
  67437. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67438. /**
  67439. * Creates the animationMap texture Buffer
  67440. * @param buffer normally and array of numbers, or a false to generate from scratch
  67441. * @returns RawTexture of the animationMap
  67442. */
  67443. private _createTileAnimationBuffer;
  67444. /**
  67445. * Modifies the data of the animationMap
  67446. * @param cellID is the Index of the Sprite
  67447. * @param _frame is the target Animation frame
  67448. * @param toCell is the Target Index of the next frame of the animation
  67449. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67450. * @param speed is a global scalar of the time variable on the map.
  67451. */
  67452. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67453. /**
  67454. * Exports the .tilemaps file
  67455. */
  67456. saveTileMaps(): void;
  67457. /**
  67458. * Imports the .tilemaps file
  67459. * @param url of the .tilemaps file
  67460. */
  67461. loadTileMaps(url: string): void;
  67462. /**
  67463. * Release associated resources
  67464. */
  67465. dispose(): void;
  67466. }
  67467. }
  67468. declare module "babylonjs/Sprites/spritePackedManager" {
  67469. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  67470. import { Scene } from "babylonjs/scene";
  67471. /**
  67472. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67473. * @see http://doc.babylonjs.com/babylon101/sprites
  67474. */
  67475. export class SpritePackedManager extends SpriteManager {
  67476. /** defines the packed manager's name */
  67477. name: string;
  67478. /**
  67479. * Creates a new sprite manager from a packed sprite sheet
  67480. * @param name defines the manager's name
  67481. * @param imgUrl defines the sprite sheet url
  67482. * @param capacity defines the maximum allowed number of sprites
  67483. * @param scene defines the hosting scene
  67484. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67485. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67486. * @param samplingMode defines the smapling mode to use with spritesheet
  67487. * @param fromPacked set to true; do not alter
  67488. */
  67489. constructor(
  67490. /** defines the packed manager's name */
  67491. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67492. }
  67493. }
  67494. declare module "babylonjs/Sprites/index" {
  67495. export * from "babylonjs/Sprites/sprite";
  67496. export * from "babylonjs/Sprites/ISprites";
  67497. export * from "babylonjs/Sprites/spriteManager";
  67498. export * from "babylonjs/Sprites/spriteMap";
  67499. export * from "babylonjs/Sprites/spritePackedManager";
  67500. export * from "babylonjs/Sprites/spriteSceneComponent";
  67501. }
  67502. declare module "babylonjs/States/index" {
  67503. export * from "babylonjs/States/alphaCullingState";
  67504. export * from "babylonjs/States/depthCullingState";
  67505. export * from "babylonjs/States/stencilState";
  67506. }
  67507. declare module "babylonjs/Misc/assetsManager" {
  67508. import { Scene } from "babylonjs/scene";
  67509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67510. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  67511. import { Skeleton } from "babylonjs/Bones/skeleton";
  67512. import { Observable } from "babylonjs/Misc/observable";
  67513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67514. import { Texture } from "babylonjs/Materials/Textures/texture";
  67515. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  67516. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  67517. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  67518. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  67519. /**
  67520. * Defines the list of states available for a task inside a AssetsManager
  67521. */
  67522. export enum AssetTaskState {
  67523. /**
  67524. * Initialization
  67525. */
  67526. INIT = 0,
  67527. /**
  67528. * Running
  67529. */
  67530. RUNNING = 1,
  67531. /**
  67532. * Done
  67533. */
  67534. DONE = 2,
  67535. /**
  67536. * Error
  67537. */
  67538. ERROR = 3
  67539. }
  67540. /**
  67541. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67542. */
  67543. export abstract class AbstractAssetTask {
  67544. /**
  67545. * Task name
  67546. */ name: string;
  67547. /**
  67548. * Callback called when the task is successful
  67549. */
  67550. onSuccess: (task: any) => void;
  67551. /**
  67552. * Callback called when the task is not successful
  67553. */
  67554. onError: (task: any, message?: string, exception?: any) => void;
  67555. /**
  67556. * Creates a new AssetsManager
  67557. * @param name defines the name of the task
  67558. */
  67559. constructor(
  67560. /**
  67561. * Task name
  67562. */ name: string);
  67563. private _isCompleted;
  67564. private _taskState;
  67565. private _errorObject;
  67566. /**
  67567. * Get if the task is completed
  67568. */
  67569. readonly isCompleted: boolean;
  67570. /**
  67571. * Gets the current state of the task
  67572. */
  67573. readonly taskState: AssetTaskState;
  67574. /**
  67575. * Gets the current error object (if task is in error)
  67576. */
  67577. readonly errorObject: {
  67578. message?: string;
  67579. exception?: any;
  67580. };
  67581. /**
  67582. * Internal only
  67583. * @hidden
  67584. */
  67585. _setErrorObject(message?: string, exception?: any): void;
  67586. /**
  67587. * Execute the current task
  67588. * @param scene defines the scene where you want your assets to be loaded
  67589. * @param onSuccess is a callback called when the task is successfully executed
  67590. * @param onError is a callback called if an error occurs
  67591. */
  67592. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67593. /**
  67594. * Execute the current task
  67595. * @param scene defines the scene where you want your assets to be loaded
  67596. * @param onSuccess is a callback called when the task is successfully executed
  67597. * @param onError is a callback called if an error occurs
  67598. */
  67599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67600. /**
  67601. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67602. * This can be used with failed tasks that have the reason for failure fixed.
  67603. */
  67604. reset(): void;
  67605. private onErrorCallback;
  67606. private onDoneCallback;
  67607. }
  67608. /**
  67609. * Define the interface used by progress events raised during assets loading
  67610. */
  67611. export interface IAssetsProgressEvent {
  67612. /**
  67613. * Defines the number of remaining tasks to process
  67614. */
  67615. remainingCount: number;
  67616. /**
  67617. * Defines the total number of tasks
  67618. */
  67619. totalCount: number;
  67620. /**
  67621. * Defines the task that was just processed
  67622. */
  67623. task: AbstractAssetTask;
  67624. }
  67625. /**
  67626. * Class used to share progress information about assets loading
  67627. */
  67628. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67629. /**
  67630. * Defines the number of remaining tasks to process
  67631. */
  67632. remainingCount: number;
  67633. /**
  67634. * Defines the total number of tasks
  67635. */
  67636. totalCount: number;
  67637. /**
  67638. * Defines the task that was just processed
  67639. */
  67640. task: AbstractAssetTask;
  67641. /**
  67642. * Creates a AssetsProgressEvent
  67643. * @param remainingCount defines the number of remaining tasks to process
  67644. * @param totalCount defines the total number of tasks
  67645. * @param task defines the task that was just processed
  67646. */
  67647. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67648. }
  67649. /**
  67650. * Define a task used by AssetsManager to load meshes
  67651. */
  67652. export class MeshAssetTask extends AbstractAssetTask {
  67653. /**
  67654. * Defines the name of the task
  67655. */
  67656. name: string;
  67657. /**
  67658. * Defines the list of mesh's names you want to load
  67659. */
  67660. meshesNames: any;
  67661. /**
  67662. * Defines the root url to use as a base to load your meshes and associated resources
  67663. */
  67664. rootUrl: string;
  67665. /**
  67666. * Defines the filename of the scene to load from
  67667. */
  67668. sceneFilename: string;
  67669. /**
  67670. * Gets the list of loaded meshes
  67671. */
  67672. loadedMeshes: Array<AbstractMesh>;
  67673. /**
  67674. * Gets the list of loaded particle systems
  67675. */
  67676. loadedParticleSystems: Array<IParticleSystem>;
  67677. /**
  67678. * Gets the list of loaded skeletons
  67679. */
  67680. loadedSkeletons: Array<Skeleton>;
  67681. /**
  67682. * Gets the list of loaded animation groups
  67683. */
  67684. loadedAnimationGroups: Array<AnimationGroup>;
  67685. /**
  67686. * Callback called when the task is successful
  67687. */
  67688. onSuccess: (task: MeshAssetTask) => void;
  67689. /**
  67690. * Callback called when the task is successful
  67691. */
  67692. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67693. /**
  67694. * Creates a new MeshAssetTask
  67695. * @param name defines the name of the task
  67696. * @param meshesNames defines the list of mesh's names you want to load
  67697. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67698. * @param sceneFilename defines the filename of the scene to load from
  67699. */
  67700. constructor(
  67701. /**
  67702. * Defines the name of the task
  67703. */
  67704. name: string,
  67705. /**
  67706. * Defines the list of mesh's names you want to load
  67707. */
  67708. meshesNames: any,
  67709. /**
  67710. * Defines the root url to use as a base to load your meshes and associated resources
  67711. */
  67712. rootUrl: string,
  67713. /**
  67714. * Defines the filename of the scene to load from
  67715. */
  67716. sceneFilename: string);
  67717. /**
  67718. * Execute the current task
  67719. * @param scene defines the scene where you want your assets to be loaded
  67720. * @param onSuccess is a callback called when the task is successfully executed
  67721. * @param onError is a callback called if an error occurs
  67722. */
  67723. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67724. }
  67725. /**
  67726. * Define a task used by AssetsManager to load text content
  67727. */
  67728. export class TextFileAssetTask extends AbstractAssetTask {
  67729. /**
  67730. * Defines the name of the task
  67731. */
  67732. name: string;
  67733. /**
  67734. * Defines the location of the file to load
  67735. */
  67736. url: string;
  67737. /**
  67738. * Gets the loaded text string
  67739. */
  67740. text: string;
  67741. /**
  67742. * Callback called when the task is successful
  67743. */
  67744. onSuccess: (task: TextFileAssetTask) => void;
  67745. /**
  67746. * Callback called when the task is successful
  67747. */
  67748. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67749. /**
  67750. * Creates a new TextFileAssetTask object
  67751. * @param name defines the name of the task
  67752. * @param url defines the location of the file to load
  67753. */
  67754. constructor(
  67755. /**
  67756. * Defines the name of the task
  67757. */
  67758. name: string,
  67759. /**
  67760. * Defines the location of the file to load
  67761. */
  67762. url: string);
  67763. /**
  67764. * Execute the current task
  67765. * @param scene defines the scene where you want your assets to be loaded
  67766. * @param onSuccess is a callback called when the task is successfully executed
  67767. * @param onError is a callback called if an error occurs
  67768. */
  67769. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67770. }
  67771. /**
  67772. * Define a task used by AssetsManager to load binary data
  67773. */
  67774. export class BinaryFileAssetTask extends AbstractAssetTask {
  67775. /**
  67776. * Defines the name of the task
  67777. */
  67778. name: string;
  67779. /**
  67780. * Defines the location of the file to load
  67781. */
  67782. url: string;
  67783. /**
  67784. * Gets the lodaded data (as an array buffer)
  67785. */
  67786. data: ArrayBuffer;
  67787. /**
  67788. * Callback called when the task is successful
  67789. */
  67790. onSuccess: (task: BinaryFileAssetTask) => void;
  67791. /**
  67792. * Callback called when the task is successful
  67793. */
  67794. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67795. /**
  67796. * Creates a new BinaryFileAssetTask object
  67797. * @param name defines the name of the new task
  67798. * @param url defines the location of the file to load
  67799. */
  67800. constructor(
  67801. /**
  67802. * Defines the name of the task
  67803. */
  67804. name: string,
  67805. /**
  67806. * Defines the location of the file to load
  67807. */
  67808. url: string);
  67809. /**
  67810. * Execute the current task
  67811. * @param scene defines the scene where you want your assets to be loaded
  67812. * @param onSuccess is a callback called when the task is successfully executed
  67813. * @param onError is a callback called if an error occurs
  67814. */
  67815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67816. }
  67817. /**
  67818. * Define a task used by AssetsManager to load images
  67819. */
  67820. export class ImageAssetTask extends AbstractAssetTask {
  67821. /**
  67822. * Defines the name of the task
  67823. */
  67824. name: string;
  67825. /**
  67826. * Defines the location of the image to load
  67827. */
  67828. url: string;
  67829. /**
  67830. * Gets the loaded images
  67831. */
  67832. image: HTMLImageElement;
  67833. /**
  67834. * Callback called when the task is successful
  67835. */
  67836. onSuccess: (task: ImageAssetTask) => void;
  67837. /**
  67838. * Callback called when the task is successful
  67839. */
  67840. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67841. /**
  67842. * Creates a new ImageAssetTask
  67843. * @param name defines the name of the task
  67844. * @param url defines the location of the image to load
  67845. */
  67846. constructor(
  67847. /**
  67848. * Defines the name of the task
  67849. */
  67850. name: string,
  67851. /**
  67852. * Defines the location of the image to load
  67853. */
  67854. url: string);
  67855. /**
  67856. * Execute the current task
  67857. * @param scene defines the scene where you want your assets to be loaded
  67858. * @param onSuccess is a callback called when the task is successfully executed
  67859. * @param onError is a callback called if an error occurs
  67860. */
  67861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67862. }
  67863. /**
  67864. * Defines the interface used by texture loading tasks
  67865. */
  67866. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67867. /**
  67868. * Gets the loaded texture
  67869. */
  67870. texture: TEX;
  67871. }
  67872. /**
  67873. * Define a task used by AssetsManager to load 2D textures
  67874. */
  67875. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67876. /**
  67877. * Defines the name of the task
  67878. */
  67879. name: string;
  67880. /**
  67881. * Defines the location of the file to load
  67882. */
  67883. url: string;
  67884. /**
  67885. * Defines if mipmap should not be generated (default is false)
  67886. */
  67887. noMipmap?: boolean | undefined;
  67888. /**
  67889. * Defines if texture must be inverted on Y axis (default is false)
  67890. */
  67891. invertY?: boolean | undefined;
  67892. /**
  67893. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67894. */
  67895. samplingMode: number;
  67896. /**
  67897. * Gets the loaded texture
  67898. */
  67899. texture: Texture;
  67900. /**
  67901. * Callback called when the task is successful
  67902. */
  67903. onSuccess: (task: TextureAssetTask) => void;
  67904. /**
  67905. * Callback called when the task is successful
  67906. */
  67907. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67908. /**
  67909. * Creates a new TextureAssetTask object
  67910. * @param name defines the name of the task
  67911. * @param url defines the location of the file to load
  67912. * @param noMipmap defines if mipmap should not be generated (default is false)
  67913. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67914. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67915. */
  67916. constructor(
  67917. /**
  67918. * Defines the name of the task
  67919. */
  67920. name: string,
  67921. /**
  67922. * Defines the location of the file to load
  67923. */
  67924. url: string,
  67925. /**
  67926. * Defines if mipmap should not be generated (default is false)
  67927. */
  67928. noMipmap?: boolean | undefined,
  67929. /**
  67930. * Defines if texture must be inverted on Y axis (default is false)
  67931. */
  67932. invertY?: boolean | undefined,
  67933. /**
  67934. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67935. */
  67936. samplingMode?: number);
  67937. /**
  67938. * Execute the current task
  67939. * @param scene defines the scene where you want your assets to be loaded
  67940. * @param onSuccess is a callback called when the task is successfully executed
  67941. * @param onError is a callback called if an error occurs
  67942. */
  67943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67944. }
  67945. /**
  67946. * Define a task used by AssetsManager to load cube textures
  67947. */
  67948. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67949. /**
  67950. * Defines the name of the task
  67951. */
  67952. name: string;
  67953. /**
  67954. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67955. */
  67956. url: string;
  67957. /**
  67958. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67959. */
  67960. extensions?: string[] | undefined;
  67961. /**
  67962. * Defines if mipmaps should not be generated (default is false)
  67963. */
  67964. noMipmap?: boolean | undefined;
  67965. /**
  67966. * Defines the explicit list of files (undefined by default)
  67967. */
  67968. files?: string[] | undefined;
  67969. /**
  67970. * Gets the loaded texture
  67971. */
  67972. texture: CubeTexture;
  67973. /**
  67974. * Callback called when the task is successful
  67975. */
  67976. onSuccess: (task: CubeTextureAssetTask) => void;
  67977. /**
  67978. * Callback called when the task is successful
  67979. */
  67980. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67981. /**
  67982. * Creates a new CubeTextureAssetTask
  67983. * @param name defines the name of the task
  67984. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67985. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67986. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67987. * @param files defines the explicit list of files (undefined by default)
  67988. */
  67989. constructor(
  67990. /**
  67991. * Defines the name of the task
  67992. */
  67993. name: string,
  67994. /**
  67995. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67996. */
  67997. url: string,
  67998. /**
  67999. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68000. */
  68001. extensions?: string[] | undefined,
  68002. /**
  68003. * Defines if mipmaps should not be generated (default is false)
  68004. */
  68005. noMipmap?: boolean | undefined,
  68006. /**
  68007. * Defines the explicit list of files (undefined by default)
  68008. */
  68009. files?: string[] | undefined);
  68010. /**
  68011. * Execute the current task
  68012. * @param scene defines the scene where you want your assets to be loaded
  68013. * @param onSuccess is a callback called when the task is successfully executed
  68014. * @param onError is a callback called if an error occurs
  68015. */
  68016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68017. }
  68018. /**
  68019. * Define a task used by AssetsManager to load HDR cube textures
  68020. */
  68021. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68022. /**
  68023. * Defines the name of the task
  68024. */
  68025. name: string;
  68026. /**
  68027. * Defines the location of the file to load
  68028. */
  68029. url: string;
  68030. /**
  68031. * Defines the desired size (the more it increases the longer the generation will be)
  68032. */
  68033. size: number;
  68034. /**
  68035. * Defines if mipmaps should not be generated (default is false)
  68036. */
  68037. noMipmap: boolean;
  68038. /**
  68039. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68040. */
  68041. generateHarmonics: boolean;
  68042. /**
  68043. * 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)
  68044. */
  68045. gammaSpace: boolean;
  68046. /**
  68047. * Internal Use Only
  68048. */
  68049. reserved: boolean;
  68050. /**
  68051. * Gets the loaded texture
  68052. */
  68053. texture: HDRCubeTexture;
  68054. /**
  68055. * Callback called when the task is successful
  68056. */
  68057. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68058. /**
  68059. * Callback called when the task is successful
  68060. */
  68061. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68062. /**
  68063. * Creates a new HDRCubeTextureAssetTask object
  68064. * @param name defines the name of the task
  68065. * @param url defines the location of the file to load
  68066. * @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.
  68067. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68068. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68069. * @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)
  68070. * @param reserved Internal use only
  68071. */
  68072. constructor(
  68073. /**
  68074. * Defines the name of the task
  68075. */
  68076. name: string,
  68077. /**
  68078. * Defines the location of the file to load
  68079. */
  68080. url: string,
  68081. /**
  68082. * Defines the desired size (the more it increases the longer the generation will be)
  68083. */
  68084. size: number,
  68085. /**
  68086. * Defines if mipmaps should not be generated (default is false)
  68087. */
  68088. noMipmap?: boolean,
  68089. /**
  68090. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68091. */
  68092. generateHarmonics?: boolean,
  68093. /**
  68094. * 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)
  68095. */
  68096. gammaSpace?: boolean,
  68097. /**
  68098. * Internal Use Only
  68099. */
  68100. reserved?: boolean);
  68101. /**
  68102. * Execute the current task
  68103. * @param scene defines the scene where you want your assets to be loaded
  68104. * @param onSuccess is a callback called when the task is successfully executed
  68105. * @param onError is a callback called if an error occurs
  68106. */
  68107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68108. }
  68109. /**
  68110. * Define a task used by AssetsManager to load Equirectangular cube textures
  68111. */
  68112. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68113. /**
  68114. * Defines the name of the task
  68115. */
  68116. name: string;
  68117. /**
  68118. * Defines the location of the file to load
  68119. */
  68120. url: string;
  68121. /**
  68122. * Defines the desired size (the more it increases the longer the generation will be)
  68123. */
  68124. size: number;
  68125. /**
  68126. * Defines if mipmaps should not be generated (default is false)
  68127. */
  68128. noMipmap: boolean;
  68129. /**
  68130. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68131. * but the standard material would require them in Gamma space) (default is true)
  68132. */
  68133. gammaSpace: boolean;
  68134. /**
  68135. * Gets the loaded texture
  68136. */
  68137. texture: EquiRectangularCubeTexture;
  68138. /**
  68139. * Callback called when the task is successful
  68140. */
  68141. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68142. /**
  68143. * Callback called when the task is successful
  68144. */
  68145. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68146. /**
  68147. * Creates a new EquiRectangularCubeTextureAssetTask object
  68148. * @param name defines the name of the task
  68149. * @param url defines the location of the file to load
  68150. * @param size defines the desired size (the more it increases the longer the generation will be)
  68151. * If the size is omitted this implies you are using a preprocessed cubemap.
  68152. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68153. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68154. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68155. * (default is true)
  68156. */
  68157. constructor(
  68158. /**
  68159. * Defines the name of the task
  68160. */
  68161. name: string,
  68162. /**
  68163. * Defines the location of the file to load
  68164. */
  68165. url: string,
  68166. /**
  68167. * Defines the desired size (the more it increases the longer the generation will be)
  68168. */
  68169. size: number,
  68170. /**
  68171. * Defines if mipmaps should not be generated (default is false)
  68172. */
  68173. noMipmap?: boolean,
  68174. /**
  68175. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68176. * but the standard material would require them in Gamma space) (default is true)
  68177. */
  68178. gammaSpace?: boolean);
  68179. /**
  68180. * Execute the current task
  68181. * @param scene defines the scene where you want your assets to be loaded
  68182. * @param onSuccess is a callback called when the task is successfully executed
  68183. * @param onError is a callback called if an error occurs
  68184. */
  68185. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68186. }
  68187. /**
  68188. * This class can be used to easily import assets into a scene
  68189. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68190. */
  68191. export class AssetsManager {
  68192. private _scene;
  68193. private _isLoading;
  68194. protected _tasks: AbstractAssetTask[];
  68195. protected _waitingTasksCount: number;
  68196. protected _totalTasksCount: number;
  68197. /**
  68198. * Callback called when all tasks are processed
  68199. */
  68200. onFinish: (tasks: AbstractAssetTask[]) => void;
  68201. /**
  68202. * Callback called when a task is successful
  68203. */
  68204. onTaskSuccess: (task: AbstractAssetTask) => void;
  68205. /**
  68206. * Callback called when a task had an error
  68207. */
  68208. onTaskError: (task: AbstractAssetTask) => void;
  68209. /**
  68210. * Callback called when a task is done (whatever the result is)
  68211. */
  68212. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68213. /**
  68214. * Observable called when all tasks are processed
  68215. */
  68216. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68217. /**
  68218. * Observable called when a task had an error
  68219. */
  68220. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68221. /**
  68222. * Observable called when all tasks were executed
  68223. */
  68224. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68225. /**
  68226. * Observable called when a task is done (whatever the result is)
  68227. */
  68228. onProgressObservable: Observable<IAssetsProgressEvent>;
  68229. /**
  68230. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68232. */
  68233. useDefaultLoadingScreen: boolean;
  68234. /**
  68235. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68236. * when all assets have been downloaded.
  68237. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68238. */
  68239. autoHideLoadingUI: boolean;
  68240. /**
  68241. * Creates a new AssetsManager
  68242. * @param scene defines the scene to work on
  68243. */
  68244. constructor(scene: Scene);
  68245. /**
  68246. * Add a MeshAssetTask to the list of active tasks
  68247. * @param taskName defines the name of the new task
  68248. * @param meshesNames defines the name of meshes to load
  68249. * @param rootUrl defines the root url to use to locate files
  68250. * @param sceneFilename defines the filename of the scene file
  68251. * @returns a new MeshAssetTask object
  68252. */
  68253. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68254. /**
  68255. * Add a TextFileAssetTask to the list of active tasks
  68256. * @param taskName defines the name of the new task
  68257. * @param url defines the url of the file to load
  68258. * @returns a new TextFileAssetTask object
  68259. */
  68260. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68261. /**
  68262. * Add a BinaryFileAssetTask to the list of active tasks
  68263. * @param taskName defines the name of the new task
  68264. * @param url defines the url of the file to load
  68265. * @returns a new BinaryFileAssetTask object
  68266. */
  68267. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68268. /**
  68269. * Add a ImageAssetTask to the list of active tasks
  68270. * @param taskName defines the name of the new task
  68271. * @param url defines the url of the file to load
  68272. * @returns a new ImageAssetTask object
  68273. */
  68274. addImageTask(taskName: string, url: string): ImageAssetTask;
  68275. /**
  68276. * Add a TextureAssetTask to the list of active tasks
  68277. * @param taskName defines the name of the new task
  68278. * @param url defines the url of the file to load
  68279. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68280. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68281. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68282. * @returns a new TextureAssetTask object
  68283. */
  68284. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68285. /**
  68286. * Add a CubeTextureAssetTask to the list of active tasks
  68287. * @param taskName defines the name of the new task
  68288. * @param url defines the url of the file to load
  68289. * @param extensions defines the extension to use to load the cube map (can be null)
  68290. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68291. * @param files defines the list of files to load (can be null)
  68292. * @returns a new CubeTextureAssetTask object
  68293. */
  68294. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68295. /**
  68296. *
  68297. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68298. * @param taskName defines the name of the new task
  68299. * @param url defines the url of the file to load
  68300. * @param size defines the size you want for the cubemap (can be null)
  68301. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68302. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68303. * @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)
  68304. * @param reserved Internal use only
  68305. * @returns a new HDRCubeTextureAssetTask object
  68306. */
  68307. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68308. /**
  68309. *
  68310. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68311. * @param taskName defines the name of the new task
  68312. * @param url defines the url of the file to load
  68313. * @param size defines the size you want for the cubemap (can be null)
  68314. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68315. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68316. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68317. * @returns a new EquiRectangularCubeTextureAssetTask object
  68318. */
  68319. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68320. /**
  68321. * Remove a task from the assets manager.
  68322. * @param task the task to remove
  68323. */
  68324. removeTask(task: AbstractAssetTask): void;
  68325. private _decreaseWaitingTasksCount;
  68326. private _runTask;
  68327. /**
  68328. * Reset the AssetsManager and remove all tasks
  68329. * @return the current instance of the AssetsManager
  68330. */
  68331. reset(): AssetsManager;
  68332. /**
  68333. * Start the loading process
  68334. * @return the current instance of the AssetsManager
  68335. */
  68336. load(): AssetsManager;
  68337. /**
  68338. * Start the loading process as an async operation
  68339. * @return a promise returning the list of failed tasks
  68340. */
  68341. loadAsync(): Promise<void>;
  68342. }
  68343. }
  68344. declare module "babylonjs/Misc/deferred" {
  68345. /**
  68346. * Wrapper class for promise with external resolve and reject.
  68347. */
  68348. export class Deferred<T> {
  68349. /**
  68350. * The promise associated with this deferred object.
  68351. */
  68352. readonly promise: Promise<T>;
  68353. private _resolve;
  68354. private _reject;
  68355. /**
  68356. * The resolve method of the promise associated with this deferred object.
  68357. */
  68358. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  68359. /**
  68360. * The reject method of the promise associated with this deferred object.
  68361. */
  68362. readonly reject: (reason?: any) => void;
  68363. /**
  68364. * Constructor for this deferred object.
  68365. */
  68366. constructor();
  68367. }
  68368. }
  68369. declare module "babylonjs/Misc/meshExploder" {
  68370. import { Mesh } from "babylonjs/Meshes/mesh";
  68371. /**
  68372. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68373. */
  68374. export class MeshExploder {
  68375. private _centerMesh;
  68376. private _meshes;
  68377. private _meshesOrigins;
  68378. private _toCenterVectors;
  68379. private _scaledDirection;
  68380. private _newPosition;
  68381. private _centerPosition;
  68382. /**
  68383. * Explodes meshes from a center mesh.
  68384. * @param meshes The meshes to explode.
  68385. * @param centerMesh The mesh to be center of explosion.
  68386. */
  68387. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68388. private _setCenterMesh;
  68389. /**
  68390. * Get class name
  68391. * @returns "MeshExploder"
  68392. */
  68393. getClassName(): string;
  68394. /**
  68395. * "Exploded meshes"
  68396. * @returns Array of meshes with the centerMesh at index 0.
  68397. */
  68398. getMeshes(): Array<Mesh>;
  68399. /**
  68400. * Explodes meshes giving a specific direction
  68401. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68402. */
  68403. explode(direction?: number): void;
  68404. }
  68405. }
  68406. declare module "babylonjs/Misc/filesInput" {
  68407. import { Engine } from "babylonjs/Engines/engine";
  68408. import { Scene } from "babylonjs/scene";
  68409. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  68410. /**
  68411. * Class used to help managing file picking and drag'n'drop
  68412. */
  68413. export class FilesInput {
  68414. /**
  68415. * List of files ready to be loaded
  68416. */
  68417. static readonly FilesToLoad: {
  68418. [key: string]: File;
  68419. };
  68420. /**
  68421. * Callback called when a file is processed
  68422. */
  68423. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68424. private _engine;
  68425. private _currentScene;
  68426. private _sceneLoadedCallback;
  68427. private _progressCallback;
  68428. private _additionalRenderLoopLogicCallback;
  68429. private _textureLoadingCallback;
  68430. private _startingProcessingFilesCallback;
  68431. private _onReloadCallback;
  68432. private _errorCallback;
  68433. private _elementToMonitor;
  68434. private _sceneFileToLoad;
  68435. private _filesToLoad;
  68436. /**
  68437. * Creates a new FilesInput
  68438. * @param engine defines the rendering engine
  68439. * @param scene defines the hosting scene
  68440. * @param sceneLoadedCallback callback called when scene is loaded
  68441. * @param progressCallback callback called to track progress
  68442. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68443. * @param textureLoadingCallback callback called when a texture is loading
  68444. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68445. * @param onReloadCallback callback called when a reload is requested
  68446. * @param errorCallback callback call if an error occurs
  68447. */
  68448. 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);
  68449. private _dragEnterHandler;
  68450. private _dragOverHandler;
  68451. private _dropHandler;
  68452. /**
  68453. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68454. * @param elementToMonitor defines the DOM element to track
  68455. */
  68456. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68457. /**
  68458. * Release all associated resources
  68459. */
  68460. dispose(): void;
  68461. private renderFunction;
  68462. private drag;
  68463. private drop;
  68464. private _traverseFolder;
  68465. private _processFiles;
  68466. /**
  68467. * Load files from a drop event
  68468. * @param event defines the drop event to use as source
  68469. */
  68470. loadFiles(event: any): void;
  68471. private _processReload;
  68472. /**
  68473. * Reload the current scene from the loaded files
  68474. */
  68475. reload(): void;
  68476. }
  68477. }
  68478. declare module "babylonjs/Misc/HighDynamicRange/index" {
  68479. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  68480. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  68481. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  68482. }
  68483. declare module "babylonjs/Misc/sceneOptimizer" {
  68484. import { Scene, IDisposable } from "babylonjs/scene";
  68485. import { Observable } from "babylonjs/Misc/observable";
  68486. /**
  68487. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68489. */
  68490. export class SceneOptimization {
  68491. /**
  68492. * Defines the priority of this optimization (0 by default which means first in the list)
  68493. */
  68494. priority: number;
  68495. /**
  68496. * Gets a string describing the action executed by the current optimization
  68497. * @returns description string
  68498. */
  68499. getDescription(): string;
  68500. /**
  68501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68502. * @param scene defines the current scene where to apply this optimization
  68503. * @param optimizer defines the current optimizer
  68504. * @returns true if everything that can be done was applied
  68505. */
  68506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68507. /**
  68508. * Creates the SceneOptimization object
  68509. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68510. * @param desc defines the description associated with the optimization
  68511. */
  68512. constructor(
  68513. /**
  68514. * Defines the priority of this optimization (0 by default which means first in the list)
  68515. */
  68516. priority?: number);
  68517. }
  68518. /**
  68519. * Defines an optimization used to reduce the size of render target textures
  68520. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68521. */
  68522. export class TextureOptimization extends SceneOptimization {
  68523. /**
  68524. * Defines the priority of this optimization (0 by default which means first in the list)
  68525. */
  68526. priority: number;
  68527. /**
  68528. * 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
  68529. */
  68530. maximumSize: number;
  68531. /**
  68532. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68533. */
  68534. step: number;
  68535. /**
  68536. * Gets a string describing the action executed by the current optimization
  68537. * @returns description string
  68538. */
  68539. getDescription(): string;
  68540. /**
  68541. * Creates the TextureOptimization object
  68542. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68543. * @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
  68544. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68545. */
  68546. constructor(
  68547. /**
  68548. * Defines the priority of this optimization (0 by default which means first in the list)
  68549. */
  68550. priority?: number,
  68551. /**
  68552. * 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
  68553. */
  68554. maximumSize?: number,
  68555. /**
  68556. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68557. */
  68558. step?: number);
  68559. /**
  68560. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68561. * @param scene defines the current scene where to apply this optimization
  68562. * @param optimizer defines the current optimizer
  68563. * @returns true if everything that can be done was applied
  68564. */
  68565. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68566. }
  68567. /**
  68568. * Defines an optimization used to increase or decrease the rendering resolution
  68569. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68570. */
  68571. export class HardwareScalingOptimization extends SceneOptimization {
  68572. /**
  68573. * Defines the priority of this optimization (0 by default which means first in the list)
  68574. */
  68575. priority: number;
  68576. /**
  68577. * Defines the maximum scale to use (2 by default)
  68578. */
  68579. maximumScale: number;
  68580. /**
  68581. * Defines the step to use between two passes (0.5 by default)
  68582. */
  68583. step: number;
  68584. private _currentScale;
  68585. private _directionOffset;
  68586. /**
  68587. * Gets a string describing the action executed by the current optimization
  68588. * @return description string
  68589. */
  68590. getDescription(): string;
  68591. /**
  68592. * Creates the HardwareScalingOptimization object
  68593. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68594. * @param maximumScale defines the maximum scale to use (2 by default)
  68595. * @param step defines the step to use between two passes (0.5 by default)
  68596. */
  68597. constructor(
  68598. /**
  68599. * Defines the priority of this optimization (0 by default which means first in the list)
  68600. */
  68601. priority?: number,
  68602. /**
  68603. * Defines the maximum scale to use (2 by default)
  68604. */
  68605. maximumScale?: number,
  68606. /**
  68607. * Defines the step to use between two passes (0.5 by default)
  68608. */
  68609. step?: number);
  68610. /**
  68611. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68612. * @param scene defines the current scene where to apply this optimization
  68613. * @param optimizer defines the current optimizer
  68614. * @returns true if everything that can be done was applied
  68615. */
  68616. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68617. }
  68618. /**
  68619. * Defines an optimization used to remove shadows
  68620. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68621. */
  68622. export class ShadowsOptimization extends SceneOptimization {
  68623. /**
  68624. * Gets a string describing the action executed by the current optimization
  68625. * @return description string
  68626. */
  68627. getDescription(): string;
  68628. /**
  68629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68630. * @param scene defines the current scene where to apply this optimization
  68631. * @param optimizer defines the current optimizer
  68632. * @returns true if everything that can be done was applied
  68633. */
  68634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68635. }
  68636. /**
  68637. * Defines an optimization used to turn post-processes off
  68638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68639. */
  68640. export class PostProcessesOptimization extends SceneOptimization {
  68641. /**
  68642. * Gets a string describing the action executed by the current optimization
  68643. * @return description string
  68644. */
  68645. getDescription(): string;
  68646. /**
  68647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68648. * @param scene defines the current scene where to apply this optimization
  68649. * @param optimizer defines the current optimizer
  68650. * @returns true if everything that can be done was applied
  68651. */
  68652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68653. }
  68654. /**
  68655. * Defines an optimization used to turn lens flares off
  68656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68657. */
  68658. export class LensFlaresOptimization extends SceneOptimization {
  68659. /**
  68660. * Gets a string describing the action executed by the current optimization
  68661. * @return description string
  68662. */
  68663. getDescription(): string;
  68664. /**
  68665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68666. * @param scene defines the current scene where to apply this optimization
  68667. * @param optimizer defines the current optimizer
  68668. * @returns true if everything that can be done was applied
  68669. */
  68670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68671. }
  68672. /**
  68673. * Defines an optimization based on user defined callback.
  68674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68675. */
  68676. export class CustomOptimization extends SceneOptimization {
  68677. /**
  68678. * Callback called to apply the custom optimization.
  68679. */
  68680. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68681. /**
  68682. * Callback called to get custom description
  68683. */
  68684. onGetDescription: () => string;
  68685. /**
  68686. * Gets a string describing the action executed by the current optimization
  68687. * @returns description string
  68688. */
  68689. getDescription(): string;
  68690. /**
  68691. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68692. * @param scene defines the current scene where to apply this optimization
  68693. * @param optimizer defines the current optimizer
  68694. * @returns true if everything that can be done was applied
  68695. */
  68696. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68697. }
  68698. /**
  68699. * Defines an optimization used to turn particles off
  68700. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68701. */
  68702. export class ParticlesOptimization extends SceneOptimization {
  68703. /**
  68704. * Gets a string describing the action executed by the current optimization
  68705. * @return description string
  68706. */
  68707. getDescription(): string;
  68708. /**
  68709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68710. * @param scene defines the current scene where to apply this optimization
  68711. * @param optimizer defines the current optimizer
  68712. * @returns true if everything that can be done was applied
  68713. */
  68714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68715. }
  68716. /**
  68717. * Defines an optimization used to turn render targets off
  68718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68719. */
  68720. export class RenderTargetsOptimization extends SceneOptimization {
  68721. /**
  68722. * Gets a string describing the action executed by the current optimization
  68723. * @return description string
  68724. */
  68725. getDescription(): string;
  68726. /**
  68727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68728. * @param scene defines the current scene where to apply this optimization
  68729. * @param optimizer defines the current optimizer
  68730. * @returns true if everything that can be done was applied
  68731. */
  68732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68733. }
  68734. /**
  68735. * Defines an optimization used to merge meshes with compatible materials
  68736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68737. */
  68738. export class MergeMeshesOptimization extends SceneOptimization {
  68739. private static _UpdateSelectionTree;
  68740. /**
  68741. * Gets or sets a boolean which defines if optimization octree has to be updated
  68742. */
  68743. /**
  68744. * Gets or sets a boolean which defines if optimization octree has to be updated
  68745. */
  68746. static UpdateSelectionTree: boolean;
  68747. /**
  68748. * Gets a string describing the action executed by the current optimization
  68749. * @return description string
  68750. */
  68751. getDescription(): string;
  68752. private _canBeMerged;
  68753. /**
  68754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68755. * @param scene defines the current scene where to apply this optimization
  68756. * @param optimizer defines the current optimizer
  68757. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68758. * @returns true if everything that can be done was applied
  68759. */
  68760. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68761. }
  68762. /**
  68763. * Defines a list of options used by SceneOptimizer
  68764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68765. */
  68766. export class SceneOptimizerOptions {
  68767. /**
  68768. * Defines the target frame rate to reach (60 by default)
  68769. */
  68770. targetFrameRate: number;
  68771. /**
  68772. * Defines the interval between two checkes (2000ms by default)
  68773. */
  68774. trackerDuration: number;
  68775. /**
  68776. * Gets the list of optimizations to apply
  68777. */
  68778. optimizations: SceneOptimization[];
  68779. /**
  68780. * Creates a new list of options used by SceneOptimizer
  68781. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68782. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68783. */
  68784. constructor(
  68785. /**
  68786. * Defines the target frame rate to reach (60 by default)
  68787. */
  68788. targetFrameRate?: number,
  68789. /**
  68790. * Defines the interval between two checkes (2000ms by default)
  68791. */
  68792. trackerDuration?: number);
  68793. /**
  68794. * Add a new optimization
  68795. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68796. * @returns the current SceneOptimizerOptions
  68797. */
  68798. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68799. /**
  68800. * Add a new custom optimization
  68801. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68802. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68803. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68804. * @returns the current SceneOptimizerOptions
  68805. */
  68806. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68807. /**
  68808. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68809. * @param targetFrameRate defines the target frame rate (60 by default)
  68810. * @returns a SceneOptimizerOptions object
  68811. */
  68812. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68813. /**
  68814. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68815. * @param targetFrameRate defines the target frame rate (60 by default)
  68816. * @returns a SceneOptimizerOptions object
  68817. */
  68818. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68819. /**
  68820. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68821. * @param targetFrameRate defines the target frame rate (60 by default)
  68822. * @returns a SceneOptimizerOptions object
  68823. */
  68824. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68825. }
  68826. /**
  68827. * Class used to run optimizations in order to reach a target frame rate
  68828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68829. */
  68830. export class SceneOptimizer implements IDisposable {
  68831. private _isRunning;
  68832. private _options;
  68833. private _scene;
  68834. private _currentPriorityLevel;
  68835. private _targetFrameRate;
  68836. private _trackerDuration;
  68837. private _currentFrameRate;
  68838. private _sceneDisposeObserver;
  68839. private _improvementMode;
  68840. /**
  68841. * Defines an observable called when the optimizer reaches the target frame rate
  68842. */
  68843. onSuccessObservable: Observable<SceneOptimizer>;
  68844. /**
  68845. * Defines an observable called when the optimizer enables an optimization
  68846. */
  68847. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68848. /**
  68849. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68850. */
  68851. onFailureObservable: Observable<SceneOptimizer>;
  68852. /**
  68853. * Gets a boolean indicating if the optimizer is in improvement mode
  68854. */
  68855. readonly isInImprovementMode: boolean;
  68856. /**
  68857. * Gets the current priority level (0 at start)
  68858. */
  68859. readonly currentPriorityLevel: number;
  68860. /**
  68861. * Gets the current frame rate checked by the SceneOptimizer
  68862. */
  68863. readonly currentFrameRate: number;
  68864. /**
  68865. * Gets or sets the current target frame rate (60 by default)
  68866. */
  68867. /**
  68868. * Gets or sets the current target frame rate (60 by default)
  68869. */
  68870. targetFrameRate: number;
  68871. /**
  68872. * Gets or sets the current interval between two checks (every 2000ms by default)
  68873. */
  68874. /**
  68875. * Gets or sets the current interval between two checks (every 2000ms by default)
  68876. */
  68877. trackerDuration: number;
  68878. /**
  68879. * Gets the list of active optimizations
  68880. */
  68881. readonly optimizations: SceneOptimization[];
  68882. /**
  68883. * Creates a new SceneOptimizer
  68884. * @param scene defines the scene to work on
  68885. * @param options defines the options to use with the SceneOptimizer
  68886. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68887. * @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)
  68888. */
  68889. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68890. /**
  68891. * Stops the current optimizer
  68892. */
  68893. stop(): void;
  68894. /**
  68895. * Reset the optimizer to initial step (current priority level = 0)
  68896. */
  68897. reset(): void;
  68898. /**
  68899. * Start the optimizer. By default it will try to reach a specific framerate
  68900. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68901. */
  68902. start(): void;
  68903. private _checkCurrentState;
  68904. /**
  68905. * Release all resources
  68906. */
  68907. dispose(): void;
  68908. /**
  68909. * Helper function to create a SceneOptimizer with one single line of code
  68910. * @param scene defines the scene to work on
  68911. * @param options defines the options to use with the SceneOptimizer
  68912. * @param onSuccess defines a callback to call on success
  68913. * @param onFailure defines a callback to call on failure
  68914. * @returns the new SceneOptimizer object
  68915. */
  68916. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68917. }
  68918. }
  68919. declare module "babylonjs/Misc/sceneSerializer" {
  68920. import { Scene } from "babylonjs/scene";
  68921. /**
  68922. * Class used to serialize a scene into a string
  68923. */
  68924. export class SceneSerializer {
  68925. /**
  68926. * Clear cache used by a previous serialization
  68927. */
  68928. static ClearCache(): void;
  68929. /**
  68930. * Serialize a scene into a JSON compatible object
  68931. * @param scene defines the scene to serialize
  68932. * @returns a JSON compatible object
  68933. */
  68934. static Serialize(scene: Scene): any;
  68935. /**
  68936. * Serialize a mesh into a JSON compatible object
  68937. * @param toSerialize defines the mesh to serialize
  68938. * @param withParents defines if parents must be serialized as well
  68939. * @param withChildren defines if children must be serialized as well
  68940. * @returns a JSON compatible object
  68941. */
  68942. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68943. }
  68944. }
  68945. declare module "babylonjs/Misc/textureTools" {
  68946. import { Texture } from "babylonjs/Materials/Textures/texture";
  68947. /**
  68948. * Class used to host texture specific utilities
  68949. */
  68950. export class TextureTools {
  68951. /**
  68952. * Uses the GPU to create a copy texture rescaled at a given size
  68953. * @param texture Texture to copy from
  68954. * @param width defines the desired width
  68955. * @param height defines the desired height
  68956. * @param useBilinearMode defines if bilinear mode has to be used
  68957. * @return the generated texture
  68958. */
  68959. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68960. }
  68961. }
  68962. declare module "babylonjs/Misc/videoRecorder" {
  68963. import { Nullable } from "babylonjs/types";
  68964. import { Engine } from "babylonjs/Engines/engine";
  68965. /**
  68966. * This represents the different options available for the video capture.
  68967. */
  68968. export interface VideoRecorderOptions {
  68969. /** Defines the mime type of the video. */
  68970. mimeType: string;
  68971. /** Defines the FPS the video should be recorded at. */
  68972. fps: number;
  68973. /** Defines the chunk size for the recording data. */
  68974. recordChunckSize: number;
  68975. /** The audio tracks to attach to the recording. */
  68976. audioTracks?: MediaStreamTrack[];
  68977. }
  68978. /**
  68979. * This can help with recording videos from BabylonJS.
  68980. * This is based on the available WebRTC functionalities of the browser.
  68981. *
  68982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68983. */
  68984. export class VideoRecorder {
  68985. private static readonly _defaultOptions;
  68986. /**
  68987. * Returns whether or not the VideoRecorder is available in your browser.
  68988. * @param engine Defines the Babylon Engine.
  68989. * @returns true if supported otherwise false.
  68990. */
  68991. static IsSupported(engine: Engine): boolean;
  68992. private readonly _options;
  68993. private _canvas;
  68994. private _mediaRecorder;
  68995. private _recordedChunks;
  68996. private _fileName;
  68997. private _resolve;
  68998. private _reject;
  68999. /**
  69000. * True when a recording is already in progress.
  69001. */
  69002. readonly isRecording: boolean;
  69003. /**
  69004. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69005. * @param engine Defines the BabylonJS Engine you wish to record.
  69006. * @param options Defines options that can be used to customize the capture.
  69007. */
  69008. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69009. /**
  69010. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69011. */
  69012. stopRecording(): void;
  69013. /**
  69014. * Starts recording the canvas for a max duration specified in parameters.
  69015. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69016. * If null no automatic download will start and you can rely on the promise to get the data back.
  69017. * @param maxDuration Defines the maximum recording time in seconds.
  69018. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69019. * @return A promise callback at the end of the recording with the video data in Blob.
  69020. */
  69021. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69022. /**
  69023. * Releases internal resources used during the recording.
  69024. */
  69025. dispose(): void;
  69026. private _handleDataAvailable;
  69027. private _handleError;
  69028. private _handleStop;
  69029. }
  69030. }
  69031. declare module "babylonjs/Misc/screenshotTools" {
  69032. import { Camera } from "babylonjs/Cameras/camera";
  69033. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  69034. import { Engine } from "babylonjs/Engines/engine";
  69035. /**
  69036. * Class containing a set of static utilities functions for screenshots
  69037. */
  69038. export class ScreenshotTools {
  69039. /**
  69040. * Captures a screenshot of the current rendering
  69041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69042. * @param engine defines the rendering engine
  69043. * @param camera defines the source camera
  69044. * @param size This parameter can be set to a single number or to an object with the
  69045. * following (optional) properties: precision, width, height. If a single number is passed,
  69046. * it will be used for both width and height. If an object is passed, the screenshot size
  69047. * will be derived from the parameters. The precision property is a multiplier allowing
  69048. * rendering at a higher or lower resolution
  69049. * @param successCallback defines the callback receives a single parameter which contains the
  69050. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69051. * src parameter of an <img> to display it
  69052. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69053. * Check your browser for supported MIME types
  69054. */
  69055. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69056. /**
  69057. * Captures a screenshot of the current rendering
  69058. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69059. * @param engine defines the rendering engine
  69060. * @param camera defines the source camera
  69061. * @param size This parameter can be set to a single number or to an object with the
  69062. * following (optional) properties: precision, width, height. If a single number is passed,
  69063. * it will be used for both width and height. If an object is passed, the screenshot size
  69064. * will be derived from the parameters. The precision property is a multiplier allowing
  69065. * rendering at a higher or lower resolution
  69066. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69067. * Check your browser for supported MIME types
  69068. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69069. * to the src parameter of an <img> to display it
  69070. */
  69071. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69072. /**
  69073. * Generates an image screenshot from the specified camera.
  69074. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69075. * @param engine The engine to use for rendering
  69076. * @param camera The camera to use for rendering
  69077. * @param size This parameter can be set to a single number or to an object with the
  69078. * following (optional) properties: precision, width, height. If a single number is passed,
  69079. * it will be used for both width and height. If an object is passed, the screenshot size
  69080. * will be derived from the parameters. The precision property is a multiplier allowing
  69081. * rendering at a higher or lower resolution
  69082. * @param successCallback The callback receives a single parameter which contains the
  69083. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69084. * src parameter of an <img> to display it
  69085. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69086. * Check your browser for supported MIME types
  69087. * @param samples Texture samples (default: 1)
  69088. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69089. * @param fileName A name for for the downloaded file.
  69090. */
  69091. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  69092. /**
  69093. * Generates an image screenshot from the specified camera.
  69094. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69095. * @param engine The engine to use for rendering
  69096. * @param camera The camera to use for rendering
  69097. * @param size This parameter can be set to a single number or to an object with the
  69098. * following (optional) properties: precision, width, height. If a single number is passed,
  69099. * it will be used for both width and height. If an object is passed, the screenshot size
  69100. * will be derived from the parameters. The precision property is a multiplier allowing
  69101. * rendering at a higher or lower resolution
  69102. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69103. * Check your browser for supported MIME types
  69104. * @param samples Texture samples (default: 1)
  69105. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69106. * @param fileName A name for for the downloaded file.
  69107. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69108. * to the src parameter of an <img> to display it
  69109. */
  69110. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  69111. /**
  69112. * Gets height and width for screenshot size
  69113. * @private
  69114. */
  69115. private static _getScreenshotSize;
  69116. }
  69117. }
  69118. declare module "babylonjs/Misc/dataReader" {
  69119. /**
  69120. * Interface for a data buffer
  69121. */
  69122. export interface IDataBuffer {
  69123. /**
  69124. * Reads bytes from the data buffer.
  69125. * @param byteOffset The byte offset to read
  69126. * @param byteLength The byte length to read
  69127. * @returns A promise that resolves when the bytes are read
  69128. */
  69129. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69130. /**
  69131. * The byte length of the buffer.
  69132. */
  69133. readonly byteLength: number;
  69134. }
  69135. /**
  69136. * Utility class for reading from a data buffer
  69137. */
  69138. export class DataReader {
  69139. /**
  69140. * The data buffer associated with this data reader.
  69141. */
  69142. readonly buffer: IDataBuffer;
  69143. /**
  69144. * The current byte offset from the beginning of the data buffer.
  69145. */
  69146. byteOffset: number;
  69147. private _dataView;
  69148. private _dataByteOffset;
  69149. /**
  69150. * Constructor
  69151. * @param buffer The buffer to read
  69152. */
  69153. constructor(buffer: IDataBuffer);
  69154. /**
  69155. * Loads the given byte length.
  69156. * @param byteLength The byte length to load
  69157. * @returns A promise that resolves when the load is complete
  69158. */
  69159. loadAsync(byteLength: number): Promise<void>;
  69160. /**
  69161. * Read a unsigned 32-bit integer from the currently loaded data range.
  69162. * @returns The 32-bit integer read
  69163. */
  69164. readUint32(): number;
  69165. /**
  69166. * Read a byte array from the currently loaded data range.
  69167. * @param byteLength The byte length to read
  69168. * @returns The byte array read
  69169. */
  69170. readUint8Array(byteLength: number): Uint8Array;
  69171. /**
  69172. * Read a string from the currently loaded data range.
  69173. * @param byteLength The byte length to read
  69174. * @returns The string read
  69175. */
  69176. readString(byteLength: number): string;
  69177. /**
  69178. * Skips the given byte length the currently loaded data range.
  69179. * @param byteLength The byte length to skip
  69180. */
  69181. skipBytes(byteLength: number): void;
  69182. }
  69183. }
  69184. declare module "babylonjs/Misc/index" {
  69185. export * from "babylonjs/Misc/andOrNotEvaluator";
  69186. export * from "babylonjs/Misc/assetsManager";
  69187. export * from "babylonjs/Misc/basis";
  69188. export * from "babylonjs/Misc/dds";
  69189. export * from "babylonjs/Misc/decorators";
  69190. export * from "babylonjs/Misc/deferred";
  69191. export * from "babylonjs/Misc/environmentTextureTools";
  69192. export * from "babylonjs/Misc/meshExploder";
  69193. export * from "babylonjs/Misc/filesInput";
  69194. export * from "babylonjs/Misc/HighDynamicRange/index";
  69195. export * from "babylonjs/Misc/khronosTextureContainer";
  69196. export * from "babylonjs/Misc/observable";
  69197. export * from "babylonjs/Misc/performanceMonitor";
  69198. export * from "babylonjs/Misc/promise";
  69199. export * from "babylonjs/Misc/sceneOptimizer";
  69200. export * from "babylonjs/Misc/sceneSerializer";
  69201. export * from "babylonjs/Misc/smartArray";
  69202. export * from "babylonjs/Misc/stringDictionary";
  69203. export * from "babylonjs/Misc/tags";
  69204. export * from "babylonjs/Misc/textureTools";
  69205. export * from "babylonjs/Misc/tga";
  69206. export * from "babylonjs/Misc/tools";
  69207. export * from "babylonjs/Misc/videoRecorder";
  69208. export * from "babylonjs/Misc/virtualJoystick";
  69209. export * from "babylonjs/Misc/workerPool";
  69210. export * from "babylonjs/Misc/logger";
  69211. export * from "babylonjs/Misc/typeStore";
  69212. export * from "babylonjs/Misc/filesInputStore";
  69213. export * from "babylonjs/Misc/deepCopier";
  69214. export * from "babylonjs/Misc/pivotTools";
  69215. export * from "babylonjs/Misc/precisionDate";
  69216. export * from "babylonjs/Misc/screenshotTools";
  69217. export * from "babylonjs/Misc/typeStore";
  69218. export * from "babylonjs/Misc/webRequest";
  69219. export * from "babylonjs/Misc/iInspectable";
  69220. export * from "babylonjs/Misc/brdfTextureTools";
  69221. export * from "babylonjs/Misc/rgbdTextureTools";
  69222. export * from "babylonjs/Misc/gradients";
  69223. export * from "babylonjs/Misc/perfCounter";
  69224. export * from "babylonjs/Misc/fileRequest";
  69225. export * from "babylonjs/Misc/customAnimationFrameRequester";
  69226. export * from "babylonjs/Misc/retryStrategy";
  69227. export * from "babylonjs/Misc/interfaces/screenshotSize";
  69228. export * from "babylonjs/Misc/canvasGenerator";
  69229. export * from "babylonjs/Misc/fileTools";
  69230. export * from "babylonjs/Misc/stringTools";
  69231. export * from "babylonjs/Misc/dataReader";
  69232. }
  69233. declare module "babylonjs/index" {
  69234. export * from "babylonjs/abstractScene";
  69235. export * from "babylonjs/Actions/index";
  69236. export * from "babylonjs/Animations/index";
  69237. export * from "babylonjs/assetContainer";
  69238. export * from "babylonjs/Audio/index";
  69239. export * from "babylonjs/Behaviors/index";
  69240. export * from "babylonjs/Bones/index";
  69241. export * from "babylonjs/Cameras/index";
  69242. export * from "babylonjs/Collisions/index";
  69243. export * from "babylonjs/Culling/index";
  69244. export * from "babylonjs/Debug/index";
  69245. export * from "babylonjs/Engines/index";
  69246. export * from "babylonjs/Events/index";
  69247. export * from "babylonjs/Gamepads/index";
  69248. export * from "babylonjs/Gizmos/index";
  69249. export * from "babylonjs/Helpers/index";
  69250. export * from "babylonjs/Instrumentation/index";
  69251. export * from "babylonjs/Layers/index";
  69252. export * from "babylonjs/LensFlares/index";
  69253. export * from "babylonjs/Lights/index";
  69254. export * from "babylonjs/Loading/index";
  69255. export * from "babylonjs/Materials/index";
  69256. export * from "babylonjs/Maths/index";
  69257. export * from "babylonjs/Meshes/index";
  69258. export * from "babylonjs/Morph/index";
  69259. export * from "babylonjs/Navigation/index";
  69260. export * from "babylonjs/node";
  69261. export * from "babylonjs/Offline/index";
  69262. export * from "babylonjs/Particles/index";
  69263. export * from "babylonjs/Physics/index";
  69264. export * from "babylonjs/PostProcesses/index";
  69265. export * from "babylonjs/Probes/index";
  69266. export * from "babylonjs/Rendering/index";
  69267. export * from "babylonjs/scene";
  69268. export * from "babylonjs/sceneComponent";
  69269. export * from "babylonjs/Sprites/index";
  69270. export * from "babylonjs/States/index";
  69271. export * from "babylonjs/Misc/index";
  69272. export * from "babylonjs/types";
  69273. }
  69274. declare module "babylonjs/Animations/pathCursor" {
  69275. import { Vector3 } from "babylonjs/Maths/math.vector";
  69276. import { Path2 } from "babylonjs/Maths/math.path";
  69277. /**
  69278. * A cursor which tracks a point on a path
  69279. */
  69280. export class PathCursor {
  69281. private path;
  69282. /**
  69283. * Stores path cursor callbacks for when an onchange event is triggered
  69284. */
  69285. private _onchange;
  69286. /**
  69287. * The value of the path cursor
  69288. */
  69289. value: number;
  69290. /**
  69291. * The animation array of the path cursor
  69292. */
  69293. animations: Animation[];
  69294. /**
  69295. * Initializes the path cursor
  69296. * @param path The path to track
  69297. */
  69298. constructor(path: Path2);
  69299. /**
  69300. * Gets the cursor point on the path
  69301. * @returns A point on the path cursor at the cursor location
  69302. */
  69303. getPoint(): Vector3;
  69304. /**
  69305. * Moves the cursor ahead by the step amount
  69306. * @param step The amount to move the cursor forward
  69307. * @returns This path cursor
  69308. */
  69309. moveAhead(step?: number): PathCursor;
  69310. /**
  69311. * Moves the cursor behind by the step amount
  69312. * @param step The amount to move the cursor back
  69313. * @returns This path cursor
  69314. */
  69315. moveBack(step?: number): PathCursor;
  69316. /**
  69317. * Moves the cursor by the step amount
  69318. * If the step amount is greater than one, an exception is thrown
  69319. * @param step The amount to move the cursor
  69320. * @returns This path cursor
  69321. */
  69322. move(step: number): PathCursor;
  69323. /**
  69324. * Ensures that the value is limited between zero and one
  69325. * @returns This path cursor
  69326. */
  69327. private ensureLimits;
  69328. /**
  69329. * Runs onchange callbacks on change (used by the animation engine)
  69330. * @returns This path cursor
  69331. */
  69332. private raiseOnChange;
  69333. /**
  69334. * Executes a function on change
  69335. * @param f A path cursor onchange callback
  69336. * @returns This path cursor
  69337. */
  69338. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69339. }
  69340. }
  69341. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  69342. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  69343. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  69344. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  69345. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  69346. }
  69347. declare module "babylonjs/Engines/Processors/Expressions/index" {
  69348. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  69349. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  69350. }
  69351. declare module "babylonjs/Engines/Processors/index" {
  69352. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  69353. export * from "babylonjs/Engines/Processors/Expressions/index";
  69354. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  69355. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  69356. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  69357. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  69358. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  69359. export * from "babylonjs/Engines/Processors/shaderProcessor";
  69360. }
  69361. declare module "babylonjs/Legacy/legacy" {
  69362. import * as Babylon from "babylonjs/index";
  69363. export * from "babylonjs/index";
  69364. }
  69365. declare module "babylonjs/Shaders/blur.fragment" {
  69366. /** @hidden */
  69367. export var blurPixelShader: {
  69368. name: string;
  69369. shader: string;
  69370. };
  69371. }
  69372. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  69373. /** @hidden */
  69374. export var pointCloudVertexDeclaration: {
  69375. name: string;
  69376. shader: string;
  69377. };
  69378. }
  69379. declare module "babylonjs" {
  69380. export * from "babylonjs/Legacy/legacy";
  69381. }
  69382. declare module BABYLON {
  69383. /** Alias type for value that can be null */
  69384. export type Nullable<T> = T | null;
  69385. /**
  69386. * Alias type for number that are floats
  69387. * @ignorenaming
  69388. */
  69389. export type float = number;
  69390. /**
  69391. * Alias type for number that are doubles.
  69392. * @ignorenaming
  69393. */
  69394. export type double = number;
  69395. /**
  69396. * Alias type for number that are integer
  69397. * @ignorenaming
  69398. */
  69399. export type int = number;
  69400. /** Alias type for number array or Float32Array */
  69401. export type FloatArray = number[] | Float32Array;
  69402. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  69403. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  69404. /**
  69405. * Alias for types that can be used by a Buffer or VertexBuffer.
  69406. */
  69407. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  69408. /**
  69409. * Alias type for primitive types
  69410. * @ignorenaming
  69411. */
  69412. type Primitive = undefined | null | boolean | string | number | Function;
  69413. /**
  69414. * Type modifier to make all the properties of an object Readonly
  69415. */
  69416. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  69417. /**
  69418. * Type modifier to make all the properties of an object Readonly recursively
  69419. */
  69420. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  69421. /**
  69422. * Type modifier to make object properties readonly.
  69423. */
  69424. export type DeepImmutableObject<T> = {
  69425. readonly [K in keyof T]: DeepImmutable<T[K]>;
  69426. };
  69427. /** @hidden */
  69428. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  69429. }
  69430. }
  69431. declare module BABYLON {
  69432. /**
  69433. * A class serves as a medium between the observable and its observers
  69434. */
  69435. export class EventState {
  69436. /**
  69437. * Create a new EventState
  69438. * @param mask defines the mask associated with this state
  69439. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69440. * @param target defines the original target of the state
  69441. * @param currentTarget defines the current target of the state
  69442. */
  69443. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  69444. /**
  69445. * Initialize the current event state
  69446. * @param mask defines the mask associated with this state
  69447. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  69448. * @param target defines the original target of the state
  69449. * @param currentTarget defines the current target of the state
  69450. * @returns the current event state
  69451. */
  69452. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  69453. /**
  69454. * An Observer can set this property to true to prevent subsequent observers of being notified
  69455. */
  69456. skipNextObservers: boolean;
  69457. /**
  69458. * Get the mask value that were used to trigger the event corresponding to this EventState object
  69459. */
  69460. mask: number;
  69461. /**
  69462. * The object that originally notified the event
  69463. */
  69464. target?: any;
  69465. /**
  69466. * The current object in the bubbling phase
  69467. */
  69468. currentTarget?: any;
  69469. /**
  69470. * This will be populated with the return value of the last function that was executed.
  69471. * If it is the first function in the callback chain it will be the event data.
  69472. */
  69473. lastReturnValue?: any;
  69474. }
  69475. /**
  69476. * Represent an Observer registered to a given Observable object.
  69477. */
  69478. export class Observer<T> {
  69479. /**
  69480. * Defines the callback to call when the observer is notified
  69481. */
  69482. callback: (eventData: T, eventState: EventState) => void;
  69483. /**
  69484. * Defines the mask of the observer (used to filter notifications)
  69485. */
  69486. mask: number;
  69487. /**
  69488. * Defines the current scope used to restore the JS context
  69489. */
  69490. scope: any;
  69491. /** @hidden */
  69492. _willBeUnregistered: boolean;
  69493. /**
  69494. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  69495. */
  69496. unregisterOnNextCall: boolean;
  69497. /**
  69498. * Creates a new observer
  69499. * @param callback defines the callback to call when the observer is notified
  69500. * @param mask defines the mask of the observer (used to filter notifications)
  69501. * @param scope defines the current scope used to restore the JS context
  69502. */
  69503. constructor(
  69504. /**
  69505. * Defines the callback to call when the observer is notified
  69506. */
  69507. callback: (eventData: T, eventState: EventState) => void,
  69508. /**
  69509. * Defines the mask of the observer (used to filter notifications)
  69510. */
  69511. mask: number,
  69512. /**
  69513. * Defines the current scope used to restore the JS context
  69514. */
  69515. scope?: any);
  69516. }
  69517. /**
  69518. * Represent a list of observers registered to multiple Observables object.
  69519. */
  69520. export class MultiObserver<T> {
  69521. private _observers;
  69522. private _observables;
  69523. /**
  69524. * Release associated resources
  69525. */
  69526. dispose(): void;
  69527. /**
  69528. * Raise a callback when one of the observable will notify
  69529. * @param observables defines a list of observables to watch
  69530. * @param callback defines the callback to call on notification
  69531. * @param mask defines the mask used to filter notifications
  69532. * @param scope defines the current scope used to restore the JS context
  69533. * @returns the new MultiObserver
  69534. */
  69535. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  69536. }
  69537. /**
  69538. * The Observable class is a simple implementation of the Observable pattern.
  69539. *
  69540. * 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.
  69541. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  69542. * 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).
  69543. * 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.
  69544. */
  69545. export class Observable<T> {
  69546. private _observers;
  69547. private _eventState;
  69548. private _onObserverAdded;
  69549. /**
  69550. * Gets the list of observers
  69551. */
  69552. readonly observers: Array<Observer<T>>;
  69553. /**
  69554. * Creates a new observable
  69555. * @param onObserverAdded defines a callback to call when a new observer is added
  69556. */
  69557. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  69558. /**
  69559. * Create a new Observer with the specified callback
  69560. * @param callback the callback that will be executed for that Observer
  69561. * @param mask the mask used to filter observers
  69562. * @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.
  69563. * @param scope optional scope for the callback to be called from
  69564. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  69565. * @returns the new observer created for the callback
  69566. */
  69567. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  69568. /**
  69569. * Create a new Observer with the specified callback and unregisters after the next notification
  69570. * @param callback the callback that will be executed for that Observer
  69571. * @returns the new observer created for the callback
  69572. */
  69573. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  69574. /**
  69575. * Remove an Observer from the Observable object
  69576. * @param observer the instance of the Observer to remove
  69577. * @returns false if it doesn't belong to this Observable
  69578. */
  69579. remove(observer: Nullable<Observer<T>>): boolean;
  69580. /**
  69581. * Remove a callback from the Observable object
  69582. * @param callback the callback to remove
  69583. * @param scope optional scope. If used only the callbacks with this scope will be removed
  69584. * @returns false if it doesn't belong to this Observable
  69585. */
  69586. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  69587. private _deferUnregister;
  69588. private _remove;
  69589. /**
  69590. * Moves the observable to the top of the observer list making it get called first when notified
  69591. * @param observer the observer to move
  69592. */
  69593. makeObserverTopPriority(observer: Observer<T>): void;
  69594. /**
  69595. * Moves the observable to the bottom of the observer list making it get called last when notified
  69596. * @param observer the observer to move
  69597. */
  69598. makeObserverBottomPriority(observer: Observer<T>): void;
  69599. /**
  69600. * Notify all Observers by calling their respective callback with the given data
  69601. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  69602. * @param eventData defines the data to send to all observers
  69603. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  69604. * @param target defines the original target of the state
  69605. * @param currentTarget defines the current target of the state
  69606. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  69607. */
  69608. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  69609. /**
  69610. * Calling this will execute each callback, expecting it to be a promise or return a value.
  69611. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  69612. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  69613. * and it is crucial that all callbacks will be executed.
  69614. * The order of the callbacks is kept, callbacks are not executed parallel.
  69615. *
  69616. * @param eventData The data to be sent to each callback
  69617. * @param mask is used to filter observers defaults to -1
  69618. * @param target defines the callback target (see EventState)
  69619. * @param currentTarget defines he current object in the bubbling phase
  69620. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  69621. */
  69622. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  69623. /**
  69624. * Notify a specific observer
  69625. * @param observer defines the observer to notify
  69626. * @param eventData defines the data to be sent to each callback
  69627. * @param mask is used to filter observers defaults to -1
  69628. */
  69629. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  69630. /**
  69631. * Gets a boolean indicating if the observable has at least one observer
  69632. * @returns true is the Observable has at least one Observer registered
  69633. */
  69634. hasObservers(): boolean;
  69635. /**
  69636. * Clear the list of observers
  69637. */
  69638. clear(): void;
  69639. /**
  69640. * Clone the current observable
  69641. * @returns a new observable
  69642. */
  69643. clone(): Observable<T>;
  69644. /**
  69645. * Does this observable handles observer registered with a given mask
  69646. * @param mask defines the mask to be tested
  69647. * @return whether or not one observer registered with the given mask is handeled
  69648. **/
  69649. hasSpecificMask(mask?: number): boolean;
  69650. }
  69651. }
  69652. declare module BABYLON {
  69653. /**
  69654. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  69655. * Babylon.js
  69656. */
  69657. export class DomManagement {
  69658. /**
  69659. * Checks if the window object exists
  69660. * @returns true if the window object exists
  69661. */
  69662. static IsWindowObjectExist(): boolean;
  69663. /**
  69664. * Checks if the navigator object exists
  69665. * @returns true if the navigator object exists
  69666. */
  69667. static IsNavigatorAvailable(): boolean;
  69668. /**
  69669. * Extracts text content from a DOM element hierarchy
  69670. * @param element defines the root element
  69671. * @returns a string
  69672. */
  69673. static GetDOMTextContent(element: HTMLElement): string;
  69674. }
  69675. }
  69676. declare module BABYLON {
  69677. /**
  69678. * Logger used througouht the application to allow configuration of
  69679. * the log level required for the messages.
  69680. */
  69681. export class Logger {
  69682. /**
  69683. * No log
  69684. */
  69685. static readonly NoneLogLevel: number;
  69686. /**
  69687. * Only message logs
  69688. */
  69689. static readonly MessageLogLevel: number;
  69690. /**
  69691. * Only warning logs
  69692. */
  69693. static readonly WarningLogLevel: number;
  69694. /**
  69695. * Only error logs
  69696. */
  69697. static readonly ErrorLogLevel: number;
  69698. /**
  69699. * All logs
  69700. */
  69701. static readonly AllLogLevel: number;
  69702. private static _LogCache;
  69703. /**
  69704. * Gets a value indicating the number of loading errors
  69705. * @ignorenaming
  69706. */
  69707. static errorsCount: number;
  69708. /**
  69709. * Callback called when a new log is added
  69710. */
  69711. static OnNewCacheEntry: (entry: string) => void;
  69712. private static _AddLogEntry;
  69713. private static _FormatMessage;
  69714. private static _LogDisabled;
  69715. private static _LogEnabled;
  69716. private static _WarnDisabled;
  69717. private static _WarnEnabled;
  69718. private static _ErrorDisabled;
  69719. private static _ErrorEnabled;
  69720. /**
  69721. * Log a message to the console
  69722. */
  69723. static Log: (message: string) => void;
  69724. /**
  69725. * Write a warning message to the console
  69726. */
  69727. static Warn: (message: string) => void;
  69728. /**
  69729. * Write an error message to the console
  69730. */
  69731. static Error: (message: string) => void;
  69732. /**
  69733. * Gets current log cache (list of logs)
  69734. */
  69735. static readonly LogCache: string;
  69736. /**
  69737. * Clears the log cache
  69738. */
  69739. static ClearLogCache(): void;
  69740. /**
  69741. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  69742. */
  69743. static LogLevels: number;
  69744. }
  69745. }
  69746. declare module BABYLON {
  69747. /** @hidden */
  69748. export class _TypeStore {
  69749. /** @hidden */
  69750. static RegisteredTypes: {
  69751. [key: string]: Object;
  69752. };
  69753. /** @hidden */
  69754. static GetClass(fqdn: string): any;
  69755. }
  69756. }
  69757. declare module BABYLON {
  69758. /**
  69759. * Helper to manipulate strings
  69760. */
  69761. export class StringTools {
  69762. /**
  69763. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  69764. * @param str Source string
  69765. * @param suffix Suffix to search for in the source string
  69766. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69767. */
  69768. static EndsWith(str: string, suffix: string): boolean;
  69769. /**
  69770. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  69771. * @param str Source string
  69772. * @param suffix Suffix to search for in the source string
  69773. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  69774. */
  69775. static StartsWith(str: string, suffix: string): boolean;
  69776. /**
  69777. * Decodes a buffer into a string
  69778. * @param buffer The buffer to decode
  69779. * @returns The decoded string
  69780. */
  69781. static Decode(buffer: Uint8Array | Uint16Array): string;
  69782. /**
  69783. * Encode a buffer to a base64 string
  69784. * @param buffer defines the buffer to encode
  69785. * @returns the encoded string
  69786. */
  69787. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  69788. }
  69789. }
  69790. declare module BABYLON {
  69791. /**
  69792. * Class containing a set of static utilities functions for deep copy.
  69793. */
  69794. export class DeepCopier {
  69795. /**
  69796. * Tries to copy an object by duplicating every property
  69797. * @param source defines the source object
  69798. * @param destination defines the target object
  69799. * @param doNotCopyList defines a list of properties to avoid
  69800. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  69801. */
  69802. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  69803. }
  69804. }
  69805. declare module BABYLON {
  69806. /**
  69807. * Class containing a set of static utilities functions for precision date
  69808. */
  69809. export class PrecisionDate {
  69810. /**
  69811. * Gets either window.performance.now() if supported or Date.now() else
  69812. */
  69813. static readonly Now: number;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /** @hidden */
  69818. export class _DevTools {
  69819. static WarnImport(name: string): string;
  69820. }
  69821. }
  69822. declare module BABYLON {
  69823. /**
  69824. * Interface used to define the mechanism to get data from the network
  69825. */
  69826. export interface IWebRequest {
  69827. /**
  69828. * Returns client's response url
  69829. */
  69830. responseURL: string;
  69831. /**
  69832. * Returns client's status
  69833. */
  69834. status: number;
  69835. /**
  69836. * Returns client's status as a text
  69837. */
  69838. statusText: string;
  69839. }
  69840. }
  69841. declare module BABYLON {
  69842. /**
  69843. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  69844. */
  69845. export class WebRequest implements IWebRequest {
  69846. private _xhr;
  69847. /**
  69848. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  69849. * i.e. when loading files, where the server/service expects an Authorization header
  69850. */
  69851. static CustomRequestHeaders: {
  69852. [key: string]: string;
  69853. };
  69854. /**
  69855. * Add callback functions in this array to update all the requests before they get sent to the network
  69856. */
  69857. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  69858. private _injectCustomRequestHeaders;
  69859. /**
  69860. * Gets or sets a function to be called when loading progress changes
  69861. */
  69862. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  69863. /**
  69864. * Returns client's state
  69865. */
  69866. readonly readyState: number;
  69867. /**
  69868. * Returns client's status
  69869. */
  69870. readonly status: number;
  69871. /**
  69872. * Returns client's status as a text
  69873. */
  69874. readonly statusText: string;
  69875. /**
  69876. * Returns client's response
  69877. */
  69878. readonly response: any;
  69879. /**
  69880. * Returns client's response url
  69881. */
  69882. readonly responseURL: string;
  69883. /**
  69884. * Returns client's response as text
  69885. */
  69886. readonly responseText: string;
  69887. /**
  69888. * Gets or sets the expected response type
  69889. */
  69890. responseType: XMLHttpRequestResponseType;
  69891. /** @hidden */
  69892. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  69893. /** @hidden */
  69894. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  69895. /**
  69896. * Cancels any network activity
  69897. */
  69898. abort(): void;
  69899. /**
  69900. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  69901. * @param body defines an optional request body
  69902. */
  69903. send(body?: Document | BodyInit | null): void;
  69904. /**
  69905. * Sets the request method, request URL
  69906. * @param method defines the method to use (GET, POST, etc..)
  69907. * @param url defines the url to connect with
  69908. */
  69909. open(method: string, url: string): void;
  69910. /**
  69911. * Sets the value of a request header.
  69912. * @param name The name of the header whose value is to be set
  69913. * @param value The value to set as the body of the header
  69914. */
  69915. setRequestHeader(name: string, value: string): void;
  69916. /**
  69917. * Get the string containing the text of a particular header's value.
  69918. * @param name The name of the header
  69919. * @returns The string containing the text of the given header name
  69920. */
  69921. getResponseHeader(name: string): Nullable<string>;
  69922. }
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * File request interface
  69927. */
  69928. export interface IFileRequest {
  69929. /**
  69930. * Raised when the request is complete (success or error).
  69931. */
  69932. onCompleteObservable: Observable<IFileRequest>;
  69933. /**
  69934. * Aborts the request for a file.
  69935. */
  69936. abort: () => void;
  69937. }
  69938. }
  69939. declare module BABYLON {
  69940. /**
  69941. * Define options used to create a render target texture
  69942. */
  69943. export class RenderTargetCreationOptions {
  69944. /**
  69945. * Specifies is mipmaps must be generated
  69946. */
  69947. generateMipMaps?: boolean;
  69948. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69949. generateDepthBuffer?: boolean;
  69950. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69951. generateStencilBuffer?: boolean;
  69952. /** Defines texture type (int by default) */
  69953. type?: number;
  69954. /** Defines sampling mode (trilinear by default) */
  69955. samplingMode?: number;
  69956. /** Defines format (RGBA by default) */
  69957. format?: number;
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /**
  69962. * @hidden
  69963. **/
  69964. export class _TimeToken {
  69965. _startTimeQuery: Nullable<WebGLQuery>;
  69966. _endTimeQuery: Nullable<WebGLQuery>;
  69967. _timeElapsedQuery: Nullable<WebGLQuery>;
  69968. _timeElapsedQueryEnded: boolean;
  69969. }
  69970. }
  69971. declare module BABYLON {
  69972. /** Defines the cross module used constants to avoid circular dependncies */
  69973. export class Constants {
  69974. /** Defines that alpha blending is disabled */
  69975. static readonly ALPHA_DISABLE: number;
  69976. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  69977. static readonly ALPHA_ADD: number;
  69978. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69979. static readonly ALPHA_COMBINE: number;
  69980. /** Defines that alpha blending is DEST - SRC * DEST */
  69981. static readonly ALPHA_SUBTRACT: number;
  69982. /** Defines that alpha blending is SRC * DEST */
  69983. static readonly ALPHA_MULTIPLY: number;
  69984. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  69985. static readonly ALPHA_MAXIMIZED: number;
  69986. /** Defines that alpha blending is SRC + DEST */
  69987. static readonly ALPHA_ONEONE: number;
  69988. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  69989. static readonly ALPHA_PREMULTIPLIED: number;
  69990. /**
  69991. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  69992. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69993. */
  69994. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69995. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  69996. static readonly ALPHA_INTERPOLATE: number;
  69997. /**
  69998. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  69999. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70000. */
  70001. static readonly ALPHA_SCREENMODE: number;
  70002. /**
  70003. * Defines that alpha blending is SRC + DST
  70004. * Alpha will be set to SRC ALPHA + DST ALPHA
  70005. */
  70006. static readonly ALPHA_ONEONE_ONEONE: number;
  70007. /**
  70008. * Defines that alpha blending is SRC * DST ALPHA + DST
  70009. * Alpha will be set to 0
  70010. */
  70011. static readonly ALPHA_ALPHATOCOLOR: number;
  70012. /**
  70013. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  70014. */
  70015. static readonly ALPHA_REVERSEONEMINUS: number;
  70016. /**
  70017. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  70018. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70019. */
  70020. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70021. /**
  70022. * Defines that alpha blending is SRC + DST
  70023. * Alpha will be set to SRC ALPHA
  70024. */
  70025. static readonly ALPHA_ONEONE_ONEZERO: number;
  70026. /**
  70027. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  70028. * Alpha will be set to DST ALPHA
  70029. */
  70030. static readonly ALPHA_EXCLUSION: number;
  70031. /** Defines that alpha blending equation a SUM */
  70032. static readonly ALPHA_EQUATION_ADD: number;
  70033. /** Defines that alpha blending equation a SUBSTRACTION */
  70034. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70035. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70036. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70037. /** Defines that alpha blending equation a MAX operation */
  70038. static readonly ALPHA_EQUATION_MAX: number;
  70039. /** Defines that alpha blending equation a MIN operation */
  70040. static readonly ALPHA_EQUATION_MIN: number;
  70041. /**
  70042. * Defines that alpha blending equation a DARKEN operation:
  70043. * It takes the min of the src and sums the alpha channels.
  70044. */
  70045. static readonly ALPHA_EQUATION_DARKEN: number;
  70046. /** Defines that the ressource is not delayed*/
  70047. static readonly DELAYLOADSTATE_NONE: number;
  70048. /** Defines that the ressource was successfully delay loaded */
  70049. static readonly DELAYLOADSTATE_LOADED: number;
  70050. /** Defines that the ressource is currently delay loading */
  70051. static readonly DELAYLOADSTATE_LOADING: number;
  70052. /** Defines that the ressource is delayed and has not started loading */
  70053. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70054. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70055. static readonly NEVER: number;
  70056. /** 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 */
  70057. static readonly ALWAYS: number;
  70058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70059. static readonly LESS: number;
  70060. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70061. static readonly EQUAL: number;
  70062. /** 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 */
  70063. static readonly LEQUAL: number;
  70064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70065. static readonly GREATER: number;
  70066. /** 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 */
  70067. static readonly GEQUAL: number;
  70068. /** 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 */
  70069. static readonly NOTEQUAL: number;
  70070. /** Passed to stencilOperation to specify that stencil value must be kept */
  70071. static readonly KEEP: number;
  70072. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70073. static readonly REPLACE: number;
  70074. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70075. static readonly INCR: number;
  70076. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70077. static readonly DECR: number;
  70078. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70079. static readonly INVERT: number;
  70080. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70081. static readonly INCR_WRAP: number;
  70082. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70083. static readonly DECR_WRAP: number;
  70084. /** Texture is not repeating outside of 0..1 UVs */
  70085. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70086. /** Texture is repeating outside of 0..1 UVs */
  70087. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70088. /** Texture is repeating and mirrored */
  70089. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70090. /** ALPHA */
  70091. static readonly TEXTUREFORMAT_ALPHA: number;
  70092. /** LUMINANCE */
  70093. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70094. /** LUMINANCE_ALPHA */
  70095. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70096. /** RGB */
  70097. static readonly TEXTUREFORMAT_RGB: number;
  70098. /** RGBA */
  70099. static readonly TEXTUREFORMAT_RGBA: number;
  70100. /** RED */
  70101. static readonly TEXTUREFORMAT_RED: number;
  70102. /** RED (2nd reference) */
  70103. static readonly TEXTUREFORMAT_R: number;
  70104. /** RG */
  70105. static readonly TEXTUREFORMAT_RG: number;
  70106. /** RED_INTEGER */
  70107. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70108. /** RED_INTEGER (2nd reference) */
  70109. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70110. /** RG_INTEGER */
  70111. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70112. /** RGB_INTEGER */
  70113. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70114. /** RGBA_INTEGER */
  70115. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70116. /** UNSIGNED_BYTE */
  70117. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70118. /** UNSIGNED_BYTE (2nd reference) */
  70119. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70120. /** FLOAT */
  70121. static readonly TEXTURETYPE_FLOAT: number;
  70122. /** HALF_FLOAT */
  70123. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70124. /** BYTE */
  70125. static readonly TEXTURETYPE_BYTE: number;
  70126. /** SHORT */
  70127. static readonly TEXTURETYPE_SHORT: number;
  70128. /** UNSIGNED_SHORT */
  70129. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70130. /** INT */
  70131. static readonly TEXTURETYPE_INT: number;
  70132. /** UNSIGNED_INT */
  70133. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70134. /** UNSIGNED_SHORT_4_4_4_4 */
  70135. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70136. /** UNSIGNED_SHORT_5_5_5_1 */
  70137. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70138. /** UNSIGNED_SHORT_5_6_5 */
  70139. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70140. /** UNSIGNED_INT_2_10_10_10_REV */
  70141. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70142. /** UNSIGNED_INT_24_8 */
  70143. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70144. /** UNSIGNED_INT_10F_11F_11F_REV */
  70145. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70146. /** UNSIGNED_INT_5_9_9_9_REV */
  70147. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70148. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70149. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70150. /** nearest is mag = nearest and min = nearest and mip = nearest */
  70151. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70152. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70153. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70154. /** Trilinear is mag = linear and min = linear and mip = linear */
  70155. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70156. /** nearest is mag = nearest and min = nearest and mip = linear */
  70157. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70158. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70159. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70160. /** Trilinear is mag = linear and min = linear and mip = linear */
  70161. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70162. /** mag = nearest and min = nearest and mip = nearest */
  70163. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70164. /** mag = nearest and min = linear and mip = nearest */
  70165. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70166. /** mag = nearest and min = linear and mip = linear */
  70167. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70168. /** mag = nearest and min = linear and mip = none */
  70169. static readonly TEXTURE_NEAREST_LINEAR: number;
  70170. /** mag = nearest and min = nearest and mip = none */
  70171. static readonly TEXTURE_NEAREST_NEAREST: number;
  70172. /** mag = linear and min = nearest and mip = nearest */
  70173. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70174. /** mag = linear and min = nearest and mip = linear */
  70175. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70176. /** mag = linear and min = linear and mip = none */
  70177. static readonly TEXTURE_LINEAR_LINEAR: number;
  70178. /** mag = linear and min = nearest and mip = none */
  70179. static readonly TEXTURE_LINEAR_NEAREST: number;
  70180. /** Explicit coordinates mode */
  70181. static readonly TEXTURE_EXPLICIT_MODE: number;
  70182. /** Spherical coordinates mode */
  70183. static readonly TEXTURE_SPHERICAL_MODE: number;
  70184. /** Planar coordinates mode */
  70185. static readonly TEXTURE_PLANAR_MODE: number;
  70186. /** Cubic coordinates mode */
  70187. static readonly TEXTURE_CUBIC_MODE: number;
  70188. /** Projection coordinates mode */
  70189. static readonly TEXTURE_PROJECTION_MODE: number;
  70190. /** Skybox coordinates mode */
  70191. static readonly TEXTURE_SKYBOX_MODE: number;
  70192. /** Inverse Cubic coordinates mode */
  70193. static readonly TEXTURE_INVCUBIC_MODE: number;
  70194. /** Equirectangular coordinates mode */
  70195. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70196. /** Equirectangular Fixed coordinates mode */
  70197. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70198. /** Equirectangular Fixed Mirrored coordinates mode */
  70199. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70200. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70201. static readonly SCALEMODE_FLOOR: number;
  70202. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70203. static readonly SCALEMODE_NEAREST: number;
  70204. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70205. static readonly SCALEMODE_CEILING: number;
  70206. /**
  70207. * The dirty texture flag value
  70208. */
  70209. static readonly MATERIAL_TextureDirtyFlag: number;
  70210. /**
  70211. * The dirty light flag value
  70212. */
  70213. static readonly MATERIAL_LightDirtyFlag: number;
  70214. /**
  70215. * The dirty fresnel flag value
  70216. */
  70217. static readonly MATERIAL_FresnelDirtyFlag: number;
  70218. /**
  70219. * The dirty attribute flag value
  70220. */
  70221. static readonly MATERIAL_AttributesDirtyFlag: number;
  70222. /**
  70223. * The dirty misc flag value
  70224. */
  70225. static readonly MATERIAL_MiscDirtyFlag: number;
  70226. /**
  70227. * The all dirty flag value
  70228. */
  70229. static readonly MATERIAL_AllDirtyFlag: number;
  70230. /**
  70231. * Returns the triangle fill mode
  70232. */
  70233. static readonly MATERIAL_TriangleFillMode: number;
  70234. /**
  70235. * Returns the wireframe mode
  70236. */
  70237. static readonly MATERIAL_WireFrameFillMode: number;
  70238. /**
  70239. * Returns the point fill mode
  70240. */
  70241. static readonly MATERIAL_PointFillMode: number;
  70242. /**
  70243. * Returns the point list draw mode
  70244. */
  70245. static readonly MATERIAL_PointListDrawMode: number;
  70246. /**
  70247. * Returns the line list draw mode
  70248. */
  70249. static readonly MATERIAL_LineListDrawMode: number;
  70250. /**
  70251. * Returns the line loop draw mode
  70252. */
  70253. static readonly MATERIAL_LineLoopDrawMode: number;
  70254. /**
  70255. * Returns the line strip draw mode
  70256. */
  70257. static readonly MATERIAL_LineStripDrawMode: number;
  70258. /**
  70259. * Returns the triangle strip draw mode
  70260. */
  70261. static readonly MATERIAL_TriangleStripDrawMode: number;
  70262. /**
  70263. * Returns the triangle fan draw mode
  70264. */
  70265. static readonly MATERIAL_TriangleFanDrawMode: number;
  70266. /**
  70267. * Stores the clock-wise side orientation
  70268. */
  70269. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70270. /**
  70271. * Stores the counter clock-wise side orientation
  70272. */
  70273. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70274. /**
  70275. * Nothing
  70276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70277. */
  70278. static readonly ACTION_NothingTrigger: number;
  70279. /**
  70280. * On pick
  70281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70282. */
  70283. static readonly ACTION_OnPickTrigger: number;
  70284. /**
  70285. * On left pick
  70286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70287. */
  70288. static readonly ACTION_OnLeftPickTrigger: number;
  70289. /**
  70290. * On right pick
  70291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70292. */
  70293. static readonly ACTION_OnRightPickTrigger: number;
  70294. /**
  70295. * On center pick
  70296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70297. */
  70298. static readonly ACTION_OnCenterPickTrigger: number;
  70299. /**
  70300. * On pick down
  70301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70302. */
  70303. static readonly ACTION_OnPickDownTrigger: number;
  70304. /**
  70305. * On double pick
  70306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70307. */
  70308. static readonly ACTION_OnDoublePickTrigger: number;
  70309. /**
  70310. * On pick up
  70311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70312. */
  70313. static readonly ACTION_OnPickUpTrigger: number;
  70314. /**
  70315. * On pick out.
  70316. * This trigger will only be raised if you also declared a OnPickDown
  70317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70318. */
  70319. static readonly ACTION_OnPickOutTrigger: number;
  70320. /**
  70321. * On long press
  70322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70323. */
  70324. static readonly ACTION_OnLongPressTrigger: number;
  70325. /**
  70326. * On pointer over
  70327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70328. */
  70329. static readonly ACTION_OnPointerOverTrigger: number;
  70330. /**
  70331. * On pointer out
  70332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70333. */
  70334. static readonly ACTION_OnPointerOutTrigger: number;
  70335. /**
  70336. * On every frame
  70337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70338. */
  70339. static readonly ACTION_OnEveryFrameTrigger: number;
  70340. /**
  70341. * On intersection enter
  70342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70343. */
  70344. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70345. /**
  70346. * On intersection exit
  70347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70348. */
  70349. static readonly ACTION_OnIntersectionExitTrigger: number;
  70350. /**
  70351. * On key down
  70352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70353. */
  70354. static readonly ACTION_OnKeyDownTrigger: number;
  70355. /**
  70356. * On key up
  70357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70358. */
  70359. static readonly ACTION_OnKeyUpTrigger: number;
  70360. /**
  70361. * Billboard mode will only apply to Y axis
  70362. */
  70363. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70364. /**
  70365. * Billboard mode will apply to all axes
  70366. */
  70367. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70368. /**
  70369. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70370. */
  70371. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70372. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70373. * Test order :
  70374. * Is the bounding sphere outside the frustum ?
  70375. * If not, are the bounding box vertices outside the frustum ?
  70376. * It not, then the cullable object is in the frustum.
  70377. */
  70378. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70379. /** Culling strategy : Bounding Sphere Only.
  70380. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70381. * It's also less accurate than the standard because some not visible objects can still be selected.
  70382. * Test : is the bounding sphere outside the frustum ?
  70383. * If not, then the cullable object is in the frustum.
  70384. */
  70385. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70386. /** Culling strategy : Optimistic Inclusion.
  70387. * This in an inclusion test first, then the standard exclusion test.
  70388. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70389. * 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.
  70390. * Anyway, it's as accurate as the standard strategy.
  70391. * Test :
  70392. * Is the cullable object bounding sphere center in the frustum ?
  70393. * If not, apply the default culling strategy.
  70394. */
  70395. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70396. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70397. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70398. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70399. * 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.
  70400. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70401. * Test :
  70402. * Is the cullable object bounding sphere center in the frustum ?
  70403. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70404. */
  70405. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70406. /**
  70407. * No logging while loading
  70408. */
  70409. static readonly SCENELOADER_NO_LOGGING: number;
  70410. /**
  70411. * Minimal logging while loading
  70412. */
  70413. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70414. /**
  70415. * Summary logging while loading
  70416. */
  70417. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70418. /**
  70419. * Detailled logging while loading
  70420. */
  70421. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70422. }
  70423. }
  70424. declare module BABYLON {
  70425. /**
  70426. * This represents the required contract to create a new type of texture loader.
  70427. */
  70428. export interface IInternalTextureLoader {
  70429. /**
  70430. * Defines wether the loader supports cascade loading the different faces.
  70431. */
  70432. supportCascades: boolean;
  70433. /**
  70434. * This returns if the loader support the current file information.
  70435. * @param extension defines the file extension of the file being loaded
  70436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70437. * @param fallback defines the fallback internal texture if any
  70438. * @param isBase64 defines whether the texture is encoded as a base64
  70439. * @param isBuffer defines whether the texture data are stored as a buffer
  70440. * @returns true if the loader can load the specified file
  70441. */
  70442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70443. /**
  70444. * Transform the url before loading if required.
  70445. * @param rootUrl the url of the texture
  70446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70447. * @returns the transformed texture
  70448. */
  70449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70450. /**
  70451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70452. * @param rootUrl the url of the texture
  70453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70454. * @returns the fallback texture
  70455. */
  70456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70457. /**
  70458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70459. * @param data contains the texture data
  70460. * @param texture defines the BabylonJS internal texture
  70461. * @param createPolynomials will be true if polynomials have been requested
  70462. * @param onLoad defines the callback to trigger once the texture is ready
  70463. * @param onError defines the callback to trigger in case of error
  70464. */
  70465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70466. /**
  70467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70468. * @param data contains the texture data
  70469. * @param texture defines the BabylonJS internal texture
  70470. * @param callback defines the method to call once ready to upload
  70471. */
  70472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70473. }
  70474. }
  70475. declare module BABYLON {
  70476. /**
  70477. * Class used to store and describe the pipeline context associated with an effect
  70478. */
  70479. export interface IPipelineContext {
  70480. /**
  70481. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70482. */
  70483. isAsync: boolean;
  70484. /**
  70485. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70486. */
  70487. isReady: boolean;
  70488. /** @hidden */
  70489. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70490. }
  70491. }
  70492. declare module BABYLON {
  70493. /**
  70494. * Class used to store gfx data (like WebGLBuffer)
  70495. */
  70496. export class DataBuffer {
  70497. /**
  70498. * Gets or sets the number of objects referencing this buffer
  70499. */
  70500. references: number;
  70501. /** Gets or sets the size of the underlying buffer */
  70502. capacity: number;
  70503. /**
  70504. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  70505. */
  70506. is32Bits: boolean;
  70507. /**
  70508. * Gets the underlying buffer
  70509. */
  70510. readonly underlyingResource: any;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /** @hidden */
  70515. export interface IShaderProcessor {
  70516. attributeProcessor?: (attribute: string) => string;
  70517. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70518. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70519. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70520. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70521. lineProcessor?: (line: string, isFragment: boolean) => string;
  70522. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70523. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70524. }
  70525. }
  70526. declare module BABYLON {
  70527. /** @hidden */
  70528. export interface ProcessingOptions {
  70529. defines: string[];
  70530. indexParameters: any;
  70531. isFragment: boolean;
  70532. shouldUseHighPrecisionShader: boolean;
  70533. supportsUniformBuffers: boolean;
  70534. shadersRepository: string;
  70535. includesShadersStore: {
  70536. [key: string]: string;
  70537. };
  70538. processor?: IShaderProcessor;
  70539. version: string;
  70540. platformName: string;
  70541. lookForClosingBracketForUniformBuffer?: boolean;
  70542. }
  70543. }
  70544. declare module BABYLON {
  70545. /** @hidden */
  70546. export class ShaderCodeNode {
  70547. line: string;
  70548. children: ShaderCodeNode[];
  70549. additionalDefineKey?: string;
  70550. additionalDefineValue?: string;
  70551. isValid(preprocessors: {
  70552. [key: string]: string;
  70553. }): boolean;
  70554. process(preprocessors: {
  70555. [key: string]: string;
  70556. }, options: ProcessingOptions): string;
  70557. }
  70558. }
  70559. declare module BABYLON {
  70560. /** @hidden */
  70561. export class ShaderCodeCursor {
  70562. private _lines;
  70563. lineIndex: number;
  70564. readonly currentLine: string;
  70565. readonly canRead: boolean;
  70566. lines: string[];
  70567. }
  70568. }
  70569. declare module BABYLON {
  70570. /** @hidden */
  70571. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70572. process(preprocessors: {
  70573. [key: string]: string;
  70574. }, options: ProcessingOptions): string;
  70575. }
  70576. }
  70577. declare module BABYLON {
  70578. /** @hidden */
  70579. export class ShaderDefineExpression {
  70580. isTrue(preprocessors: {
  70581. [key: string]: string;
  70582. }): boolean;
  70583. }
  70584. }
  70585. declare module BABYLON {
  70586. /** @hidden */
  70587. export class ShaderCodeTestNode extends ShaderCodeNode {
  70588. testExpression: ShaderDefineExpression;
  70589. isValid(preprocessors: {
  70590. [key: string]: string;
  70591. }): boolean;
  70592. }
  70593. }
  70594. declare module BABYLON {
  70595. /** @hidden */
  70596. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70597. define: string;
  70598. not: boolean;
  70599. constructor(define: string, not?: boolean);
  70600. isTrue(preprocessors: {
  70601. [key: string]: string;
  70602. }): boolean;
  70603. }
  70604. }
  70605. declare module BABYLON {
  70606. /** @hidden */
  70607. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70608. leftOperand: ShaderDefineExpression;
  70609. rightOperand: ShaderDefineExpression;
  70610. isTrue(preprocessors: {
  70611. [key: string]: string;
  70612. }): boolean;
  70613. }
  70614. }
  70615. declare module BABYLON {
  70616. /** @hidden */
  70617. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70618. leftOperand: ShaderDefineExpression;
  70619. rightOperand: ShaderDefineExpression;
  70620. isTrue(preprocessors: {
  70621. [key: string]: string;
  70622. }): boolean;
  70623. }
  70624. }
  70625. declare module BABYLON {
  70626. /** @hidden */
  70627. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70628. define: string;
  70629. operand: string;
  70630. testValue: string;
  70631. constructor(define: string, operand: string, testValue: string);
  70632. isTrue(preprocessors: {
  70633. [key: string]: string;
  70634. }): boolean;
  70635. }
  70636. }
  70637. declare module BABYLON {
  70638. /**
  70639. * Class used to enable access to offline support
  70640. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70641. */
  70642. export interface IOfflineProvider {
  70643. /**
  70644. * Gets a boolean indicating if scene must be saved in the database
  70645. */
  70646. enableSceneOffline: boolean;
  70647. /**
  70648. * Gets a boolean indicating if textures must be saved in the database
  70649. */
  70650. enableTexturesOffline: boolean;
  70651. /**
  70652. * Open the offline support and make it available
  70653. * @param successCallback defines the callback to call on success
  70654. * @param errorCallback defines the callback to call on error
  70655. */
  70656. open(successCallback: () => void, errorCallback: () => void): void;
  70657. /**
  70658. * Loads an image from the offline support
  70659. * @param url defines the url to load from
  70660. * @param image defines the target DOM image
  70661. */
  70662. loadImage(url: string, image: HTMLImageElement): void;
  70663. /**
  70664. * Loads a file from offline support
  70665. * @param url defines the URL to load from
  70666. * @param sceneLoaded defines a callback to call on success
  70667. * @param progressCallBack defines a callback to call when progress changed
  70668. * @param errorCallback defines a callback to call on error
  70669. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70670. */
  70671. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70672. }
  70673. }
  70674. declare module BABYLON {
  70675. /**
  70676. * Class used to help managing file picking and drag'n'drop
  70677. * File Storage
  70678. */
  70679. export class FilesInputStore {
  70680. /**
  70681. * List of files ready to be loaded
  70682. */
  70683. static FilesToLoad: {
  70684. [key: string]: File;
  70685. };
  70686. }
  70687. }
  70688. declare module BABYLON {
  70689. /**
  70690. * Class used to define a retry strategy when error happens while loading assets
  70691. */
  70692. export class RetryStrategy {
  70693. /**
  70694. * Function used to defines an exponential back off strategy
  70695. * @param maxRetries defines the maximum number of retries (3 by default)
  70696. * @param baseInterval defines the interval between retries
  70697. * @returns the strategy function to use
  70698. */
  70699. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70700. }
  70701. }
  70702. declare module BABYLON {
  70703. /**
  70704. * @ignore
  70705. * Application error to support additional information when loading a file
  70706. */
  70707. export abstract class BaseError extends Error {
  70708. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  70709. }
  70710. }
  70711. declare module BABYLON {
  70712. /** @ignore */
  70713. export class LoadFileError extends BaseError {
  70714. request?: WebRequest;
  70715. file?: File;
  70716. /**
  70717. * Creates a new LoadFileError
  70718. * @param message defines the message of the error
  70719. * @param request defines the optional web request
  70720. * @param file defines the optional file
  70721. */
  70722. constructor(message: string, object?: WebRequest | File);
  70723. }
  70724. /** @ignore */
  70725. export class RequestFileError extends BaseError {
  70726. request: WebRequest;
  70727. /**
  70728. * Creates a new LoadFileError
  70729. * @param message defines the message of the error
  70730. * @param request defines the optional web request
  70731. */
  70732. constructor(message: string, request: WebRequest);
  70733. }
  70734. /** @ignore */
  70735. export class ReadFileError extends BaseError {
  70736. file: File;
  70737. /**
  70738. * Creates a new ReadFileError
  70739. * @param message defines the message of the error
  70740. * @param file defines the optional file
  70741. */
  70742. constructor(message: string, file: File);
  70743. }
  70744. /**
  70745. * @hidden
  70746. */
  70747. export class FileTools {
  70748. /**
  70749. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70750. */
  70751. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70752. /**
  70753. * Gets or sets the base URL to use to load assets
  70754. */
  70755. static BaseUrl: string;
  70756. /**
  70757. * Default behaviour for cors in the application.
  70758. * It can be a string if the expected behavior is identical in the entire app.
  70759. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70760. */
  70761. static CorsBehavior: string | ((url: string | string[]) => string);
  70762. /**
  70763. * Gets or sets a function used to pre-process url before using them to load assets
  70764. */
  70765. static PreprocessUrl: (url: string) => string;
  70766. /**
  70767. * Removes unwanted characters from an url
  70768. * @param url defines the url to clean
  70769. * @returns the cleaned url
  70770. */
  70771. private static _CleanUrl;
  70772. /**
  70773. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70774. * @param url define the url we are trying
  70775. * @param element define the dom element where to configure the cors policy
  70776. */
  70777. static SetCorsBehavior(url: string | string[], element: {
  70778. crossOrigin: string | null;
  70779. }): void;
  70780. /**
  70781. * Loads an image as an HTMLImageElement.
  70782. * @param input url string, ArrayBuffer, or Blob to load
  70783. * @param onLoad callback called when the image successfully loads
  70784. * @param onError callback called when the image fails to load
  70785. * @param offlineProvider offline provider for caching
  70786. * @param mimeType optional mime type
  70787. * @returns the HTMLImageElement of the loaded image
  70788. */
  70789. 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>;
  70790. /**
  70791. * Reads a file from a File object
  70792. * @param file defines the file to load
  70793. * @param onSuccess defines the callback to call when data is loaded
  70794. * @param onProgress defines the callback to call during loading process
  70795. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70796. * @param onError defines the callback to call when an error occurs
  70797. * @returns a file request object
  70798. */
  70799. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  70800. /**
  70801. * Loads a file from a url
  70802. * @param url url to load
  70803. * @param onSuccess callback called when the file successfully loads
  70804. * @param onProgress callback called while file is loading (if the server supports this mode)
  70805. * @param offlineProvider defines the offline provider for caching
  70806. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70807. * @param onError callback called when the file fails to load
  70808. * @returns a file request object
  70809. */
  70810. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  70811. /**
  70812. * Loads a file
  70813. * @param url url to load
  70814. * @param onSuccess callback called when the file successfully loads
  70815. * @param onProgress callback called while file is loading (if the server supports this mode)
  70816. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70817. * @param onError callback called when the file fails to load
  70818. * @param onOpened callback called when the web request is opened
  70819. * @returns a file request object
  70820. */
  70821. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  70822. /**
  70823. * Checks if the loaded document was accessed via `file:`-Protocol.
  70824. * @returns boolean
  70825. */
  70826. static IsFileURL(): boolean;
  70827. }
  70828. }
  70829. declare module BABYLON {
  70830. /** @hidden */
  70831. export class ShaderProcessor {
  70832. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70833. private static _ProcessPrecision;
  70834. private static _ExtractOperation;
  70835. private static _BuildSubExpression;
  70836. private static _BuildExpression;
  70837. private static _MoveCursorWithinIf;
  70838. private static _MoveCursor;
  70839. private static _EvaluatePreProcessors;
  70840. private static _PreparePreProcessors;
  70841. private static _ProcessShaderConversion;
  70842. private static _ProcessIncludes;
  70843. }
  70844. }
  70845. declare module BABYLON {
  70846. /**
  70847. * @hidden
  70848. */
  70849. export interface IColor4Like {
  70850. r: float;
  70851. g: float;
  70852. b: float;
  70853. a: float;
  70854. }
  70855. /**
  70856. * @hidden
  70857. */
  70858. export interface IColor3Like {
  70859. r: float;
  70860. g: float;
  70861. b: float;
  70862. }
  70863. /**
  70864. * @hidden
  70865. */
  70866. export interface IVector4Like {
  70867. x: float;
  70868. y: float;
  70869. z: float;
  70870. w: float;
  70871. }
  70872. /**
  70873. * @hidden
  70874. */
  70875. export interface IVector3Like {
  70876. x: float;
  70877. y: float;
  70878. z: float;
  70879. }
  70880. /**
  70881. * @hidden
  70882. */
  70883. export interface IVector2Like {
  70884. x: float;
  70885. y: float;
  70886. }
  70887. /**
  70888. * @hidden
  70889. */
  70890. export interface IMatrixLike {
  70891. toArray(): DeepImmutable<Float32Array>;
  70892. updateFlag: int;
  70893. }
  70894. /**
  70895. * @hidden
  70896. */
  70897. export interface IViewportLike {
  70898. x: float;
  70899. y: float;
  70900. width: float;
  70901. height: float;
  70902. }
  70903. /**
  70904. * @hidden
  70905. */
  70906. export interface IPlaneLike {
  70907. normal: IVector3Like;
  70908. d: float;
  70909. normalize(): void;
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /**
  70914. * Interface used to define common properties for effect fallbacks
  70915. */
  70916. export interface IEffectFallbacks {
  70917. /**
  70918. * Removes the defines that should be removed when falling back.
  70919. * @param currentDefines defines the current define statements for the shader.
  70920. * @param effect defines the current effect we try to compile
  70921. * @returns The resulting defines with defines of the current rank removed.
  70922. */
  70923. reduce(currentDefines: string, effect: Effect): string;
  70924. /**
  70925. * Removes the fallback from the bound mesh.
  70926. */
  70927. unBindMesh(): void;
  70928. /**
  70929. * Checks to see if more fallbacks are still availible.
  70930. */
  70931. hasMoreFallbacks: boolean;
  70932. }
  70933. }
  70934. declare module BABYLON {
  70935. /**
  70936. * Class used to evalaute queries containing `and` and `or` operators
  70937. */
  70938. export class AndOrNotEvaluator {
  70939. /**
  70940. * Evaluate a query
  70941. * @param query defines the query to evaluate
  70942. * @param evaluateCallback defines the callback used to filter result
  70943. * @returns true if the query matches
  70944. */
  70945. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  70946. private static _HandleParenthesisContent;
  70947. private static _SimplifyNegation;
  70948. }
  70949. }
  70950. declare module BABYLON {
  70951. /**
  70952. * Class used to store custom tags
  70953. */
  70954. export class Tags {
  70955. /**
  70956. * Adds support for tags on the given object
  70957. * @param obj defines the object to use
  70958. */
  70959. static EnableFor(obj: any): void;
  70960. /**
  70961. * Removes tags support
  70962. * @param obj defines the object to use
  70963. */
  70964. static DisableFor(obj: any): void;
  70965. /**
  70966. * Gets a boolean indicating if the given object has tags
  70967. * @param obj defines the object to use
  70968. * @returns a boolean
  70969. */
  70970. static HasTags(obj: any): boolean;
  70971. /**
  70972. * Gets the tags available on a given object
  70973. * @param obj defines the object to use
  70974. * @param asString defines if the tags must be returned as a string instead of an array of strings
  70975. * @returns the tags
  70976. */
  70977. static GetTags(obj: any, asString?: boolean): any;
  70978. /**
  70979. * Adds tags to an object
  70980. * @param obj defines the object to use
  70981. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  70982. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  70983. */
  70984. static AddTagsTo(obj: any, tagsString: string): void;
  70985. /**
  70986. * @hidden
  70987. */
  70988. static _AddTagTo(obj: any, tag: string): void;
  70989. /**
  70990. * Removes specific tags from a specific object
  70991. * @param obj defines the object to use
  70992. * @param tagsString defines the tags to remove
  70993. */
  70994. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70995. /**
  70996. * @hidden
  70997. */
  70998. static _RemoveTagFrom(obj: any, tag: string): void;
  70999. /**
  71000. * Defines if tags hosted on an object match a given query
  71001. * @param obj defines the object to use
  71002. * @param tagsQuery defines the tag query
  71003. * @returns a boolean
  71004. */
  71005. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71006. }
  71007. }
  71008. declare module BABYLON {
  71009. /**
  71010. * Scalar computation library
  71011. */
  71012. export class Scalar {
  71013. /**
  71014. * Two pi constants convenient for computation.
  71015. */
  71016. static TwoPi: number;
  71017. /**
  71018. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71019. * @param a number
  71020. * @param b number
  71021. * @param epsilon (default = 1.401298E-45)
  71022. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  71023. */
  71024. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  71025. /**
  71026. * Returns a string : the upper case translation of the number i to hexadecimal.
  71027. * @param i number
  71028. * @returns the upper case translation of the number i to hexadecimal.
  71029. */
  71030. static ToHex(i: number): string;
  71031. /**
  71032. * Returns -1 if value is negative and +1 is value is positive.
  71033. * @param value the value
  71034. * @returns the value itself if it's equal to zero.
  71035. */
  71036. static Sign(value: number): number;
  71037. /**
  71038. * Returns the value itself if it's between min and max.
  71039. * Returns min if the value is lower than min.
  71040. * Returns max if the value is greater than max.
  71041. * @param value the value to clmap
  71042. * @param min the min value to clamp to (default: 0)
  71043. * @param max the max value to clamp to (default: 1)
  71044. * @returns the clamped value
  71045. */
  71046. static Clamp(value: number, min?: number, max?: number): number;
  71047. /**
  71048. * the log2 of value.
  71049. * @param value the value to compute log2 of
  71050. * @returns the log2 of value.
  71051. */
  71052. static Log2(value: number): number;
  71053. /**
  71054. * Loops the value, so that it is never larger than length and never smaller than 0.
  71055. *
  71056. * This is similar to the modulo operator but it works with floating point numbers.
  71057. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  71058. * With t = 5 and length = 2.5, the result would be 0.0.
  71059. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  71060. * @param value the value
  71061. * @param length the length
  71062. * @returns the looped value
  71063. */
  71064. static Repeat(value: number, length: number): number;
  71065. /**
  71066. * Normalize the value between 0.0 and 1.0 using min and max values
  71067. * @param value value to normalize
  71068. * @param min max to normalize between
  71069. * @param max min to normalize between
  71070. * @returns the normalized value
  71071. */
  71072. static Normalize(value: number, min: number, max: number): number;
  71073. /**
  71074. * Denormalize the value from 0.0 and 1.0 using min and max values
  71075. * @param normalized value to denormalize
  71076. * @param min max to denormalize between
  71077. * @param max min to denormalize between
  71078. * @returns the denormalized value
  71079. */
  71080. static Denormalize(normalized: number, min: number, max: number): number;
  71081. /**
  71082. * Calculates the shortest difference between two given angles given in degrees.
  71083. * @param current current angle in degrees
  71084. * @param target target angle in degrees
  71085. * @returns the delta
  71086. */
  71087. static DeltaAngle(current: number, target: number): number;
  71088. /**
  71089. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  71090. * @param tx value
  71091. * @param length length
  71092. * @returns The returned value will move back and forth between 0 and length
  71093. */
  71094. static PingPong(tx: number, length: number): number;
  71095. /**
  71096. * Interpolates between min and max with smoothing at the limits.
  71097. *
  71098. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  71099. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  71100. * @param from from
  71101. * @param to to
  71102. * @param tx value
  71103. * @returns the smooth stepped value
  71104. */
  71105. static SmoothStep(from: number, to: number, tx: number): number;
  71106. /**
  71107. * Moves a value current towards target.
  71108. *
  71109. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  71110. * Negative values of maxDelta pushes the value away from target.
  71111. * @param current current value
  71112. * @param target target value
  71113. * @param maxDelta max distance to move
  71114. * @returns resulting value
  71115. */
  71116. static MoveTowards(current: number, target: number, maxDelta: number): number;
  71117. /**
  71118. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71119. *
  71120. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  71121. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  71122. * @param current current value
  71123. * @param target target value
  71124. * @param maxDelta max distance to move
  71125. * @returns resulting angle
  71126. */
  71127. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  71128. /**
  71129. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  71130. * @param start start value
  71131. * @param end target value
  71132. * @param amount amount to lerp between
  71133. * @returns the lerped value
  71134. */
  71135. static Lerp(start: number, end: number, amount: number): number;
  71136. /**
  71137. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  71138. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  71139. * @param start start value
  71140. * @param end target value
  71141. * @param amount amount to lerp between
  71142. * @returns the lerped value
  71143. */
  71144. static LerpAngle(start: number, end: number, amount: number): number;
  71145. /**
  71146. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  71147. * @param a start value
  71148. * @param b target value
  71149. * @param value value between a and b
  71150. * @returns the inverseLerp value
  71151. */
  71152. static InverseLerp(a: number, b: number, value: number): number;
  71153. /**
  71154. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  71155. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  71156. * @param value1 spline value
  71157. * @param tangent1 spline value
  71158. * @param value2 spline value
  71159. * @param tangent2 spline value
  71160. * @param amount input value
  71161. * @returns hermite result
  71162. */
  71163. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  71164. /**
  71165. * Returns a random float number between and min and max values
  71166. * @param min min value of random
  71167. * @param max max value of random
  71168. * @returns random value
  71169. */
  71170. static RandomRange(min: number, max: number): number;
  71171. /**
  71172. * This function returns percentage of a number in a given range.
  71173. *
  71174. * RangeToPercent(40,20,60) will return 0.5 (50%)
  71175. * RangeToPercent(34,0,100) will return 0.34 (34%)
  71176. * @param number to convert to percentage
  71177. * @param min min range
  71178. * @param max max range
  71179. * @returns the percentage
  71180. */
  71181. static RangeToPercent(number: number, min: number, max: number): number;
  71182. /**
  71183. * This function returns number that corresponds to the percentage in a given range.
  71184. *
  71185. * PercentToRange(0.34,0,100) will return 34.
  71186. * @param percent to convert to number
  71187. * @param min min range
  71188. * @param max max range
  71189. * @returns the number
  71190. */
  71191. static PercentToRange(percent: number, min: number, max: number): number;
  71192. /**
  71193. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  71194. * @param angle The angle to normalize in radian.
  71195. * @return The converted angle.
  71196. */
  71197. static NormalizeRadians(angle: number): number;
  71198. }
  71199. }
  71200. declare module BABYLON {
  71201. /**
  71202. * Constant used to convert a value to gamma space
  71203. * @ignorenaming
  71204. */
  71205. export const ToGammaSpace: number;
  71206. /**
  71207. * Constant used to convert a value to linear space
  71208. * @ignorenaming
  71209. */
  71210. export const ToLinearSpace = 2.2;
  71211. /**
  71212. * Constant used to define the minimal number value in Babylon.js
  71213. * @ignorenaming
  71214. */
  71215. let Epsilon: number;
  71216. }
  71217. declare module BABYLON {
  71218. /**
  71219. * Class used to represent a viewport on screen
  71220. */
  71221. export class Viewport {
  71222. /** viewport left coordinate */
  71223. x: number;
  71224. /** viewport top coordinate */
  71225. y: number;
  71226. /**viewport width */
  71227. width: number;
  71228. /** viewport height */
  71229. height: number;
  71230. /**
  71231. * Creates a Viewport object located at (x, y) and sized (width, height)
  71232. * @param x defines viewport left coordinate
  71233. * @param y defines viewport top coordinate
  71234. * @param width defines the viewport width
  71235. * @param height defines the viewport height
  71236. */
  71237. constructor(
  71238. /** viewport left coordinate */
  71239. x: number,
  71240. /** viewport top coordinate */
  71241. y: number,
  71242. /**viewport width */
  71243. width: number,
  71244. /** viewport height */
  71245. height: number);
  71246. /**
  71247. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  71248. * @param renderWidth defines the rendering width
  71249. * @param renderHeight defines the rendering height
  71250. * @returns a new Viewport
  71251. */
  71252. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  71253. /**
  71254. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  71255. * @param renderWidth defines the rendering width
  71256. * @param renderHeight defines the rendering height
  71257. * @param ref defines the target viewport
  71258. * @returns the current viewport
  71259. */
  71260. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  71261. /**
  71262. * Returns a new Viewport copied from the current one
  71263. * @returns a new Viewport
  71264. */
  71265. clone(): Viewport;
  71266. }
  71267. }
  71268. declare module BABYLON {
  71269. /**
  71270. * Class containing a set of static utilities functions for arrays.
  71271. */
  71272. export class ArrayTools {
  71273. /**
  71274. * Returns an array of the given size filled with element built from the given constructor and the paramters
  71275. * @param size the number of element to construct and put in the array
  71276. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  71277. * @returns a new array filled with new objects
  71278. */
  71279. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  71280. }
  71281. }
  71282. declare module BABYLON {
  71283. /**
  71284. * Class representing a vector containing 2 coordinates
  71285. */
  71286. export class Vector2 {
  71287. /** defines the first coordinate */
  71288. x: number;
  71289. /** defines the second coordinate */
  71290. y: number;
  71291. /**
  71292. * Creates a new Vector2 from the given x and y coordinates
  71293. * @param x defines the first coordinate
  71294. * @param y defines the second coordinate
  71295. */
  71296. constructor(
  71297. /** defines the first coordinate */
  71298. x?: number,
  71299. /** defines the second coordinate */
  71300. y?: number);
  71301. /**
  71302. * Gets a string with the Vector2 coordinates
  71303. * @returns a string with the Vector2 coordinates
  71304. */
  71305. toString(): string;
  71306. /**
  71307. * Gets class name
  71308. * @returns the string "Vector2"
  71309. */
  71310. getClassName(): string;
  71311. /**
  71312. * Gets current vector hash code
  71313. * @returns the Vector2 hash code as a number
  71314. */
  71315. getHashCode(): number;
  71316. /**
  71317. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71318. * @param array defines the source array
  71319. * @param index defines the offset in source array
  71320. * @returns the current Vector2
  71321. */
  71322. toArray(array: FloatArray, index?: number): Vector2;
  71323. /**
  71324. * Copy the current vector to an array
  71325. * @returns a new array with 2 elements: the Vector2 coordinates.
  71326. */
  71327. asArray(): number[];
  71328. /**
  71329. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71330. * @param source defines the source Vector2
  71331. * @returns the current updated Vector2
  71332. */
  71333. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  71334. /**
  71335. * Sets the Vector2 coordinates with the given floats
  71336. * @param x defines the first coordinate
  71337. * @param y defines the second coordinate
  71338. * @returns the current updated Vector2
  71339. */
  71340. copyFromFloats(x: number, y: number): Vector2;
  71341. /**
  71342. * Sets the Vector2 coordinates with the given floats
  71343. * @param x defines the first coordinate
  71344. * @param y defines the second coordinate
  71345. * @returns the current updated Vector2
  71346. */
  71347. set(x: number, y: number): Vector2;
  71348. /**
  71349. * Add another vector with the current one
  71350. * @param otherVector defines the other vector
  71351. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71352. */
  71353. add(otherVector: DeepImmutable<Vector2>): Vector2;
  71354. /**
  71355. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71356. * @param otherVector defines the other vector
  71357. * @param result defines the target vector
  71358. * @returns the unmodified current Vector2
  71359. */
  71360. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71361. /**
  71362. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  71363. * @param otherVector defines the other vector
  71364. * @returns the current updated Vector2
  71365. */
  71366. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71367. /**
  71368. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  71369. * @param otherVector defines the other vector
  71370. * @returns a new Vector2
  71371. */
  71372. addVector3(otherVector: Vector3): Vector2;
  71373. /**
  71374. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  71375. * @param otherVector defines the other vector
  71376. * @returns a new Vector2
  71377. */
  71378. subtract(otherVector: Vector2): Vector2;
  71379. /**
  71380. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  71381. * @param otherVector defines the other vector
  71382. * @param result defines the target vector
  71383. * @returns the unmodified current Vector2
  71384. */
  71385. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71386. /**
  71387. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  71388. * @param otherVector defines the other vector
  71389. * @returns the current updated Vector2
  71390. */
  71391. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71392. /**
  71393. * Multiplies in place the current Vector2 coordinates by the given ones
  71394. * @param otherVector defines the other vector
  71395. * @returns the current updated Vector2
  71396. */
  71397. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71398. /**
  71399. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  71400. * @param otherVector defines the other vector
  71401. * @returns a new Vector2
  71402. */
  71403. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  71404. /**
  71405. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  71406. * @param otherVector defines the other vector
  71407. * @param result defines the target vector
  71408. * @returns the unmodified current Vector2
  71409. */
  71410. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71411. /**
  71412. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  71413. * @param x defines the first coordinate
  71414. * @param y defines the second coordinate
  71415. * @returns a new Vector2
  71416. */
  71417. multiplyByFloats(x: number, y: number): Vector2;
  71418. /**
  71419. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  71420. * @param otherVector defines the other vector
  71421. * @returns a new Vector2
  71422. */
  71423. divide(otherVector: Vector2): Vector2;
  71424. /**
  71425. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  71426. * @param otherVector defines the other vector
  71427. * @param result defines the target vector
  71428. * @returns the unmodified current Vector2
  71429. */
  71430. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  71431. /**
  71432. * Divides the current Vector2 coordinates by the given ones
  71433. * @param otherVector defines the other vector
  71434. * @returns the current updated Vector2
  71435. */
  71436. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  71437. /**
  71438. * Gets a new Vector2 with current Vector2 negated coordinates
  71439. * @returns a new Vector2
  71440. */
  71441. negate(): Vector2;
  71442. /**
  71443. * Multiply the Vector2 coordinates by scale
  71444. * @param scale defines the scaling factor
  71445. * @returns the current updated Vector2
  71446. */
  71447. scaleInPlace(scale: number): Vector2;
  71448. /**
  71449. * Returns a new Vector2 scaled by "scale" from the current Vector2
  71450. * @param scale defines the scaling factor
  71451. * @returns a new Vector2
  71452. */
  71453. scale(scale: number): Vector2;
  71454. /**
  71455. * Scale the current Vector2 values by a factor to a given Vector2
  71456. * @param scale defines the scale factor
  71457. * @param result defines the Vector2 object where to store the result
  71458. * @returns the unmodified current Vector2
  71459. */
  71460. scaleToRef(scale: number, result: Vector2): Vector2;
  71461. /**
  71462. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  71463. * @param scale defines the scale factor
  71464. * @param result defines the Vector2 object where to store the result
  71465. * @returns the unmodified current Vector2
  71466. */
  71467. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  71468. /**
  71469. * Gets a boolean if two vectors are equals
  71470. * @param otherVector defines the other vector
  71471. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  71472. */
  71473. equals(otherVector: DeepImmutable<Vector2>): boolean;
  71474. /**
  71475. * Gets a boolean if two vectors are equals (using an epsilon value)
  71476. * @param otherVector defines the other vector
  71477. * @param epsilon defines the minimal distance to consider equality
  71478. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  71479. */
  71480. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  71481. /**
  71482. * Gets a new Vector2 from current Vector2 floored values
  71483. * @returns a new Vector2
  71484. */
  71485. floor(): Vector2;
  71486. /**
  71487. * Gets a new Vector2 from current Vector2 floored values
  71488. * @returns a new Vector2
  71489. */
  71490. fract(): Vector2;
  71491. /**
  71492. * Gets the length of the vector
  71493. * @returns the vector length (float)
  71494. */
  71495. length(): number;
  71496. /**
  71497. * Gets the vector squared length
  71498. * @returns the vector squared length (float)
  71499. */
  71500. lengthSquared(): number;
  71501. /**
  71502. * Normalize the vector
  71503. * @returns the current updated Vector2
  71504. */
  71505. normalize(): Vector2;
  71506. /**
  71507. * Gets a new Vector2 copied from the Vector2
  71508. * @returns a new Vector2
  71509. */
  71510. clone(): Vector2;
  71511. /**
  71512. * Gets a new Vector2(0, 0)
  71513. * @returns a new Vector2
  71514. */
  71515. static Zero(): Vector2;
  71516. /**
  71517. * Gets a new Vector2(1, 1)
  71518. * @returns a new Vector2
  71519. */
  71520. static One(): Vector2;
  71521. /**
  71522. * Gets a new Vector2 set from the given index element of the given array
  71523. * @param array defines the data source
  71524. * @param offset defines the offset in the data source
  71525. * @returns a new Vector2
  71526. */
  71527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  71528. /**
  71529. * Sets "result" from the given index element of the given array
  71530. * @param array defines the data source
  71531. * @param offset defines the offset in the data source
  71532. * @param result defines the target vector
  71533. */
  71534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  71535. /**
  71536. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  71537. * @param value1 defines 1st point of control
  71538. * @param value2 defines 2nd point of control
  71539. * @param value3 defines 3rd point of control
  71540. * @param value4 defines 4th point of control
  71541. * @param amount defines the interpolation factor
  71542. * @returns a new Vector2
  71543. */
  71544. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  71545. /**
  71546. * 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".
  71547. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  71548. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  71549. * @param value defines the value to clamp
  71550. * @param min defines the lower limit
  71551. * @param max defines the upper limit
  71552. * @returns a new Vector2
  71553. */
  71554. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  71555. /**
  71556. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  71557. * @param value1 defines the 1st control point
  71558. * @param tangent1 defines the outgoing tangent
  71559. * @param value2 defines the 2nd control point
  71560. * @param tangent2 defines the incoming tangent
  71561. * @param amount defines the interpolation factor
  71562. * @returns a new Vector2
  71563. */
  71564. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  71565. /**
  71566. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  71567. * @param start defines the start vector
  71568. * @param end defines the end vector
  71569. * @param amount defines the interpolation factor
  71570. * @returns a new Vector2
  71571. */
  71572. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  71573. /**
  71574. * Gets the dot product of the vector "left" and the vector "right"
  71575. * @param left defines first vector
  71576. * @param right defines second vector
  71577. * @returns the dot product (float)
  71578. */
  71579. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  71580. /**
  71581. * Returns a new Vector2 equal to the normalized given vector
  71582. * @param vector defines the vector to normalize
  71583. * @returns a new Vector2
  71584. */
  71585. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  71586. /**
  71587. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  71588. * @param left defines 1st vector
  71589. * @param right defines 2nd vector
  71590. * @returns a new Vector2
  71591. */
  71592. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71593. /**
  71594. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  71595. * @param left defines 1st vector
  71596. * @param right defines 2nd vector
  71597. * @returns a new Vector2
  71598. */
  71599. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  71600. /**
  71601. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  71602. * @param vector defines the vector to transform
  71603. * @param transformation defines the matrix to apply
  71604. * @returns a new Vector2
  71605. */
  71606. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  71607. /**
  71608. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  71609. * @param vector defines the vector to transform
  71610. * @param transformation defines the matrix to apply
  71611. * @param result defines the target vector
  71612. */
  71613. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  71614. /**
  71615. * Determines if a given vector is included in a triangle
  71616. * @param p defines the vector to test
  71617. * @param p0 defines 1st triangle point
  71618. * @param p1 defines 2nd triangle point
  71619. * @param p2 defines 3rd triangle point
  71620. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  71621. */
  71622. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  71623. /**
  71624. * Gets the distance between the vectors "value1" and "value2"
  71625. * @param value1 defines first vector
  71626. * @param value2 defines second vector
  71627. * @returns the distance between vectors
  71628. */
  71629. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71630. /**
  71631. * Returns the squared distance between the vectors "value1" and "value2"
  71632. * @param value1 defines first vector
  71633. * @param value2 defines second vector
  71634. * @returns the squared distance between vectors
  71635. */
  71636. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  71637. /**
  71638. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  71639. * @param value1 defines first vector
  71640. * @param value2 defines second vector
  71641. * @returns a new Vector2
  71642. */
  71643. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  71644. /**
  71645. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  71646. * @param p defines the middle point
  71647. * @param segA defines one point of the segment
  71648. * @param segB defines the other point of the segment
  71649. * @returns the shortest distance
  71650. */
  71651. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  71652. }
  71653. /**
  71654. * Class used to store (x,y,z) vector representation
  71655. * A Vector3 is the main object used in 3D geometry
  71656. * It can represent etiher the coordinates of a point the space, either a direction
  71657. * Reminder: js uses a left handed forward facing system
  71658. */
  71659. export class Vector3 {
  71660. /**
  71661. * Defines the first coordinates (on X axis)
  71662. */
  71663. x: number;
  71664. /**
  71665. * Defines the second coordinates (on Y axis)
  71666. */
  71667. y: number;
  71668. /**
  71669. * Defines the third coordinates (on Z axis)
  71670. */
  71671. z: number;
  71672. private static _UpReadOnly;
  71673. private static _ZeroReadOnly;
  71674. /**
  71675. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  71676. * @param x defines the first coordinates (on X axis)
  71677. * @param y defines the second coordinates (on Y axis)
  71678. * @param z defines the third coordinates (on Z axis)
  71679. */
  71680. constructor(
  71681. /**
  71682. * Defines the first coordinates (on X axis)
  71683. */
  71684. x?: number,
  71685. /**
  71686. * Defines the second coordinates (on Y axis)
  71687. */
  71688. y?: number,
  71689. /**
  71690. * Defines the third coordinates (on Z axis)
  71691. */
  71692. z?: number);
  71693. /**
  71694. * Creates a string representation of the Vector3
  71695. * @returns a string with the Vector3 coordinates.
  71696. */
  71697. toString(): string;
  71698. /**
  71699. * Gets the class name
  71700. * @returns the string "Vector3"
  71701. */
  71702. getClassName(): string;
  71703. /**
  71704. * Creates the Vector3 hash code
  71705. * @returns a number which tends to be unique between Vector3 instances
  71706. */
  71707. getHashCode(): number;
  71708. /**
  71709. * Creates an array containing three elements : the coordinates of the Vector3
  71710. * @returns a new array of numbers
  71711. */
  71712. asArray(): number[];
  71713. /**
  71714. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  71715. * @param array defines the destination array
  71716. * @param index defines the offset in the destination array
  71717. * @returns the current Vector3
  71718. */
  71719. toArray(array: FloatArray, index?: number): Vector3;
  71720. /**
  71721. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  71722. * @returns a new Quaternion object, computed from the Vector3 coordinates
  71723. */
  71724. toQuaternion(): Quaternion;
  71725. /**
  71726. * Adds the given vector to the current Vector3
  71727. * @param otherVector defines the second operand
  71728. * @returns the current updated Vector3
  71729. */
  71730. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71731. /**
  71732. * Adds the given coordinates to the current Vector3
  71733. * @param x defines the x coordinate of the operand
  71734. * @param y defines the y coordinate of the operand
  71735. * @param z defines the z coordinate of the operand
  71736. * @returns the current updated Vector3
  71737. */
  71738. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71739. /**
  71740. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  71741. * @param otherVector defines the second operand
  71742. * @returns the resulting Vector3
  71743. */
  71744. add(otherVector: DeepImmutable<Vector3>): Vector3;
  71745. /**
  71746. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  71747. * @param otherVector defines the second operand
  71748. * @param result defines the Vector3 object where to store the result
  71749. * @returns the current Vector3
  71750. */
  71751. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71752. /**
  71753. * Subtract the given vector from the current Vector3
  71754. * @param otherVector defines the second operand
  71755. * @returns the current updated Vector3
  71756. */
  71757. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71758. /**
  71759. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  71760. * @param otherVector defines the second operand
  71761. * @returns the resulting Vector3
  71762. */
  71763. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  71764. /**
  71765. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  71766. * @param otherVector defines the second operand
  71767. * @param result defines the Vector3 object where to store the result
  71768. * @returns the current Vector3
  71769. */
  71770. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71771. /**
  71772. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  71773. * @param x defines the x coordinate of the operand
  71774. * @param y defines the y coordinate of the operand
  71775. * @param z defines the z coordinate of the operand
  71776. * @returns the resulting Vector3
  71777. */
  71778. subtractFromFloats(x: number, y: number, z: number): Vector3;
  71779. /**
  71780. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  71781. * @param x defines the x coordinate of the operand
  71782. * @param y defines the y coordinate of the operand
  71783. * @param z defines the z coordinate of the operand
  71784. * @param result defines the Vector3 object where to store the result
  71785. * @returns the current Vector3
  71786. */
  71787. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  71788. /**
  71789. * Gets a new Vector3 set with the current Vector3 negated coordinates
  71790. * @returns a new Vector3
  71791. */
  71792. negate(): Vector3;
  71793. /**
  71794. * Multiplies the Vector3 coordinates by the float "scale"
  71795. * @param scale defines the multiplier factor
  71796. * @returns the current updated Vector3
  71797. */
  71798. scaleInPlace(scale: number): Vector3;
  71799. /**
  71800. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  71801. * @param scale defines the multiplier factor
  71802. * @returns a new Vector3
  71803. */
  71804. scale(scale: number): Vector3;
  71805. /**
  71806. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  71807. * @param scale defines the multiplier factor
  71808. * @param result defines the Vector3 object where to store the result
  71809. * @returns the current Vector3
  71810. */
  71811. scaleToRef(scale: number, result: Vector3): Vector3;
  71812. /**
  71813. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  71814. * @param scale defines the scale factor
  71815. * @param result defines the Vector3 object where to store the result
  71816. * @returns the unmodified current Vector3
  71817. */
  71818. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  71819. /**
  71820. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  71821. * @param otherVector defines the second operand
  71822. * @returns true if both vectors are equals
  71823. */
  71824. equals(otherVector: DeepImmutable<Vector3>): boolean;
  71825. /**
  71826. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  71827. * @param otherVector defines the second operand
  71828. * @param epsilon defines the minimal distance to define values as equals
  71829. * @returns true if both vectors are distant less than epsilon
  71830. */
  71831. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  71832. /**
  71833. * Returns true if the current Vector3 coordinates equals the given floats
  71834. * @param x defines the x coordinate of the operand
  71835. * @param y defines the y coordinate of the operand
  71836. * @param z defines the z coordinate of the operand
  71837. * @returns true if both vectors are equals
  71838. */
  71839. equalsToFloats(x: number, y: number, z: number): boolean;
  71840. /**
  71841. * Multiplies the current Vector3 coordinates by the given ones
  71842. * @param otherVector defines the second operand
  71843. * @returns the current updated Vector3
  71844. */
  71845. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  71846. /**
  71847. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  71848. * @param otherVector defines the second operand
  71849. * @returns the new Vector3
  71850. */
  71851. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  71852. /**
  71853. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  71854. * @param otherVector defines the second operand
  71855. * @param result defines the Vector3 object where to store the result
  71856. * @returns the current Vector3
  71857. */
  71858. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71859. /**
  71860. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  71861. * @param x defines the x coordinate of the operand
  71862. * @param y defines the y coordinate of the operand
  71863. * @param z defines the z coordinate of the operand
  71864. * @returns the new Vector3
  71865. */
  71866. multiplyByFloats(x: number, y: number, z: number): Vector3;
  71867. /**
  71868. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  71869. * @param otherVector defines the second operand
  71870. * @returns the new Vector3
  71871. */
  71872. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  71873. /**
  71874. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  71875. * @param otherVector defines the second operand
  71876. * @param result defines the Vector3 object where to store the result
  71877. * @returns the current Vector3
  71878. */
  71879. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  71880. /**
  71881. * Divides the current Vector3 coordinates by the given ones.
  71882. * @param otherVector defines the second operand
  71883. * @returns the current updated Vector3
  71884. */
  71885. divideInPlace(otherVector: Vector3): Vector3;
  71886. /**
  71887. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  71888. * @param other defines the second operand
  71889. * @returns the current updated Vector3
  71890. */
  71891. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71892. /**
  71893. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  71894. * @param other defines the second operand
  71895. * @returns the current updated Vector3
  71896. */
  71897. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  71898. /**
  71899. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  71900. * @param x defines the x coordinate of the operand
  71901. * @param y defines the y coordinate of the operand
  71902. * @param z defines the z coordinate of the operand
  71903. * @returns the current updated Vector3
  71904. */
  71905. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71906. /**
  71907. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  71908. * @param x defines the x coordinate of the operand
  71909. * @param y defines the y coordinate of the operand
  71910. * @param z defines the z coordinate of the operand
  71911. * @returns the current updated Vector3
  71912. */
  71913. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  71914. /**
  71915. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  71916. * Check if is non uniform within a certain amount of decimal places to account for this
  71917. * @param epsilon the amount the values can differ
  71918. * @returns if the the vector is non uniform to a certain number of decimal places
  71919. */
  71920. isNonUniformWithinEpsilon(epsilon: number): boolean;
  71921. /**
  71922. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  71923. */
  71924. readonly isNonUniform: boolean;
  71925. /**
  71926. * Gets a new Vector3 from current Vector3 floored values
  71927. * @returns a new Vector3
  71928. */
  71929. floor(): Vector3;
  71930. /**
  71931. * Gets a new Vector3 from current Vector3 floored values
  71932. * @returns a new Vector3
  71933. */
  71934. fract(): Vector3;
  71935. /**
  71936. * Gets the length of the Vector3
  71937. * @returns the length of the Vector3
  71938. */
  71939. length(): number;
  71940. /**
  71941. * Gets the squared length of the Vector3
  71942. * @returns squared length of the Vector3
  71943. */
  71944. lengthSquared(): number;
  71945. /**
  71946. * Normalize the current Vector3.
  71947. * Please note that this is an in place operation.
  71948. * @returns the current updated Vector3
  71949. */
  71950. normalize(): Vector3;
  71951. /**
  71952. * Reorders the x y z properties of the vector in place
  71953. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  71954. * @returns the current updated vector
  71955. */
  71956. reorderInPlace(order: string): this;
  71957. /**
  71958. * Rotates the vector around 0,0,0 by a quaternion
  71959. * @param quaternion the rotation quaternion
  71960. * @param result vector to store the result
  71961. * @returns the resulting vector
  71962. */
  71963. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  71964. /**
  71965. * Rotates a vector around a given point
  71966. * @param quaternion the rotation quaternion
  71967. * @param point the point to rotate around
  71968. * @param result vector to store the result
  71969. * @returns the resulting vector
  71970. */
  71971. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  71972. /**
  71973. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  71974. * The cross product is then orthogonal to both current and "other"
  71975. * @param other defines the right operand
  71976. * @returns the cross product
  71977. */
  71978. cross(other: Vector3): Vector3;
  71979. /**
  71980. * Normalize the current Vector3 with the given input length.
  71981. * Please note that this is an in place operation.
  71982. * @param len the length of the vector
  71983. * @returns the current updated Vector3
  71984. */
  71985. normalizeFromLength(len: number): Vector3;
  71986. /**
  71987. * Normalize the current Vector3 to a new vector
  71988. * @returns the new Vector3
  71989. */
  71990. normalizeToNew(): Vector3;
  71991. /**
  71992. * Normalize the current Vector3 to the reference
  71993. * @param reference define the Vector3 to update
  71994. * @returns the updated Vector3
  71995. */
  71996. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71997. /**
  71998. * Creates a new Vector3 copied from the current Vector3
  71999. * @returns the new Vector3
  72000. */
  72001. clone(): Vector3;
  72002. /**
  72003. * Copies the given vector coordinates to the current Vector3 ones
  72004. * @param source defines the source Vector3
  72005. * @returns the current updated Vector3
  72006. */
  72007. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  72008. /**
  72009. * Copies the given floats to the current Vector3 coordinates
  72010. * @param x defines the x coordinate of the operand
  72011. * @param y defines the y coordinate of the operand
  72012. * @param z defines the z coordinate of the operand
  72013. * @returns the current updated Vector3
  72014. */
  72015. copyFromFloats(x: number, y: number, z: number): Vector3;
  72016. /**
  72017. * Copies the given floats to the current Vector3 coordinates
  72018. * @param x defines the x coordinate of the operand
  72019. * @param y defines the y coordinate of the operand
  72020. * @param z defines the z coordinate of the operand
  72021. * @returns the current updated Vector3
  72022. */
  72023. set(x: number, y: number, z: number): Vector3;
  72024. /**
  72025. * Copies the given float to the current Vector3 coordinates
  72026. * @param v defines the x, y and z coordinates of the operand
  72027. * @returns the current updated Vector3
  72028. */
  72029. setAll(v: number): Vector3;
  72030. /**
  72031. * Get the clip factor between two vectors
  72032. * @param vector0 defines the first operand
  72033. * @param vector1 defines the second operand
  72034. * @param axis defines the axis to use
  72035. * @param size defines the size along the axis
  72036. * @returns the clip factor
  72037. */
  72038. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  72039. /**
  72040. * Get angle between two vectors
  72041. * @param vector0 angle between vector0 and vector1
  72042. * @param vector1 angle between vector0 and vector1
  72043. * @param normal direction of the normal
  72044. * @return the angle between vector0 and vector1
  72045. */
  72046. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  72047. /**
  72048. * Returns a new Vector3 set from the index "offset" of the given array
  72049. * @param array defines the source array
  72050. * @param offset defines the offset in the source array
  72051. * @returns the new Vector3
  72052. */
  72053. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  72054. /**
  72055. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  72056. * @param array defines the source array
  72057. * @param offset defines the offset in the source array
  72058. * @returns the new Vector3
  72059. * @deprecated Please use FromArray instead.
  72060. */
  72061. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  72062. /**
  72063. * Sets the given vector "result" with the element values from the index "offset" of the given array
  72064. * @param array defines the source array
  72065. * @param offset defines the offset in the source array
  72066. * @param result defines the Vector3 where to store the result
  72067. */
  72068. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  72069. /**
  72070. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  72071. * @param array defines the source array
  72072. * @param offset defines the offset in the source array
  72073. * @param result defines the Vector3 where to store the result
  72074. * @deprecated Please use FromArrayToRef instead.
  72075. */
  72076. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  72077. /**
  72078. * Sets the given vector "result" with the given floats.
  72079. * @param x defines the x coordinate of the source
  72080. * @param y defines the y coordinate of the source
  72081. * @param z defines the z coordinate of the source
  72082. * @param result defines the Vector3 where to store the result
  72083. */
  72084. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  72085. /**
  72086. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  72087. * @returns a new empty Vector3
  72088. */
  72089. static Zero(): Vector3;
  72090. /**
  72091. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  72092. * @returns a new unit Vector3
  72093. */
  72094. static One(): Vector3;
  72095. /**
  72096. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  72097. * @returns a new up Vector3
  72098. */
  72099. static Up(): Vector3;
  72100. /**
  72101. * Gets a up Vector3 that must not be updated
  72102. */
  72103. static readonly UpReadOnly: DeepImmutable<Vector3>;
  72104. /**
  72105. * Gets a zero Vector3 that must not be updated
  72106. */
  72107. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  72108. /**
  72109. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  72110. * @returns a new down Vector3
  72111. */
  72112. static Down(): Vector3;
  72113. /**
  72114. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  72115. * @returns a new forward Vector3
  72116. */
  72117. static Forward(): Vector3;
  72118. /**
  72119. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  72120. * @returns a new forward Vector3
  72121. */
  72122. static Backward(): Vector3;
  72123. /**
  72124. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  72125. * @returns a new right Vector3
  72126. */
  72127. static Right(): Vector3;
  72128. /**
  72129. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  72130. * @returns a new left Vector3
  72131. */
  72132. static Left(): Vector3;
  72133. /**
  72134. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  72135. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72136. * @param vector defines the Vector3 to transform
  72137. * @param transformation defines the transformation matrix
  72138. * @returns the transformed Vector3
  72139. */
  72140. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72141. /**
  72142. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  72143. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  72144. * @param vector defines the Vector3 to transform
  72145. * @param transformation defines the transformation matrix
  72146. * @param result defines the Vector3 where to store the result
  72147. */
  72148. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72149. /**
  72150. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  72151. * This method computes tranformed coordinates only, not transformed direction vectors
  72152. * @param x define the x coordinate of the source vector
  72153. * @param y define the y coordinate of the source vector
  72154. * @param z define the z coordinate of the source vector
  72155. * @param transformation defines the transformation matrix
  72156. * @param result defines the Vector3 where to store the result
  72157. */
  72158. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72159. /**
  72160. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  72161. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72162. * @param vector defines the Vector3 to transform
  72163. * @param transformation defines the transformation matrix
  72164. * @returns the new Vector3
  72165. */
  72166. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  72167. /**
  72168. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  72169. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72170. * @param vector defines the Vector3 to transform
  72171. * @param transformation defines the transformation matrix
  72172. * @param result defines the Vector3 where to store the result
  72173. */
  72174. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72175. /**
  72176. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  72177. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  72178. * @param x define the x coordinate of the source vector
  72179. * @param y define the y coordinate of the source vector
  72180. * @param z define the z coordinate of the source vector
  72181. * @param transformation defines the transformation matrix
  72182. * @param result defines the Vector3 where to store the result
  72183. */
  72184. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  72185. /**
  72186. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  72187. * @param value1 defines the first control point
  72188. * @param value2 defines the second control point
  72189. * @param value3 defines the third control point
  72190. * @param value4 defines the fourth control point
  72191. * @param amount defines the amount on the spline to use
  72192. * @returns the new Vector3
  72193. */
  72194. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  72195. /**
  72196. * 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"
  72197. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72198. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72199. * @param value defines the current value
  72200. * @param min defines the lower range value
  72201. * @param max defines the upper range value
  72202. * @returns the new Vector3
  72203. */
  72204. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  72205. /**
  72206. * 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"
  72207. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  72208. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  72209. * @param value defines the current value
  72210. * @param min defines the lower range value
  72211. * @param max defines the upper range value
  72212. * @param result defines the Vector3 where to store the result
  72213. */
  72214. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  72215. /**
  72216. * Checks if a given vector is inside a specific range
  72217. * @param v defines the vector to test
  72218. * @param min defines the minimum range
  72219. * @param max defines the maximum range
  72220. */
  72221. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  72222. /**
  72223. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  72224. * @param value1 defines the first control point
  72225. * @param tangent1 defines the first tangent vector
  72226. * @param value2 defines the second control point
  72227. * @param tangent2 defines the second tangent vector
  72228. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  72229. * @returns the new Vector3
  72230. */
  72231. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  72232. /**
  72233. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  72234. * @param start defines the start value
  72235. * @param end defines the end value
  72236. * @param amount max defines amount between both (between 0 and 1)
  72237. * @returns the new Vector3
  72238. */
  72239. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  72240. /**
  72241. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  72242. * @param start defines the start value
  72243. * @param end defines the end value
  72244. * @param amount max defines amount between both (between 0 and 1)
  72245. * @param result defines the Vector3 where to store the result
  72246. */
  72247. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  72248. /**
  72249. * Returns the dot product (float) between the vectors "left" and "right"
  72250. * @param left defines the left operand
  72251. * @param right defines the right operand
  72252. * @returns the dot product
  72253. */
  72254. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  72255. /**
  72256. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  72257. * The cross product is then orthogonal to both "left" and "right"
  72258. * @param left defines the left operand
  72259. * @param right defines the right operand
  72260. * @returns the cross product
  72261. */
  72262. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72263. /**
  72264. * Sets the given vector "result" with the cross product of "left" and "right"
  72265. * The cross product is then orthogonal to both "left" and "right"
  72266. * @param left defines the left operand
  72267. * @param right defines the right operand
  72268. * @param result defines the Vector3 where to store the result
  72269. */
  72270. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  72271. /**
  72272. * Returns a new Vector3 as the normalization of the given vector
  72273. * @param vector defines the Vector3 to normalize
  72274. * @returns the new Vector3
  72275. */
  72276. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  72277. /**
  72278. * Sets the given vector "result" with the normalization of the given first vector
  72279. * @param vector defines the Vector3 to normalize
  72280. * @param result defines the Vector3 where to store the result
  72281. */
  72282. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  72283. /**
  72284. * Project a Vector3 onto screen space
  72285. * @param vector defines the Vector3 to project
  72286. * @param world defines the world matrix to use
  72287. * @param transform defines the transform (view x projection) matrix to use
  72288. * @param viewport defines the screen viewport to use
  72289. * @returns the new Vector3
  72290. */
  72291. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  72292. /** @hidden */
  72293. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  72294. /**
  72295. * Unproject from screen space to object space
  72296. * @param source defines the screen space Vector3 to use
  72297. * @param viewportWidth defines the current width of the viewport
  72298. * @param viewportHeight defines the current height of the viewport
  72299. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72300. * @param transform defines the transform (view x projection) matrix to use
  72301. * @returns the new Vector3
  72302. */
  72303. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  72304. /**
  72305. * Unproject from screen space to object space
  72306. * @param source defines the screen space Vector3 to use
  72307. * @param viewportWidth defines the current width of the viewport
  72308. * @param viewportHeight defines the current height of the viewport
  72309. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72310. * @param view defines the view matrix to use
  72311. * @param projection defines the projection matrix to use
  72312. * @returns the new Vector3
  72313. */
  72314. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  72315. /**
  72316. * Unproject from screen space to object space
  72317. * @param source defines the screen space Vector3 to use
  72318. * @param viewportWidth defines the current width of the viewport
  72319. * @param viewportHeight defines the current height of the viewport
  72320. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72321. * @param view defines the view matrix to use
  72322. * @param projection defines the projection matrix to use
  72323. * @param result defines the Vector3 where to store the result
  72324. */
  72325. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72326. /**
  72327. * Unproject from screen space to object space
  72328. * @param sourceX defines the screen space x coordinate to use
  72329. * @param sourceY defines the screen space y coordinate to use
  72330. * @param sourceZ defines the screen space z coordinate to use
  72331. * @param viewportWidth defines the current width of the viewport
  72332. * @param viewportHeight defines the current height of the viewport
  72333. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  72334. * @param view defines the view matrix to use
  72335. * @param projection defines the projection matrix to use
  72336. * @param result defines the Vector3 where to store the result
  72337. */
  72338. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  72339. /**
  72340. * Gets the minimal coordinate values between two Vector3
  72341. * @param left defines the first operand
  72342. * @param right defines the second operand
  72343. * @returns the new Vector3
  72344. */
  72345. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72346. /**
  72347. * Gets the maximal coordinate values between two Vector3
  72348. * @param left defines the first operand
  72349. * @param right defines the second operand
  72350. * @returns the new Vector3
  72351. */
  72352. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  72353. /**
  72354. * Returns the distance between the vectors "value1" and "value2"
  72355. * @param value1 defines the first operand
  72356. * @param value2 defines the second operand
  72357. * @returns the distance
  72358. */
  72359. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72360. /**
  72361. * Returns the squared distance between the vectors "value1" and "value2"
  72362. * @param value1 defines the first operand
  72363. * @param value2 defines the second operand
  72364. * @returns the squared distance
  72365. */
  72366. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  72367. /**
  72368. * Returns a new Vector3 located at the center between "value1" and "value2"
  72369. * @param value1 defines the first operand
  72370. * @param value2 defines the second operand
  72371. * @returns the new Vector3
  72372. */
  72373. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  72374. /**
  72375. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  72376. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  72377. * to something in order to rotate it from its local system to the given target system
  72378. * Note: axis1, axis2 and axis3 are normalized during this operation
  72379. * @param axis1 defines the first axis
  72380. * @param axis2 defines the second axis
  72381. * @param axis3 defines the third axis
  72382. * @returns a new Vector3
  72383. */
  72384. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  72385. /**
  72386. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  72387. * @param axis1 defines the first axis
  72388. * @param axis2 defines the second axis
  72389. * @param axis3 defines the third axis
  72390. * @param ref defines the Vector3 where to store the result
  72391. */
  72392. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  72393. }
  72394. /**
  72395. * Vector4 class created for EulerAngle class conversion to Quaternion
  72396. */
  72397. export class Vector4 {
  72398. /** x value of the vector */
  72399. x: number;
  72400. /** y value of the vector */
  72401. y: number;
  72402. /** z value of the vector */
  72403. z: number;
  72404. /** w value of the vector */
  72405. w: number;
  72406. /**
  72407. * Creates a Vector4 object from the given floats.
  72408. * @param x x value of the vector
  72409. * @param y y value of the vector
  72410. * @param z z value of the vector
  72411. * @param w w value of the vector
  72412. */
  72413. constructor(
  72414. /** x value of the vector */
  72415. x: number,
  72416. /** y value of the vector */
  72417. y: number,
  72418. /** z value of the vector */
  72419. z: number,
  72420. /** w value of the vector */
  72421. w: number);
  72422. /**
  72423. * Returns the string with the Vector4 coordinates.
  72424. * @returns a string containing all the vector values
  72425. */
  72426. toString(): string;
  72427. /**
  72428. * Returns the string "Vector4".
  72429. * @returns "Vector4"
  72430. */
  72431. getClassName(): string;
  72432. /**
  72433. * Returns the Vector4 hash code.
  72434. * @returns a unique hash code
  72435. */
  72436. getHashCode(): number;
  72437. /**
  72438. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  72439. * @returns the resulting array
  72440. */
  72441. asArray(): number[];
  72442. /**
  72443. * Populates the given array from the given index with the Vector4 coordinates.
  72444. * @param array array to populate
  72445. * @param index index of the array to start at (default: 0)
  72446. * @returns the Vector4.
  72447. */
  72448. toArray(array: FloatArray, index?: number): Vector4;
  72449. /**
  72450. * Adds the given vector to the current Vector4.
  72451. * @param otherVector the vector to add
  72452. * @returns the updated Vector4.
  72453. */
  72454. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72455. /**
  72456. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  72457. * @param otherVector the vector to add
  72458. * @returns the resulting vector
  72459. */
  72460. add(otherVector: DeepImmutable<Vector4>): Vector4;
  72461. /**
  72462. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  72463. * @param otherVector the vector to add
  72464. * @param result the vector to store the result
  72465. * @returns the current Vector4.
  72466. */
  72467. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72468. /**
  72469. * Subtract in place the given vector from the current Vector4.
  72470. * @param otherVector the vector to subtract
  72471. * @returns the updated Vector4.
  72472. */
  72473. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72474. /**
  72475. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  72476. * @param otherVector the vector to add
  72477. * @returns the new vector with the result
  72478. */
  72479. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  72480. /**
  72481. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  72482. * @param otherVector the vector to subtract
  72483. * @param result the vector to store the result
  72484. * @returns the current Vector4.
  72485. */
  72486. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72487. /**
  72488. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72489. */
  72490. /**
  72491. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72492. * @param x value to subtract
  72493. * @param y value to subtract
  72494. * @param z value to subtract
  72495. * @param w value to subtract
  72496. * @returns new vector containing the result
  72497. */
  72498. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72499. /**
  72500. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  72501. * @param x value to subtract
  72502. * @param y value to subtract
  72503. * @param z value to subtract
  72504. * @param w value to subtract
  72505. * @param result the vector to store the result in
  72506. * @returns the current Vector4.
  72507. */
  72508. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  72509. /**
  72510. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  72511. * @returns a new vector with the negated values
  72512. */
  72513. negate(): Vector4;
  72514. /**
  72515. * Multiplies the current Vector4 coordinates by scale (float).
  72516. * @param scale the number to scale with
  72517. * @returns the updated Vector4.
  72518. */
  72519. scaleInPlace(scale: number): Vector4;
  72520. /**
  72521. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  72522. * @param scale the number to scale with
  72523. * @returns a new vector with the result
  72524. */
  72525. scale(scale: number): Vector4;
  72526. /**
  72527. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  72528. * @param scale the number to scale with
  72529. * @param result a vector to store the result in
  72530. * @returns the current Vector4.
  72531. */
  72532. scaleToRef(scale: number, result: Vector4): Vector4;
  72533. /**
  72534. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  72535. * @param scale defines the scale factor
  72536. * @param result defines the Vector4 object where to store the result
  72537. * @returns the unmodified current Vector4
  72538. */
  72539. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  72540. /**
  72541. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  72542. * @param otherVector the vector to compare against
  72543. * @returns true if they are equal
  72544. */
  72545. equals(otherVector: DeepImmutable<Vector4>): boolean;
  72546. /**
  72547. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  72548. * @param otherVector vector to compare against
  72549. * @param epsilon (Default: very small number)
  72550. * @returns true if they are equal
  72551. */
  72552. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  72553. /**
  72554. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  72555. * @param x x value to compare against
  72556. * @param y y value to compare against
  72557. * @param z z value to compare against
  72558. * @param w w value to compare against
  72559. * @returns true if equal
  72560. */
  72561. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  72562. /**
  72563. * Multiplies in place the current Vector4 by the given one.
  72564. * @param otherVector vector to multiple with
  72565. * @returns the updated Vector4.
  72566. */
  72567. multiplyInPlace(otherVector: Vector4): Vector4;
  72568. /**
  72569. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  72570. * @param otherVector vector to multiple with
  72571. * @returns resulting new vector
  72572. */
  72573. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  72574. /**
  72575. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  72576. * @param otherVector vector to multiple with
  72577. * @param result vector to store the result
  72578. * @returns the current Vector4.
  72579. */
  72580. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72581. /**
  72582. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  72583. * @param x x value multiply with
  72584. * @param y y value multiply with
  72585. * @param z z value multiply with
  72586. * @param w w value multiply with
  72587. * @returns resulting new vector
  72588. */
  72589. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  72590. /**
  72591. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  72592. * @param otherVector vector to devide with
  72593. * @returns resulting new vector
  72594. */
  72595. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  72596. /**
  72597. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  72598. * @param otherVector vector to devide with
  72599. * @param result vector to store the result
  72600. * @returns the current Vector4.
  72601. */
  72602. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  72603. /**
  72604. * Divides the current Vector3 coordinates by the given ones.
  72605. * @param otherVector vector to devide with
  72606. * @returns the updated Vector3.
  72607. */
  72608. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  72609. /**
  72610. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  72611. * @param other defines the second operand
  72612. * @returns the current updated Vector4
  72613. */
  72614. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72615. /**
  72616. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  72617. * @param other defines the second operand
  72618. * @returns the current updated Vector4
  72619. */
  72620. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  72621. /**
  72622. * Gets a new Vector4 from current Vector4 floored values
  72623. * @returns a new Vector4
  72624. */
  72625. floor(): Vector4;
  72626. /**
  72627. * Gets a new Vector4 from current Vector3 floored values
  72628. * @returns a new Vector4
  72629. */
  72630. fract(): Vector4;
  72631. /**
  72632. * Returns the Vector4 length (float).
  72633. * @returns the length
  72634. */
  72635. length(): number;
  72636. /**
  72637. * Returns the Vector4 squared length (float).
  72638. * @returns the length squared
  72639. */
  72640. lengthSquared(): number;
  72641. /**
  72642. * Normalizes in place the Vector4.
  72643. * @returns the updated Vector4.
  72644. */
  72645. normalize(): Vector4;
  72646. /**
  72647. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  72648. * @returns this converted to a new vector3
  72649. */
  72650. toVector3(): Vector3;
  72651. /**
  72652. * Returns a new Vector4 copied from the current one.
  72653. * @returns the new cloned vector
  72654. */
  72655. clone(): Vector4;
  72656. /**
  72657. * Updates the current Vector4 with the given one coordinates.
  72658. * @param source the source vector to copy from
  72659. * @returns the updated Vector4.
  72660. */
  72661. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  72662. /**
  72663. * Updates the current Vector4 coordinates with the given floats.
  72664. * @param x float to copy from
  72665. * @param y float to copy from
  72666. * @param z float to copy from
  72667. * @param w float to copy from
  72668. * @returns the updated Vector4.
  72669. */
  72670. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  72671. /**
  72672. * Updates the current Vector4 coordinates with the given floats.
  72673. * @param x float to set from
  72674. * @param y float to set from
  72675. * @param z float to set from
  72676. * @param w float to set from
  72677. * @returns the updated Vector4.
  72678. */
  72679. set(x: number, y: number, z: number, w: number): Vector4;
  72680. /**
  72681. * Copies the given float to the current Vector3 coordinates
  72682. * @param v defines the x, y, z and w coordinates of the operand
  72683. * @returns the current updated Vector3
  72684. */
  72685. setAll(v: number): Vector4;
  72686. /**
  72687. * Returns a new Vector4 set from the starting index of the given array.
  72688. * @param array the array to pull values from
  72689. * @param offset the offset into the array to start at
  72690. * @returns the new vector
  72691. */
  72692. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  72693. /**
  72694. * Updates the given vector "result" from the starting index of the given array.
  72695. * @param array the array to pull values from
  72696. * @param offset the offset into the array to start at
  72697. * @param result the vector to store the result in
  72698. */
  72699. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  72700. /**
  72701. * Updates the given vector "result" from the starting index of the given Float32Array.
  72702. * @param array the array to pull values from
  72703. * @param offset the offset into the array to start at
  72704. * @param result the vector to store the result in
  72705. */
  72706. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  72707. /**
  72708. * Updates the given vector "result" coordinates from the given floats.
  72709. * @param x float to set from
  72710. * @param y float to set from
  72711. * @param z float to set from
  72712. * @param w float to set from
  72713. * @param result the vector to the floats in
  72714. */
  72715. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  72716. /**
  72717. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  72718. * @returns the new vector
  72719. */
  72720. static Zero(): Vector4;
  72721. /**
  72722. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  72723. * @returns the new vector
  72724. */
  72725. static One(): Vector4;
  72726. /**
  72727. * Returns a new normalized Vector4 from the given one.
  72728. * @param vector the vector to normalize
  72729. * @returns the vector
  72730. */
  72731. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  72732. /**
  72733. * Updates the given vector "result" from the normalization of the given one.
  72734. * @param vector the vector to normalize
  72735. * @param result the vector to store the result in
  72736. */
  72737. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  72738. /**
  72739. * Returns a vector with the minimum values from the left and right vectors
  72740. * @param left left vector to minimize
  72741. * @param right right vector to minimize
  72742. * @returns a new vector with the minimum of the left and right vector values
  72743. */
  72744. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72745. /**
  72746. * Returns a vector with the maximum values from the left and right vectors
  72747. * @param left left vector to maximize
  72748. * @param right right vector to maximize
  72749. * @returns a new vector with the maximum of the left and right vector values
  72750. */
  72751. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  72752. /**
  72753. * Returns the distance (float) between the vectors "value1" and "value2".
  72754. * @param value1 value to calulate the distance between
  72755. * @param value2 value to calulate the distance between
  72756. * @return the distance between the two vectors
  72757. */
  72758. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72759. /**
  72760. * Returns the squared distance (float) between the vectors "value1" and "value2".
  72761. * @param value1 value to calulate the distance between
  72762. * @param value2 value to calulate the distance between
  72763. * @return the distance between the two vectors squared
  72764. */
  72765. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  72766. /**
  72767. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  72768. * @param value1 value to calulate the center between
  72769. * @param value2 value to calulate the center between
  72770. * @return the center between the two vectors
  72771. */
  72772. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  72773. /**
  72774. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  72775. * This methods computes transformed normalized direction vectors only.
  72776. * @param vector the vector to transform
  72777. * @param transformation the transformation matrix to apply
  72778. * @returns the new vector
  72779. */
  72780. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  72781. /**
  72782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  72783. * This methods computes transformed normalized direction vectors only.
  72784. * @param vector the vector to transform
  72785. * @param transformation the transformation matrix to apply
  72786. * @param result the vector to store the result in
  72787. */
  72788. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72789. /**
  72790. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  72791. * This methods computes transformed normalized direction vectors only.
  72792. * @param x value to transform
  72793. * @param y value to transform
  72794. * @param z value to transform
  72795. * @param w value to transform
  72796. * @param transformation the transformation matrix to apply
  72797. * @param result the vector to store the results in
  72798. */
  72799. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  72800. /**
  72801. * Creates a new Vector4 from a Vector3
  72802. * @param source defines the source data
  72803. * @param w defines the 4th component (default is 0)
  72804. * @returns a new Vector4
  72805. */
  72806. static FromVector3(source: Vector3, w?: number): Vector4;
  72807. }
  72808. /**
  72809. * Class used to store quaternion data
  72810. * @see https://en.wikipedia.org/wiki/Quaternion
  72811. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  72812. */
  72813. export class Quaternion {
  72814. /** defines the first component (0 by default) */
  72815. x: number;
  72816. /** defines the second component (0 by default) */
  72817. y: number;
  72818. /** defines the third component (0 by default) */
  72819. z: number;
  72820. /** defines the fourth component (1.0 by default) */
  72821. w: number;
  72822. /**
  72823. * Creates a new Quaternion from the given floats
  72824. * @param x defines the first component (0 by default)
  72825. * @param y defines the second component (0 by default)
  72826. * @param z defines the third component (0 by default)
  72827. * @param w defines the fourth component (1.0 by default)
  72828. */
  72829. constructor(
  72830. /** defines the first component (0 by default) */
  72831. x?: number,
  72832. /** defines the second component (0 by default) */
  72833. y?: number,
  72834. /** defines the third component (0 by default) */
  72835. z?: number,
  72836. /** defines the fourth component (1.0 by default) */
  72837. w?: number);
  72838. /**
  72839. * Gets a string representation for the current quaternion
  72840. * @returns a string with the Quaternion coordinates
  72841. */
  72842. toString(): string;
  72843. /**
  72844. * Gets the class name of the quaternion
  72845. * @returns the string "Quaternion"
  72846. */
  72847. getClassName(): string;
  72848. /**
  72849. * Gets a hash code for this quaternion
  72850. * @returns the quaternion hash code
  72851. */
  72852. getHashCode(): number;
  72853. /**
  72854. * Copy the quaternion to an array
  72855. * @returns a new array populated with 4 elements from the quaternion coordinates
  72856. */
  72857. asArray(): number[];
  72858. /**
  72859. * Check if two quaternions are equals
  72860. * @param otherQuaternion defines the second operand
  72861. * @return true if the current quaternion and the given one coordinates are strictly equals
  72862. */
  72863. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  72864. /**
  72865. * Clone the current quaternion
  72866. * @returns a new quaternion copied from the current one
  72867. */
  72868. clone(): Quaternion;
  72869. /**
  72870. * Copy a quaternion to the current one
  72871. * @param other defines the other quaternion
  72872. * @returns the updated current quaternion
  72873. */
  72874. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  72875. /**
  72876. * Updates the current quaternion with the given float coordinates
  72877. * @param x defines the x coordinate
  72878. * @param y defines the y coordinate
  72879. * @param z defines the z coordinate
  72880. * @param w defines the w coordinate
  72881. * @returns the updated current quaternion
  72882. */
  72883. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  72884. /**
  72885. * Updates the current quaternion from the given float coordinates
  72886. * @param x defines the x coordinate
  72887. * @param y defines the y coordinate
  72888. * @param z defines the z coordinate
  72889. * @param w defines the w coordinate
  72890. * @returns the updated current quaternion
  72891. */
  72892. set(x: number, y: number, z: number, w: number): Quaternion;
  72893. /**
  72894. * Adds two quaternions
  72895. * @param other defines the second operand
  72896. * @returns a new quaternion as the addition result of the given one and the current quaternion
  72897. */
  72898. add(other: DeepImmutable<Quaternion>): Quaternion;
  72899. /**
  72900. * Add a quaternion to the current one
  72901. * @param other defines the quaternion to add
  72902. * @returns the current quaternion
  72903. */
  72904. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  72905. /**
  72906. * Subtract two quaternions
  72907. * @param other defines the second operand
  72908. * @returns a new quaternion as the subtraction result of the given one from the current one
  72909. */
  72910. subtract(other: Quaternion): Quaternion;
  72911. /**
  72912. * Multiplies the current quaternion by a scale factor
  72913. * @param value defines the scale factor
  72914. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  72915. */
  72916. scale(value: number): Quaternion;
  72917. /**
  72918. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  72919. * @param scale defines the scale factor
  72920. * @param result defines the Quaternion object where to store the result
  72921. * @returns the unmodified current quaternion
  72922. */
  72923. scaleToRef(scale: number, result: Quaternion): Quaternion;
  72924. /**
  72925. * Multiplies in place the current quaternion by a scale factor
  72926. * @param value defines the scale factor
  72927. * @returns the current modified quaternion
  72928. */
  72929. scaleInPlace(value: number): Quaternion;
  72930. /**
  72931. * Scale the current quaternion values by a factor and add the result to a given quaternion
  72932. * @param scale defines the scale factor
  72933. * @param result defines the Quaternion object where to store the result
  72934. * @returns the unmodified current quaternion
  72935. */
  72936. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  72937. /**
  72938. * Multiplies two quaternions
  72939. * @param q1 defines the second operand
  72940. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  72941. */
  72942. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  72943. /**
  72944. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  72945. * @param q1 defines the second operand
  72946. * @param result defines the target quaternion
  72947. * @returns the current quaternion
  72948. */
  72949. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  72950. /**
  72951. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  72952. * @param q1 defines the second operand
  72953. * @returns the currentupdated quaternion
  72954. */
  72955. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  72956. /**
  72957. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  72958. * @param ref defines the target quaternion
  72959. * @returns the current quaternion
  72960. */
  72961. conjugateToRef(ref: Quaternion): Quaternion;
  72962. /**
  72963. * Conjugates in place (1-q) the current quaternion
  72964. * @returns the current updated quaternion
  72965. */
  72966. conjugateInPlace(): Quaternion;
  72967. /**
  72968. * Conjugates in place (1-q) the current quaternion
  72969. * @returns a new quaternion
  72970. */
  72971. conjugate(): Quaternion;
  72972. /**
  72973. * Gets length of current quaternion
  72974. * @returns the quaternion length (float)
  72975. */
  72976. length(): number;
  72977. /**
  72978. * Normalize in place the current quaternion
  72979. * @returns the current updated quaternion
  72980. */
  72981. normalize(): Quaternion;
  72982. /**
  72983. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  72984. * @param order is a reserved parameter and is ignore for now
  72985. * @returns a new Vector3 containing the Euler angles
  72986. */
  72987. toEulerAngles(order?: string): Vector3;
  72988. /**
  72989. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72990. * @param result defines the vector which will be filled with the Euler angles
  72991. * @param order is a reserved parameter and is ignore for now
  72992. * @returns the current unchanged quaternion
  72993. */
  72994. toEulerAnglesToRef(result: Vector3): Quaternion;
  72995. /**
  72996. * Updates the given rotation matrix with the current quaternion values
  72997. * @param result defines the target matrix
  72998. * @returns the current unchanged quaternion
  72999. */
  73000. toRotationMatrix(result: Matrix): Quaternion;
  73001. /**
  73002. * Updates the current quaternion from the given rotation matrix values
  73003. * @param matrix defines the source matrix
  73004. * @returns the current updated quaternion
  73005. */
  73006. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  73007. /**
  73008. * Creates a new quaternion from a rotation matrix
  73009. * @param matrix defines the source matrix
  73010. * @returns a new quaternion created from the given rotation matrix values
  73011. */
  73012. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  73013. /**
  73014. * Updates the given quaternion with the given rotation matrix values
  73015. * @param matrix defines the source matrix
  73016. * @param result defines the target quaternion
  73017. */
  73018. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  73019. /**
  73020. * Returns the dot product (float) between the quaternions "left" and "right"
  73021. * @param left defines the left operand
  73022. * @param right defines the right operand
  73023. * @returns the dot product
  73024. */
  73025. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  73026. /**
  73027. * Checks if the two quaternions are close to each other
  73028. * @param quat0 defines the first quaternion to check
  73029. * @param quat1 defines the second quaternion to check
  73030. * @returns true if the two quaternions are close to each other
  73031. */
  73032. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  73033. /**
  73034. * Creates an empty quaternion
  73035. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  73036. */
  73037. static Zero(): Quaternion;
  73038. /**
  73039. * Inverse a given quaternion
  73040. * @param q defines the source quaternion
  73041. * @returns a new quaternion as the inverted current quaternion
  73042. */
  73043. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  73044. /**
  73045. * Inverse a given quaternion
  73046. * @param q defines the source quaternion
  73047. * @param result the quaternion the result will be stored in
  73048. * @returns the result quaternion
  73049. */
  73050. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  73051. /**
  73052. * Creates an identity quaternion
  73053. * @returns the identity quaternion
  73054. */
  73055. static Identity(): Quaternion;
  73056. /**
  73057. * Gets a boolean indicating if the given quaternion is identity
  73058. * @param quaternion defines the quaternion to check
  73059. * @returns true if the quaternion is identity
  73060. */
  73061. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  73062. /**
  73063. * Creates a quaternion from a rotation around an axis
  73064. * @param axis defines the axis to use
  73065. * @param angle defines the angle to use
  73066. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  73067. */
  73068. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  73069. /**
  73070. * Creates a rotation around an axis and stores it into the given quaternion
  73071. * @param axis defines the axis to use
  73072. * @param angle defines the angle to use
  73073. * @param result defines the target quaternion
  73074. * @returns the target quaternion
  73075. */
  73076. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  73077. /**
  73078. * Creates a new quaternion from data stored into an array
  73079. * @param array defines the data source
  73080. * @param offset defines the offset in the source array where the data starts
  73081. * @returns a new quaternion
  73082. */
  73083. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  73084. /**
  73085. * Create a quaternion from Euler rotation angles
  73086. * @param x Pitch
  73087. * @param y Yaw
  73088. * @param z Roll
  73089. * @returns the new Quaternion
  73090. */
  73091. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  73092. /**
  73093. * Updates a quaternion from Euler rotation angles
  73094. * @param x Pitch
  73095. * @param y Yaw
  73096. * @param z Roll
  73097. * @param result the quaternion to store the result
  73098. * @returns the updated quaternion
  73099. */
  73100. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  73101. /**
  73102. * Create a quaternion from Euler rotation vector
  73103. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73104. * @returns the new Quaternion
  73105. */
  73106. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  73107. /**
  73108. * Updates a quaternion from Euler rotation vector
  73109. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  73110. * @param result the quaternion to store the result
  73111. * @returns the updated quaternion
  73112. */
  73113. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  73114. /**
  73115. * Creates a new quaternion from the given Euler float angles (y, x, z)
  73116. * @param yaw defines the rotation around Y axis
  73117. * @param pitch defines the rotation around X axis
  73118. * @param roll defines the rotation around Z axis
  73119. * @returns the new quaternion
  73120. */
  73121. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  73122. /**
  73123. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  73124. * @param yaw defines the rotation around Y axis
  73125. * @param pitch defines the rotation around X axis
  73126. * @param roll defines the rotation around Z axis
  73127. * @param result defines the target quaternion
  73128. */
  73129. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  73130. /**
  73131. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  73132. * @param alpha defines the rotation around first axis
  73133. * @param beta defines the rotation around second axis
  73134. * @param gamma defines the rotation around third axis
  73135. * @returns the new quaternion
  73136. */
  73137. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  73138. /**
  73139. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  73140. * @param alpha defines the rotation around first axis
  73141. * @param beta defines the rotation around second axis
  73142. * @param gamma defines the rotation around third axis
  73143. * @param result defines the target quaternion
  73144. */
  73145. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  73146. /**
  73147. * 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)
  73148. * @param axis1 defines the first axis
  73149. * @param axis2 defines the second axis
  73150. * @param axis3 defines the third axis
  73151. * @returns the new quaternion
  73152. */
  73153. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  73154. /**
  73155. * 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
  73156. * @param axis1 defines the first axis
  73157. * @param axis2 defines the second axis
  73158. * @param axis3 defines the third axis
  73159. * @param ref defines the target quaternion
  73160. */
  73161. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  73162. /**
  73163. * Interpolates between two quaternions
  73164. * @param left defines first quaternion
  73165. * @param right defines second quaternion
  73166. * @param amount defines the gradient to use
  73167. * @returns the new interpolated quaternion
  73168. */
  73169. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73170. /**
  73171. * Interpolates between two quaternions and stores it into a target quaternion
  73172. * @param left defines first quaternion
  73173. * @param right defines second quaternion
  73174. * @param amount defines the gradient to use
  73175. * @param result defines the target quaternion
  73176. */
  73177. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  73178. /**
  73179. * Interpolate between two quaternions using Hermite interpolation
  73180. * @param value1 defines first quaternion
  73181. * @param tangent1 defines the incoming tangent
  73182. * @param value2 defines second quaternion
  73183. * @param tangent2 defines the outgoing tangent
  73184. * @param amount defines the target quaternion
  73185. * @returns the new interpolated quaternion
  73186. */
  73187. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  73188. }
  73189. /**
  73190. * Class used to store matrix data (4x4)
  73191. */
  73192. export class Matrix {
  73193. private static _updateFlagSeed;
  73194. private static _identityReadOnly;
  73195. private _isIdentity;
  73196. private _isIdentityDirty;
  73197. private _isIdentity3x2;
  73198. private _isIdentity3x2Dirty;
  73199. /**
  73200. * Gets the update flag of the matrix which is an unique number for the matrix.
  73201. * It will be incremented every time the matrix data change.
  73202. * You can use it to speed the comparison between two versions of the same matrix.
  73203. */
  73204. updateFlag: number;
  73205. private readonly _m;
  73206. /**
  73207. * Gets the internal data of the matrix
  73208. */
  73209. readonly m: DeepImmutable<Float32Array>;
  73210. /** @hidden */
  73211. _markAsUpdated(): void;
  73212. /** @hidden */
  73213. private _updateIdentityStatus;
  73214. /**
  73215. * Creates an empty matrix (filled with zeros)
  73216. */
  73217. constructor();
  73218. /**
  73219. * Check if the current matrix is identity
  73220. * @returns true is the matrix is the identity matrix
  73221. */
  73222. isIdentity(): boolean;
  73223. /**
  73224. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  73225. * @returns true is the matrix is the identity matrix
  73226. */
  73227. isIdentityAs3x2(): boolean;
  73228. /**
  73229. * Gets the determinant of the matrix
  73230. * @returns the matrix determinant
  73231. */
  73232. determinant(): number;
  73233. /**
  73234. * Returns the matrix as a Float32Array
  73235. * @returns the matrix underlying array
  73236. */
  73237. toArray(): DeepImmutable<Float32Array>;
  73238. /**
  73239. * Returns the matrix as a Float32Array
  73240. * @returns the matrix underlying array.
  73241. */
  73242. asArray(): DeepImmutable<Float32Array>;
  73243. /**
  73244. * Inverts the current matrix in place
  73245. * @returns the current inverted matrix
  73246. */
  73247. invert(): Matrix;
  73248. /**
  73249. * Sets all the matrix elements to zero
  73250. * @returns the current matrix
  73251. */
  73252. reset(): Matrix;
  73253. /**
  73254. * Adds the current matrix with a second one
  73255. * @param other defines the matrix to add
  73256. * @returns a new matrix as the addition of the current matrix and the given one
  73257. */
  73258. add(other: DeepImmutable<Matrix>): Matrix;
  73259. /**
  73260. * Sets the given matrix "result" to the addition of the current matrix and the given one
  73261. * @param other defines the matrix to add
  73262. * @param result defines the target matrix
  73263. * @returns the current matrix
  73264. */
  73265. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73266. /**
  73267. * Adds in place the given matrix to the current matrix
  73268. * @param other defines the second operand
  73269. * @returns the current updated matrix
  73270. */
  73271. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  73272. /**
  73273. * Sets the given matrix to the current inverted Matrix
  73274. * @param other defines the target matrix
  73275. * @returns the unmodified current matrix
  73276. */
  73277. invertToRef(other: Matrix): Matrix;
  73278. /**
  73279. * add a value at the specified position in the current Matrix
  73280. * @param index the index of the value within the matrix. between 0 and 15.
  73281. * @param value the value to be added
  73282. * @returns the current updated matrix
  73283. */
  73284. addAtIndex(index: number, value: number): Matrix;
  73285. /**
  73286. * mutiply the specified position in the current Matrix by a value
  73287. * @param index the index of the value within the matrix. between 0 and 15.
  73288. * @param value the value to be added
  73289. * @returns the current updated matrix
  73290. */
  73291. multiplyAtIndex(index: number, value: number): Matrix;
  73292. /**
  73293. * Inserts the translation vector (using 3 floats) in the current matrix
  73294. * @param x defines the 1st component of the translation
  73295. * @param y defines the 2nd component of the translation
  73296. * @param z defines the 3rd component of the translation
  73297. * @returns the current updated matrix
  73298. */
  73299. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73300. /**
  73301. * Adds the translation vector (using 3 floats) in the current matrix
  73302. * @param x defines the 1st component of the translation
  73303. * @param y defines the 2nd component of the translation
  73304. * @param z defines the 3rd component of the translation
  73305. * @returns the current updated matrix
  73306. */
  73307. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  73308. /**
  73309. * Inserts the translation vector in the current matrix
  73310. * @param vector3 defines the translation to insert
  73311. * @returns the current updated matrix
  73312. */
  73313. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  73314. /**
  73315. * Gets the translation value of the current matrix
  73316. * @returns a new Vector3 as the extracted translation from the matrix
  73317. */
  73318. getTranslation(): Vector3;
  73319. /**
  73320. * Fill a Vector3 with the extracted translation from the matrix
  73321. * @param result defines the Vector3 where to store the translation
  73322. * @returns the current matrix
  73323. */
  73324. getTranslationToRef(result: Vector3): Matrix;
  73325. /**
  73326. * Remove rotation and scaling part from the matrix
  73327. * @returns the updated matrix
  73328. */
  73329. removeRotationAndScaling(): Matrix;
  73330. /**
  73331. * Multiply two matrices
  73332. * @param other defines the second operand
  73333. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  73334. */
  73335. multiply(other: DeepImmutable<Matrix>): Matrix;
  73336. /**
  73337. * Copy the current matrix from the given one
  73338. * @param other defines the source matrix
  73339. * @returns the current updated matrix
  73340. */
  73341. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  73342. /**
  73343. * Populates the given array from the starting index with the current matrix values
  73344. * @param array defines the target array
  73345. * @param offset defines the offset in the target array where to start storing values
  73346. * @returns the current matrix
  73347. */
  73348. copyToArray(array: Float32Array, offset?: number): Matrix;
  73349. /**
  73350. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  73351. * @param other defines the second operand
  73352. * @param result defines the matrix where to store the multiplication
  73353. * @returns the current matrix
  73354. */
  73355. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  73356. /**
  73357. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  73358. * @param other defines the second operand
  73359. * @param result defines the array where to store the multiplication
  73360. * @param offset defines the offset in the target array where to start storing values
  73361. * @returns the current matrix
  73362. */
  73363. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  73364. /**
  73365. * Check equality between this matrix and a second one
  73366. * @param value defines the second matrix to compare
  73367. * @returns true is the current matrix and the given one values are strictly equal
  73368. */
  73369. equals(value: DeepImmutable<Matrix>): boolean;
  73370. /**
  73371. * Clone the current matrix
  73372. * @returns a new matrix from the current matrix
  73373. */
  73374. clone(): Matrix;
  73375. /**
  73376. * Returns the name of the current matrix class
  73377. * @returns the string "Matrix"
  73378. */
  73379. getClassName(): string;
  73380. /**
  73381. * Gets the hash code of the current matrix
  73382. * @returns the hash code
  73383. */
  73384. getHashCode(): number;
  73385. /**
  73386. * Decomposes the current Matrix into a translation, rotation and scaling components
  73387. * @param scale defines the scale vector3 given as a reference to update
  73388. * @param rotation defines the rotation quaternion given as a reference to update
  73389. * @param translation defines the translation vector3 given as a reference to update
  73390. * @returns true if operation was successful
  73391. */
  73392. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  73393. /**
  73394. * Gets specific row of the matrix
  73395. * @param index defines the number of the row to get
  73396. * @returns the index-th row of the current matrix as a new Vector4
  73397. */
  73398. getRow(index: number): Nullable<Vector4>;
  73399. /**
  73400. * Sets the index-th row of the current matrix to the vector4 values
  73401. * @param index defines the number of the row to set
  73402. * @param row defines the target vector4
  73403. * @returns the updated current matrix
  73404. */
  73405. setRow(index: number, row: Vector4): Matrix;
  73406. /**
  73407. * Compute the transpose of the matrix
  73408. * @returns the new transposed matrix
  73409. */
  73410. transpose(): Matrix;
  73411. /**
  73412. * Compute the transpose of the matrix and store it in a given matrix
  73413. * @param result defines the target matrix
  73414. * @returns the current matrix
  73415. */
  73416. transposeToRef(result: Matrix): Matrix;
  73417. /**
  73418. * Sets the index-th row of the current matrix with the given 4 x float values
  73419. * @param index defines the row index
  73420. * @param x defines the x component to set
  73421. * @param y defines the y component to set
  73422. * @param z defines the z component to set
  73423. * @param w defines the w component to set
  73424. * @returns the updated current matrix
  73425. */
  73426. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  73427. /**
  73428. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  73429. * @param scale defines the scale factor
  73430. * @returns a new matrix
  73431. */
  73432. scale(scale: number): Matrix;
  73433. /**
  73434. * Scale the current matrix values by a factor to a given result matrix
  73435. * @param scale defines the scale factor
  73436. * @param result defines the matrix to store the result
  73437. * @returns the current matrix
  73438. */
  73439. scaleToRef(scale: number, result: Matrix): Matrix;
  73440. /**
  73441. * Scale the current matrix values by a factor and add the result to a given matrix
  73442. * @param scale defines the scale factor
  73443. * @param result defines the Matrix to store the result
  73444. * @returns the current matrix
  73445. */
  73446. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  73447. /**
  73448. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  73449. * @param ref matrix to store the result
  73450. */
  73451. toNormalMatrix(ref: Matrix): void;
  73452. /**
  73453. * Gets only rotation part of the current matrix
  73454. * @returns a new matrix sets to the extracted rotation matrix from the current one
  73455. */
  73456. getRotationMatrix(): Matrix;
  73457. /**
  73458. * Extracts the rotation matrix from the current one and sets it as the given "result"
  73459. * @param result defines the target matrix to store data to
  73460. * @returns the current matrix
  73461. */
  73462. getRotationMatrixToRef(result: Matrix): Matrix;
  73463. /**
  73464. * Toggles model matrix from being right handed to left handed in place and vice versa
  73465. */
  73466. toggleModelMatrixHandInPlace(): void;
  73467. /**
  73468. * Toggles projection matrix from being right handed to left handed in place and vice versa
  73469. */
  73470. toggleProjectionMatrixHandInPlace(): void;
  73471. /**
  73472. * Creates a matrix from an array
  73473. * @param array defines the source array
  73474. * @param offset defines an offset in the source array
  73475. * @returns a new Matrix set from the starting index of the given array
  73476. */
  73477. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  73478. /**
  73479. * Copy the content of an array into a given matrix
  73480. * @param array defines the source array
  73481. * @param offset defines an offset in the source array
  73482. * @param result defines the target matrix
  73483. */
  73484. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  73485. /**
  73486. * Stores an array into a matrix after having multiplied each component by a given factor
  73487. * @param array defines the source array
  73488. * @param offset defines the offset in the source array
  73489. * @param scale defines the scaling factor
  73490. * @param result defines the target matrix
  73491. */
  73492. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  73493. /**
  73494. * Gets an identity matrix that must not be updated
  73495. */
  73496. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  73497. /**
  73498. * Stores a list of values (16) inside a given matrix
  73499. * @param initialM11 defines 1st value of 1st row
  73500. * @param initialM12 defines 2nd value of 1st row
  73501. * @param initialM13 defines 3rd value of 1st row
  73502. * @param initialM14 defines 4th value of 1st row
  73503. * @param initialM21 defines 1st value of 2nd row
  73504. * @param initialM22 defines 2nd value of 2nd row
  73505. * @param initialM23 defines 3rd value of 2nd row
  73506. * @param initialM24 defines 4th value of 2nd row
  73507. * @param initialM31 defines 1st value of 3rd row
  73508. * @param initialM32 defines 2nd value of 3rd row
  73509. * @param initialM33 defines 3rd value of 3rd row
  73510. * @param initialM34 defines 4th value of 3rd row
  73511. * @param initialM41 defines 1st value of 4th row
  73512. * @param initialM42 defines 2nd value of 4th row
  73513. * @param initialM43 defines 3rd value of 4th row
  73514. * @param initialM44 defines 4th value of 4th row
  73515. * @param result defines the target matrix
  73516. */
  73517. 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;
  73518. /**
  73519. * Creates new matrix from a list of values (16)
  73520. * @param initialM11 defines 1st value of 1st row
  73521. * @param initialM12 defines 2nd value of 1st row
  73522. * @param initialM13 defines 3rd value of 1st row
  73523. * @param initialM14 defines 4th value of 1st row
  73524. * @param initialM21 defines 1st value of 2nd row
  73525. * @param initialM22 defines 2nd value of 2nd row
  73526. * @param initialM23 defines 3rd value of 2nd row
  73527. * @param initialM24 defines 4th value of 2nd row
  73528. * @param initialM31 defines 1st value of 3rd row
  73529. * @param initialM32 defines 2nd value of 3rd row
  73530. * @param initialM33 defines 3rd value of 3rd row
  73531. * @param initialM34 defines 4th value of 3rd row
  73532. * @param initialM41 defines 1st value of 4th row
  73533. * @param initialM42 defines 2nd value of 4th row
  73534. * @param initialM43 defines 3rd value of 4th row
  73535. * @param initialM44 defines 4th value of 4th row
  73536. * @returns the new matrix
  73537. */
  73538. 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;
  73539. /**
  73540. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73541. * @param scale defines the scale vector3
  73542. * @param rotation defines the rotation quaternion
  73543. * @param translation defines the translation vector3
  73544. * @returns a new matrix
  73545. */
  73546. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  73547. /**
  73548. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73549. * @param scale defines the scale vector3
  73550. * @param rotation defines the rotation quaternion
  73551. * @param translation defines the translation vector3
  73552. * @param result defines the target matrix
  73553. */
  73554. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  73555. /**
  73556. * Creates a new identity matrix
  73557. * @returns a new identity matrix
  73558. */
  73559. static Identity(): Matrix;
  73560. /**
  73561. * Creates a new identity matrix and stores the result in a given matrix
  73562. * @param result defines the target matrix
  73563. */
  73564. static IdentityToRef(result: Matrix): void;
  73565. /**
  73566. * Creates a new zero matrix
  73567. * @returns a new zero matrix
  73568. */
  73569. static Zero(): Matrix;
  73570. /**
  73571. * Creates a new rotation matrix for "angle" radians around the X axis
  73572. * @param angle defines the angle (in radians) to use
  73573. * @return the new matrix
  73574. */
  73575. static RotationX(angle: number): Matrix;
  73576. /**
  73577. * Creates a new matrix as the invert of a given matrix
  73578. * @param source defines the source matrix
  73579. * @returns the new matrix
  73580. */
  73581. static Invert(source: DeepImmutable<Matrix>): Matrix;
  73582. /**
  73583. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73584. * @param angle defines the angle (in radians) to use
  73585. * @param result defines the target matrix
  73586. */
  73587. static RotationXToRef(angle: number, result: Matrix): void;
  73588. /**
  73589. * Creates a new rotation matrix for "angle" radians around the Y axis
  73590. * @param angle defines the angle (in radians) to use
  73591. * @return the new matrix
  73592. */
  73593. static RotationY(angle: number): Matrix;
  73594. /**
  73595. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73596. * @param angle defines the angle (in radians) to use
  73597. * @param result defines the target matrix
  73598. */
  73599. static RotationYToRef(angle: number, result: Matrix): void;
  73600. /**
  73601. * Creates a new rotation matrix for "angle" radians around the Z axis
  73602. * @param angle defines the angle (in radians) to use
  73603. * @return the new matrix
  73604. */
  73605. static RotationZ(angle: number): Matrix;
  73606. /**
  73607. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73608. * @param angle defines the angle (in radians) to use
  73609. * @param result defines the target matrix
  73610. */
  73611. static RotationZToRef(angle: number, result: Matrix): void;
  73612. /**
  73613. * Creates a new rotation matrix for "angle" radians around the given axis
  73614. * @param axis defines the axis to use
  73615. * @param angle defines the angle (in radians) to use
  73616. * @return the new matrix
  73617. */
  73618. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  73619. /**
  73620. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73621. * @param axis defines the axis to use
  73622. * @param angle defines the angle (in radians) to use
  73623. * @param result defines the target matrix
  73624. */
  73625. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  73626. /**
  73627. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  73628. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  73629. * @param from defines the vector to align
  73630. * @param to defines the vector to align to
  73631. * @param result defines the target matrix
  73632. */
  73633. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  73634. /**
  73635. * Creates a rotation matrix
  73636. * @param yaw defines the yaw angle in radians (Y axis)
  73637. * @param pitch defines the pitch angle in radians (X axis)
  73638. * @param roll defines the roll angle in radians (X axis)
  73639. * @returns the new rotation matrix
  73640. */
  73641. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  73642. /**
  73643. * Creates a rotation matrix and stores it in a given matrix
  73644. * @param yaw defines the yaw angle in radians (Y axis)
  73645. * @param pitch defines the pitch angle in radians (X axis)
  73646. * @param roll defines the roll angle in radians (X axis)
  73647. * @param result defines the target matrix
  73648. */
  73649. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  73650. /**
  73651. * Creates a scaling matrix
  73652. * @param x defines the scale factor on X axis
  73653. * @param y defines the scale factor on Y axis
  73654. * @param z defines the scale factor on Z axis
  73655. * @returns the new matrix
  73656. */
  73657. static Scaling(x: number, y: number, z: number): Matrix;
  73658. /**
  73659. * Creates a scaling matrix and stores it in a given matrix
  73660. * @param x defines the scale factor on X axis
  73661. * @param y defines the scale factor on Y axis
  73662. * @param z defines the scale factor on Z axis
  73663. * @param result defines the target matrix
  73664. */
  73665. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  73666. /**
  73667. * Creates a translation matrix
  73668. * @param x defines the translation on X axis
  73669. * @param y defines the translation on Y axis
  73670. * @param z defines the translationon Z axis
  73671. * @returns the new matrix
  73672. */
  73673. static Translation(x: number, y: number, z: number): Matrix;
  73674. /**
  73675. * Creates a translation matrix and stores it in a given matrix
  73676. * @param x defines the translation on X axis
  73677. * @param y defines the translation on Y axis
  73678. * @param z defines the translationon Z axis
  73679. * @param result defines the target matrix
  73680. */
  73681. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  73682. /**
  73683. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73684. * @param startValue defines the start value
  73685. * @param endValue defines the end value
  73686. * @param gradient defines the gradient factor
  73687. * @returns the new matrix
  73688. */
  73689. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73690. /**
  73691. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73692. * @param startValue defines the start value
  73693. * @param endValue defines the end value
  73694. * @param gradient defines the gradient factor
  73695. * @param result defines the Matrix object where to store data
  73696. */
  73697. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73698. /**
  73699. * Builds a new matrix whose values are computed by:
  73700. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73701. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73702. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73703. * @param startValue defines the first matrix
  73704. * @param endValue defines the second matrix
  73705. * @param gradient defines the gradient between the two matrices
  73706. * @returns the new matrix
  73707. */
  73708. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  73709. /**
  73710. * Update a matrix to values which are computed by:
  73711. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73712. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73713. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73714. * @param startValue defines the first matrix
  73715. * @param endValue defines the second matrix
  73716. * @param gradient defines the gradient between the two matrices
  73717. * @param result defines the target matrix
  73718. */
  73719. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  73720. /**
  73721. * 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"
  73722. * This function works in left handed mode
  73723. * @param eye defines the final position of the entity
  73724. * @param target defines where the entity should look at
  73725. * @param up defines the up vector for the entity
  73726. * @returns the new matrix
  73727. */
  73728. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73729. /**
  73730. * 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".
  73731. * This function works in left handed mode
  73732. * @param eye defines the final position of the entity
  73733. * @param target defines where the entity should look at
  73734. * @param up defines the up vector for the entity
  73735. * @param result defines the target matrix
  73736. */
  73737. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73738. /**
  73739. * 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"
  73740. * This function works in right handed mode
  73741. * @param eye defines the final position of the entity
  73742. * @param target defines where the entity should look at
  73743. * @param up defines the up vector for the entity
  73744. * @returns the new matrix
  73745. */
  73746. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  73747. /**
  73748. * 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".
  73749. * This function works in right handed mode
  73750. * @param eye defines the final position of the entity
  73751. * @param target defines where the entity should look at
  73752. * @param up defines the up vector for the entity
  73753. * @param result defines the target matrix
  73754. */
  73755. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  73756. /**
  73757. * Create a left-handed orthographic projection matrix
  73758. * @param width defines the viewport width
  73759. * @param height defines the viewport height
  73760. * @param znear defines the near clip plane
  73761. * @param zfar defines the far clip plane
  73762. * @returns a new matrix as a left-handed orthographic projection matrix
  73763. */
  73764. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73765. /**
  73766. * Store a left-handed orthographic projection to a given matrix
  73767. * @param width defines the viewport width
  73768. * @param height defines the viewport height
  73769. * @param znear defines the near clip plane
  73770. * @param zfar defines the far clip plane
  73771. * @param result defines the target matrix
  73772. */
  73773. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  73774. /**
  73775. * Create a left-handed orthographic projection matrix
  73776. * @param left defines the viewport left coordinate
  73777. * @param right defines the viewport right coordinate
  73778. * @param bottom defines the viewport bottom coordinate
  73779. * @param top defines the viewport top coordinate
  73780. * @param znear defines the near clip plane
  73781. * @param zfar defines the far clip plane
  73782. * @returns a new matrix as a left-handed orthographic projection matrix
  73783. */
  73784. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73785. /**
  73786. * Stores a left-handed orthographic projection into a given matrix
  73787. * @param left defines the viewport left coordinate
  73788. * @param right defines the viewport right coordinate
  73789. * @param bottom defines the viewport bottom coordinate
  73790. * @param top defines the viewport top coordinate
  73791. * @param znear defines the near clip plane
  73792. * @param zfar defines the far clip plane
  73793. * @param result defines the target matrix
  73794. */
  73795. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73796. /**
  73797. * Creates a right-handed orthographic projection matrix
  73798. * @param left defines the viewport left coordinate
  73799. * @param right defines the viewport right coordinate
  73800. * @param bottom defines the viewport bottom coordinate
  73801. * @param top defines the viewport top coordinate
  73802. * @param znear defines the near clip plane
  73803. * @param zfar defines the far clip plane
  73804. * @returns a new matrix as a right-handed orthographic projection matrix
  73805. */
  73806. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  73807. /**
  73808. * Stores a right-handed orthographic projection into a given matrix
  73809. * @param left defines the viewport left coordinate
  73810. * @param right defines the viewport right coordinate
  73811. * @param bottom defines the viewport bottom coordinate
  73812. * @param top defines the viewport top coordinate
  73813. * @param znear defines the near clip plane
  73814. * @param zfar defines the far clip plane
  73815. * @param result defines the target matrix
  73816. */
  73817. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  73818. /**
  73819. * Creates a left-handed perspective projection matrix
  73820. * @param width defines the viewport width
  73821. * @param height defines the viewport height
  73822. * @param znear defines the near clip plane
  73823. * @param zfar defines the far clip plane
  73824. * @returns a new matrix as a left-handed perspective projection matrix
  73825. */
  73826. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  73827. /**
  73828. * Creates a left-handed perspective projection matrix
  73829. * @param fov defines the horizontal field of view
  73830. * @param aspect defines the aspect ratio
  73831. * @param znear defines the near clip plane
  73832. * @param zfar defines the far clip plane
  73833. * @returns a new matrix as a left-handed perspective projection matrix
  73834. */
  73835. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73836. /**
  73837. * Stores a left-handed perspective projection into a given matrix
  73838. * @param fov defines the horizontal field of view
  73839. * @param aspect defines the aspect ratio
  73840. * @param znear defines the near clip plane
  73841. * @param zfar defines the far clip plane
  73842. * @param result defines the target matrix
  73843. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73844. */
  73845. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73846. /**
  73847. * Stores a left-handed perspective projection into a given matrix with depth reversed
  73848. * @param fov defines the horizontal field of view
  73849. * @param aspect defines the aspect ratio
  73850. * @param znear defines the near clip plane
  73851. * @param zfar not used as infinity is used as far clip
  73852. * @param result defines the target matrix
  73853. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73854. */
  73855. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73856. /**
  73857. * Creates a right-handed perspective projection matrix
  73858. * @param fov defines the horizontal field of view
  73859. * @param aspect defines the aspect ratio
  73860. * @param znear defines the near clip plane
  73861. * @param zfar defines the far clip plane
  73862. * @returns a new matrix as a right-handed perspective projection matrix
  73863. */
  73864. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  73865. /**
  73866. * Stores a right-handed perspective projection into a given matrix
  73867. * @param fov defines the horizontal field of view
  73868. * @param aspect defines the aspect ratio
  73869. * @param znear defines the near clip plane
  73870. * @param zfar defines the far clip plane
  73871. * @param result defines the target matrix
  73872. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73873. */
  73874. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73875. /**
  73876. * Stores a right-handed perspective projection into a given matrix
  73877. * @param fov defines the horizontal field of view
  73878. * @param aspect defines the aspect ratio
  73879. * @param znear defines the near clip plane
  73880. * @param zfar not used as infinity is used as far clip
  73881. * @param result defines the target matrix
  73882. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73883. */
  73884. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  73885. /**
  73886. * Stores a perspective projection for WebVR info a given matrix
  73887. * @param fov defines the field of view
  73888. * @param znear defines the near clip plane
  73889. * @param zfar defines the far clip plane
  73890. * @param result defines the target matrix
  73891. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73892. */
  73893. static PerspectiveFovWebVRToRef(fov: {
  73894. upDegrees: number;
  73895. downDegrees: number;
  73896. leftDegrees: number;
  73897. rightDegrees: number;
  73898. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  73899. /**
  73900. * Computes a complete transformation matrix
  73901. * @param viewport defines the viewport to use
  73902. * @param world defines the world matrix
  73903. * @param view defines the view matrix
  73904. * @param projection defines the projection matrix
  73905. * @param zmin defines the near clip plane
  73906. * @param zmax defines the far clip plane
  73907. * @returns the transformation matrix
  73908. */
  73909. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  73910. /**
  73911. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73912. * @param matrix defines the matrix to use
  73913. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73914. */
  73915. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  73916. /**
  73917. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73918. * @param matrix defines the matrix to use
  73919. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73920. */
  73921. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  73922. /**
  73923. * Compute the transpose of a given matrix
  73924. * @param matrix defines the matrix to transpose
  73925. * @returns the new matrix
  73926. */
  73927. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  73928. /**
  73929. * Compute the transpose of a matrix and store it in a target matrix
  73930. * @param matrix defines the matrix to transpose
  73931. * @param result defines the target matrix
  73932. */
  73933. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  73934. /**
  73935. * Computes a reflection matrix from a plane
  73936. * @param plane defines the reflection plane
  73937. * @returns a new matrix
  73938. */
  73939. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  73940. /**
  73941. * Computes a reflection matrix from a plane
  73942. * @param plane defines the reflection plane
  73943. * @param result defines the target matrix
  73944. */
  73945. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  73946. /**
  73947. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73948. * @param xaxis defines the value of the 1st axis
  73949. * @param yaxis defines the value of the 2nd axis
  73950. * @param zaxis defines the value of the 3rd axis
  73951. * @param result defines the target matrix
  73952. */
  73953. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  73954. /**
  73955. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73956. * @param quat defines the quaternion to use
  73957. * @param result defines the target matrix
  73958. */
  73959. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  73960. }
  73961. /**
  73962. * @hidden
  73963. */
  73964. export class TmpVectors {
  73965. static Vector2: Vector2[];
  73966. static Vector3: Vector3[];
  73967. static Vector4: Vector4[];
  73968. static Quaternion: Quaternion[];
  73969. static Matrix: Matrix[];
  73970. }
  73971. }
  73972. declare module BABYLON {
  73973. /**
  73974. * Defines potential orientation for back face culling
  73975. */
  73976. export enum Orientation {
  73977. /**
  73978. * Clockwise
  73979. */
  73980. CW = 0,
  73981. /** Counter clockwise */
  73982. CCW = 1
  73983. }
  73984. /** Class used to represent a Bezier curve */
  73985. export class BezierCurve {
  73986. /**
  73987. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  73988. * @param t defines the time
  73989. * @param x1 defines the left coordinate on X axis
  73990. * @param y1 defines the left coordinate on Y axis
  73991. * @param x2 defines the right coordinate on X axis
  73992. * @param y2 defines the right coordinate on Y axis
  73993. * @returns the interpolated value
  73994. */
  73995. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73996. }
  73997. /**
  73998. * Defines angle representation
  73999. */
  74000. export class Angle {
  74001. private _radians;
  74002. /**
  74003. * Creates an Angle object of "radians" radians (float).
  74004. * @param radians the angle in radians
  74005. */
  74006. constructor(radians: number);
  74007. /**
  74008. * Get value in degrees
  74009. * @returns the Angle value in degrees (float)
  74010. */
  74011. degrees(): number;
  74012. /**
  74013. * Get value in radians
  74014. * @returns the Angle value in radians (float)
  74015. */
  74016. radians(): number;
  74017. /**
  74018. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  74019. * @param a defines first vector
  74020. * @param b defines second vector
  74021. * @returns a new Angle
  74022. */
  74023. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  74024. /**
  74025. * Gets a new Angle object from the given float in radians
  74026. * @param radians defines the angle value in radians
  74027. * @returns a new Angle
  74028. */
  74029. static FromRadians(radians: number): Angle;
  74030. /**
  74031. * Gets a new Angle object from the given float in degrees
  74032. * @param degrees defines the angle value in degrees
  74033. * @returns a new Angle
  74034. */
  74035. static FromDegrees(degrees: number): Angle;
  74036. }
  74037. /**
  74038. * This represents an arc in a 2d space.
  74039. */
  74040. export class Arc2 {
  74041. /** Defines the start point of the arc */
  74042. startPoint: Vector2;
  74043. /** Defines the mid point of the arc */
  74044. midPoint: Vector2;
  74045. /** Defines the end point of the arc */
  74046. endPoint: Vector2;
  74047. /**
  74048. * Defines the center point of the arc.
  74049. */
  74050. centerPoint: Vector2;
  74051. /**
  74052. * Defines the radius of the arc.
  74053. */
  74054. radius: number;
  74055. /**
  74056. * Defines the angle of the arc (from mid point to end point).
  74057. */
  74058. angle: Angle;
  74059. /**
  74060. * Defines the start angle of the arc (from start point to middle point).
  74061. */
  74062. startAngle: Angle;
  74063. /**
  74064. * Defines the orientation of the arc (clock wise/counter clock wise).
  74065. */
  74066. orientation: Orientation;
  74067. /**
  74068. * Creates an Arc object from the three given points : start, middle and end.
  74069. * @param startPoint Defines the start point of the arc
  74070. * @param midPoint Defines the midlle point of the arc
  74071. * @param endPoint Defines the end point of the arc
  74072. */
  74073. constructor(
  74074. /** Defines the start point of the arc */
  74075. startPoint: Vector2,
  74076. /** Defines the mid point of the arc */
  74077. midPoint: Vector2,
  74078. /** Defines the end point of the arc */
  74079. endPoint: Vector2);
  74080. }
  74081. /**
  74082. * Represents a 2D path made up of multiple 2D points
  74083. */
  74084. export class Path2 {
  74085. private _points;
  74086. private _length;
  74087. /**
  74088. * If the path start and end point are the same
  74089. */
  74090. closed: boolean;
  74091. /**
  74092. * Creates a Path2 object from the starting 2D coordinates x and y.
  74093. * @param x the starting points x value
  74094. * @param y the starting points y value
  74095. */
  74096. constructor(x: number, y: number);
  74097. /**
  74098. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  74099. * @param x the added points x value
  74100. * @param y the added points y value
  74101. * @returns the updated Path2.
  74102. */
  74103. addLineTo(x: number, y: number): Path2;
  74104. /**
  74105. * 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.
  74106. * @param midX middle point x value
  74107. * @param midY middle point y value
  74108. * @param endX end point x value
  74109. * @param endY end point y value
  74110. * @param numberOfSegments (default: 36)
  74111. * @returns the updated Path2.
  74112. */
  74113. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  74114. /**
  74115. * Closes the Path2.
  74116. * @returns the Path2.
  74117. */
  74118. close(): Path2;
  74119. /**
  74120. * Gets the sum of the distance between each sequential point in the path
  74121. * @returns the Path2 total length (float).
  74122. */
  74123. length(): number;
  74124. /**
  74125. * Gets the points which construct the path
  74126. * @returns the Path2 internal array of points.
  74127. */
  74128. getPoints(): Vector2[];
  74129. /**
  74130. * Retreives the point at the distance aways from the starting point
  74131. * @param normalizedLengthPosition the length along the path to retreive the point from
  74132. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74133. */
  74134. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  74135. /**
  74136. * Creates a new path starting from an x and y position
  74137. * @param x starting x value
  74138. * @param y starting y value
  74139. * @returns a new Path2 starting at the coordinates (x, y).
  74140. */
  74141. static StartingAt(x: number, y: number): Path2;
  74142. }
  74143. /**
  74144. * Represents a 3D path made up of multiple 3D points
  74145. */
  74146. export class Path3D {
  74147. /**
  74148. * an array of Vector3, the curve axis of the Path3D
  74149. */
  74150. path: Vector3[];
  74151. private _curve;
  74152. private _distances;
  74153. private _tangents;
  74154. private _normals;
  74155. private _binormals;
  74156. private _raw;
  74157. private _alignTangentsWithPath;
  74158. private readonly _pointAtData;
  74159. /**
  74160. * new Path3D(path, normal, raw)
  74161. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74162. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74163. * @param path an array of Vector3, the curve axis of the Path3D
  74164. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74165. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  74167. */
  74168. constructor(
  74169. /**
  74170. * an array of Vector3, the curve axis of the Path3D
  74171. */
  74172. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  74173. /**
  74174. * Returns the Path3D array of successive Vector3 designing its curve.
  74175. * @returns the Path3D array of successive Vector3 designing its curve.
  74176. */
  74177. getCurve(): Vector3[];
  74178. /**
  74179. * Returns the Path3D array of successive Vector3 designing its curve.
  74180. * @returns the Path3D array of successive Vector3 designing its curve.
  74181. */
  74182. getPoints(): Vector3[];
  74183. /**
  74184. * @returns the computed length (float) of the path.
  74185. */
  74186. length(): number;
  74187. /**
  74188. * Returns an array populated with tangent vectors on each Path3D curve point.
  74189. * @returns an array populated with tangent vectors on each Path3D curve point.
  74190. */
  74191. getTangents(): Vector3[];
  74192. /**
  74193. * Returns an array populated with normal vectors on each Path3D curve point.
  74194. * @returns an array populated with normal vectors on each Path3D curve point.
  74195. */
  74196. getNormals(): Vector3[];
  74197. /**
  74198. * Returns an array populated with binormal vectors on each Path3D curve point.
  74199. * @returns an array populated with binormal vectors on each Path3D curve point.
  74200. */
  74201. getBinormals(): Vector3[];
  74202. /**
  74203. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74204. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74205. */
  74206. getDistances(): number[];
  74207. /**
  74208. * Returns an interpolated point along this path
  74209. * @param position the position of the point along this path, from 0.0 to 1.0
  74210. * @returns a new Vector3 as the point
  74211. */
  74212. getPointAt(position: number): Vector3;
  74213. /**
  74214. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74215. * @param position the position of the point along this path, from 0.0 to 1.0
  74216. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  74217. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  74218. */
  74219. getTangentAt(position: number, interpolated?: boolean): Vector3;
  74220. /**
  74221. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  74222. * @param position the position of the point along this path, from 0.0 to 1.0
  74223. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  74224. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  74225. */
  74226. getNormalAt(position: number, interpolated?: boolean): Vector3;
  74227. /**
  74228. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  74229. * @param position the position of the point along this path, from 0.0 to 1.0
  74230. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  74231. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  74232. */
  74233. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  74234. /**
  74235. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  74236. * @param position the position of the point along this path, from 0.0 to 1.0
  74237. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  74238. */
  74239. getDistanceAt(position: number): number;
  74240. /**
  74241. * Returns the array index of the previous point of an interpolated point along this path
  74242. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74243. * @returns the array index
  74244. */
  74245. getPreviousPointIndexAt(position: number): number;
  74246. /**
  74247. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  74248. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  74249. * @returns the sub position
  74250. */
  74251. getSubPositionAt(position: number): number;
  74252. /**
  74253. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  74254. * @param target the vector of which to get the closest position to
  74255. * @returns the position of the closest virtual point on this path to the target vector
  74256. */
  74257. getClosestPositionTo(target: Vector3): number;
  74258. /**
  74259. * Returns a sub path (slice) of this path
  74260. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74261. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  74262. * @returns a sub path (slice) of this path
  74263. */
  74264. slice(start?: number, end?: number): Path3D;
  74265. /**
  74266. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74267. * @param path path which all values are copied into the curves points
  74268. * @param firstNormal which should be projected onto the curve
  74269. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  74270. * @returns the same object updated.
  74271. */
  74272. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  74273. private _compute;
  74274. private _getFirstNonNullVector;
  74275. private _getLastNonNullVector;
  74276. private _normalVector;
  74277. /**
  74278. * Updates the point at data for an interpolated point along this curve
  74279. * @param position the position of the point along this curve, from 0.0 to 1.0
  74280. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  74281. * @returns the (updated) point at data
  74282. */
  74283. private _updatePointAtData;
  74284. /**
  74285. * Updates the point at data from the specified parameters
  74286. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  74287. * @param point the interpolated point
  74288. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  74289. */
  74290. private _setPointAtData;
  74291. /**
  74292. * Updates the point at interpolation matrix for the tangents, normals and binormals
  74293. */
  74294. private _updateInterpolationMatrix;
  74295. }
  74296. /**
  74297. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74298. * A Curve3 is designed from a series of successive Vector3.
  74299. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74300. */
  74301. export class Curve3 {
  74302. private _points;
  74303. private _length;
  74304. /**
  74305. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74306. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74307. * @param v1 (Vector3) the control point
  74308. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74309. * @param nbPoints (integer) the wanted number of points in the curve
  74310. * @returns the created Curve3
  74311. */
  74312. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74313. /**
  74314. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74315. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74316. * @param v1 (Vector3) the first control point
  74317. * @param v2 (Vector3) the second control point
  74318. * @param v3 (Vector3) the end point of the Cubic Bezier
  74319. * @param nbPoints (integer) the wanted number of points in the curve
  74320. * @returns the created Curve3
  74321. */
  74322. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74323. /**
  74324. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74325. * @param p1 (Vector3) the origin point of the Hermite Spline
  74326. * @param t1 (Vector3) the tangent vector at the origin point
  74327. * @param p2 (Vector3) the end point of the Hermite Spline
  74328. * @param t2 (Vector3) the tangent vector at the end point
  74329. * @param nbPoints (integer) the wanted number of points in the curve
  74330. * @returns the created Curve3
  74331. */
  74332. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  74333. /**
  74334. * Returns a Curve3 object along a CatmullRom Spline curve :
  74335. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74336. * @param nbPoints (integer) the wanted number of points between each curve control points
  74337. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74338. * @returns the created Curve3
  74339. */
  74340. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  74341. /**
  74342. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74343. * A Curve3 is designed from a series of successive Vector3.
  74344. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74345. * @param points points which make up the curve
  74346. */
  74347. constructor(points: Vector3[]);
  74348. /**
  74349. * @returns the Curve3 stored array of successive Vector3
  74350. */
  74351. getPoints(): Vector3[];
  74352. /**
  74353. * @returns the computed length (float) of the curve.
  74354. */
  74355. length(): number;
  74356. /**
  74357. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74358. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74359. * curveA and curveB keep unchanged.
  74360. * @param curve the curve to continue from this curve
  74361. * @returns the newly constructed curve
  74362. */
  74363. continue(curve: DeepImmutable<Curve3>): Curve3;
  74364. private _computeLength;
  74365. }
  74366. }
  74367. declare module BABYLON {
  74368. /**
  74369. * This represents the main contract an easing function should follow.
  74370. * Easing functions are used throughout the animation system.
  74371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74372. */
  74373. export interface IEasingFunction {
  74374. /**
  74375. * Given an input gradient between 0 and 1, this returns the corrseponding value
  74376. * of the easing function.
  74377. * The link below provides some of the most common examples of easing functions.
  74378. * @see https://easings.net/
  74379. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74380. * @returns the corresponding value on the curve defined by the easing function
  74381. */
  74382. ease(gradient: number): number;
  74383. }
  74384. /**
  74385. * Base class used for every default easing function.
  74386. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74387. */
  74388. export class EasingFunction implements IEasingFunction {
  74389. /**
  74390. * Interpolation follows the mathematical formula associated with the easing function.
  74391. */
  74392. static readonly EASINGMODE_EASEIN: number;
  74393. /**
  74394. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  74395. */
  74396. static readonly EASINGMODE_EASEOUT: number;
  74397. /**
  74398. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  74399. */
  74400. static readonly EASINGMODE_EASEINOUT: number;
  74401. private _easingMode;
  74402. /**
  74403. * Sets the easing mode of the current function.
  74404. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  74405. */
  74406. setEasingMode(easingMode: number): void;
  74407. /**
  74408. * Gets the current easing mode.
  74409. * @returns the easing mode
  74410. */
  74411. getEasingMode(): number;
  74412. /**
  74413. * @hidden
  74414. */
  74415. easeInCore(gradient: number): number;
  74416. /**
  74417. * Given an input gradient between 0 and 1, this returns the corresponding value
  74418. * of the easing function.
  74419. * @param gradient Defines the value between 0 and 1 we want the easing value for
  74420. * @returns the corresponding value on the curve defined by the easing function
  74421. */
  74422. ease(gradient: number): number;
  74423. }
  74424. /**
  74425. * Easing function with a circle shape (see link below).
  74426. * @see https://easings.net/#easeInCirc
  74427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74428. */
  74429. export class CircleEase extends EasingFunction implements IEasingFunction {
  74430. /** @hidden */
  74431. easeInCore(gradient: number): number;
  74432. }
  74433. /**
  74434. * Easing function with a ease back shape (see link below).
  74435. * @see https://easings.net/#easeInBack
  74436. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74437. */
  74438. export class BackEase extends EasingFunction implements IEasingFunction {
  74439. /** Defines the amplitude of the function */
  74440. amplitude: number;
  74441. /**
  74442. * Instantiates a back ease easing
  74443. * @see https://easings.net/#easeInBack
  74444. * @param amplitude Defines the amplitude of the function
  74445. */
  74446. constructor(
  74447. /** Defines the amplitude of the function */
  74448. amplitude?: number);
  74449. /** @hidden */
  74450. easeInCore(gradient: number): number;
  74451. }
  74452. /**
  74453. * Easing function with a bouncing shape (see link below).
  74454. * @see https://easings.net/#easeInBounce
  74455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74456. */
  74457. export class BounceEase extends EasingFunction implements IEasingFunction {
  74458. /** Defines the number of bounces */
  74459. bounces: number;
  74460. /** Defines the amplitude of the bounce */
  74461. bounciness: number;
  74462. /**
  74463. * Instantiates a bounce easing
  74464. * @see https://easings.net/#easeInBounce
  74465. * @param bounces Defines the number of bounces
  74466. * @param bounciness Defines the amplitude of the bounce
  74467. */
  74468. constructor(
  74469. /** Defines the number of bounces */
  74470. bounces?: number,
  74471. /** Defines the amplitude of the bounce */
  74472. bounciness?: number);
  74473. /** @hidden */
  74474. easeInCore(gradient: number): number;
  74475. }
  74476. /**
  74477. * Easing function with a power of 3 shape (see link below).
  74478. * @see https://easings.net/#easeInCubic
  74479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74480. */
  74481. export class CubicEase extends EasingFunction implements IEasingFunction {
  74482. /** @hidden */
  74483. easeInCore(gradient: number): number;
  74484. }
  74485. /**
  74486. * Easing function with an elastic shape (see link below).
  74487. * @see https://easings.net/#easeInElastic
  74488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74489. */
  74490. export class ElasticEase extends EasingFunction implements IEasingFunction {
  74491. /** Defines the number of oscillations*/
  74492. oscillations: number;
  74493. /** Defines the amplitude of the oscillations*/
  74494. springiness: number;
  74495. /**
  74496. * Instantiates an elastic easing function
  74497. * @see https://easings.net/#easeInElastic
  74498. * @param oscillations Defines the number of oscillations
  74499. * @param springiness Defines the amplitude of the oscillations
  74500. */
  74501. constructor(
  74502. /** Defines the number of oscillations*/
  74503. oscillations?: number,
  74504. /** Defines the amplitude of the oscillations*/
  74505. springiness?: number);
  74506. /** @hidden */
  74507. easeInCore(gradient: number): number;
  74508. }
  74509. /**
  74510. * Easing function with an exponential shape (see link below).
  74511. * @see https://easings.net/#easeInExpo
  74512. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74513. */
  74514. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  74515. /** Defines the exponent of the function */
  74516. exponent: number;
  74517. /**
  74518. * Instantiates an exponential easing function
  74519. * @see https://easings.net/#easeInExpo
  74520. * @param exponent Defines the exponent of the function
  74521. */
  74522. constructor(
  74523. /** Defines the exponent of the function */
  74524. exponent?: number);
  74525. /** @hidden */
  74526. easeInCore(gradient: number): number;
  74527. }
  74528. /**
  74529. * Easing function with a power shape (see link below).
  74530. * @see https://easings.net/#easeInQuad
  74531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74532. */
  74533. export class PowerEase extends EasingFunction implements IEasingFunction {
  74534. /** Defines the power of the function */
  74535. power: number;
  74536. /**
  74537. * Instantiates an power base easing function
  74538. * @see https://easings.net/#easeInQuad
  74539. * @param power Defines the power of the function
  74540. */
  74541. constructor(
  74542. /** Defines the power of the function */
  74543. power?: number);
  74544. /** @hidden */
  74545. easeInCore(gradient: number): number;
  74546. }
  74547. /**
  74548. * Easing function with a power of 2 shape (see link below).
  74549. * @see https://easings.net/#easeInQuad
  74550. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74551. */
  74552. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  74553. /** @hidden */
  74554. easeInCore(gradient: number): number;
  74555. }
  74556. /**
  74557. * Easing function with a power of 4 shape (see link below).
  74558. * @see https://easings.net/#easeInQuart
  74559. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74560. */
  74561. export class QuarticEase extends EasingFunction implements IEasingFunction {
  74562. /** @hidden */
  74563. easeInCore(gradient: number): number;
  74564. }
  74565. /**
  74566. * Easing function with a power of 5 shape (see link below).
  74567. * @see https://easings.net/#easeInQuint
  74568. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74569. */
  74570. export class QuinticEase extends EasingFunction implements IEasingFunction {
  74571. /** @hidden */
  74572. easeInCore(gradient: number): number;
  74573. }
  74574. /**
  74575. * Easing function with a sin shape (see link below).
  74576. * @see https://easings.net/#easeInSine
  74577. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74578. */
  74579. export class SineEase extends EasingFunction implements IEasingFunction {
  74580. /** @hidden */
  74581. easeInCore(gradient: number): number;
  74582. }
  74583. /**
  74584. * Easing function with a bezier shape (see link below).
  74585. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74586. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  74587. */
  74588. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  74589. /** Defines the x component of the start tangent in the bezier curve */
  74590. x1: number;
  74591. /** Defines the y component of the start tangent in the bezier curve */
  74592. y1: number;
  74593. /** Defines the x component of the end tangent in the bezier curve */
  74594. x2: number;
  74595. /** Defines the y component of the end tangent in the bezier curve */
  74596. y2: number;
  74597. /**
  74598. * Instantiates a bezier function
  74599. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  74600. * @param x1 Defines the x component of the start tangent in the bezier curve
  74601. * @param y1 Defines the y component of the start tangent in the bezier curve
  74602. * @param x2 Defines the x component of the end tangent in the bezier curve
  74603. * @param y2 Defines the y component of the end tangent in the bezier curve
  74604. */
  74605. constructor(
  74606. /** Defines the x component of the start tangent in the bezier curve */
  74607. x1?: number,
  74608. /** Defines the y component of the start tangent in the bezier curve */
  74609. y1?: number,
  74610. /** Defines the x component of the end tangent in the bezier curve */
  74611. x2?: number,
  74612. /** Defines the y component of the end tangent in the bezier curve */
  74613. y2?: number);
  74614. /** @hidden */
  74615. easeInCore(gradient: number): number;
  74616. }
  74617. }
  74618. declare module BABYLON {
  74619. /**
  74620. * Class used to hold a RBG color
  74621. */
  74622. export class Color3 {
  74623. /**
  74624. * Defines the red component (between 0 and 1, default is 0)
  74625. */
  74626. r: number;
  74627. /**
  74628. * Defines the green component (between 0 and 1, default is 0)
  74629. */
  74630. g: number;
  74631. /**
  74632. * Defines the blue component (between 0 and 1, default is 0)
  74633. */
  74634. b: number;
  74635. /**
  74636. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  74637. * @param r defines the red component (between 0 and 1, default is 0)
  74638. * @param g defines the green component (between 0 and 1, default is 0)
  74639. * @param b defines the blue component (between 0 and 1, default is 0)
  74640. */
  74641. constructor(
  74642. /**
  74643. * Defines the red component (between 0 and 1, default is 0)
  74644. */
  74645. r?: number,
  74646. /**
  74647. * Defines the green component (between 0 and 1, default is 0)
  74648. */
  74649. g?: number,
  74650. /**
  74651. * Defines the blue component (between 0 and 1, default is 0)
  74652. */
  74653. b?: number);
  74654. /**
  74655. * Creates a string with the Color3 current values
  74656. * @returns the string representation of the Color3 object
  74657. */
  74658. toString(): string;
  74659. /**
  74660. * Returns the string "Color3"
  74661. * @returns "Color3"
  74662. */
  74663. getClassName(): string;
  74664. /**
  74665. * Compute the Color3 hash code
  74666. * @returns an unique number that can be used to hash Color3 objects
  74667. */
  74668. getHashCode(): number;
  74669. /**
  74670. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  74671. * @param array defines the array where to store the r,g,b components
  74672. * @param index defines an optional index in the target array to define where to start storing values
  74673. * @returns the current Color3 object
  74674. */
  74675. toArray(array: FloatArray, index?: number): Color3;
  74676. /**
  74677. * Returns a new Color4 object from the current Color3 and the given alpha
  74678. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  74679. * @returns a new Color4 object
  74680. */
  74681. toColor4(alpha?: number): Color4;
  74682. /**
  74683. * Returns a new array populated with 3 numeric elements : red, green and blue values
  74684. * @returns the new array
  74685. */
  74686. asArray(): number[];
  74687. /**
  74688. * Returns the luminance value
  74689. * @returns a float value
  74690. */
  74691. toLuminance(): number;
  74692. /**
  74693. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  74694. * @param otherColor defines the second operand
  74695. * @returns the new Color3 object
  74696. */
  74697. multiply(otherColor: DeepImmutable<Color3>): Color3;
  74698. /**
  74699. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  74700. * @param otherColor defines the second operand
  74701. * @param result defines the Color3 object where to store the result
  74702. * @returns the current Color3
  74703. */
  74704. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74705. /**
  74706. * Determines equality between Color3 objects
  74707. * @param otherColor defines the second operand
  74708. * @returns true if the rgb values are equal to the given ones
  74709. */
  74710. equals(otherColor: DeepImmutable<Color3>): boolean;
  74711. /**
  74712. * Determines equality between the current Color3 object and a set of r,b,g values
  74713. * @param r defines the red component to check
  74714. * @param g defines the green component to check
  74715. * @param b defines the blue component to check
  74716. * @returns true if the rgb values are equal to the given ones
  74717. */
  74718. equalsFloats(r: number, g: number, b: number): boolean;
  74719. /**
  74720. * Multiplies in place each rgb value by scale
  74721. * @param scale defines the scaling factor
  74722. * @returns the updated Color3
  74723. */
  74724. scale(scale: number): Color3;
  74725. /**
  74726. * Multiplies the rgb values by scale and stores the result into "result"
  74727. * @param scale defines the scaling factor
  74728. * @param result defines the Color3 object where to store the result
  74729. * @returns the unmodified current Color3
  74730. */
  74731. scaleToRef(scale: number, result: Color3): Color3;
  74732. /**
  74733. * Scale the current Color3 values by a factor and add the result to a given Color3
  74734. * @param scale defines the scale factor
  74735. * @param result defines color to store the result into
  74736. * @returns the unmodified current Color3
  74737. */
  74738. scaleAndAddToRef(scale: number, result: Color3): Color3;
  74739. /**
  74740. * Clamps the rgb values by the min and max values and stores the result into "result"
  74741. * @param min defines minimum clamping value (default is 0)
  74742. * @param max defines maximum clamping value (default is 1)
  74743. * @param result defines color to store the result into
  74744. * @returns the original Color3
  74745. */
  74746. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  74747. /**
  74748. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  74749. * @param otherColor defines the second operand
  74750. * @returns the new Color3
  74751. */
  74752. add(otherColor: DeepImmutable<Color3>): Color3;
  74753. /**
  74754. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  74755. * @param otherColor defines the second operand
  74756. * @param result defines Color3 object to store the result into
  74757. * @returns the unmodified current Color3
  74758. */
  74759. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74760. /**
  74761. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  74762. * @param otherColor defines the second operand
  74763. * @returns the new Color3
  74764. */
  74765. subtract(otherColor: DeepImmutable<Color3>): Color3;
  74766. /**
  74767. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  74768. * @param otherColor defines the second operand
  74769. * @param result defines Color3 object to store the result into
  74770. * @returns the unmodified current Color3
  74771. */
  74772. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  74773. /**
  74774. * Copy the current object
  74775. * @returns a new Color3 copied the current one
  74776. */
  74777. clone(): Color3;
  74778. /**
  74779. * Copies the rgb values from the source in the current Color3
  74780. * @param source defines the source Color3 object
  74781. * @returns the updated Color3 object
  74782. */
  74783. copyFrom(source: DeepImmutable<Color3>): Color3;
  74784. /**
  74785. * Updates the Color3 rgb values from the given floats
  74786. * @param r defines the red component to read from
  74787. * @param g defines the green component to read from
  74788. * @param b defines the blue component to read from
  74789. * @returns the current Color3 object
  74790. */
  74791. copyFromFloats(r: number, g: number, b: number): Color3;
  74792. /**
  74793. * Updates the Color3 rgb values from the given floats
  74794. * @param r defines the red component to read from
  74795. * @param g defines the green component to read from
  74796. * @param b defines the blue component to read from
  74797. * @returns the current Color3 object
  74798. */
  74799. set(r: number, g: number, b: number): Color3;
  74800. /**
  74801. * Compute the Color3 hexadecimal code as a string
  74802. * @returns a string containing the hexadecimal representation of the Color3 object
  74803. */
  74804. toHexString(): string;
  74805. /**
  74806. * Computes a new Color3 converted from the current one to linear space
  74807. * @returns a new Color3 object
  74808. */
  74809. toLinearSpace(): Color3;
  74810. /**
  74811. * Converts current color in rgb space to HSV values
  74812. * @returns a new color3 representing the HSV values
  74813. */
  74814. toHSV(): Color3;
  74815. /**
  74816. * Converts current color in rgb space to HSV values
  74817. * @param result defines the Color3 where to store the HSV values
  74818. */
  74819. toHSVToRef(result: Color3): void;
  74820. /**
  74821. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  74822. * @param convertedColor defines the Color3 object where to store the linear space version
  74823. * @returns the unmodified Color3
  74824. */
  74825. toLinearSpaceToRef(convertedColor: Color3): Color3;
  74826. /**
  74827. * Computes a new Color3 converted from the current one to gamma space
  74828. * @returns a new Color3 object
  74829. */
  74830. toGammaSpace(): Color3;
  74831. /**
  74832. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  74833. * @param convertedColor defines the Color3 object where to store the gamma space version
  74834. * @returns the unmodified Color3
  74835. */
  74836. toGammaSpaceToRef(convertedColor: Color3): Color3;
  74837. private static _BlackReadOnly;
  74838. /**
  74839. * Convert Hue, saturation and value to a Color3 (RGB)
  74840. * @param hue defines the hue
  74841. * @param saturation defines the saturation
  74842. * @param value defines the value
  74843. * @param result defines the Color3 where to store the RGB values
  74844. */
  74845. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  74846. /**
  74847. * Creates a new Color3 from the string containing valid hexadecimal values
  74848. * @param hex defines a string containing valid hexadecimal values
  74849. * @returns a new Color3 object
  74850. */
  74851. static FromHexString(hex: string): Color3;
  74852. /**
  74853. * Creates a new Color3 from the starting index of the given array
  74854. * @param array defines the source array
  74855. * @param offset defines an offset in the source array
  74856. * @returns a new Color3 object
  74857. */
  74858. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  74859. /**
  74860. * Creates a new Color3 from integer values (< 256)
  74861. * @param r defines the red component to read from (value between 0 and 255)
  74862. * @param g defines the green component to read from (value between 0 and 255)
  74863. * @param b defines the blue component to read from (value between 0 and 255)
  74864. * @returns a new Color3 object
  74865. */
  74866. static FromInts(r: number, g: number, b: number): Color3;
  74867. /**
  74868. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74869. * @param start defines the start Color3 value
  74870. * @param end defines the end Color3 value
  74871. * @param amount defines the gradient value between start and end
  74872. * @returns a new Color3 object
  74873. */
  74874. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  74875. /**
  74876. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  74877. * @param left defines the start value
  74878. * @param right defines the end value
  74879. * @param amount defines the gradient factor
  74880. * @param result defines the Color3 object where to store the result
  74881. */
  74882. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  74883. /**
  74884. * Returns a Color3 value containing a red color
  74885. * @returns a new Color3 object
  74886. */
  74887. static Red(): Color3;
  74888. /**
  74889. * Returns a Color3 value containing a green color
  74890. * @returns a new Color3 object
  74891. */
  74892. static Green(): Color3;
  74893. /**
  74894. * Returns a Color3 value containing a blue color
  74895. * @returns a new Color3 object
  74896. */
  74897. static Blue(): Color3;
  74898. /**
  74899. * Returns a Color3 value containing a black color
  74900. * @returns a new Color3 object
  74901. */
  74902. static Black(): Color3;
  74903. /**
  74904. * Gets a Color3 value containing a black color that must not be updated
  74905. */
  74906. static readonly BlackReadOnly: DeepImmutable<Color3>;
  74907. /**
  74908. * Returns a Color3 value containing a white color
  74909. * @returns a new Color3 object
  74910. */
  74911. static White(): Color3;
  74912. /**
  74913. * Returns a Color3 value containing a purple color
  74914. * @returns a new Color3 object
  74915. */
  74916. static Purple(): Color3;
  74917. /**
  74918. * Returns a Color3 value containing a magenta color
  74919. * @returns a new Color3 object
  74920. */
  74921. static Magenta(): Color3;
  74922. /**
  74923. * Returns a Color3 value containing a yellow color
  74924. * @returns a new Color3 object
  74925. */
  74926. static Yellow(): Color3;
  74927. /**
  74928. * Returns a Color3 value containing a gray color
  74929. * @returns a new Color3 object
  74930. */
  74931. static Gray(): Color3;
  74932. /**
  74933. * Returns a Color3 value containing a teal color
  74934. * @returns a new Color3 object
  74935. */
  74936. static Teal(): Color3;
  74937. /**
  74938. * Returns a Color3 value containing a random color
  74939. * @returns a new Color3 object
  74940. */
  74941. static Random(): Color3;
  74942. }
  74943. /**
  74944. * Class used to hold a RBGA color
  74945. */
  74946. export class Color4 {
  74947. /**
  74948. * Defines the red component (between 0 and 1, default is 0)
  74949. */
  74950. r: number;
  74951. /**
  74952. * Defines the green component (between 0 and 1, default is 0)
  74953. */
  74954. g: number;
  74955. /**
  74956. * Defines the blue component (between 0 and 1, default is 0)
  74957. */
  74958. b: number;
  74959. /**
  74960. * Defines the alpha component (between 0 and 1, default is 1)
  74961. */
  74962. a: number;
  74963. /**
  74964. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  74965. * @param r defines the red component (between 0 and 1, default is 0)
  74966. * @param g defines the green component (between 0 and 1, default is 0)
  74967. * @param b defines the blue component (between 0 and 1, default is 0)
  74968. * @param a defines the alpha component (between 0 and 1, default is 1)
  74969. */
  74970. constructor(
  74971. /**
  74972. * Defines the red component (between 0 and 1, default is 0)
  74973. */
  74974. r?: number,
  74975. /**
  74976. * Defines the green component (between 0 and 1, default is 0)
  74977. */
  74978. g?: number,
  74979. /**
  74980. * Defines the blue component (between 0 and 1, default is 0)
  74981. */
  74982. b?: number,
  74983. /**
  74984. * Defines the alpha component (between 0 and 1, default is 1)
  74985. */
  74986. a?: number);
  74987. /**
  74988. * Adds in place the given Color4 values to the current Color4 object
  74989. * @param right defines the second operand
  74990. * @returns the current updated Color4 object
  74991. */
  74992. addInPlace(right: DeepImmutable<Color4>): Color4;
  74993. /**
  74994. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74995. * @returns the new array
  74996. */
  74997. asArray(): number[];
  74998. /**
  74999. * Stores from the starting index in the given array the Color4 successive values
  75000. * @param array defines the array where to store the r,g,b components
  75001. * @param index defines an optional index in the target array to define where to start storing values
  75002. * @returns the current Color4 object
  75003. */
  75004. toArray(array: number[], index?: number): Color4;
  75005. /**
  75006. * Determines equality between Color4 objects
  75007. * @param otherColor defines the second operand
  75008. * @returns true if the rgba values are equal to the given ones
  75009. */
  75010. equals(otherColor: DeepImmutable<Color4>): boolean;
  75011. /**
  75012. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  75013. * @param right defines the second operand
  75014. * @returns a new Color4 object
  75015. */
  75016. add(right: DeepImmutable<Color4>): Color4;
  75017. /**
  75018. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  75019. * @param right defines the second operand
  75020. * @returns a new Color4 object
  75021. */
  75022. subtract(right: DeepImmutable<Color4>): Color4;
  75023. /**
  75024. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  75025. * @param right defines the second operand
  75026. * @param result defines the Color4 object where to store the result
  75027. * @returns the current Color4 object
  75028. */
  75029. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  75030. /**
  75031. * Creates a new Color4 with the current Color4 values multiplied by scale
  75032. * @param scale defines the scaling factor to apply
  75033. * @returns a new Color4 object
  75034. */
  75035. scale(scale: number): Color4;
  75036. /**
  75037. * Multiplies the current Color4 values by scale and stores the result in "result"
  75038. * @param scale defines the scaling factor to apply
  75039. * @param result defines the Color4 object where to store the result
  75040. * @returns the current unmodified Color4
  75041. */
  75042. scaleToRef(scale: number, result: Color4): Color4;
  75043. /**
  75044. * Scale the current Color4 values by a factor and add the result to a given Color4
  75045. * @param scale defines the scale factor
  75046. * @param result defines the Color4 object where to store the result
  75047. * @returns the unmodified current Color4
  75048. */
  75049. scaleAndAddToRef(scale: number, result: Color4): Color4;
  75050. /**
  75051. * Clamps the rgb values by the min and max values and stores the result into "result"
  75052. * @param min defines minimum clamping value (default is 0)
  75053. * @param max defines maximum clamping value (default is 1)
  75054. * @param result defines color to store the result into.
  75055. * @returns the cuurent Color4
  75056. */
  75057. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  75058. /**
  75059. * Multipy an Color4 value by another and return a new Color4 object
  75060. * @param color defines the Color4 value to multiply by
  75061. * @returns a new Color4 object
  75062. */
  75063. multiply(color: Color4): Color4;
  75064. /**
  75065. * Multipy a Color4 value by another and push the result in a reference value
  75066. * @param color defines the Color4 value to multiply by
  75067. * @param result defines the Color4 to fill the result in
  75068. * @returns the result Color4
  75069. */
  75070. multiplyToRef(color: Color4, result: Color4): Color4;
  75071. /**
  75072. * Creates a string with the Color4 current values
  75073. * @returns the string representation of the Color4 object
  75074. */
  75075. toString(): string;
  75076. /**
  75077. * Returns the string "Color4"
  75078. * @returns "Color4"
  75079. */
  75080. getClassName(): string;
  75081. /**
  75082. * Compute the Color4 hash code
  75083. * @returns an unique number that can be used to hash Color4 objects
  75084. */
  75085. getHashCode(): number;
  75086. /**
  75087. * Creates a new Color4 copied from the current one
  75088. * @returns a new Color4 object
  75089. */
  75090. clone(): Color4;
  75091. /**
  75092. * Copies the given Color4 values into the current one
  75093. * @param source defines the source Color4 object
  75094. * @returns the current updated Color4 object
  75095. */
  75096. copyFrom(source: Color4): Color4;
  75097. /**
  75098. * Copies the given float values into the current one
  75099. * @param r defines the red component to read from
  75100. * @param g defines the green component to read from
  75101. * @param b defines the blue component to read from
  75102. * @param a defines the alpha component to read from
  75103. * @returns the current updated Color4 object
  75104. */
  75105. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  75106. /**
  75107. * Copies the given float values into the current one
  75108. * @param r defines the red component to read from
  75109. * @param g defines the green component to read from
  75110. * @param b defines the blue component to read from
  75111. * @param a defines the alpha component to read from
  75112. * @returns the current updated Color4 object
  75113. */
  75114. set(r: number, g: number, b: number, a: number): Color4;
  75115. /**
  75116. * Compute the Color4 hexadecimal code as a string
  75117. * @returns a string containing the hexadecimal representation of the Color4 object
  75118. */
  75119. toHexString(): string;
  75120. /**
  75121. * Computes a new Color4 converted from the current one to linear space
  75122. * @returns a new Color4 object
  75123. */
  75124. toLinearSpace(): Color4;
  75125. /**
  75126. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  75127. * @param convertedColor defines the Color4 object where to store the linear space version
  75128. * @returns the unmodified Color4
  75129. */
  75130. toLinearSpaceToRef(convertedColor: Color4): Color4;
  75131. /**
  75132. * Computes a new Color4 converted from the current one to gamma space
  75133. * @returns a new Color4 object
  75134. */
  75135. toGammaSpace(): Color4;
  75136. /**
  75137. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  75138. * @param convertedColor defines the Color4 object where to store the gamma space version
  75139. * @returns the unmodified Color4
  75140. */
  75141. toGammaSpaceToRef(convertedColor: Color4): Color4;
  75142. /**
  75143. * Creates a new Color4 from the string containing valid hexadecimal values
  75144. * @param hex defines a string containing valid hexadecimal values
  75145. * @returns a new Color4 object
  75146. */
  75147. static FromHexString(hex: string): Color4;
  75148. /**
  75149. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75150. * @param left defines the start value
  75151. * @param right defines the end value
  75152. * @param amount defines the gradient factor
  75153. * @returns a new Color4 object
  75154. */
  75155. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  75156. /**
  75157. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  75158. * @param left defines the start value
  75159. * @param right defines the end value
  75160. * @param amount defines the gradient factor
  75161. * @param result defines the Color4 object where to store data
  75162. */
  75163. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  75164. /**
  75165. * Creates a new Color4 from a Color3 and an alpha value
  75166. * @param color3 defines the source Color3 to read from
  75167. * @param alpha defines the alpha component (1.0 by default)
  75168. * @returns a new Color4 object
  75169. */
  75170. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  75171. /**
  75172. * Creates a new Color4 from the starting index element of the given array
  75173. * @param array defines the source array to read from
  75174. * @param offset defines the offset in the source array
  75175. * @returns a new Color4 object
  75176. */
  75177. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  75178. /**
  75179. * Creates a new Color3 from integer values (< 256)
  75180. * @param r defines the red component to read from (value between 0 and 255)
  75181. * @param g defines the green component to read from (value between 0 and 255)
  75182. * @param b defines the blue component to read from (value between 0 and 255)
  75183. * @param a defines the alpha component to read from (value between 0 and 255)
  75184. * @returns a new Color3 object
  75185. */
  75186. static FromInts(r: number, g: number, b: number, a: number): Color4;
  75187. /**
  75188. * Check the content of a given array and convert it to an array containing RGBA data
  75189. * If the original array was already containing count * 4 values then it is returned directly
  75190. * @param colors defines the array to check
  75191. * @param count defines the number of RGBA data to expect
  75192. * @returns an array containing count * 4 values (RGBA)
  75193. */
  75194. static CheckColors4(colors: number[], count: number): number[];
  75195. }
  75196. /**
  75197. * @hidden
  75198. */
  75199. export class TmpColors {
  75200. static Color3: Color3[];
  75201. static Color4: Color4[];
  75202. }
  75203. }
  75204. declare module BABYLON {
  75205. /**
  75206. * Defines an interface which represents an animation key frame
  75207. */
  75208. export interface IAnimationKey {
  75209. /**
  75210. * Frame of the key frame
  75211. */
  75212. frame: number;
  75213. /**
  75214. * Value at the specifies key frame
  75215. */
  75216. value: any;
  75217. /**
  75218. * The input tangent for the cubic hermite spline
  75219. */
  75220. inTangent?: any;
  75221. /**
  75222. * The output tangent for the cubic hermite spline
  75223. */
  75224. outTangent?: any;
  75225. /**
  75226. * The animation interpolation type
  75227. */
  75228. interpolation?: AnimationKeyInterpolation;
  75229. }
  75230. /**
  75231. * Enum for the animation key frame interpolation type
  75232. */
  75233. export enum AnimationKeyInterpolation {
  75234. /**
  75235. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  75236. */
  75237. STEP = 1
  75238. }
  75239. }
  75240. declare module BABYLON {
  75241. /**
  75242. * Represents the range of an animation
  75243. */
  75244. export class AnimationRange {
  75245. /**The name of the animation range**/
  75246. name: string;
  75247. /**The starting frame of the animation */
  75248. from: number;
  75249. /**The ending frame of the animation*/
  75250. to: number;
  75251. /**
  75252. * Initializes the range of an animation
  75253. * @param name The name of the animation range
  75254. * @param from The starting frame of the animation
  75255. * @param to The ending frame of the animation
  75256. */
  75257. constructor(
  75258. /**The name of the animation range**/
  75259. name: string,
  75260. /**The starting frame of the animation */
  75261. from: number,
  75262. /**The ending frame of the animation*/
  75263. to: number);
  75264. /**
  75265. * Makes a copy of the animation range
  75266. * @returns A copy of the animation range
  75267. */
  75268. clone(): AnimationRange;
  75269. }
  75270. }
  75271. declare module BABYLON {
  75272. /**
  75273. * Composed of a frame, and an action function
  75274. */
  75275. export class AnimationEvent {
  75276. /** The frame for which the event is triggered **/
  75277. frame: number;
  75278. /** The event to perform when triggered **/
  75279. action: (currentFrame: number) => void;
  75280. /** Specifies if the event should be triggered only once**/
  75281. onlyOnce?: boolean | undefined;
  75282. /**
  75283. * Specifies if the animation event is done
  75284. */
  75285. isDone: boolean;
  75286. /**
  75287. * Initializes the animation event
  75288. * @param frame The frame for which the event is triggered
  75289. * @param action The event to perform when triggered
  75290. * @param onlyOnce Specifies if the event should be triggered only once
  75291. */
  75292. constructor(
  75293. /** The frame for which the event is triggered **/
  75294. frame: number,
  75295. /** The event to perform when triggered **/
  75296. action: (currentFrame: number) => void,
  75297. /** Specifies if the event should be triggered only once**/
  75298. onlyOnce?: boolean | undefined);
  75299. /** @hidden */
  75300. _clone(): AnimationEvent;
  75301. }
  75302. }
  75303. declare module BABYLON {
  75304. /**
  75305. * Interface used to define a behavior
  75306. */
  75307. export interface Behavior<T> {
  75308. /** gets or sets behavior's name */
  75309. name: string;
  75310. /**
  75311. * Function called when the behavior needs to be initialized (after attaching it to a target)
  75312. */
  75313. init(): void;
  75314. /**
  75315. * Called when the behavior is attached to a target
  75316. * @param target defines the target where the behavior is attached to
  75317. */
  75318. attach(target: T): void;
  75319. /**
  75320. * Called when the behavior is detached from its target
  75321. */
  75322. detach(): void;
  75323. }
  75324. /**
  75325. * Interface implemented by classes supporting behaviors
  75326. */
  75327. export interface IBehaviorAware<T> {
  75328. /**
  75329. * Attach a behavior
  75330. * @param behavior defines the behavior to attach
  75331. * @returns the current host
  75332. */
  75333. addBehavior(behavior: Behavior<T>): T;
  75334. /**
  75335. * Remove a behavior from the current object
  75336. * @param behavior defines the behavior to detach
  75337. * @returns the current host
  75338. */
  75339. removeBehavior(behavior: Behavior<T>): T;
  75340. /**
  75341. * Gets a behavior using its name to search
  75342. * @param name defines the name to search
  75343. * @returns the behavior or null if not found
  75344. */
  75345. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  75346. }
  75347. }
  75348. declare module BABYLON {
  75349. /**
  75350. * Defines an array and its length.
  75351. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  75352. */
  75353. export interface ISmartArrayLike<T> {
  75354. /**
  75355. * The data of the array.
  75356. */
  75357. data: Array<T>;
  75358. /**
  75359. * The active length of the array.
  75360. */
  75361. length: number;
  75362. }
  75363. /**
  75364. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75365. */
  75366. export class SmartArray<T> implements ISmartArrayLike<T> {
  75367. /**
  75368. * The full set of data from the array.
  75369. */
  75370. data: Array<T>;
  75371. /**
  75372. * The active length of the array.
  75373. */
  75374. length: number;
  75375. protected _id: number;
  75376. /**
  75377. * Instantiates a Smart Array.
  75378. * @param capacity defines the default capacity of the array.
  75379. */
  75380. constructor(capacity: number);
  75381. /**
  75382. * Pushes a value at the end of the active data.
  75383. * @param value defines the object to push in the array.
  75384. */
  75385. push(value: T): void;
  75386. /**
  75387. * Iterates over the active data and apply the lambda to them.
  75388. * @param func defines the action to apply on each value.
  75389. */
  75390. forEach(func: (content: T) => void): void;
  75391. /**
  75392. * Sorts the full sets of data.
  75393. * @param compareFn defines the comparison function to apply.
  75394. */
  75395. sort(compareFn: (a: T, b: T) => number): void;
  75396. /**
  75397. * Resets the active data to an empty array.
  75398. */
  75399. reset(): void;
  75400. /**
  75401. * Releases all the data from the array as well as the array.
  75402. */
  75403. dispose(): void;
  75404. /**
  75405. * Concats the active data with a given array.
  75406. * @param array defines the data to concatenate with.
  75407. */
  75408. concat(array: any): void;
  75409. /**
  75410. * Returns the position of a value in the active data.
  75411. * @param value defines the value to find the index for
  75412. * @returns the index if found in the active data otherwise -1
  75413. */
  75414. indexOf(value: T): number;
  75415. /**
  75416. * Returns whether an element is part of the active data.
  75417. * @param value defines the value to look for
  75418. * @returns true if found in the active data otherwise false
  75419. */
  75420. contains(value: T): boolean;
  75421. private static _GlobalId;
  75422. }
  75423. /**
  75424. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  75425. * The data in this array can only be present once
  75426. */
  75427. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  75428. private _duplicateId;
  75429. /**
  75430. * Pushes a value at the end of the active data.
  75431. * THIS DOES NOT PREVENT DUPPLICATE DATA
  75432. * @param value defines the object to push in the array.
  75433. */
  75434. push(value: T): void;
  75435. /**
  75436. * Pushes a value at the end of the active data.
  75437. * If the data is already present, it won t be added again
  75438. * @param value defines the object to push in the array.
  75439. * @returns true if added false if it was already present
  75440. */
  75441. pushNoDuplicate(value: T): boolean;
  75442. /**
  75443. * Resets the active data to an empty array.
  75444. */
  75445. reset(): void;
  75446. /**
  75447. * Concats the active data with a given array.
  75448. * This ensures no dupplicate will be present in the result.
  75449. * @param array defines the data to concatenate with.
  75450. */
  75451. concatWithNoDuplicate(array: any): void;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /**
  75456. * @ignore
  75457. * This is a list of all the different input types that are available in the application.
  75458. * Fo instance: ArcRotateCameraGamepadInput...
  75459. */
  75460. export var CameraInputTypes: {};
  75461. /**
  75462. * This is the contract to implement in order to create a new input class.
  75463. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  75464. */
  75465. export interface ICameraInput<TCamera extends Camera> {
  75466. /**
  75467. * Defines the camera the input is attached to.
  75468. */
  75469. camera: Nullable<TCamera>;
  75470. /**
  75471. * Gets the class name of the current intput.
  75472. * @returns the class name
  75473. */
  75474. getClassName(): string;
  75475. /**
  75476. * Get the friendly name associated with the input class.
  75477. * @returns the input friendly name
  75478. */
  75479. getSimpleName(): string;
  75480. /**
  75481. * Attach the input controls to a specific dom element to get the input from.
  75482. * @param element Defines the element the controls should be listened from
  75483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75484. */
  75485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75486. /**
  75487. * Detach the current controls from the specified dom element.
  75488. * @param element Defines the element to stop listening the inputs from
  75489. */
  75490. detachControl(element: Nullable<HTMLElement>): void;
  75491. /**
  75492. * Update the current camera state depending on the inputs that have been used this frame.
  75493. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75494. */
  75495. checkInputs?: () => void;
  75496. }
  75497. /**
  75498. * Represents a map of input types to input instance or input index to input instance.
  75499. */
  75500. export interface CameraInputsMap<TCamera extends Camera> {
  75501. /**
  75502. * Accessor to the input by input type.
  75503. */
  75504. [name: string]: ICameraInput<TCamera>;
  75505. /**
  75506. * Accessor to the input by input index.
  75507. */
  75508. [idx: number]: ICameraInput<TCamera>;
  75509. }
  75510. /**
  75511. * This represents the input manager used within a camera.
  75512. * It helps dealing with all the different kind of input attached to a camera.
  75513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75514. */
  75515. export class CameraInputsManager<TCamera extends Camera> {
  75516. /**
  75517. * Defines the list of inputs attahed to the camera.
  75518. */
  75519. attached: CameraInputsMap<TCamera>;
  75520. /**
  75521. * Defines the dom element the camera is collecting inputs from.
  75522. * This is null if the controls have not been attached.
  75523. */
  75524. attachedElement: Nullable<HTMLElement>;
  75525. /**
  75526. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75527. */
  75528. noPreventDefault: boolean;
  75529. /**
  75530. * Defined the camera the input manager belongs to.
  75531. */
  75532. camera: TCamera;
  75533. /**
  75534. * Update the current camera state depending on the inputs that have been used this frame.
  75535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75536. */
  75537. checkInputs: () => void;
  75538. /**
  75539. * Instantiate a new Camera Input Manager.
  75540. * @param camera Defines the camera the input manager blongs to
  75541. */
  75542. constructor(camera: TCamera);
  75543. /**
  75544. * Add an input method to a camera
  75545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75546. * @param input camera input method
  75547. */
  75548. add(input: ICameraInput<TCamera>): void;
  75549. /**
  75550. * Remove a specific input method from a camera
  75551. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  75552. * @param inputToRemove camera input method
  75553. */
  75554. remove(inputToRemove: ICameraInput<TCamera>): void;
  75555. /**
  75556. * Remove a specific input type from a camera
  75557. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  75558. * @param inputType the type of the input to remove
  75559. */
  75560. removeByType(inputType: string): void;
  75561. private _addCheckInputs;
  75562. /**
  75563. * Attach the input controls to the currently attached dom element to listen the events from.
  75564. * @param input Defines the input to attach
  75565. */
  75566. attachInput(input: ICameraInput<TCamera>): void;
  75567. /**
  75568. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  75569. * @param element Defines the dom element to collect the events from
  75570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75571. */
  75572. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  75573. /**
  75574. * Detach the current manager inputs controls from a specific dom element.
  75575. * @param element Defines the dom element to collect the events from
  75576. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  75577. */
  75578. detachElement(element: HTMLElement, disconnect?: boolean): void;
  75579. /**
  75580. * Rebuild the dynamic inputCheck function from the current list of
  75581. * defined inputs in the manager.
  75582. */
  75583. rebuildInputCheck(): void;
  75584. /**
  75585. * Remove all attached input methods from a camera
  75586. */
  75587. clear(): void;
  75588. /**
  75589. * Serialize the current input manager attached to a camera.
  75590. * This ensures than once parsed,
  75591. * the input associated to the camera will be identical to the current ones
  75592. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  75593. */
  75594. serialize(serializedCamera: any): void;
  75595. /**
  75596. * Parses an input manager serialized JSON to restore the previous list of inputs
  75597. * and states associated to a camera.
  75598. * @param parsedCamera Defines the JSON to parse
  75599. */
  75600. parse(parsedCamera: any): void;
  75601. }
  75602. }
  75603. declare module BABYLON {
  75604. /**
  75605. * Class used to store data that will be store in GPU memory
  75606. */
  75607. export class Buffer {
  75608. private _engine;
  75609. private _buffer;
  75610. /** @hidden */
  75611. _data: Nullable<DataArray>;
  75612. private _updatable;
  75613. private _instanced;
  75614. private _divisor;
  75615. /**
  75616. * Gets the byte stride.
  75617. */
  75618. readonly byteStride: number;
  75619. /**
  75620. * Constructor
  75621. * @param engine the engine
  75622. * @param data the data to use for this buffer
  75623. * @param updatable whether the data is updatable
  75624. * @param stride the stride (optional)
  75625. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75626. * @param instanced whether the buffer is instanced (optional)
  75627. * @param useBytes set to true if the stride in in bytes (optional)
  75628. * @param divisor sets an optional divisor for instances (1 by default)
  75629. */
  75630. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  75631. /**
  75632. * Create a new VertexBuffer based on the current buffer
  75633. * @param kind defines the vertex buffer kind (position, normal, etc.)
  75634. * @param offset defines offset in the buffer (0 by default)
  75635. * @param size defines the size in floats of attributes (position is 3 for instance)
  75636. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  75637. * @param instanced defines if the vertex buffer contains indexed data
  75638. * @param useBytes defines if the offset and stride are in bytes *
  75639. * @param divisor sets an optional divisor for instances (1 by default)
  75640. * @returns the new vertex buffer
  75641. */
  75642. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  75643. /**
  75644. * Gets a boolean indicating if the Buffer is updatable?
  75645. * @returns true if the buffer is updatable
  75646. */
  75647. isUpdatable(): boolean;
  75648. /**
  75649. * Gets current buffer's data
  75650. * @returns a DataArray or null
  75651. */
  75652. getData(): Nullable<DataArray>;
  75653. /**
  75654. * Gets underlying native buffer
  75655. * @returns underlying native buffer
  75656. */
  75657. getBuffer(): Nullable<DataBuffer>;
  75658. /**
  75659. * Gets the stride in float32 units (i.e. byte stride / 4).
  75660. * May not be an integer if the byte stride is not divisible by 4.
  75661. * @returns the stride in float32 units
  75662. * @deprecated Please use byteStride instead.
  75663. */
  75664. getStrideSize(): number;
  75665. /**
  75666. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75667. * @param data defines the data to store
  75668. */
  75669. create(data?: Nullable<DataArray>): void;
  75670. /** @hidden */
  75671. _rebuild(): void;
  75672. /**
  75673. * Update current buffer data
  75674. * @param data defines the data to store
  75675. */
  75676. update(data: DataArray): void;
  75677. /**
  75678. * Updates the data directly.
  75679. * @param data the new data
  75680. * @param offset the new offset
  75681. * @param vertexCount the vertex count (optional)
  75682. * @param useBytes set to true if the offset is in bytes
  75683. */
  75684. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  75685. /**
  75686. * Release all resources
  75687. */
  75688. dispose(): void;
  75689. }
  75690. /**
  75691. * Specialized buffer used to store vertex data
  75692. */
  75693. export class VertexBuffer {
  75694. /** @hidden */
  75695. _buffer: Buffer;
  75696. private _kind;
  75697. private _size;
  75698. private _ownsBuffer;
  75699. private _instanced;
  75700. private _instanceDivisor;
  75701. /**
  75702. * The byte type.
  75703. */
  75704. static readonly BYTE: number;
  75705. /**
  75706. * The unsigned byte type.
  75707. */
  75708. static readonly UNSIGNED_BYTE: number;
  75709. /**
  75710. * The short type.
  75711. */
  75712. static readonly SHORT: number;
  75713. /**
  75714. * The unsigned short type.
  75715. */
  75716. static readonly UNSIGNED_SHORT: number;
  75717. /**
  75718. * The integer type.
  75719. */
  75720. static readonly INT: number;
  75721. /**
  75722. * The unsigned integer type.
  75723. */
  75724. static readonly UNSIGNED_INT: number;
  75725. /**
  75726. * The float type.
  75727. */
  75728. static readonly FLOAT: number;
  75729. /**
  75730. * Gets or sets the instance divisor when in instanced mode
  75731. */
  75732. instanceDivisor: number;
  75733. /**
  75734. * Gets the byte stride.
  75735. */
  75736. readonly byteStride: number;
  75737. /**
  75738. * Gets the byte offset.
  75739. */
  75740. readonly byteOffset: number;
  75741. /**
  75742. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  75743. */
  75744. readonly normalized: boolean;
  75745. /**
  75746. * Gets the data type of each component in the array.
  75747. */
  75748. readonly type: number;
  75749. /**
  75750. * Constructor
  75751. * @param engine the engine
  75752. * @param data the data to use for this vertex buffer
  75753. * @param kind the vertex buffer kind
  75754. * @param updatable whether the data is updatable
  75755. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  75756. * @param stride the stride (optional)
  75757. * @param instanced whether the buffer is instanced (optional)
  75758. * @param offset the offset of the data (optional)
  75759. * @param size the number of components (optional)
  75760. * @param type the type of the component (optional)
  75761. * @param normalized whether the data contains normalized data (optional)
  75762. * @param useBytes set to true if stride and offset are in bytes (optional)
  75763. * @param divisor defines the instance divisor to use (1 by default)
  75764. */
  75765. 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);
  75766. /** @hidden */
  75767. _rebuild(): void;
  75768. /**
  75769. * Returns the kind of the VertexBuffer (string)
  75770. * @returns a string
  75771. */
  75772. getKind(): string;
  75773. /**
  75774. * Gets a boolean indicating if the VertexBuffer is updatable?
  75775. * @returns true if the buffer is updatable
  75776. */
  75777. isUpdatable(): boolean;
  75778. /**
  75779. * Gets current buffer's data
  75780. * @returns a DataArray or null
  75781. */
  75782. getData(): Nullable<DataArray>;
  75783. /**
  75784. * Gets underlying native buffer
  75785. * @returns underlying native buffer
  75786. */
  75787. getBuffer(): Nullable<DataBuffer>;
  75788. /**
  75789. * Gets the stride in float32 units (i.e. byte stride / 4).
  75790. * May not be an integer if the byte stride is not divisible by 4.
  75791. * @returns the stride in float32 units
  75792. * @deprecated Please use byteStride instead.
  75793. */
  75794. getStrideSize(): number;
  75795. /**
  75796. * Returns the offset as a multiple of the type byte length.
  75797. * @returns the offset in bytes
  75798. * @deprecated Please use byteOffset instead.
  75799. */
  75800. getOffset(): number;
  75801. /**
  75802. * Returns the number of components per vertex attribute (integer)
  75803. * @returns the size in float
  75804. */
  75805. getSize(): number;
  75806. /**
  75807. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  75808. * @returns true if this buffer is instanced
  75809. */
  75810. getIsInstanced(): boolean;
  75811. /**
  75812. * Returns the instancing divisor, zero for non-instanced (integer).
  75813. * @returns a number
  75814. */
  75815. getInstanceDivisor(): number;
  75816. /**
  75817. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  75818. * @param data defines the data to store
  75819. */
  75820. create(data?: DataArray): void;
  75821. /**
  75822. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  75823. * This function will create a new buffer if the current one is not updatable
  75824. * @param data defines the data to store
  75825. */
  75826. update(data: DataArray): void;
  75827. /**
  75828. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  75829. * Returns the directly updated WebGLBuffer.
  75830. * @param data the new data
  75831. * @param offset the new offset
  75832. * @param useBytes set to true if the offset is in bytes
  75833. */
  75834. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  75835. /**
  75836. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  75837. */
  75838. dispose(): void;
  75839. /**
  75840. * Enumerates each value of this vertex buffer as numbers.
  75841. * @param count the number of values to enumerate
  75842. * @param callback the callback function called for each value
  75843. */
  75844. forEach(count: number, callback: (value: number, index: number) => void): void;
  75845. /**
  75846. * Positions
  75847. */
  75848. static readonly PositionKind: string;
  75849. /**
  75850. * Normals
  75851. */
  75852. static readonly NormalKind: string;
  75853. /**
  75854. * Tangents
  75855. */
  75856. static readonly TangentKind: string;
  75857. /**
  75858. * Texture coordinates
  75859. */
  75860. static readonly UVKind: string;
  75861. /**
  75862. * Texture coordinates 2
  75863. */
  75864. static readonly UV2Kind: string;
  75865. /**
  75866. * Texture coordinates 3
  75867. */
  75868. static readonly UV3Kind: string;
  75869. /**
  75870. * Texture coordinates 4
  75871. */
  75872. static readonly UV4Kind: string;
  75873. /**
  75874. * Texture coordinates 5
  75875. */
  75876. static readonly UV5Kind: string;
  75877. /**
  75878. * Texture coordinates 6
  75879. */
  75880. static readonly UV6Kind: string;
  75881. /**
  75882. * Colors
  75883. */
  75884. static readonly ColorKind: string;
  75885. /**
  75886. * Matrix indices (for bones)
  75887. */
  75888. static readonly MatricesIndicesKind: string;
  75889. /**
  75890. * Matrix weights (for bones)
  75891. */
  75892. static readonly MatricesWeightsKind: string;
  75893. /**
  75894. * Additional matrix indices (for bones)
  75895. */
  75896. static readonly MatricesIndicesExtraKind: string;
  75897. /**
  75898. * Additional matrix weights (for bones)
  75899. */
  75900. static readonly MatricesWeightsExtraKind: string;
  75901. /**
  75902. * Deduces the stride given a kind.
  75903. * @param kind The kind string to deduce
  75904. * @returns The deduced stride
  75905. */
  75906. static DeduceStride(kind: string): number;
  75907. /**
  75908. * Gets the byte length of the given type.
  75909. * @param type the type
  75910. * @returns the number of bytes
  75911. */
  75912. static GetTypeByteLength(type: number): number;
  75913. /**
  75914. * Enumerates each value of the given parameters as numbers.
  75915. * @param data the data to enumerate
  75916. * @param byteOffset the byte offset of the data
  75917. * @param byteStride the byte stride of the data
  75918. * @param componentCount the number of components per element
  75919. * @param componentType the type of the component
  75920. * @param count the number of values to enumerate
  75921. * @param normalized whether the data is normalized
  75922. * @param callback the callback function called for each value
  75923. */
  75924. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  75925. private static _GetFloatValue;
  75926. }
  75927. }
  75928. declare module BABYLON {
  75929. /**
  75930. * @hidden
  75931. */
  75932. export class IntersectionInfo {
  75933. bu: Nullable<number>;
  75934. bv: Nullable<number>;
  75935. distance: number;
  75936. faceId: number;
  75937. subMeshId: number;
  75938. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  75939. }
  75940. }
  75941. declare module BABYLON {
  75942. /**
  75943. * Represens a plane by the equation ax + by + cz + d = 0
  75944. */
  75945. export class Plane {
  75946. private static _TmpMatrix;
  75947. /**
  75948. * Normal of the plane (a,b,c)
  75949. */
  75950. normal: Vector3;
  75951. /**
  75952. * d component of the plane
  75953. */
  75954. d: number;
  75955. /**
  75956. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  75957. * @param a a component of the plane
  75958. * @param b b component of the plane
  75959. * @param c c component of the plane
  75960. * @param d d component of the plane
  75961. */
  75962. constructor(a: number, b: number, c: number, d: number);
  75963. /**
  75964. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  75965. */
  75966. asArray(): number[];
  75967. /**
  75968. * @returns a new plane copied from the current Plane.
  75969. */
  75970. clone(): Plane;
  75971. /**
  75972. * @returns the string "Plane".
  75973. */
  75974. getClassName(): string;
  75975. /**
  75976. * @returns the Plane hash code.
  75977. */
  75978. getHashCode(): number;
  75979. /**
  75980. * Normalize the current Plane in place.
  75981. * @returns the updated Plane.
  75982. */
  75983. normalize(): Plane;
  75984. /**
  75985. * Applies a transformation the plane and returns the result
  75986. * @param transformation the transformation matrix to be applied to the plane
  75987. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  75988. */
  75989. transform(transformation: DeepImmutable<Matrix>): Plane;
  75990. /**
  75991. * Calcualtte the dot product between the point and the plane normal
  75992. * @param point point to calculate the dot product with
  75993. * @returns the dot product (float) of the point coordinates and the plane normal.
  75994. */
  75995. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75996. /**
  75997. * Updates the current Plane from the plane defined by the three given points.
  75998. * @param point1 one of the points used to contruct the plane
  75999. * @param point2 one of the points used to contruct the plane
  76000. * @param point3 one of the points used to contruct the plane
  76001. * @returns the updated Plane.
  76002. */
  76003. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  76004. /**
  76005. * Checks if the plane is facing a given direction
  76006. * @param direction the direction to check if the plane is facing
  76007. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  76008. * @returns True is the vector "direction" is the same side than the plane normal.
  76009. */
  76010. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  76011. /**
  76012. * Calculates the distance to a point
  76013. * @param point point to calculate distance to
  76014. * @returns the signed distance (float) from the given point to the Plane.
  76015. */
  76016. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  76017. /**
  76018. * Creates a plane from an array
  76019. * @param array the array to create a plane from
  76020. * @returns a new Plane from the given array.
  76021. */
  76022. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  76023. /**
  76024. * Creates a plane from three points
  76025. * @param point1 point used to create the plane
  76026. * @param point2 point used to create the plane
  76027. * @param point3 point used to create the plane
  76028. * @returns a new Plane defined by the three given points.
  76029. */
  76030. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  76031. /**
  76032. * Creates a plane from an origin point and a normal
  76033. * @param origin origin of the plane to be constructed
  76034. * @param normal normal of the plane to be constructed
  76035. * @returns a new Plane the normal vector to this plane at the given origin point.
  76036. * Note : the vector "normal" is updated because normalized.
  76037. */
  76038. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  76039. /**
  76040. * Calculates the distance from a plane and a point
  76041. * @param origin origin of the plane to be constructed
  76042. * @param normal normal of the plane to be constructed
  76043. * @param point point to calculate distance to
  76044. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  76045. */
  76046. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  76047. }
  76048. }
  76049. declare module BABYLON {
  76050. /**
  76051. * Class used to store bounding sphere information
  76052. */
  76053. export class BoundingSphere {
  76054. /**
  76055. * Gets the center of the bounding sphere in local space
  76056. */
  76057. readonly center: Vector3;
  76058. /**
  76059. * Radius of the bounding sphere in local space
  76060. */
  76061. radius: number;
  76062. /**
  76063. * Gets the center of the bounding sphere in world space
  76064. */
  76065. readonly centerWorld: Vector3;
  76066. /**
  76067. * Radius of the bounding sphere in world space
  76068. */
  76069. radiusWorld: number;
  76070. /**
  76071. * Gets the minimum vector in local space
  76072. */
  76073. readonly minimum: Vector3;
  76074. /**
  76075. * Gets the maximum vector in local space
  76076. */
  76077. readonly maximum: Vector3;
  76078. private _worldMatrix;
  76079. private static readonly TmpVector3;
  76080. /**
  76081. * Creates a new bounding sphere
  76082. * @param min defines the minimum vector (in local space)
  76083. * @param max defines the maximum vector (in local space)
  76084. * @param worldMatrix defines the new world matrix
  76085. */
  76086. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76087. /**
  76088. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  76089. * @param min defines the new minimum vector (in local space)
  76090. * @param max defines the new maximum vector (in local space)
  76091. * @param worldMatrix defines the new world matrix
  76092. */
  76093. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76094. /**
  76095. * Scale the current bounding sphere by applying a scale factor
  76096. * @param factor defines the scale factor to apply
  76097. * @returns the current bounding box
  76098. */
  76099. scale(factor: number): BoundingSphere;
  76100. /**
  76101. * Gets the world matrix of the bounding box
  76102. * @returns a matrix
  76103. */
  76104. getWorldMatrix(): DeepImmutable<Matrix>;
  76105. /** @hidden */
  76106. _update(worldMatrix: DeepImmutable<Matrix>): void;
  76107. /**
  76108. * Tests if the bounding sphere is intersecting the frustum planes
  76109. * @param frustumPlanes defines the frustum planes to test
  76110. * @returns true if there is an intersection
  76111. */
  76112. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76113. /**
  76114. * Tests if the bounding sphere center is in between the frustum planes.
  76115. * Used for optimistic fast inclusion.
  76116. * @param frustumPlanes defines the frustum planes to test
  76117. * @returns true if the sphere center is in between the frustum planes
  76118. */
  76119. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76120. /**
  76121. * Tests if a point is inside the bounding sphere
  76122. * @param point defines the point to test
  76123. * @returns true if the point is inside the bounding sphere
  76124. */
  76125. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76126. /**
  76127. * Checks if two sphere intersct
  76128. * @param sphere0 sphere 0
  76129. * @param sphere1 sphere 1
  76130. * @returns true if the speres intersect
  76131. */
  76132. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  76133. }
  76134. }
  76135. declare module BABYLON {
  76136. /**
  76137. * Class used to store bounding box information
  76138. */
  76139. export class BoundingBox implements ICullable {
  76140. /**
  76141. * Gets the 8 vectors representing the bounding box in local space
  76142. */
  76143. readonly vectors: Vector3[];
  76144. /**
  76145. * Gets the center of the bounding box in local space
  76146. */
  76147. readonly center: Vector3;
  76148. /**
  76149. * Gets the center of the bounding box in world space
  76150. */
  76151. readonly centerWorld: Vector3;
  76152. /**
  76153. * Gets the extend size in local space
  76154. */
  76155. readonly extendSize: Vector3;
  76156. /**
  76157. * Gets the extend size in world space
  76158. */
  76159. readonly extendSizeWorld: Vector3;
  76160. /**
  76161. * Gets the OBB (object bounding box) directions
  76162. */
  76163. readonly directions: Vector3[];
  76164. /**
  76165. * Gets the 8 vectors representing the bounding box in world space
  76166. */
  76167. readonly vectorsWorld: Vector3[];
  76168. /**
  76169. * Gets the minimum vector in world space
  76170. */
  76171. readonly minimumWorld: Vector3;
  76172. /**
  76173. * Gets the maximum vector in world space
  76174. */
  76175. readonly maximumWorld: Vector3;
  76176. /**
  76177. * Gets the minimum vector in local space
  76178. */
  76179. readonly minimum: Vector3;
  76180. /**
  76181. * Gets the maximum vector in local space
  76182. */
  76183. readonly maximum: Vector3;
  76184. private _worldMatrix;
  76185. private static readonly TmpVector3;
  76186. /**
  76187. * @hidden
  76188. */
  76189. _tag: number;
  76190. /**
  76191. * Creates a new bounding box
  76192. * @param min defines the minimum vector (in local space)
  76193. * @param max defines the maximum vector (in local space)
  76194. * @param worldMatrix defines the new world matrix
  76195. */
  76196. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76197. /**
  76198. * Recreates the entire bounding box from scratch as if we call the constructor in place
  76199. * @param min defines the new minimum vector (in local space)
  76200. * @param max defines the new maximum vector (in local space)
  76201. * @param worldMatrix defines the new world matrix
  76202. */
  76203. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76204. /**
  76205. * Scale the current bounding box by applying a scale factor
  76206. * @param factor defines the scale factor to apply
  76207. * @returns the current bounding box
  76208. */
  76209. scale(factor: number): BoundingBox;
  76210. /**
  76211. * Gets the world matrix of the bounding box
  76212. * @returns a matrix
  76213. */
  76214. getWorldMatrix(): DeepImmutable<Matrix>;
  76215. /** @hidden */
  76216. _update(world: DeepImmutable<Matrix>): void;
  76217. /**
  76218. * Tests if the bounding box is intersecting the frustum planes
  76219. * @param frustumPlanes defines the frustum planes to test
  76220. * @returns true if there is an intersection
  76221. */
  76222. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76223. /**
  76224. * Tests if the bounding box is entirely inside the frustum planes
  76225. * @param frustumPlanes defines the frustum planes to test
  76226. * @returns true if there is an inclusion
  76227. */
  76228. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76229. /**
  76230. * Tests if a point is inside the bounding box
  76231. * @param point defines the point to test
  76232. * @returns true if the point is inside the bounding box
  76233. */
  76234. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76235. /**
  76236. * Tests if the bounding box intersects with a bounding sphere
  76237. * @param sphere defines the sphere to test
  76238. * @returns true if there is an intersection
  76239. */
  76240. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  76241. /**
  76242. * Tests if the bounding box intersects with a box defined by a min and max vectors
  76243. * @param min defines the min vector to use
  76244. * @param max defines the max vector to use
  76245. * @returns true if there is an intersection
  76246. */
  76247. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  76248. /**
  76249. * Tests if two bounding boxes are intersections
  76250. * @param box0 defines the first box to test
  76251. * @param box1 defines the second box to test
  76252. * @returns true if there is an intersection
  76253. */
  76254. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  76255. /**
  76256. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  76257. * @param minPoint defines the minimum vector of the bounding box
  76258. * @param maxPoint defines the maximum vector of the bounding box
  76259. * @param sphereCenter defines the sphere center
  76260. * @param sphereRadius defines the sphere radius
  76261. * @returns true if there is an intersection
  76262. */
  76263. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  76264. /**
  76265. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  76266. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76267. * @param frustumPlanes defines the frustum planes to test
  76268. * @return true if there is an inclusion
  76269. */
  76270. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76271. /**
  76272. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  76273. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  76274. * @param frustumPlanes defines the frustum planes to test
  76275. * @return true if there is an intersection
  76276. */
  76277. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76278. }
  76279. }
  76280. declare module BABYLON {
  76281. /** @hidden */
  76282. export class Collider {
  76283. /** Define if a collision was found */
  76284. collisionFound: boolean;
  76285. /**
  76286. * Define last intersection point in local space
  76287. */
  76288. intersectionPoint: Vector3;
  76289. /**
  76290. * Define last collided mesh
  76291. */
  76292. collidedMesh: Nullable<AbstractMesh>;
  76293. private _collisionPoint;
  76294. private _planeIntersectionPoint;
  76295. private _tempVector;
  76296. private _tempVector2;
  76297. private _tempVector3;
  76298. private _tempVector4;
  76299. private _edge;
  76300. private _baseToVertex;
  76301. private _destinationPoint;
  76302. private _slidePlaneNormal;
  76303. private _displacementVector;
  76304. /** @hidden */
  76305. _radius: Vector3;
  76306. /** @hidden */
  76307. _retry: number;
  76308. private _velocity;
  76309. private _basePoint;
  76310. private _epsilon;
  76311. /** @hidden */
  76312. _velocityWorldLength: number;
  76313. /** @hidden */
  76314. _basePointWorld: Vector3;
  76315. private _velocityWorld;
  76316. private _normalizedVelocity;
  76317. /** @hidden */
  76318. _initialVelocity: Vector3;
  76319. /** @hidden */
  76320. _initialPosition: Vector3;
  76321. private _nearestDistance;
  76322. private _collisionMask;
  76323. collisionMask: number;
  76324. /**
  76325. * Gets the plane normal used to compute the sliding response (in local space)
  76326. */
  76327. readonly slidePlaneNormal: Vector3;
  76328. /** @hidden */
  76329. _initialize(source: Vector3, dir: Vector3, e: number): void;
  76330. /** @hidden */
  76331. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  76332. /** @hidden */
  76333. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  76334. /** @hidden */
  76335. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76336. /** @hidden */
  76337. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  76338. /** @hidden */
  76339. _getResponse(pos: Vector3, vel: Vector3): void;
  76340. }
  76341. }
  76342. declare module BABYLON {
  76343. /**
  76344. * Interface for cullable objects
  76345. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  76346. */
  76347. export interface ICullable {
  76348. /**
  76349. * Checks if the object or part of the object is in the frustum
  76350. * @param frustumPlanes Camera near/planes
  76351. * @returns true if the object is in frustum otherwise false
  76352. */
  76353. isInFrustum(frustumPlanes: Plane[]): boolean;
  76354. /**
  76355. * Checks if a cullable object (mesh...) is in the camera frustum
  76356. * Unlike isInFrustum this cheks the full bounding box
  76357. * @param frustumPlanes Camera near/planes
  76358. * @returns true if the object is in frustum otherwise false
  76359. */
  76360. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  76361. }
  76362. /**
  76363. * Info for a bounding data of a mesh
  76364. */
  76365. export class BoundingInfo implements ICullable {
  76366. /**
  76367. * Bounding box for the mesh
  76368. */
  76369. readonly boundingBox: BoundingBox;
  76370. /**
  76371. * Bounding sphere for the mesh
  76372. */
  76373. readonly boundingSphere: BoundingSphere;
  76374. private _isLocked;
  76375. private static readonly TmpVector3;
  76376. /**
  76377. * Constructs bounding info
  76378. * @param minimum min vector of the bounding box/sphere
  76379. * @param maximum max vector of the bounding box/sphere
  76380. * @param worldMatrix defines the new world matrix
  76381. */
  76382. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  76383. /**
  76384. * Recreates the entire bounding info from scratch as if we call the constructor in place
  76385. * @param min defines the new minimum vector (in local space)
  76386. * @param max defines the new maximum vector (in local space)
  76387. * @param worldMatrix defines the new world matrix
  76388. */
  76389. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  76390. /**
  76391. * min vector of the bounding box/sphere
  76392. */
  76393. readonly minimum: Vector3;
  76394. /**
  76395. * max vector of the bounding box/sphere
  76396. */
  76397. readonly maximum: Vector3;
  76398. /**
  76399. * If the info is locked and won't be updated to avoid perf overhead
  76400. */
  76401. isLocked: boolean;
  76402. /**
  76403. * Updates the bounding sphere and box
  76404. * @param world world matrix to be used to update
  76405. */
  76406. update(world: DeepImmutable<Matrix>): void;
  76407. /**
  76408. * Recreate the bounding info to be centered around a specific point given a specific extend.
  76409. * @param center New center of the bounding info
  76410. * @param extend New extend of the bounding info
  76411. * @returns the current bounding info
  76412. */
  76413. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  76414. /**
  76415. * Scale the current bounding info by applying a scale factor
  76416. * @param factor defines the scale factor to apply
  76417. * @returns the current bounding info
  76418. */
  76419. scale(factor: number): BoundingInfo;
  76420. /**
  76421. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  76422. * @param frustumPlanes defines the frustum to test
  76423. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  76424. * @returns true if the bounding info is in the frustum planes
  76425. */
  76426. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  76427. /**
  76428. * Gets the world distance between the min and max points of the bounding box
  76429. */
  76430. readonly diagonalLength: number;
  76431. /**
  76432. * Checks if a cullable object (mesh...) is in the camera frustum
  76433. * Unlike isInFrustum this cheks the full bounding box
  76434. * @param frustumPlanes Camera near/planes
  76435. * @returns true if the object is in frustum otherwise false
  76436. */
  76437. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  76438. /** @hidden */
  76439. _checkCollision(collider: Collider): boolean;
  76440. /**
  76441. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  76442. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76443. * @param point the point to check intersection with
  76444. * @returns if the point intersects
  76445. */
  76446. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  76447. /**
  76448. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  76449. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  76450. * @param boundingInfo the bounding info to check intersection with
  76451. * @param precise if the intersection should be done using OBB
  76452. * @returns if the bounding info intersects
  76453. */
  76454. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  76455. }
  76456. }
  76457. declare module BABYLON {
  76458. /**
  76459. * Extracts minimum and maximum values from a list of indexed positions
  76460. * @param positions defines the positions to use
  76461. * @param indices defines the indices to the positions
  76462. * @param indexStart defines the start index
  76463. * @param indexCount defines the end index
  76464. * @param bias defines bias value to add to the result
  76465. * @return minimum and maximum values
  76466. */
  76467. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  76468. minimum: Vector3;
  76469. maximum: Vector3;
  76470. };
  76471. /**
  76472. * Extracts minimum and maximum values from a list of positions
  76473. * @param positions defines the positions to use
  76474. * @param start defines the start index in the positions array
  76475. * @param count defines the number of positions to handle
  76476. * @param bias defines bias value to add to the result
  76477. * @param stride defines the stride size to use (distance between two positions in the positions array)
  76478. * @return minimum and maximum values
  76479. */
  76480. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  76481. minimum: Vector3;
  76482. maximum: Vector3;
  76483. };
  76484. }
  76485. declare module BABYLON {
  76486. /** @hidden */
  76487. export class WebGLDataBuffer extends DataBuffer {
  76488. private _buffer;
  76489. constructor(resource: WebGLBuffer);
  76490. readonly underlyingResource: any;
  76491. }
  76492. }
  76493. declare module BABYLON {
  76494. /** @hidden */
  76495. export class WebGLPipelineContext implements IPipelineContext {
  76496. engine: ThinEngine;
  76497. program: Nullable<WebGLProgram>;
  76498. context?: WebGLRenderingContext;
  76499. vertexShader?: WebGLShader;
  76500. fragmentShader?: WebGLShader;
  76501. isParallelCompiled: boolean;
  76502. onCompiled?: () => void;
  76503. transformFeedback?: WebGLTransformFeedback | null;
  76504. readonly isAsync: boolean;
  76505. readonly isReady: boolean;
  76506. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  76507. }
  76508. }
  76509. declare module BABYLON {
  76510. interface ThinEngine {
  76511. /**
  76512. * Create an uniform buffer
  76513. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76514. * @param elements defines the content of the uniform buffer
  76515. * @returns the webGL uniform buffer
  76516. */
  76517. createUniformBuffer(elements: FloatArray): DataBuffer;
  76518. /**
  76519. * Create a dynamic uniform buffer
  76520. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76521. * @param elements defines the content of the uniform buffer
  76522. * @returns the webGL uniform buffer
  76523. */
  76524. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  76525. /**
  76526. * Update an existing uniform buffer
  76527. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  76528. * @param uniformBuffer defines the target uniform buffer
  76529. * @param elements defines the content to update
  76530. * @param offset defines the offset in the uniform buffer where update should start
  76531. * @param count defines the size of the data to update
  76532. */
  76533. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  76534. /**
  76535. * Bind an uniform buffer to the current webGL context
  76536. * @param buffer defines the buffer to bind
  76537. */
  76538. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  76539. /**
  76540. * Bind a buffer to the current webGL context at a given location
  76541. * @param buffer defines the buffer to bind
  76542. * @param location defines the index where to bind the buffer
  76543. */
  76544. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  76545. /**
  76546. * Bind a specific block at a given index in a specific shader program
  76547. * @param pipelineContext defines the pipeline context to use
  76548. * @param blockName defines the block name
  76549. * @param index defines the index where to bind the block
  76550. */
  76551. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  76552. }
  76553. }
  76554. declare module BABYLON {
  76555. /**
  76556. * Uniform buffer objects.
  76557. *
  76558. * Handles blocks of uniform on the GPU.
  76559. *
  76560. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76561. *
  76562. * For more information, please refer to :
  76563. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76564. */
  76565. export class UniformBuffer {
  76566. private _engine;
  76567. private _buffer;
  76568. private _data;
  76569. private _bufferData;
  76570. private _dynamic?;
  76571. private _uniformLocations;
  76572. private _uniformSizes;
  76573. private _uniformLocationPointer;
  76574. private _needSync;
  76575. private _noUBO;
  76576. private _currentEffect;
  76577. /** @hidden */
  76578. _alreadyBound: boolean;
  76579. private static _MAX_UNIFORM_SIZE;
  76580. private static _tempBuffer;
  76581. /**
  76582. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  76583. * This is dynamic to allow compat with webgl 1 and 2.
  76584. * You will need to pass the name of the uniform as well as the value.
  76585. */
  76586. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  76587. /**
  76588. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  76589. * This is dynamic to allow compat with webgl 1 and 2.
  76590. * You will need to pass the name of the uniform as well as the value.
  76591. */
  76592. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  76593. /**
  76594. * Lambda to Update a single float in a uniform buffer.
  76595. * This is dynamic to allow compat with webgl 1 and 2.
  76596. * You will need to pass the name of the uniform as well as the value.
  76597. */
  76598. updateFloat: (name: string, x: number) => void;
  76599. /**
  76600. * Lambda to Update a vec2 of float in a uniform buffer.
  76601. * This is dynamic to allow compat with webgl 1 and 2.
  76602. * You will need to pass the name of the uniform as well as the value.
  76603. */
  76604. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  76605. /**
  76606. * Lambda to Update a vec3 of float in a uniform buffer.
  76607. * This is dynamic to allow compat with webgl 1 and 2.
  76608. * You will need to pass the name of the uniform as well as the value.
  76609. */
  76610. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  76611. /**
  76612. * Lambda to Update a vec4 of float in a uniform buffer.
  76613. * This is dynamic to allow compat with webgl 1 and 2.
  76614. * You will need to pass the name of the uniform as well as the value.
  76615. */
  76616. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  76617. /**
  76618. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  76619. * This is dynamic to allow compat with webgl 1 and 2.
  76620. * You will need to pass the name of the uniform as well as the value.
  76621. */
  76622. updateMatrix: (name: string, mat: Matrix) => void;
  76623. /**
  76624. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  76625. * This is dynamic to allow compat with webgl 1 and 2.
  76626. * You will need to pass the name of the uniform as well as the value.
  76627. */
  76628. updateVector3: (name: string, vector: Vector3) => void;
  76629. /**
  76630. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  76631. * This is dynamic to allow compat with webgl 1 and 2.
  76632. * You will need to pass the name of the uniform as well as the value.
  76633. */
  76634. updateVector4: (name: string, vector: Vector4) => void;
  76635. /**
  76636. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  76637. * This is dynamic to allow compat with webgl 1 and 2.
  76638. * You will need to pass the name of the uniform as well as the value.
  76639. */
  76640. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  76641. /**
  76642. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  76643. * This is dynamic to allow compat with webgl 1 and 2.
  76644. * You will need to pass the name of the uniform as well as the value.
  76645. */
  76646. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  76647. /**
  76648. * Instantiates a new Uniform buffer objects.
  76649. *
  76650. * Handles blocks of uniform on the GPU.
  76651. *
  76652. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  76653. *
  76654. * For more information, please refer to :
  76655. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  76656. * @param engine Define the engine the buffer is associated with
  76657. * @param data Define the data contained in the buffer
  76658. * @param dynamic Define if the buffer is updatable
  76659. */
  76660. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  76661. /**
  76662. * Indicates if the buffer is using the WebGL2 UBO implementation,
  76663. * or just falling back on setUniformXXX calls.
  76664. */
  76665. readonly useUbo: boolean;
  76666. /**
  76667. * Indicates if the WebGL underlying uniform buffer is in sync
  76668. * with the javascript cache data.
  76669. */
  76670. readonly isSync: boolean;
  76671. /**
  76672. * Indicates if the WebGL underlying uniform buffer is dynamic.
  76673. * Also, a dynamic UniformBuffer will disable cache verification and always
  76674. * update the underlying WebGL uniform buffer to the GPU.
  76675. * @returns if Dynamic, otherwise false
  76676. */
  76677. isDynamic(): boolean;
  76678. /**
  76679. * The data cache on JS side.
  76680. * @returns the underlying data as a float array
  76681. */
  76682. getData(): Float32Array;
  76683. /**
  76684. * The underlying WebGL Uniform buffer.
  76685. * @returns the webgl buffer
  76686. */
  76687. getBuffer(): Nullable<DataBuffer>;
  76688. /**
  76689. * std140 layout specifies how to align data within an UBO structure.
  76690. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  76691. * for specs.
  76692. */
  76693. private _fillAlignment;
  76694. /**
  76695. * Adds an uniform in the buffer.
  76696. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  76697. * for the layout to be correct !
  76698. * @param name Name of the uniform, as used in the uniform block in the shader.
  76699. * @param size Data size, or data directly.
  76700. */
  76701. addUniform(name: string, size: number | number[]): void;
  76702. /**
  76703. * Adds a Matrix 4x4 to the uniform buffer.
  76704. * @param name Name of the uniform, as used in the uniform block in the shader.
  76705. * @param mat A 4x4 matrix.
  76706. */
  76707. addMatrix(name: string, mat: Matrix): void;
  76708. /**
  76709. * Adds a vec2 to the uniform buffer.
  76710. * @param name Name of the uniform, as used in the uniform block in the shader.
  76711. * @param x Define the x component value of the vec2
  76712. * @param y Define the y component value of the vec2
  76713. */
  76714. addFloat2(name: string, x: number, y: number): void;
  76715. /**
  76716. * Adds a vec3 to the uniform buffer.
  76717. * @param name Name of the uniform, as used in the uniform block in the shader.
  76718. * @param x Define the x component value of the vec3
  76719. * @param y Define the y component value of the vec3
  76720. * @param z Define the z component value of the vec3
  76721. */
  76722. addFloat3(name: string, x: number, y: number, z: number): void;
  76723. /**
  76724. * Adds a vec3 to the uniform buffer.
  76725. * @param name Name of the uniform, as used in the uniform block in the shader.
  76726. * @param color Define the vec3 from a Color
  76727. */
  76728. addColor3(name: string, color: Color3): void;
  76729. /**
  76730. * Adds a vec4 to the uniform buffer.
  76731. * @param name Name of the uniform, as used in the uniform block in the shader.
  76732. * @param color Define the rgb components from a Color
  76733. * @param alpha Define the a component of the vec4
  76734. */
  76735. addColor4(name: string, color: Color3, alpha: number): void;
  76736. /**
  76737. * Adds a vec3 to the uniform buffer.
  76738. * @param name Name of the uniform, as used in the uniform block in the shader.
  76739. * @param vector Define the vec3 components from a Vector
  76740. */
  76741. addVector3(name: string, vector: Vector3): void;
  76742. /**
  76743. * Adds a Matrix 3x3 to the uniform buffer.
  76744. * @param name Name of the uniform, as used in the uniform block in the shader.
  76745. */
  76746. addMatrix3x3(name: string): void;
  76747. /**
  76748. * Adds a Matrix 2x2 to the uniform buffer.
  76749. * @param name Name of the uniform, as used in the uniform block in the shader.
  76750. */
  76751. addMatrix2x2(name: string): void;
  76752. /**
  76753. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  76754. */
  76755. create(): void;
  76756. /** @hidden */
  76757. _rebuild(): void;
  76758. /**
  76759. * Updates the WebGL Uniform Buffer on the GPU.
  76760. * If the `dynamic` flag is set to true, no cache comparison is done.
  76761. * Otherwise, the buffer will be updated only if the cache differs.
  76762. */
  76763. update(): void;
  76764. /**
  76765. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  76766. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76767. * @param data Define the flattened data
  76768. * @param size Define the size of the data.
  76769. */
  76770. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  76771. private _valueCache;
  76772. private _cacheMatrix;
  76773. private _updateMatrix3x3ForUniform;
  76774. private _updateMatrix3x3ForEffect;
  76775. private _updateMatrix2x2ForEffect;
  76776. private _updateMatrix2x2ForUniform;
  76777. private _updateFloatForEffect;
  76778. private _updateFloatForUniform;
  76779. private _updateFloat2ForEffect;
  76780. private _updateFloat2ForUniform;
  76781. private _updateFloat3ForEffect;
  76782. private _updateFloat3ForUniform;
  76783. private _updateFloat4ForEffect;
  76784. private _updateFloat4ForUniform;
  76785. private _updateMatrixForEffect;
  76786. private _updateMatrixForUniform;
  76787. private _updateVector3ForEffect;
  76788. private _updateVector3ForUniform;
  76789. private _updateVector4ForEffect;
  76790. private _updateVector4ForUniform;
  76791. private _updateColor3ForEffect;
  76792. private _updateColor3ForUniform;
  76793. private _updateColor4ForEffect;
  76794. private _updateColor4ForUniform;
  76795. /**
  76796. * Sets a sampler uniform on the effect.
  76797. * @param name Define the name of the sampler.
  76798. * @param texture Define the texture to set in the sampler
  76799. */
  76800. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  76801. /**
  76802. * Directly updates the value of the uniform in the cache AND on the GPU.
  76803. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  76804. * @param data Define the flattened data
  76805. */
  76806. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  76807. /**
  76808. * Binds this uniform buffer to an effect.
  76809. * @param effect Define the effect to bind the buffer to
  76810. * @param name Name of the uniform block in the shader.
  76811. */
  76812. bindToEffect(effect: Effect, name: string): void;
  76813. /**
  76814. * Disposes the uniform buffer.
  76815. */
  76816. dispose(): void;
  76817. }
  76818. }
  76819. declare module BABYLON {
  76820. /**
  76821. * Enum that determines the text-wrapping mode to use.
  76822. */
  76823. export enum InspectableType {
  76824. /**
  76825. * Checkbox for booleans
  76826. */
  76827. Checkbox = 0,
  76828. /**
  76829. * Sliders for numbers
  76830. */
  76831. Slider = 1,
  76832. /**
  76833. * Vector3
  76834. */
  76835. Vector3 = 2,
  76836. /**
  76837. * Quaternions
  76838. */
  76839. Quaternion = 3,
  76840. /**
  76841. * Color3
  76842. */
  76843. Color3 = 4,
  76844. /**
  76845. * String
  76846. */
  76847. String = 5
  76848. }
  76849. /**
  76850. * Interface used to define custom inspectable properties.
  76851. * This interface is used by the inspector to display custom property grids
  76852. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76853. */
  76854. export interface IInspectable {
  76855. /**
  76856. * Gets the label to display
  76857. */
  76858. label: string;
  76859. /**
  76860. * Gets the name of the property to edit
  76861. */
  76862. propertyName: string;
  76863. /**
  76864. * Gets the type of the editor to use
  76865. */
  76866. type: InspectableType;
  76867. /**
  76868. * Gets the minimum value of the property when using in "slider" mode
  76869. */
  76870. min?: number;
  76871. /**
  76872. * Gets the maximum value of the property when using in "slider" mode
  76873. */
  76874. max?: number;
  76875. /**
  76876. * Gets the setp to use when using in "slider" mode
  76877. */
  76878. step?: number;
  76879. }
  76880. }
  76881. declare module BABYLON {
  76882. /**
  76883. * Class used to provide helper for timing
  76884. */
  76885. export class TimingTools {
  76886. /**
  76887. * Polyfill for setImmediate
  76888. * @param action defines the action to execute after the current execution block
  76889. */
  76890. static SetImmediate(action: () => void): void;
  76891. }
  76892. }
  76893. declare module BABYLON {
  76894. /**
  76895. * Class used to enable instatition of objects by class name
  76896. */
  76897. export class InstantiationTools {
  76898. /**
  76899. * Use this object to register external classes like custom textures or material
  76900. * to allow the laoders to instantiate them
  76901. */
  76902. static RegisteredExternalClasses: {
  76903. [key: string]: Object;
  76904. };
  76905. /**
  76906. * Tries to instantiate a new object from a given class name
  76907. * @param className defines the class name to instantiate
  76908. * @returns the new object or null if the system was not able to do the instantiation
  76909. */
  76910. static Instantiate(className: string): any;
  76911. }
  76912. }
  76913. declare module BABYLON {
  76914. /**
  76915. * Define options used to create a depth texture
  76916. */
  76917. export class DepthTextureCreationOptions {
  76918. /** Specifies whether or not a stencil should be allocated in the texture */
  76919. generateStencil?: boolean;
  76920. /** Specifies whether or not bilinear filtering is enable on the texture */
  76921. bilinearFiltering?: boolean;
  76922. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  76923. comparisonFunction?: number;
  76924. /** Specifies if the created texture is a cube texture */
  76925. isCube?: boolean;
  76926. }
  76927. }
  76928. declare module BABYLON {
  76929. interface ThinEngine {
  76930. /**
  76931. * Creates a depth stencil cube texture.
  76932. * This is only available in WebGL 2.
  76933. * @param size The size of face edge in the cube texture.
  76934. * @param options The options defining the cube texture.
  76935. * @returns The cube texture
  76936. */
  76937. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  76938. /**
  76939. * Creates a cube texture
  76940. * @param rootUrl defines the url where the files to load is located
  76941. * @param scene defines the current scene
  76942. * @param files defines the list of files to load (1 per face)
  76943. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76944. * @param onLoad defines an optional callback raised when the texture is loaded
  76945. * @param onError defines an optional callback raised if there is an issue to load the texture
  76946. * @param format defines the format of the data
  76947. * @param forcedExtension defines the extension to use to pick the right loader
  76948. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76949. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76950. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76951. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  76952. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  76953. * @returns the cube texture as an InternalTexture
  76954. */
  76955. 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;
  76956. /**
  76957. * Creates a cube texture
  76958. * @param rootUrl defines the url where the files to load is located
  76959. * @param scene defines the current scene
  76960. * @param files defines the list of files to load (1 per face)
  76961. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76962. * @param onLoad defines an optional callback raised when the texture is loaded
  76963. * @param onError defines an optional callback raised if there is an issue to load the texture
  76964. * @param format defines the format of the data
  76965. * @param forcedExtension defines the extension to use to pick the right loader
  76966. * @returns the cube texture as an InternalTexture
  76967. */
  76968. 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;
  76969. /**
  76970. * Creates a cube texture
  76971. * @param rootUrl defines the url where the files to load is located
  76972. * @param scene defines the current scene
  76973. * @param files defines the list of files to load (1 per face)
  76974. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  76975. * @param onLoad defines an optional callback raised when the texture is loaded
  76976. * @param onError defines an optional callback raised if there is an issue to load the texture
  76977. * @param format defines the format of the data
  76978. * @param forcedExtension defines the extension to use to pick the right loader
  76979. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  76980. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76981. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76982. * @returns the cube texture as an InternalTexture
  76983. */
  76984. 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;
  76985. /** @hidden */
  76986. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  76987. /** @hidden */
  76988. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  76989. /** @hidden */
  76990. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76991. /** @hidden */
  76992. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76993. /**
  76994. * @hidden
  76995. */
  76996. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76997. }
  76998. }
  76999. declare module BABYLON {
  77000. /**
  77001. * Class for creating a cube texture
  77002. */
  77003. export class CubeTexture extends BaseTexture {
  77004. private _delayedOnLoad;
  77005. /**
  77006. * The url of the texture
  77007. */
  77008. url: string;
  77009. /**
  77010. * Gets or sets the center of the bounding box associated with the cube texture.
  77011. * It must define where the camera used to render the texture was set
  77012. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  77013. */
  77014. boundingBoxPosition: Vector3;
  77015. private _boundingBoxSize;
  77016. /**
  77017. * Gets or sets the size of the bounding box associated with the cube texture
  77018. * When defined, the cubemap will switch to local mode
  77019. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77020. * @example https://www.babylonjs-playground.com/#RNASML
  77021. */
  77022. /**
  77023. * Returns the bounding box size
  77024. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  77025. */
  77026. boundingBoxSize: Vector3;
  77027. protected _rotationY: number;
  77028. /**
  77029. * Sets texture matrix rotation angle around Y axis in radians.
  77030. */
  77031. /**
  77032. * Gets texture matrix rotation angle around Y axis radians.
  77033. */
  77034. rotationY: number;
  77035. /**
  77036. * Are mip maps generated for this texture or not.
  77037. */
  77038. readonly noMipmap: boolean;
  77039. private _noMipmap;
  77040. private _files;
  77041. protected _forcedExtension: Nullable<string>;
  77042. private _extensions;
  77043. private _textureMatrix;
  77044. private _format;
  77045. private _createPolynomials;
  77046. /** @hidden */
  77047. _prefiltered: boolean;
  77048. /**
  77049. * Creates a cube texture from an array of image urls
  77050. * @param files defines an array of image urls
  77051. * @param scene defines the hosting scene
  77052. * @param noMipmap specifies if mip maps are not used
  77053. * @returns a cube texture
  77054. */
  77055. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  77056. /**
  77057. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  77058. * @param url defines the url of the prefiltered texture
  77059. * @param scene defines the scene the texture is attached to
  77060. * @param forcedExtension defines the extension of the file if different from the url
  77061. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  77062. * @return the prefiltered texture
  77063. */
  77064. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  77065. /**
  77066. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  77067. * as prefiltered data.
  77068. * @param rootUrl defines the url of the texture or the root name of the six images
  77069. * @param scene defines the scene the texture is attached to
  77070. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  77071. * @param noMipmap defines if mipmaps should be created or not
  77072. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  77073. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  77074. * @param onError defines a callback triggered in case of error during load
  77075. * @param format defines the internal format to use for the texture once loaded
  77076. * @param prefiltered defines whether or not the texture is created from prefiltered data
  77077. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  77078. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  77079. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  77080. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  77081. * @return the cube texture
  77082. */
  77083. 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);
  77084. /**
  77085. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  77086. */
  77087. readonly isPrefiltered: boolean;
  77088. /**
  77089. * Get the current class name of the texture useful for serialization or dynamic coding.
  77090. * @returns "CubeTexture"
  77091. */
  77092. getClassName(): string;
  77093. /**
  77094. * Update the url (and optional buffer) of this texture if url was null during construction.
  77095. * @param url the url of the texture
  77096. * @param forcedExtension defines the extension to use
  77097. * @param onLoad callback called when the texture is loaded (defaults to null)
  77098. */
  77099. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  77100. /**
  77101. * Delays loading of the cube texture
  77102. * @param forcedExtension defines the extension to use
  77103. */
  77104. delayLoad(forcedExtension?: string): void;
  77105. /**
  77106. * Returns the reflection texture matrix
  77107. * @returns the reflection texture matrix
  77108. */
  77109. getReflectionTextureMatrix(): Matrix;
  77110. /**
  77111. * Sets the reflection texture matrix
  77112. * @param value Reflection texture matrix
  77113. */
  77114. setReflectionTextureMatrix(value: Matrix): void;
  77115. /**
  77116. * Parses text to create a cube texture
  77117. * @param parsedTexture define the serialized text to read from
  77118. * @param scene defines the hosting scene
  77119. * @param rootUrl defines the root url of the cube texture
  77120. * @returns a cube texture
  77121. */
  77122. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  77123. /**
  77124. * Makes a clone, or deep copy, of the cube texture
  77125. * @returns a new cube texture
  77126. */
  77127. clone(): CubeTexture;
  77128. }
  77129. }
  77130. declare module BABYLON {
  77131. /**
  77132. * Manages the defines for the Material
  77133. */
  77134. export class MaterialDefines {
  77135. /** @hidden */
  77136. protected _keys: string[];
  77137. private _isDirty;
  77138. /** @hidden */
  77139. _renderId: number;
  77140. /** @hidden */
  77141. _areLightsDirty: boolean;
  77142. /** @hidden */
  77143. _areLightsDisposed: boolean;
  77144. /** @hidden */
  77145. _areAttributesDirty: boolean;
  77146. /** @hidden */
  77147. _areTexturesDirty: boolean;
  77148. /** @hidden */
  77149. _areFresnelDirty: boolean;
  77150. /** @hidden */
  77151. _areMiscDirty: boolean;
  77152. /** @hidden */
  77153. _areImageProcessingDirty: boolean;
  77154. /** @hidden */
  77155. _normals: boolean;
  77156. /** @hidden */
  77157. _uvs: boolean;
  77158. /** @hidden */
  77159. _needNormals: boolean;
  77160. /** @hidden */
  77161. _needUVs: boolean;
  77162. [id: string]: any;
  77163. /**
  77164. * Specifies if the material needs to be re-calculated
  77165. */
  77166. readonly isDirty: boolean;
  77167. /**
  77168. * Marks the material to indicate that it has been re-calculated
  77169. */
  77170. markAsProcessed(): void;
  77171. /**
  77172. * Marks the material to indicate that it needs to be re-calculated
  77173. */
  77174. markAsUnprocessed(): void;
  77175. /**
  77176. * Marks the material to indicate all of its defines need to be re-calculated
  77177. */
  77178. markAllAsDirty(): void;
  77179. /**
  77180. * Marks the material to indicate that image processing needs to be re-calculated
  77181. */
  77182. markAsImageProcessingDirty(): void;
  77183. /**
  77184. * Marks the material to indicate the lights need to be re-calculated
  77185. * @param disposed Defines whether the light is dirty due to dispose or not
  77186. */
  77187. markAsLightDirty(disposed?: boolean): void;
  77188. /**
  77189. * Marks the attribute state as changed
  77190. */
  77191. markAsAttributesDirty(): void;
  77192. /**
  77193. * Marks the texture state as changed
  77194. */
  77195. markAsTexturesDirty(): void;
  77196. /**
  77197. * Marks the fresnel state as changed
  77198. */
  77199. markAsFresnelDirty(): void;
  77200. /**
  77201. * Marks the misc state as changed
  77202. */
  77203. markAsMiscDirty(): void;
  77204. /**
  77205. * Rebuilds the material defines
  77206. */
  77207. rebuild(): void;
  77208. /**
  77209. * Specifies if two material defines are equal
  77210. * @param other - A material define instance to compare to
  77211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  77212. */
  77213. isEqual(other: MaterialDefines): boolean;
  77214. /**
  77215. * Clones this instance's defines to another instance
  77216. * @param other - material defines to clone values to
  77217. */
  77218. cloneTo(other: MaterialDefines): void;
  77219. /**
  77220. * Resets the material define values
  77221. */
  77222. reset(): void;
  77223. /**
  77224. * Converts the material define values to a string
  77225. * @returns - String of material define information
  77226. */
  77227. toString(): string;
  77228. }
  77229. }
  77230. declare module BABYLON {
  77231. /**
  77232. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  77233. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  77234. * 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;
  77235. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  77236. */
  77237. export class ColorCurves {
  77238. private _dirty;
  77239. private _tempColor;
  77240. private _globalCurve;
  77241. private _highlightsCurve;
  77242. private _midtonesCurve;
  77243. private _shadowsCurve;
  77244. private _positiveCurve;
  77245. private _negativeCurve;
  77246. private _globalHue;
  77247. private _globalDensity;
  77248. private _globalSaturation;
  77249. private _globalExposure;
  77250. /**
  77251. * Gets the global Hue value.
  77252. * 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).
  77253. */
  77254. /**
  77255. * Sets the global Hue value.
  77256. * 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).
  77257. */
  77258. globalHue: number;
  77259. /**
  77260. * Gets the global Density value.
  77261. * 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.
  77262. * Values less than zero provide a filter of opposite hue.
  77263. */
  77264. /**
  77265. * Sets the global Density value.
  77266. * 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.
  77267. * Values less than zero provide a filter of opposite hue.
  77268. */
  77269. globalDensity: number;
  77270. /**
  77271. * Gets the global Saturation value.
  77272. * 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.
  77273. */
  77274. /**
  77275. * Sets the global Saturation value.
  77276. * 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.
  77277. */
  77278. globalSaturation: number;
  77279. /**
  77280. * Gets the global Exposure value.
  77281. * 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.
  77282. */
  77283. /**
  77284. * Sets the global Exposure value.
  77285. * 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.
  77286. */
  77287. globalExposure: number;
  77288. private _highlightsHue;
  77289. private _highlightsDensity;
  77290. private _highlightsSaturation;
  77291. private _highlightsExposure;
  77292. /**
  77293. * Gets the highlights Hue value.
  77294. * 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).
  77295. */
  77296. /**
  77297. * Sets the highlights Hue value.
  77298. * 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).
  77299. */
  77300. highlightsHue: number;
  77301. /**
  77302. * Gets the highlights Density value.
  77303. * 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.
  77304. * Values less than zero provide a filter of opposite hue.
  77305. */
  77306. /**
  77307. * Sets the highlights Density value.
  77308. * 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.
  77309. * Values less than zero provide a filter of opposite hue.
  77310. */
  77311. highlightsDensity: number;
  77312. /**
  77313. * Gets the highlights Saturation value.
  77314. * 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.
  77315. */
  77316. /**
  77317. * Sets the highlights Saturation value.
  77318. * 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.
  77319. */
  77320. highlightsSaturation: number;
  77321. /**
  77322. * Gets the highlights Exposure value.
  77323. * 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.
  77324. */
  77325. /**
  77326. * Sets the highlights Exposure value.
  77327. * 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.
  77328. */
  77329. highlightsExposure: number;
  77330. private _midtonesHue;
  77331. private _midtonesDensity;
  77332. private _midtonesSaturation;
  77333. private _midtonesExposure;
  77334. /**
  77335. * Gets the midtones Hue value.
  77336. * 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).
  77337. */
  77338. /**
  77339. * Sets the midtones Hue value.
  77340. * 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).
  77341. */
  77342. midtonesHue: number;
  77343. /**
  77344. * Gets the midtones Density value.
  77345. * 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.
  77346. * Values less than zero provide a filter of opposite hue.
  77347. */
  77348. /**
  77349. * Sets the midtones Density value.
  77350. * 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.
  77351. * Values less than zero provide a filter of opposite hue.
  77352. */
  77353. midtonesDensity: number;
  77354. /**
  77355. * Gets the midtones Saturation value.
  77356. * 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.
  77357. */
  77358. /**
  77359. * Sets the midtones Saturation value.
  77360. * 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.
  77361. */
  77362. midtonesSaturation: number;
  77363. /**
  77364. * Gets the midtones Exposure value.
  77365. * 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.
  77366. */
  77367. /**
  77368. * Sets the midtones Exposure value.
  77369. * 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.
  77370. */
  77371. midtonesExposure: number;
  77372. private _shadowsHue;
  77373. private _shadowsDensity;
  77374. private _shadowsSaturation;
  77375. private _shadowsExposure;
  77376. /**
  77377. * Gets the shadows Hue value.
  77378. * 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).
  77379. */
  77380. /**
  77381. * Sets the shadows Hue value.
  77382. * 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).
  77383. */
  77384. shadowsHue: number;
  77385. /**
  77386. * Gets the shadows Density value.
  77387. * 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.
  77388. * Values less than zero provide a filter of opposite hue.
  77389. */
  77390. /**
  77391. * Sets the shadows Density value.
  77392. * 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.
  77393. * Values less than zero provide a filter of opposite hue.
  77394. */
  77395. shadowsDensity: number;
  77396. /**
  77397. * Gets the shadows Saturation value.
  77398. * 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.
  77399. */
  77400. /**
  77401. * Sets the shadows Saturation value.
  77402. * 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.
  77403. */
  77404. shadowsSaturation: number;
  77405. /**
  77406. * Gets the shadows Exposure value.
  77407. * 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.
  77408. */
  77409. /**
  77410. * Sets the shadows Exposure value.
  77411. * 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.
  77412. */
  77413. shadowsExposure: number;
  77414. /**
  77415. * Returns the class name
  77416. * @returns The class name
  77417. */
  77418. getClassName(): string;
  77419. /**
  77420. * Binds the color curves to the shader.
  77421. * @param colorCurves The color curve to bind
  77422. * @param effect The effect to bind to
  77423. * @param positiveUniform The positive uniform shader parameter
  77424. * @param neutralUniform The neutral uniform shader parameter
  77425. * @param negativeUniform The negative uniform shader parameter
  77426. */
  77427. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  77428. /**
  77429. * Prepare the list of uniforms associated with the ColorCurves effects.
  77430. * @param uniformsList The list of uniforms used in the effect
  77431. */
  77432. static PrepareUniforms(uniformsList: string[]): void;
  77433. /**
  77434. * Returns color grading data based on a hue, density, saturation and exposure value.
  77435. * @param filterHue The hue of the color filter.
  77436. * @param filterDensity The density of the color filter.
  77437. * @param saturation The saturation.
  77438. * @param exposure The exposure.
  77439. * @param result The result data container.
  77440. */
  77441. private getColorGradingDataToRef;
  77442. /**
  77443. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  77444. * @param value The input slider value in range [-100,100].
  77445. * @returns Adjusted value.
  77446. */
  77447. private static applyColorGradingSliderNonlinear;
  77448. /**
  77449. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  77450. * @param hue The hue (H) input.
  77451. * @param saturation The saturation (S) input.
  77452. * @param brightness The brightness (B) input.
  77453. * @result An RGBA color represented as Vector4.
  77454. */
  77455. private static fromHSBToRef;
  77456. /**
  77457. * Returns a value clamped between min and max
  77458. * @param value The value to clamp
  77459. * @param min The minimum of value
  77460. * @param max The maximum of value
  77461. * @returns The clamped value.
  77462. */
  77463. private static clamp;
  77464. /**
  77465. * Clones the current color curve instance.
  77466. * @return The cloned curves
  77467. */
  77468. clone(): ColorCurves;
  77469. /**
  77470. * Serializes the current color curve instance to a json representation.
  77471. * @return a JSON representation
  77472. */
  77473. serialize(): any;
  77474. /**
  77475. * Parses the color curve from a json representation.
  77476. * @param source the JSON source to parse
  77477. * @return The parsed curves
  77478. */
  77479. static Parse(source: any): ColorCurves;
  77480. }
  77481. }
  77482. declare module BABYLON {
  77483. /**
  77484. * Interface to follow in your material defines to integrate easily the
  77485. * Image proccessing functions.
  77486. * @hidden
  77487. */
  77488. export interface IImageProcessingConfigurationDefines {
  77489. IMAGEPROCESSING: boolean;
  77490. VIGNETTE: boolean;
  77491. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77492. VIGNETTEBLENDMODEOPAQUE: boolean;
  77493. TONEMAPPING: boolean;
  77494. TONEMAPPING_ACES: boolean;
  77495. CONTRAST: boolean;
  77496. EXPOSURE: boolean;
  77497. COLORCURVES: boolean;
  77498. COLORGRADING: boolean;
  77499. COLORGRADING3D: boolean;
  77500. SAMPLER3DGREENDEPTH: boolean;
  77501. SAMPLER3DBGRMAP: boolean;
  77502. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77503. }
  77504. /**
  77505. * @hidden
  77506. */
  77507. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  77508. IMAGEPROCESSING: boolean;
  77509. VIGNETTE: boolean;
  77510. VIGNETTEBLENDMODEMULTIPLY: boolean;
  77511. VIGNETTEBLENDMODEOPAQUE: boolean;
  77512. TONEMAPPING: boolean;
  77513. TONEMAPPING_ACES: boolean;
  77514. CONTRAST: boolean;
  77515. COLORCURVES: boolean;
  77516. COLORGRADING: boolean;
  77517. COLORGRADING3D: boolean;
  77518. SAMPLER3DGREENDEPTH: boolean;
  77519. SAMPLER3DBGRMAP: boolean;
  77520. IMAGEPROCESSINGPOSTPROCESS: boolean;
  77521. EXPOSURE: boolean;
  77522. constructor();
  77523. }
  77524. /**
  77525. * This groups together the common properties used for image processing either in direct forward pass
  77526. * or through post processing effect depending on the use of the image processing pipeline in your scene
  77527. * or not.
  77528. */
  77529. export class ImageProcessingConfiguration {
  77530. /**
  77531. * Default tone mapping applied in BabylonJS.
  77532. */
  77533. static readonly TONEMAPPING_STANDARD: number;
  77534. /**
  77535. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  77536. * to other engines rendering to increase portability.
  77537. */
  77538. static readonly TONEMAPPING_ACES: number;
  77539. /**
  77540. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  77541. */
  77542. colorCurves: Nullable<ColorCurves>;
  77543. private _colorCurvesEnabled;
  77544. /**
  77545. * Gets wether the color curves effect is enabled.
  77546. */
  77547. /**
  77548. * Sets wether the color curves effect is enabled.
  77549. */
  77550. colorCurvesEnabled: boolean;
  77551. private _colorGradingTexture;
  77552. /**
  77553. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77554. */
  77555. /**
  77556. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  77557. */
  77558. colorGradingTexture: Nullable<BaseTexture>;
  77559. private _colorGradingEnabled;
  77560. /**
  77561. * Gets wether the color grading effect is enabled.
  77562. */
  77563. /**
  77564. * Sets wether the color grading effect is enabled.
  77565. */
  77566. colorGradingEnabled: boolean;
  77567. private _colorGradingWithGreenDepth;
  77568. /**
  77569. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  77570. */
  77571. /**
  77572. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  77573. */
  77574. colorGradingWithGreenDepth: boolean;
  77575. private _colorGradingBGR;
  77576. /**
  77577. * Gets wether the color grading texture contains BGR values.
  77578. */
  77579. /**
  77580. * Sets wether the color grading texture contains BGR values.
  77581. */
  77582. colorGradingBGR: boolean;
  77583. /** @hidden */
  77584. _exposure: number;
  77585. /**
  77586. * Gets the Exposure used in the effect.
  77587. */
  77588. /**
  77589. * Sets the Exposure used in the effect.
  77590. */
  77591. exposure: number;
  77592. private _toneMappingEnabled;
  77593. /**
  77594. * Gets wether the tone mapping effect is enabled.
  77595. */
  77596. /**
  77597. * Sets wether the tone mapping effect is enabled.
  77598. */
  77599. toneMappingEnabled: boolean;
  77600. private _toneMappingType;
  77601. /**
  77602. * Gets the type of tone mapping effect.
  77603. */
  77604. /**
  77605. * Sets the type of tone mapping effect used in BabylonJS.
  77606. */
  77607. toneMappingType: number;
  77608. protected _contrast: number;
  77609. /**
  77610. * Gets the contrast used in the effect.
  77611. */
  77612. /**
  77613. * Sets the contrast used in the effect.
  77614. */
  77615. contrast: number;
  77616. /**
  77617. * Vignette stretch size.
  77618. */
  77619. vignetteStretch: number;
  77620. /**
  77621. * Vignette centre X Offset.
  77622. */
  77623. vignetteCentreX: number;
  77624. /**
  77625. * Vignette centre Y Offset.
  77626. */
  77627. vignetteCentreY: number;
  77628. /**
  77629. * Vignette weight or intensity of the vignette effect.
  77630. */
  77631. vignetteWeight: number;
  77632. /**
  77633. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  77634. * if vignetteEnabled is set to true.
  77635. */
  77636. vignetteColor: Color4;
  77637. /**
  77638. * Camera field of view used by the Vignette effect.
  77639. */
  77640. vignetteCameraFov: number;
  77641. private _vignetteBlendMode;
  77642. /**
  77643. * Gets the vignette blend mode allowing different kind of effect.
  77644. */
  77645. /**
  77646. * Sets the vignette blend mode allowing different kind of effect.
  77647. */
  77648. vignetteBlendMode: number;
  77649. private _vignetteEnabled;
  77650. /**
  77651. * Gets wether the vignette effect is enabled.
  77652. */
  77653. /**
  77654. * Sets wether the vignette effect is enabled.
  77655. */
  77656. vignetteEnabled: boolean;
  77657. private _applyByPostProcess;
  77658. /**
  77659. * Gets wether the image processing is applied through a post process or not.
  77660. */
  77661. /**
  77662. * Sets wether the image processing is applied through a post process or not.
  77663. */
  77664. applyByPostProcess: boolean;
  77665. private _isEnabled;
  77666. /**
  77667. * Gets wether the image processing is enabled or not.
  77668. */
  77669. /**
  77670. * Sets wether the image processing is enabled or not.
  77671. */
  77672. isEnabled: boolean;
  77673. /**
  77674. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  77675. */
  77676. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  77677. /**
  77678. * Method called each time the image processing information changes requires to recompile the effect.
  77679. */
  77680. protected _updateParameters(): void;
  77681. /**
  77682. * Gets the current class name.
  77683. * @return "ImageProcessingConfiguration"
  77684. */
  77685. getClassName(): string;
  77686. /**
  77687. * Prepare the list of uniforms associated with the Image Processing effects.
  77688. * @param uniforms The list of uniforms used in the effect
  77689. * @param defines the list of defines currently in use
  77690. */
  77691. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  77692. /**
  77693. * Prepare the list of samplers associated with the Image Processing effects.
  77694. * @param samplersList The list of uniforms used in the effect
  77695. * @param defines the list of defines currently in use
  77696. */
  77697. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  77698. /**
  77699. * Prepare the list of defines associated to the shader.
  77700. * @param defines the list of defines to complete
  77701. * @param forPostProcess Define if we are currently in post process mode or not
  77702. */
  77703. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  77704. /**
  77705. * Returns true if all the image processing information are ready.
  77706. * @returns True if ready, otherwise, false
  77707. */
  77708. isReady(): boolean;
  77709. /**
  77710. * Binds the image processing to the shader.
  77711. * @param effect The effect to bind to
  77712. * @param overrideAspectRatio Override the aspect ratio of the effect
  77713. */
  77714. bind(effect: Effect, overrideAspectRatio?: number): void;
  77715. /**
  77716. * Clones the current image processing instance.
  77717. * @return The cloned image processing
  77718. */
  77719. clone(): ImageProcessingConfiguration;
  77720. /**
  77721. * Serializes the current image processing instance to a json representation.
  77722. * @return a JSON representation
  77723. */
  77724. serialize(): any;
  77725. /**
  77726. * Parses the image processing from a json representation.
  77727. * @param source the JSON source to parse
  77728. * @return The parsed image processing
  77729. */
  77730. static Parse(source: any): ImageProcessingConfiguration;
  77731. private static _VIGNETTEMODE_MULTIPLY;
  77732. private static _VIGNETTEMODE_OPAQUE;
  77733. /**
  77734. * Used to apply the vignette as a mix with the pixel color.
  77735. */
  77736. static readonly VIGNETTEMODE_MULTIPLY: number;
  77737. /**
  77738. * Used to apply the vignette as a replacement of the pixel color.
  77739. */
  77740. static readonly VIGNETTEMODE_OPAQUE: number;
  77741. }
  77742. }
  77743. declare module BABYLON {
  77744. /** @hidden */
  77745. export var postprocessVertexShader: {
  77746. name: string;
  77747. shader: string;
  77748. };
  77749. }
  77750. declare module BABYLON {
  77751. interface ThinEngine {
  77752. /**
  77753. * Creates a new render target texture
  77754. * @param size defines the size of the texture
  77755. * @param options defines the options used to create the texture
  77756. * @returns a new render target texture stored in an InternalTexture
  77757. */
  77758. createRenderTargetTexture(size: number | {
  77759. width: number;
  77760. height: number;
  77761. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  77762. /**
  77763. * Creates a depth stencil texture.
  77764. * This is only available in WebGL 2 or with the depth texture extension available.
  77765. * @param size The size of face edge in the texture.
  77766. * @param options The options defining the texture.
  77767. * @returns The texture
  77768. */
  77769. createDepthStencilTexture(size: number | {
  77770. width: number;
  77771. height: number;
  77772. }, options: DepthTextureCreationOptions): InternalTexture;
  77773. /** @hidden */
  77774. _createDepthStencilTexture(size: number | {
  77775. width: number;
  77776. height: number;
  77777. }, options: DepthTextureCreationOptions): InternalTexture;
  77778. }
  77779. }
  77780. declare module BABYLON {
  77781. /** Defines supported spaces */
  77782. export enum Space {
  77783. /** Local (object) space */
  77784. LOCAL = 0,
  77785. /** World space */
  77786. WORLD = 1,
  77787. /** Bone space */
  77788. BONE = 2
  77789. }
  77790. /** Defines the 3 main axes */
  77791. export class Axis {
  77792. /** X axis */
  77793. static X: Vector3;
  77794. /** Y axis */
  77795. static Y: Vector3;
  77796. /** Z axis */
  77797. static Z: Vector3;
  77798. }
  77799. }
  77800. declare module BABYLON {
  77801. /**
  77802. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  77803. * This is the base of the follow, arc rotate cameras and Free camera
  77804. * @see http://doc.babylonjs.com/features/cameras
  77805. */
  77806. export class TargetCamera extends Camera {
  77807. private static _RigCamTransformMatrix;
  77808. private static _TargetTransformMatrix;
  77809. private static _TargetFocalPoint;
  77810. /**
  77811. * Define the current direction the camera is moving to
  77812. */
  77813. cameraDirection: Vector3;
  77814. /**
  77815. * Define the current rotation the camera is rotating to
  77816. */
  77817. cameraRotation: Vector2;
  77818. /**
  77819. * When set, the up vector of the camera will be updated by the rotation of the camera
  77820. */
  77821. updateUpVectorFromRotation: boolean;
  77822. private _tmpQuaternion;
  77823. /**
  77824. * Define the current rotation of the camera
  77825. */
  77826. rotation: Vector3;
  77827. /**
  77828. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  77829. */
  77830. rotationQuaternion: Quaternion;
  77831. /**
  77832. * Define the current speed of the camera
  77833. */
  77834. speed: number;
  77835. /**
  77836. * Add constraint to the camera to prevent it to move freely in all directions and
  77837. * around all axis.
  77838. */
  77839. noRotationConstraint: boolean;
  77840. /**
  77841. * Define the current target of the camera as an object or a position.
  77842. */
  77843. lockedTarget: any;
  77844. /** @hidden */
  77845. _currentTarget: Vector3;
  77846. /** @hidden */
  77847. _initialFocalDistance: number;
  77848. /** @hidden */
  77849. _viewMatrix: Matrix;
  77850. /** @hidden */
  77851. _camMatrix: Matrix;
  77852. /** @hidden */
  77853. _cameraTransformMatrix: Matrix;
  77854. /** @hidden */
  77855. _cameraRotationMatrix: Matrix;
  77856. /** @hidden */
  77857. _referencePoint: Vector3;
  77858. /** @hidden */
  77859. _transformedReferencePoint: Vector3;
  77860. protected _globalCurrentTarget: Vector3;
  77861. protected _globalCurrentUpVector: Vector3;
  77862. /** @hidden */
  77863. _reset: () => void;
  77864. private _defaultUp;
  77865. /**
  77866. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  77867. * This is the base of the follow, arc rotate cameras and Free camera
  77868. * @see http://doc.babylonjs.com/features/cameras
  77869. * @param name Defines the name of the camera in the scene
  77870. * @param position Defines the start position of the camera in the scene
  77871. * @param scene Defines the scene the camera belongs to
  77872. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77873. */
  77874. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77875. /**
  77876. * Gets the position in front of the camera at a given distance.
  77877. * @param distance The distance from the camera we want the position to be
  77878. * @returns the position
  77879. */
  77880. getFrontPosition(distance: number): Vector3;
  77881. /** @hidden */
  77882. _getLockedTargetPosition(): Nullable<Vector3>;
  77883. private _storedPosition;
  77884. private _storedRotation;
  77885. private _storedRotationQuaternion;
  77886. /**
  77887. * Store current camera state of the camera (fov, position, rotation, etc..)
  77888. * @returns the camera
  77889. */
  77890. storeState(): Camera;
  77891. /**
  77892. * Restored camera state. You must call storeState() first
  77893. * @returns whether it was successful or not
  77894. * @hidden
  77895. */
  77896. _restoreStateValues(): boolean;
  77897. /** @hidden */
  77898. _initCache(): void;
  77899. /** @hidden */
  77900. _updateCache(ignoreParentClass?: boolean): void;
  77901. /** @hidden */
  77902. _isSynchronizedViewMatrix(): boolean;
  77903. /** @hidden */
  77904. _computeLocalCameraSpeed(): number;
  77905. /**
  77906. * Defines the target the camera should look at.
  77907. * @param target Defines the new target as a Vector or a mesh
  77908. */
  77909. setTarget(target: Vector3): void;
  77910. /**
  77911. * Return the current target position of the camera. This value is expressed in local space.
  77912. * @returns the target position
  77913. */
  77914. getTarget(): Vector3;
  77915. /** @hidden */
  77916. _decideIfNeedsToMove(): boolean;
  77917. /** @hidden */
  77918. _updatePosition(): void;
  77919. /** @hidden */
  77920. _checkInputs(): void;
  77921. protected _updateCameraRotationMatrix(): void;
  77922. /**
  77923. * 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)
  77924. * @returns the current camera
  77925. */
  77926. private _rotateUpVectorWithCameraRotationMatrix;
  77927. private _cachedRotationZ;
  77928. private _cachedQuaternionRotationZ;
  77929. /** @hidden */
  77930. _getViewMatrix(): Matrix;
  77931. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  77932. /**
  77933. * @hidden
  77934. */
  77935. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  77936. /**
  77937. * @hidden
  77938. */
  77939. _updateRigCameras(): void;
  77940. private _getRigCamPositionAndTarget;
  77941. /**
  77942. * Gets the current object class name.
  77943. * @return the class name
  77944. */
  77945. getClassName(): string;
  77946. }
  77947. }
  77948. declare module BABYLON {
  77949. /**
  77950. * Gather the list of keyboard event types as constants.
  77951. */
  77952. export class KeyboardEventTypes {
  77953. /**
  77954. * The keydown event is fired when a key becomes active (pressed).
  77955. */
  77956. static readonly KEYDOWN: number;
  77957. /**
  77958. * The keyup event is fired when a key has been released.
  77959. */
  77960. static readonly KEYUP: number;
  77961. }
  77962. /**
  77963. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77964. */
  77965. export class KeyboardInfo {
  77966. /**
  77967. * Defines the type of event (KeyboardEventTypes)
  77968. */
  77969. type: number;
  77970. /**
  77971. * Defines the related dom event
  77972. */
  77973. event: KeyboardEvent;
  77974. /**
  77975. * Instantiates a new keyboard info.
  77976. * This class is used to store keyboard related info for the onKeyboardObservable event.
  77977. * @param type Defines the type of event (KeyboardEventTypes)
  77978. * @param event Defines the related dom event
  77979. */
  77980. constructor(
  77981. /**
  77982. * Defines the type of event (KeyboardEventTypes)
  77983. */
  77984. type: number,
  77985. /**
  77986. * Defines the related dom event
  77987. */
  77988. event: KeyboardEvent);
  77989. }
  77990. /**
  77991. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77992. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77993. */
  77994. export class KeyboardInfoPre extends KeyboardInfo {
  77995. /**
  77996. * Defines the type of event (KeyboardEventTypes)
  77997. */
  77998. type: number;
  77999. /**
  78000. * Defines the related dom event
  78001. */
  78002. event: KeyboardEvent;
  78003. /**
  78004. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  78005. */
  78006. skipOnPointerObservable: boolean;
  78007. /**
  78008. * Instantiates a new keyboard pre info.
  78009. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  78010. * @param type Defines the type of event (KeyboardEventTypes)
  78011. * @param event Defines the related dom event
  78012. */
  78013. constructor(
  78014. /**
  78015. * Defines the type of event (KeyboardEventTypes)
  78016. */
  78017. type: number,
  78018. /**
  78019. * Defines the related dom event
  78020. */
  78021. event: KeyboardEvent);
  78022. }
  78023. }
  78024. declare module BABYLON {
  78025. /**
  78026. * Manage the keyboard inputs to control the movement of a free camera.
  78027. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78028. */
  78029. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  78030. /**
  78031. * Defines the camera the input is attached to.
  78032. */
  78033. camera: FreeCamera;
  78034. /**
  78035. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78036. */
  78037. keysUp: number[];
  78038. /**
  78039. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78040. */
  78041. keysDown: number[];
  78042. /**
  78043. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78044. */
  78045. keysLeft: number[];
  78046. /**
  78047. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78048. */
  78049. keysRight: number[];
  78050. private _keys;
  78051. private _onCanvasBlurObserver;
  78052. private _onKeyboardObserver;
  78053. private _engine;
  78054. private _scene;
  78055. /**
  78056. * Attach the input controls to a specific dom element to get the input from.
  78057. * @param element Defines the element the controls should be listened from
  78058. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78059. */
  78060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78061. /**
  78062. * Detach the current controls from the specified dom element.
  78063. * @param element Defines the element to stop listening the inputs from
  78064. */
  78065. detachControl(element: Nullable<HTMLElement>): void;
  78066. /**
  78067. * Update the current camera state depending on the inputs that have been used this frame.
  78068. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78069. */
  78070. checkInputs(): void;
  78071. /**
  78072. * Gets the class name of the current intput.
  78073. * @returns the class name
  78074. */
  78075. getClassName(): string;
  78076. /** @hidden */
  78077. _onLostFocus(): void;
  78078. /**
  78079. * Get the friendly name associated with the input class.
  78080. * @returns the input friendly name
  78081. */
  78082. getSimpleName(): string;
  78083. }
  78084. }
  78085. declare module BABYLON {
  78086. /**
  78087. * Interface describing all the common properties and methods a shadow light needs to implement.
  78088. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  78089. * as well as binding the different shadow properties to the effects.
  78090. */
  78091. export interface IShadowLight extends Light {
  78092. /**
  78093. * The light id in the scene (used in scene.findLighById for instance)
  78094. */
  78095. id: string;
  78096. /**
  78097. * The position the shdow will be casted from.
  78098. */
  78099. position: Vector3;
  78100. /**
  78101. * In 2d mode (needCube being false), the direction used to cast the shadow.
  78102. */
  78103. direction: Vector3;
  78104. /**
  78105. * The transformed position. Position of the light in world space taking parenting in account.
  78106. */
  78107. transformedPosition: Vector3;
  78108. /**
  78109. * The transformed direction. Direction of the light in world space taking parenting in account.
  78110. */
  78111. transformedDirection: Vector3;
  78112. /**
  78113. * The friendly name of the light in the scene.
  78114. */
  78115. name: string;
  78116. /**
  78117. * Defines the shadow projection clipping minimum z value.
  78118. */
  78119. shadowMinZ: number;
  78120. /**
  78121. * Defines the shadow projection clipping maximum z value.
  78122. */
  78123. shadowMaxZ: number;
  78124. /**
  78125. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78126. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78127. */
  78128. computeTransformedInformation(): boolean;
  78129. /**
  78130. * Gets the scene the light belongs to.
  78131. * @returns The scene
  78132. */
  78133. getScene(): Scene;
  78134. /**
  78135. * Callback defining a custom Projection Matrix Builder.
  78136. * This can be used to override the default projection matrix computation.
  78137. */
  78138. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78139. /**
  78140. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78141. * @param matrix The materix to updated with the projection information
  78142. * @param viewMatrix The transform matrix of the light
  78143. * @param renderList The list of mesh to render in the map
  78144. * @returns The current light
  78145. */
  78146. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78147. /**
  78148. * Gets the current depth scale used in ESM.
  78149. * @returns The scale
  78150. */
  78151. getDepthScale(): number;
  78152. /**
  78153. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78154. * @returns true if a cube texture needs to be use
  78155. */
  78156. needCube(): boolean;
  78157. /**
  78158. * Detects if the projection matrix requires to be recomputed this frame.
  78159. * @returns true if it requires to be recomputed otherwise, false.
  78160. */
  78161. needProjectionMatrixCompute(): boolean;
  78162. /**
  78163. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78164. */
  78165. forceProjectionMatrixCompute(): void;
  78166. /**
  78167. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78168. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78169. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78170. */
  78171. getShadowDirection(faceIndex?: number): Vector3;
  78172. /**
  78173. * Gets the minZ used for shadow according to both the scene and the light.
  78174. * @param activeCamera The camera we are returning the min for
  78175. * @returns the depth min z
  78176. */
  78177. getDepthMinZ(activeCamera: Camera): number;
  78178. /**
  78179. * Gets the maxZ used for shadow according to both the scene and the light.
  78180. * @param activeCamera The camera we are returning the max for
  78181. * @returns the depth max z
  78182. */
  78183. getDepthMaxZ(activeCamera: Camera): number;
  78184. }
  78185. /**
  78186. * Base implementation IShadowLight
  78187. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  78188. */
  78189. export abstract class ShadowLight extends Light implements IShadowLight {
  78190. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  78191. protected _position: Vector3;
  78192. protected _setPosition(value: Vector3): void;
  78193. /**
  78194. * Sets the position the shadow will be casted from. Also use as the light position for both
  78195. * point and spot lights.
  78196. */
  78197. /**
  78198. * Sets the position the shadow will be casted from. Also use as the light position for both
  78199. * point and spot lights.
  78200. */
  78201. position: Vector3;
  78202. protected _direction: Vector3;
  78203. protected _setDirection(value: Vector3): void;
  78204. /**
  78205. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  78206. * Also use as the light direction on spot and directional lights.
  78207. */
  78208. /**
  78209. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  78210. * Also use as the light direction on spot and directional lights.
  78211. */
  78212. direction: Vector3;
  78213. private _shadowMinZ;
  78214. /**
  78215. * Gets the shadow projection clipping minimum z value.
  78216. */
  78217. /**
  78218. * Sets the shadow projection clipping minimum z value.
  78219. */
  78220. shadowMinZ: number;
  78221. private _shadowMaxZ;
  78222. /**
  78223. * Sets the shadow projection clipping maximum z value.
  78224. */
  78225. /**
  78226. * Gets the shadow projection clipping maximum z value.
  78227. */
  78228. shadowMaxZ: number;
  78229. /**
  78230. * Callback defining a custom Projection Matrix Builder.
  78231. * This can be used to override the default projection matrix computation.
  78232. */
  78233. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  78234. /**
  78235. * The transformed position. Position of the light in world space taking parenting in account.
  78236. */
  78237. transformedPosition: Vector3;
  78238. /**
  78239. * The transformed direction. Direction of the light in world space taking parenting in account.
  78240. */
  78241. transformedDirection: Vector3;
  78242. private _needProjectionMatrixCompute;
  78243. /**
  78244. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  78245. * @returns true if the information has been computed, false if it does not need to (no parenting)
  78246. */
  78247. computeTransformedInformation(): boolean;
  78248. /**
  78249. * Return the depth scale used for the shadow map.
  78250. * @returns the depth scale.
  78251. */
  78252. getDepthScale(): number;
  78253. /**
  78254. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  78255. * @param faceIndex The index of the face we are computed the direction to generate shadow
  78256. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  78257. */
  78258. getShadowDirection(faceIndex?: number): Vector3;
  78259. /**
  78260. * Returns the ShadowLight absolute position in the World.
  78261. * @returns the position vector in world space
  78262. */
  78263. getAbsolutePosition(): Vector3;
  78264. /**
  78265. * Sets the ShadowLight direction toward the passed target.
  78266. * @param target The point to target in local space
  78267. * @returns the updated ShadowLight direction
  78268. */
  78269. setDirectionToTarget(target: Vector3): Vector3;
  78270. /**
  78271. * Returns the light rotation in euler definition.
  78272. * @returns the x y z rotation in local space.
  78273. */
  78274. getRotation(): Vector3;
  78275. /**
  78276. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  78277. * @returns true if a cube texture needs to be use
  78278. */
  78279. needCube(): boolean;
  78280. /**
  78281. * Detects if the projection matrix requires to be recomputed this frame.
  78282. * @returns true if it requires to be recomputed otherwise, false.
  78283. */
  78284. needProjectionMatrixCompute(): boolean;
  78285. /**
  78286. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  78287. */
  78288. forceProjectionMatrixCompute(): void;
  78289. /** @hidden */
  78290. _initCache(): void;
  78291. /** @hidden */
  78292. _isSynchronized(): boolean;
  78293. /**
  78294. * Computes the world matrix of the node
  78295. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78296. * @returns the world matrix
  78297. */
  78298. computeWorldMatrix(force?: boolean): Matrix;
  78299. /**
  78300. * Gets the minZ used for shadow according to both the scene and the light.
  78301. * @param activeCamera The camera we are returning the min for
  78302. * @returns the depth min z
  78303. */
  78304. getDepthMinZ(activeCamera: Camera): number;
  78305. /**
  78306. * Gets the maxZ used for shadow according to both the scene and the light.
  78307. * @param activeCamera The camera we are returning the max for
  78308. * @returns the depth max z
  78309. */
  78310. getDepthMaxZ(activeCamera: Camera): number;
  78311. /**
  78312. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  78313. * @param matrix The materix to updated with the projection information
  78314. * @param viewMatrix The transform matrix of the light
  78315. * @param renderList The list of mesh to render in the map
  78316. * @returns The current light
  78317. */
  78318. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  78319. }
  78320. }
  78321. declare module BABYLON {
  78322. /**
  78323. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  78324. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  78325. */
  78326. export class EffectFallbacks implements IEffectFallbacks {
  78327. private _defines;
  78328. private _currentRank;
  78329. private _maxRank;
  78330. private _mesh;
  78331. /**
  78332. * Removes the fallback from the bound mesh.
  78333. */
  78334. unBindMesh(): void;
  78335. /**
  78336. * Adds a fallback on the specified property.
  78337. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78338. * @param define The name of the define in the shader
  78339. */
  78340. addFallback(rank: number, define: string): void;
  78341. /**
  78342. * Sets the mesh to use CPU skinning when needing to fallback.
  78343. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  78344. * @param mesh The mesh to use the fallbacks.
  78345. */
  78346. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  78347. /**
  78348. * Checks to see if more fallbacks are still availible.
  78349. */
  78350. readonly hasMoreFallbacks: boolean;
  78351. /**
  78352. * Removes the defines that should be removed when falling back.
  78353. * @param currentDefines defines the current define statements for the shader.
  78354. * @param effect defines the current effect we try to compile
  78355. * @returns The resulting defines with defines of the current rank removed.
  78356. */
  78357. reduce(currentDefines: string, effect: Effect): string;
  78358. }
  78359. }
  78360. declare module BABYLON {
  78361. /**
  78362. * "Static Class" containing the most commonly used helper while dealing with material for
  78363. * rendering purpose.
  78364. *
  78365. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  78366. *
  78367. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  78368. */
  78369. export class MaterialHelper {
  78370. /**
  78371. * Bind the current view position to an effect.
  78372. * @param effect The effect to be bound
  78373. * @param scene The scene the eyes position is used from
  78374. */
  78375. static BindEyePosition(effect: Effect, scene: Scene): void;
  78376. /**
  78377. * Helps preparing the defines values about the UVs in used in the effect.
  78378. * UVs are shared as much as we can accross channels in the shaders.
  78379. * @param texture The texture we are preparing the UVs for
  78380. * @param defines The defines to update
  78381. * @param key The channel key "diffuse", "specular"... used in the shader
  78382. */
  78383. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  78384. /**
  78385. * Binds a texture matrix value to its corrsponding uniform
  78386. * @param texture The texture to bind the matrix for
  78387. * @param uniformBuffer The uniform buffer receivin the data
  78388. * @param key The channel key "diffuse", "specular"... used in the shader
  78389. */
  78390. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  78391. /**
  78392. * Gets the current status of the fog (should it be enabled?)
  78393. * @param mesh defines the mesh to evaluate for fog support
  78394. * @param scene defines the hosting scene
  78395. * @returns true if fog must be enabled
  78396. */
  78397. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  78398. /**
  78399. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  78400. * @param mesh defines the current mesh
  78401. * @param scene defines the current scene
  78402. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  78403. * @param pointsCloud defines if point cloud rendering has to be turned on
  78404. * @param fogEnabled defines if fog has to be turned on
  78405. * @param alphaTest defines if alpha testing has to be turned on
  78406. * @param defines defines the current list of defines
  78407. */
  78408. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  78409. /**
  78410. * Helper used to prepare the list of defines associated with frame values for shader compilation
  78411. * @param scene defines the current scene
  78412. * @param engine defines the current engine
  78413. * @param defines specifies the list of active defines
  78414. * @param useInstances defines if instances have to be turned on
  78415. * @param useClipPlane defines if clip plane have to be turned on
  78416. */
  78417. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  78418. /**
  78419. * Prepares the defines for bones
  78420. * @param mesh The mesh containing the geometry data we will draw
  78421. * @param defines The defines to update
  78422. */
  78423. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  78424. /**
  78425. * Prepares the defines for morph targets
  78426. * @param mesh The mesh containing the geometry data we will draw
  78427. * @param defines The defines to update
  78428. */
  78429. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  78430. /**
  78431. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  78432. * @param mesh The mesh containing the geometry data we will draw
  78433. * @param defines The defines to update
  78434. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  78435. * @param useBones Precise whether bones should be used or not (override mesh info)
  78436. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  78437. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  78438. * @returns false if defines are considered not dirty and have not been checked
  78439. */
  78440. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  78441. /**
  78442. * Prepares the defines related to multiview
  78443. * @param scene The scene we are intending to draw
  78444. * @param defines The defines to update
  78445. */
  78446. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  78447. /**
  78448. * Prepares the defines related to the light information passed in parameter
  78449. * @param scene The scene we are intending to draw
  78450. * @param mesh The mesh the effect is compiling for
  78451. * @param light The light the effect is compiling for
  78452. * @param lightIndex The index of the light
  78453. * @param defines The defines to update
  78454. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78455. * @param state Defines the current state regarding what is needed (normals, etc...)
  78456. */
  78457. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  78458. needNormals: boolean;
  78459. needRebuild: boolean;
  78460. shadowEnabled: boolean;
  78461. specularEnabled: boolean;
  78462. lightmapMode: boolean;
  78463. }): void;
  78464. /**
  78465. * Prepares the defines related to the light information passed in parameter
  78466. * @param scene The scene we are intending to draw
  78467. * @param mesh The mesh the effect is compiling for
  78468. * @param defines The defines to update
  78469. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  78470. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  78471. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  78472. * @returns true if normals will be required for the rest of the effect
  78473. */
  78474. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  78475. /**
  78476. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  78477. * @param lightIndex defines the light index
  78478. * @param uniformsList The uniform list
  78479. * @param samplersList The sampler list
  78480. * @param projectedLightTexture defines if projected texture must be used
  78481. * @param uniformBuffersList defines an optional list of uniform buffers
  78482. */
  78483. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  78484. /**
  78485. * Prepares the uniforms and samplers list to be used in the effect
  78486. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  78487. * @param samplersList The sampler list
  78488. * @param defines The defines helping in the list generation
  78489. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  78490. */
  78491. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  78492. /**
  78493. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  78494. * @param defines The defines to update while falling back
  78495. * @param fallbacks The authorized effect fallbacks
  78496. * @param maxSimultaneousLights The maximum number of lights allowed
  78497. * @param rank the current rank of the Effect
  78498. * @returns The newly affected rank
  78499. */
  78500. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  78501. private static _TmpMorphInfluencers;
  78502. /**
  78503. * Prepares the list of attributes required for morph targets according to the effect defines.
  78504. * @param attribs The current list of supported attribs
  78505. * @param mesh The mesh to prepare the morph targets attributes for
  78506. * @param influencers The number of influencers
  78507. */
  78508. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  78509. /**
  78510. * Prepares the list of attributes required for morph targets according to the effect defines.
  78511. * @param attribs The current list of supported attribs
  78512. * @param mesh The mesh to prepare the morph targets attributes for
  78513. * @param defines The current Defines of the effect
  78514. */
  78515. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  78516. /**
  78517. * Prepares the list of attributes required for bones according to the effect defines.
  78518. * @param attribs The current list of supported attribs
  78519. * @param mesh The mesh to prepare the bones attributes for
  78520. * @param defines The current Defines of the effect
  78521. * @param fallbacks The current efffect fallback strategy
  78522. */
  78523. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  78524. /**
  78525. * Check and prepare the list of attributes required for instances according to the effect defines.
  78526. * @param attribs The current list of supported attribs
  78527. * @param defines The current MaterialDefines of the effect
  78528. */
  78529. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  78530. /**
  78531. * Add the list of attributes required for instances to the attribs array.
  78532. * @param attribs The current list of supported attribs
  78533. */
  78534. static PushAttributesForInstances(attribs: string[]): void;
  78535. /**
  78536. * Binds the light information to the effect.
  78537. * @param light The light containing the generator
  78538. * @param effect The effect we are binding the data to
  78539. * @param lightIndex The light index in the effect used to render
  78540. */
  78541. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  78542. /**
  78543. * Binds the lights information from the scene to the effect for the given mesh.
  78544. * @param light Light to bind
  78545. * @param lightIndex Light index
  78546. * @param scene The scene where the light belongs to
  78547. * @param effect The effect we are binding the data to
  78548. * @param useSpecular Defines if specular is supported
  78549. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78550. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78551. */
  78552. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78553. /**
  78554. * Binds the lights information from the scene to the effect for the given mesh.
  78555. * @param scene The scene the lights belongs to
  78556. * @param mesh The mesh we are binding the information to render
  78557. * @param effect The effect we are binding the data to
  78558. * @param defines The generated defines for the effect
  78559. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  78560. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  78561. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  78562. */
  78563. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  78564. private static _tempFogColor;
  78565. /**
  78566. * Binds the fog information from the scene to the effect for the given mesh.
  78567. * @param scene The scene the lights belongs to
  78568. * @param mesh The mesh we are binding the information to render
  78569. * @param effect The effect we are binding the data to
  78570. * @param linearSpace Defines if the fog effect is applied in linear space
  78571. */
  78572. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  78573. /**
  78574. * Binds the bones information from the mesh to the effect.
  78575. * @param mesh The mesh we are binding the information to render
  78576. * @param effect The effect we are binding the data to
  78577. */
  78578. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  78579. /**
  78580. * Binds the morph targets information from the mesh to the effect.
  78581. * @param abstractMesh The mesh we are binding the information to render
  78582. * @param effect The effect we are binding the data to
  78583. */
  78584. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  78585. /**
  78586. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  78587. * @param defines The generated defines used in the effect
  78588. * @param effect The effect we are binding the data to
  78589. * @param scene The scene we are willing to render with logarithmic scale for
  78590. */
  78591. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  78592. /**
  78593. * Binds the clip plane information from the scene to the effect.
  78594. * @param scene The scene the clip plane information are extracted from
  78595. * @param effect The effect we are binding the data to
  78596. */
  78597. static BindClipPlane(effect: Effect, scene: Scene): void;
  78598. }
  78599. }
  78600. declare module BABYLON {
  78601. /** @hidden */
  78602. export var packingFunctions: {
  78603. name: string;
  78604. shader: string;
  78605. };
  78606. }
  78607. declare module BABYLON {
  78608. /** @hidden */
  78609. export var shadowMapPixelShader: {
  78610. name: string;
  78611. shader: string;
  78612. };
  78613. }
  78614. declare module BABYLON {
  78615. /** @hidden */
  78616. export var bonesDeclaration: {
  78617. name: string;
  78618. shader: string;
  78619. };
  78620. }
  78621. declare module BABYLON {
  78622. /** @hidden */
  78623. export var morphTargetsVertexGlobalDeclaration: {
  78624. name: string;
  78625. shader: string;
  78626. };
  78627. }
  78628. declare module BABYLON {
  78629. /** @hidden */
  78630. export var morphTargetsVertexDeclaration: {
  78631. name: string;
  78632. shader: string;
  78633. };
  78634. }
  78635. declare module BABYLON {
  78636. /** @hidden */
  78637. export var instancesDeclaration: {
  78638. name: string;
  78639. shader: string;
  78640. };
  78641. }
  78642. declare module BABYLON {
  78643. /** @hidden */
  78644. export var helperFunctions: {
  78645. name: string;
  78646. shader: string;
  78647. };
  78648. }
  78649. declare module BABYLON {
  78650. /** @hidden */
  78651. export var morphTargetsVertex: {
  78652. name: string;
  78653. shader: string;
  78654. };
  78655. }
  78656. declare module BABYLON {
  78657. /** @hidden */
  78658. export var instancesVertex: {
  78659. name: string;
  78660. shader: string;
  78661. };
  78662. }
  78663. declare module BABYLON {
  78664. /** @hidden */
  78665. export var bonesVertex: {
  78666. name: string;
  78667. shader: string;
  78668. };
  78669. }
  78670. declare module BABYLON {
  78671. /** @hidden */
  78672. export var shadowMapVertexShader: {
  78673. name: string;
  78674. shader: string;
  78675. };
  78676. }
  78677. declare module BABYLON {
  78678. /** @hidden */
  78679. export var depthBoxBlurPixelShader: {
  78680. name: string;
  78681. shader: string;
  78682. };
  78683. }
  78684. declare module BABYLON {
  78685. /**
  78686. * Defines the options associated with the creation of a custom shader for a shadow generator.
  78687. */
  78688. export interface ICustomShaderOptions {
  78689. /**
  78690. * Gets or sets the custom shader name to use
  78691. */
  78692. shaderName: string;
  78693. /**
  78694. * The list of attribute names used in the shader
  78695. */
  78696. attributes?: string[];
  78697. /**
  78698. * The list of unifrom names used in the shader
  78699. */
  78700. uniforms?: string[];
  78701. /**
  78702. * The list of sampler names used in the shader
  78703. */
  78704. samplers?: string[];
  78705. /**
  78706. * The list of defines used in the shader
  78707. */
  78708. defines?: string[];
  78709. }
  78710. /**
  78711. * Interface to implement to create a shadow generator compatible with BJS.
  78712. */
  78713. export interface IShadowGenerator {
  78714. /**
  78715. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78716. * @returns The render target texture if present otherwise, null
  78717. */
  78718. getShadowMap(): Nullable<RenderTargetTexture>;
  78719. /**
  78720. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78721. * @returns The render target texture if the shadow map is present otherwise, null
  78722. */
  78723. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78724. /**
  78725. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78726. * @param subMesh The submesh we want to render in the shadow map
  78727. * @param useInstances Defines wether will draw in the map using instances
  78728. * @returns true if ready otherwise, false
  78729. */
  78730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78731. /**
  78732. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78733. * @param defines Defines of the material we want to update
  78734. * @param lightIndex Index of the light in the enabled light list of the material
  78735. */
  78736. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  78737. /**
  78738. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78739. * defined in the generator but impacting the effect).
  78740. * It implies the unifroms available on the materials are the standard BJS ones.
  78741. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78742. * @param effect The effect we are binfing the information for
  78743. */
  78744. bindShadowLight(lightIndex: string, effect: Effect): void;
  78745. /**
  78746. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78747. * (eq to shadow prjection matrix * light transform matrix)
  78748. * @returns The transform matrix used to create the shadow map
  78749. */
  78750. getTransformMatrix(): Matrix;
  78751. /**
  78752. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78753. * Cube and 2D textures for instance.
  78754. */
  78755. recreateShadowMap(): void;
  78756. /**
  78757. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78758. * @param onCompiled Callback triggered at the and of the effects compilation
  78759. * @param options Sets of optional options forcing the compilation with different modes
  78760. */
  78761. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78762. useInstances: boolean;
  78763. }>): void;
  78764. /**
  78765. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78766. * @param options Sets of optional options forcing the compilation with different modes
  78767. * @returns A promise that resolves when the compilation completes
  78768. */
  78769. forceCompilationAsync(options?: Partial<{
  78770. useInstances: boolean;
  78771. }>): Promise<void>;
  78772. /**
  78773. * Serializes the shadow generator setup to a json object.
  78774. * @returns The serialized JSON object
  78775. */
  78776. serialize(): any;
  78777. /**
  78778. * Disposes the Shadow map and related Textures and effects.
  78779. */
  78780. dispose(): void;
  78781. }
  78782. /**
  78783. * Default implementation IShadowGenerator.
  78784. * This is the main object responsible of generating shadows in the framework.
  78785. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  78786. */
  78787. export class ShadowGenerator implements IShadowGenerator {
  78788. /**
  78789. * Shadow generator mode None: no filtering applied.
  78790. */
  78791. static readonly FILTER_NONE: number;
  78792. /**
  78793. * Shadow generator mode ESM: Exponential Shadow Mapping.
  78794. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78795. */
  78796. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  78797. /**
  78798. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  78799. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  78800. */
  78801. static readonly FILTER_POISSONSAMPLING: number;
  78802. /**
  78803. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  78804. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78805. */
  78806. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  78807. /**
  78808. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  78809. * edge artifacts on steep falloff.
  78810. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78811. */
  78812. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  78813. /**
  78814. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  78815. * edge artifacts on steep falloff.
  78816. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  78817. */
  78818. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  78819. /**
  78820. * Shadow generator mode PCF: Percentage Closer Filtering
  78821. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78822. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  78823. */
  78824. static readonly FILTER_PCF: number;
  78825. /**
  78826. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  78827. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  78828. * Contact Hardening
  78829. */
  78830. static readonly FILTER_PCSS: number;
  78831. /**
  78832. * Reserved for PCF and PCSS
  78833. * Highest Quality.
  78834. *
  78835. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  78836. *
  78837. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  78838. */
  78839. static readonly QUALITY_HIGH: number;
  78840. /**
  78841. * Reserved for PCF and PCSS
  78842. * Good tradeoff for quality/perf cross devices
  78843. *
  78844. * Execute PCF on a 3*3 kernel.
  78845. *
  78846. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  78847. */
  78848. static readonly QUALITY_MEDIUM: number;
  78849. /**
  78850. * Reserved for PCF and PCSS
  78851. * The lowest quality but the fastest.
  78852. *
  78853. * Execute PCF on a 1*1 kernel.
  78854. *
  78855. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  78856. */
  78857. static readonly QUALITY_LOW: number;
  78858. /** Gets or sets the custom shader name to use */
  78859. customShaderOptions: ICustomShaderOptions;
  78860. /**
  78861. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  78862. */
  78863. onBeforeShadowMapRenderObservable: Observable<Effect>;
  78864. /**
  78865. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  78866. */
  78867. onAfterShadowMapRenderObservable: Observable<Effect>;
  78868. /**
  78869. * Observable triggered before a mesh is rendered in the shadow map.
  78870. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  78871. */
  78872. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  78873. /**
  78874. * Observable triggered after a mesh is rendered in the shadow map.
  78875. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  78876. */
  78877. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  78878. private _bias;
  78879. /**
  78880. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  78881. */
  78882. /**
  78883. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  78884. */
  78885. bias: number;
  78886. private _normalBias;
  78887. /**
  78888. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78889. */
  78890. /**
  78891. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  78892. */
  78893. normalBias: number;
  78894. private _blurBoxOffset;
  78895. /**
  78896. * Gets the blur box offset: offset applied during the blur pass.
  78897. * Only useful if useKernelBlur = false
  78898. */
  78899. /**
  78900. * Sets the blur box offset: offset applied during the blur pass.
  78901. * Only useful if useKernelBlur = false
  78902. */
  78903. blurBoxOffset: number;
  78904. private _blurScale;
  78905. /**
  78906. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  78907. * 2 means half of the size.
  78908. */
  78909. /**
  78910. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  78911. * 2 means half of the size.
  78912. */
  78913. blurScale: number;
  78914. private _blurKernel;
  78915. /**
  78916. * Gets the blur kernel: kernel size of the blur pass.
  78917. * Only useful if useKernelBlur = true
  78918. */
  78919. /**
  78920. * Sets the blur kernel: kernel size of the blur pass.
  78921. * Only useful if useKernelBlur = true
  78922. */
  78923. blurKernel: number;
  78924. private _useKernelBlur;
  78925. /**
  78926. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  78927. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78928. */
  78929. /**
  78930. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  78931. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  78932. */
  78933. useKernelBlur: boolean;
  78934. private _depthScale;
  78935. /**
  78936. * Gets the depth scale used in ESM mode.
  78937. */
  78938. /**
  78939. * Sets the depth scale used in ESM mode.
  78940. * This can override the scale stored on the light.
  78941. */
  78942. depthScale: number;
  78943. private _filter;
  78944. /**
  78945. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  78946. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78947. */
  78948. /**
  78949. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  78950. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  78951. */
  78952. filter: number;
  78953. /**
  78954. * Gets if the current filter is set to Poisson Sampling.
  78955. */
  78956. /**
  78957. * Sets the current filter to Poisson Sampling.
  78958. */
  78959. usePoissonSampling: boolean;
  78960. /**
  78961. * Gets if the current filter is set to ESM.
  78962. */
  78963. /**
  78964. * Sets the current filter is to ESM.
  78965. */
  78966. useExponentialShadowMap: boolean;
  78967. /**
  78968. * Gets if the current filter is set to filtered ESM.
  78969. */
  78970. /**
  78971. * Gets if the current filter is set to filtered ESM.
  78972. */
  78973. useBlurExponentialShadowMap: boolean;
  78974. /**
  78975. * Gets if the current filter is set to "close ESM" (using the inverse of the
  78976. * exponential to prevent steep falloff artifacts).
  78977. */
  78978. /**
  78979. * Sets the current filter to "close ESM" (using the inverse of the
  78980. * exponential to prevent steep falloff artifacts).
  78981. */
  78982. useCloseExponentialShadowMap: boolean;
  78983. /**
  78984. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  78985. * exponential to prevent steep falloff artifacts).
  78986. */
  78987. /**
  78988. * Sets the current filter to filtered "close ESM" (using the inverse of the
  78989. * exponential to prevent steep falloff artifacts).
  78990. */
  78991. useBlurCloseExponentialShadowMap: boolean;
  78992. /**
  78993. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78994. */
  78995. /**
  78996. * Sets the current filter to "PCF" (percentage closer filtering).
  78997. */
  78998. usePercentageCloserFiltering: boolean;
  78999. private _filteringQuality;
  79000. /**
  79001. * Gets the PCF or PCSS Quality.
  79002. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  79003. */
  79004. /**
  79005. * Sets the PCF or PCSS Quality.
  79006. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  79007. */
  79008. filteringQuality: number;
  79009. /**
  79010. * Gets if the current filter is set to "PCSS" (contact hardening).
  79011. */
  79012. /**
  79013. * Sets the current filter to "PCSS" (contact hardening).
  79014. */
  79015. useContactHardeningShadow: boolean;
  79016. private _contactHardeningLightSizeUVRatio;
  79017. /**
  79018. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  79019. * Using a ratio helps keeping shape stability independently of the map size.
  79020. *
  79021. * It does not account for the light projection as it was having too much
  79022. * instability during the light setup or during light position changes.
  79023. *
  79024. * Only valid if useContactHardeningShadow is true.
  79025. */
  79026. /**
  79027. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  79028. * Using a ratio helps keeping shape stability independently of the map size.
  79029. *
  79030. * It does not account for the light projection as it was having too much
  79031. * instability during the light setup or during light position changes.
  79032. *
  79033. * Only valid if useContactHardeningShadow is true.
  79034. */
  79035. contactHardeningLightSizeUVRatio: number;
  79036. private _darkness;
  79037. /** Gets or sets the actual darkness of a shadow */
  79038. darkness: number;
  79039. /**
  79040. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  79041. * 0 means strongest and 1 would means no shadow.
  79042. * @returns the darkness.
  79043. */
  79044. getDarkness(): number;
  79045. /**
  79046. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  79047. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  79048. * @returns the shadow generator allowing fluent coding.
  79049. */
  79050. setDarkness(darkness: number): ShadowGenerator;
  79051. private _transparencyShadow;
  79052. /** Gets or sets the ability to have transparent shadow */
  79053. transparencyShadow: boolean;
  79054. /**
  79055. * Sets the ability to have transparent shadow (boolean).
  79056. * @param transparent True if transparent else False
  79057. * @returns the shadow generator allowing fluent coding
  79058. */
  79059. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  79060. private _shadowMap;
  79061. private _shadowMap2;
  79062. /**
  79063. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  79064. * @returns The render target texture if present otherwise, null
  79065. */
  79066. getShadowMap(): Nullable<RenderTargetTexture>;
  79067. /**
  79068. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  79069. * @returns The render target texture if the shadow map is present otherwise, null
  79070. */
  79071. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  79072. /**
  79073. * Gets the class name of that object
  79074. * @returns "ShadowGenerator"
  79075. */
  79076. getClassName(): string;
  79077. /**
  79078. * Helper function to add a mesh and its descendants to the list of shadow casters.
  79079. * @param mesh Mesh to add
  79080. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  79081. * @returns the Shadow Generator itself
  79082. */
  79083. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  79084. /**
  79085. * Helper function to remove a mesh and its descendants from the list of shadow casters
  79086. * @param mesh Mesh to remove
  79087. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  79088. * @returns the Shadow Generator itself
  79089. */
  79090. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  79091. /**
  79092. * Controls the extent to which the shadows fade out at the edge of the frustum
  79093. * Used only by directionals and spots
  79094. */
  79095. frustumEdgeFalloff: number;
  79096. private _light;
  79097. /**
  79098. * Returns the associated light object.
  79099. * @returns the light generating the shadow
  79100. */
  79101. getLight(): IShadowLight;
  79102. /**
  79103. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  79104. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  79105. * It might on the other hand introduce peter panning.
  79106. */
  79107. forceBackFacesOnly: boolean;
  79108. private _scene;
  79109. private _lightDirection;
  79110. private _effect;
  79111. private _viewMatrix;
  79112. private _projectionMatrix;
  79113. private _transformMatrix;
  79114. private _cachedPosition;
  79115. private _cachedDirection;
  79116. private _cachedDefines;
  79117. private _currentRenderID;
  79118. private _boxBlurPostprocess;
  79119. private _kernelBlurXPostprocess;
  79120. private _kernelBlurYPostprocess;
  79121. private _blurPostProcesses;
  79122. private _mapSize;
  79123. private _currentFaceIndex;
  79124. private _currentFaceIndexCache;
  79125. private _textureType;
  79126. private _defaultTextureMatrix;
  79127. private _storedUniqueId;
  79128. /** @hidden */
  79129. static _SceneComponentInitialization: (scene: Scene) => void;
  79130. /**
  79131. * Creates a ShadowGenerator object.
  79132. * A ShadowGenerator is the required tool to use the shadows.
  79133. * Each light casting shadows needs to use its own ShadowGenerator.
  79134. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  79135. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  79136. * @param light The light object generating the shadows.
  79137. * @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.
  79138. */
  79139. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  79140. private _initializeGenerator;
  79141. private _initializeShadowMap;
  79142. private _initializeBlurRTTAndPostProcesses;
  79143. private _renderForShadowMap;
  79144. private _renderSubMeshForShadowMap;
  79145. private _applyFilterValues;
  79146. /**
  79147. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79148. * @param onCompiled Callback triggered at the and of the effects compilation
  79149. * @param options Sets of optional options forcing the compilation with different modes
  79150. */
  79151. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  79152. useInstances: boolean;
  79153. }>): void;
  79154. /**
  79155. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  79156. * @param options Sets of optional options forcing the compilation with different modes
  79157. * @returns A promise that resolves when the compilation completes
  79158. */
  79159. forceCompilationAsync(options?: Partial<{
  79160. useInstances: boolean;
  79161. }>): Promise<void>;
  79162. /**
  79163. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  79164. * @param subMesh The submesh we want to render in the shadow map
  79165. * @param useInstances Defines wether will draw in the map using instances
  79166. * @returns true if ready otherwise, false
  79167. */
  79168. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  79169. /**
  79170. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  79171. * @param defines Defines of the material we want to update
  79172. * @param lightIndex Index of the light in the enabled light list of the material
  79173. */
  79174. prepareDefines(defines: any, lightIndex: number): void;
  79175. /**
  79176. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  79177. * defined in the generator but impacting the effect).
  79178. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  79179. * @param effect The effect we are binfing the information for
  79180. */
  79181. bindShadowLight(lightIndex: string, effect: Effect): void;
  79182. /**
  79183. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  79184. * (eq to shadow prjection matrix * light transform matrix)
  79185. * @returns The transform matrix used to create the shadow map
  79186. */
  79187. getTransformMatrix(): Matrix;
  79188. /**
  79189. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  79190. * Cube and 2D textures for instance.
  79191. */
  79192. recreateShadowMap(): void;
  79193. private _disposeBlurPostProcesses;
  79194. private _disposeRTTandPostProcesses;
  79195. /**
  79196. * Disposes the ShadowGenerator.
  79197. * Returns nothing.
  79198. */
  79199. dispose(): void;
  79200. /**
  79201. * Serializes the shadow generator setup to a json object.
  79202. * @returns The serialized JSON object
  79203. */
  79204. serialize(): any;
  79205. /**
  79206. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  79207. * @param parsedShadowGenerator The JSON object to parse
  79208. * @param scene The scene to create the shadow map for
  79209. * @returns The parsed shadow generator
  79210. */
  79211. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  79212. }
  79213. }
  79214. declare module BABYLON {
  79215. /**
  79216. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  79217. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  79218. * 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.
  79219. */
  79220. export abstract class Light extends Node {
  79221. /**
  79222. * Falloff Default: light is falling off following the material specification:
  79223. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  79224. */
  79225. static readonly FALLOFF_DEFAULT: number;
  79226. /**
  79227. * Falloff Physical: light is falling off following the inverse squared distance law.
  79228. */
  79229. static readonly FALLOFF_PHYSICAL: number;
  79230. /**
  79231. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  79232. * to enhance interoperability with other engines.
  79233. */
  79234. static readonly FALLOFF_GLTF: number;
  79235. /**
  79236. * Falloff Standard: light is falling off like in the standard material
  79237. * to enhance interoperability with other materials.
  79238. */
  79239. static readonly FALLOFF_STANDARD: number;
  79240. /**
  79241. * If every light affecting the material is in this lightmapMode,
  79242. * material.lightmapTexture adds or multiplies
  79243. * (depends on material.useLightmapAsShadowmap)
  79244. * after every other light calculations.
  79245. */
  79246. static readonly LIGHTMAP_DEFAULT: number;
  79247. /**
  79248. * material.lightmapTexture as only diffuse lighting from this light
  79249. * adds only specular lighting from this light
  79250. * adds dynamic shadows
  79251. */
  79252. static readonly LIGHTMAP_SPECULAR: number;
  79253. /**
  79254. * material.lightmapTexture as only lighting
  79255. * no light calculation from this light
  79256. * only adds dynamic shadows from this light
  79257. */
  79258. static readonly LIGHTMAP_SHADOWSONLY: number;
  79259. /**
  79260. * Each light type uses the default quantity according to its type:
  79261. * point/spot lights use luminous intensity
  79262. * directional lights use illuminance
  79263. */
  79264. static readonly INTENSITYMODE_AUTOMATIC: number;
  79265. /**
  79266. * lumen (lm)
  79267. */
  79268. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  79269. /**
  79270. * candela (lm/sr)
  79271. */
  79272. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  79273. /**
  79274. * lux (lm/m^2)
  79275. */
  79276. static readonly INTENSITYMODE_ILLUMINANCE: number;
  79277. /**
  79278. * nit (cd/m^2)
  79279. */
  79280. static readonly INTENSITYMODE_LUMINANCE: number;
  79281. /**
  79282. * Light type const id of the point light.
  79283. */
  79284. static readonly LIGHTTYPEID_POINTLIGHT: number;
  79285. /**
  79286. * Light type const id of the directional light.
  79287. */
  79288. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  79289. /**
  79290. * Light type const id of the spot light.
  79291. */
  79292. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  79293. /**
  79294. * Light type const id of the hemispheric light.
  79295. */
  79296. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  79297. /**
  79298. * Diffuse gives the basic color to an object.
  79299. */
  79300. diffuse: Color3;
  79301. /**
  79302. * Specular produces a highlight color on an object.
  79303. * Note: This is note affecting PBR materials.
  79304. */
  79305. specular: Color3;
  79306. /**
  79307. * Defines the falloff type for this light. This lets overrriding how punctual light are
  79308. * falling off base on range or angle.
  79309. * This can be set to any values in Light.FALLOFF_x.
  79310. *
  79311. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  79312. * other types of materials.
  79313. */
  79314. falloffType: number;
  79315. /**
  79316. * Strength of the light.
  79317. * Note: By default it is define in the framework own unit.
  79318. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  79319. */
  79320. intensity: number;
  79321. private _range;
  79322. protected _inverseSquaredRange: number;
  79323. /**
  79324. * Defines how far from the source the light is impacting in scene units.
  79325. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79326. */
  79327. /**
  79328. * Defines how far from the source the light is impacting in scene units.
  79329. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  79330. */
  79331. range: number;
  79332. /**
  79333. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  79334. * of light.
  79335. */
  79336. private _photometricScale;
  79337. private _intensityMode;
  79338. /**
  79339. * Gets the photometric scale used to interpret the intensity.
  79340. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79341. */
  79342. /**
  79343. * Sets the photometric scale used to interpret the intensity.
  79344. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  79345. */
  79346. intensityMode: number;
  79347. private _radius;
  79348. /**
  79349. * Gets the light radius used by PBR Materials to simulate soft area lights.
  79350. */
  79351. /**
  79352. * sets the light radius used by PBR Materials to simulate soft area lights.
  79353. */
  79354. radius: number;
  79355. private _renderPriority;
  79356. /**
  79357. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  79358. * exceeding the number allowed of the materials.
  79359. */
  79360. renderPriority: number;
  79361. private _shadowEnabled;
  79362. /**
  79363. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79364. * the current shadow generator.
  79365. */
  79366. /**
  79367. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  79368. * the current shadow generator.
  79369. */
  79370. shadowEnabled: boolean;
  79371. private _includedOnlyMeshes;
  79372. /**
  79373. * Gets the only meshes impacted by this light.
  79374. */
  79375. /**
  79376. * Sets the only meshes impacted by this light.
  79377. */
  79378. includedOnlyMeshes: AbstractMesh[];
  79379. private _excludedMeshes;
  79380. /**
  79381. * Gets the meshes not impacted by this light.
  79382. */
  79383. /**
  79384. * Sets the meshes not impacted by this light.
  79385. */
  79386. excludedMeshes: AbstractMesh[];
  79387. private _excludeWithLayerMask;
  79388. /**
  79389. * Gets the layer id use to find what meshes are not impacted by the light.
  79390. * Inactive if 0
  79391. */
  79392. /**
  79393. * Sets the layer id use to find what meshes are not impacted by the light.
  79394. * Inactive if 0
  79395. */
  79396. excludeWithLayerMask: number;
  79397. private _includeOnlyWithLayerMask;
  79398. /**
  79399. * Gets the layer id use to find what meshes are impacted by the light.
  79400. * Inactive if 0
  79401. */
  79402. /**
  79403. * Sets the layer id use to find what meshes are impacted by the light.
  79404. * Inactive if 0
  79405. */
  79406. includeOnlyWithLayerMask: number;
  79407. private _lightmapMode;
  79408. /**
  79409. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  79410. */
  79411. /**
  79412. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  79413. */
  79414. lightmapMode: number;
  79415. /**
  79416. * Shadow generator associted to the light.
  79417. * @hidden Internal use only.
  79418. */
  79419. _shadowGenerator: Nullable<IShadowGenerator>;
  79420. /**
  79421. * @hidden Internal use only.
  79422. */
  79423. _excludedMeshesIds: string[];
  79424. /**
  79425. * @hidden Internal use only.
  79426. */
  79427. _includedOnlyMeshesIds: string[];
  79428. /**
  79429. * The current light unifom buffer.
  79430. * @hidden Internal use only.
  79431. */
  79432. _uniformBuffer: UniformBuffer;
  79433. /** @hidden */
  79434. _renderId: number;
  79435. /**
  79436. * Creates a Light object in the scene.
  79437. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79438. * @param name The firendly name of the light
  79439. * @param scene The scene the light belongs too
  79440. */
  79441. constructor(name: string, scene: Scene);
  79442. protected abstract _buildUniformLayout(): void;
  79443. /**
  79444. * Sets the passed Effect "effect" with the Light information.
  79445. * @param effect The effect to update
  79446. * @param lightIndex The index of the light in the effect to update
  79447. * @returns The light
  79448. */
  79449. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  79450. /**
  79451. * Sets the passed Effect "effect" with the Light textures.
  79452. * @param effect The effect to update
  79453. * @param lightIndex The index of the light in the effect to update
  79454. * @returns The light
  79455. */
  79456. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  79457. /**
  79458. * Binds the lights information from the scene to the effect for the given mesh.
  79459. * @param lightIndex Light index
  79460. * @param scene The scene where the light belongs to
  79461. * @param effect The effect we are binding the data to
  79462. * @param useSpecular Defines if specular is supported
  79463. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79464. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79465. */
  79466. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79467. /**
  79468. * Sets the passed Effect "effect" with the Light information.
  79469. * @param effect The effect to update
  79470. * @param lightDataUniformName The uniform used to store light data (position or direction)
  79471. * @returns The light
  79472. */
  79473. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  79474. /**
  79475. * Returns the string "Light".
  79476. * @returns the class name
  79477. */
  79478. getClassName(): string;
  79479. /** @hidden */
  79480. readonly _isLight: boolean;
  79481. /**
  79482. * Converts the light information to a readable string for debug purpose.
  79483. * @param fullDetails Supports for multiple levels of logging within scene loading
  79484. * @returns the human readable light info
  79485. */
  79486. toString(fullDetails?: boolean): string;
  79487. /** @hidden */
  79488. protected _syncParentEnabledState(): void;
  79489. /**
  79490. * Set the enabled state of this node.
  79491. * @param value - the new enabled state
  79492. */
  79493. setEnabled(value: boolean): void;
  79494. /**
  79495. * Returns the Light associated shadow generator if any.
  79496. * @return the associated shadow generator.
  79497. */
  79498. getShadowGenerator(): Nullable<IShadowGenerator>;
  79499. /**
  79500. * Returns a Vector3, the absolute light position in the World.
  79501. * @returns the world space position of the light
  79502. */
  79503. getAbsolutePosition(): Vector3;
  79504. /**
  79505. * Specifies if the light will affect the passed mesh.
  79506. * @param mesh The mesh to test against the light
  79507. * @return true the mesh is affected otherwise, false.
  79508. */
  79509. canAffectMesh(mesh: AbstractMesh): boolean;
  79510. /**
  79511. * Sort function to order lights for rendering.
  79512. * @param a First Light object to compare to second.
  79513. * @param b Second Light object to compare first.
  79514. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  79515. */
  79516. static CompareLightsPriority(a: Light, b: Light): number;
  79517. /**
  79518. * Releases resources associated with this node.
  79519. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79520. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79521. */
  79522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79523. /**
  79524. * Returns the light type ID (integer).
  79525. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79526. */
  79527. getTypeID(): number;
  79528. /**
  79529. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  79530. * @returns the scaled intensity in intensity mode unit
  79531. */
  79532. getScaledIntensity(): number;
  79533. /**
  79534. * Returns a new Light object, named "name", from the current one.
  79535. * @param name The name of the cloned light
  79536. * @returns the new created light
  79537. */
  79538. clone(name: string): Nullable<Light>;
  79539. /**
  79540. * Serializes the current light into a Serialization object.
  79541. * @returns the serialized object.
  79542. */
  79543. serialize(): any;
  79544. /**
  79545. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  79546. * This new light is named "name" and added to the passed scene.
  79547. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  79548. * @param name The friendly name of the light
  79549. * @param scene The scene the new light will belong to
  79550. * @returns the constructor function
  79551. */
  79552. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  79553. /**
  79554. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  79555. * @param parsedLight The JSON representation of the light
  79556. * @param scene The scene to create the parsed light in
  79557. * @returns the created light after parsing
  79558. */
  79559. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  79560. private _hookArrayForExcluded;
  79561. private _hookArrayForIncludedOnly;
  79562. private _resyncMeshes;
  79563. /**
  79564. * Forces the meshes to update their light related information in their rendering used effects
  79565. * @hidden Internal Use Only
  79566. */
  79567. _markMeshesAsLightDirty(): void;
  79568. /**
  79569. * Recomputes the cached photometric scale if needed.
  79570. */
  79571. private _computePhotometricScale;
  79572. /**
  79573. * Returns the Photometric Scale according to the light type and intensity mode.
  79574. */
  79575. private _getPhotometricScale;
  79576. /**
  79577. * Reorder the light in the scene according to their defined priority.
  79578. * @hidden Internal Use Only
  79579. */
  79580. _reorderLightsInScene(): void;
  79581. /**
  79582. * Prepares the list of defines specific to the light type.
  79583. * @param defines the list of defines
  79584. * @param lightIndex defines the index of the light for the effect
  79585. */
  79586. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  79587. }
  79588. }
  79589. declare module BABYLON {
  79590. /**
  79591. * Interface used to define Action
  79592. */
  79593. export interface IAction {
  79594. /**
  79595. * Trigger for the action
  79596. */
  79597. trigger: number;
  79598. /** Options of the trigger */
  79599. triggerOptions: any;
  79600. /**
  79601. * Gets the trigger parameters
  79602. * @returns the trigger parameters
  79603. */
  79604. getTriggerParameter(): any;
  79605. /**
  79606. * Internal only - executes current action event
  79607. * @hidden
  79608. */
  79609. _executeCurrent(evt?: ActionEvent): void;
  79610. /**
  79611. * Serialize placeholder for child classes
  79612. * @param parent of child
  79613. * @returns the serialized object
  79614. */
  79615. serialize(parent: any): any;
  79616. /**
  79617. * Internal only
  79618. * @hidden
  79619. */
  79620. _prepare(): void;
  79621. /**
  79622. * Internal only - manager for action
  79623. * @hidden
  79624. */
  79625. _actionManager: AbstractActionManager;
  79626. /**
  79627. * Adds action to chain of actions, may be a DoNothingAction
  79628. * @param action defines the next action to execute
  79629. * @returns The action passed in
  79630. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79631. */
  79632. then(action: IAction): IAction;
  79633. }
  79634. /**
  79635. * The action to be carried out following a trigger
  79636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  79637. */
  79638. export class Action implements IAction {
  79639. /** the trigger, with or without parameters, for the action */
  79640. triggerOptions: any;
  79641. /**
  79642. * Trigger for the action
  79643. */
  79644. trigger: number;
  79645. /**
  79646. * Internal only - manager for action
  79647. * @hidden
  79648. */
  79649. _actionManager: ActionManager;
  79650. private _nextActiveAction;
  79651. private _child;
  79652. private _condition?;
  79653. private _triggerParameter;
  79654. /**
  79655. * An event triggered prior to action being executed.
  79656. */
  79657. onBeforeExecuteObservable: Observable<Action>;
  79658. /**
  79659. * Creates a new Action
  79660. * @param triggerOptions the trigger, with or without parameters, for the action
  79661. * @param condition an optional determinant of action
  79662. */
  79663. constructor(
  79664. /** the trigger, with or without parameters, for the action */
  79665. triggerOptions: any, condition?: Condition);
  79666. /**
  79667. * Internal only
  79668. * @hidden
  79669. */
  79670. _prepare(): void;
  79671. /**
  79672. * Gets the trigger parameters
  79673. * @returns the trigger parameters
  79674. */
  79675. getTriggerParameter(): any;
  79676. /**
  79677. * Internal only - executes current action event
  79678. * @hidden
  79679. */
  79680. _executeCurrent(evt?: ActionEvent): void;
  79681. /**
  79682. * Execute placeholder for child classes
  79683. * @param evt optional action event
  79684. */
  79685. execute(evt?: ActionEvent): void;
  79686. /**
  79687. * Skips to next active action
  79688. */
  79689. skipToNextActiveAction(): void;
  79690. /**
  79691. * Adds action to chain of actions, may be a DoNothingAction
  79692. * @param action defines the next action to execute
  79693. * @returns The action passed in
  79694. * @see https://www.babylonjs-playground.com/#1T30HR#0
  79695. */
  79696. then(action: Action): Action;
  79697. /**
  79698. * Internal only
  79699. * @hidden
  79700. */
  79701. _getProperty(propertyPath: string): string;
  79702. /**
  79703. * Internal only
  79704. * @hidden
  79705. */
  79706. _getEffectiveTarget(target: any, propertyPath: string): any;
  79707. /**
  79708. * Serialize placeholder for child classes
  79709. * @param parent of child
  79710. * @returns the serialized object
  79711. */
  79712. serialize(parent: any): any;
  79713. /**
  79714. * Internal only called by serialize
  79715. * @hidden
  79716. */
  79717. protected _serialize(serializedAction: any, parent?: any): any;
  79718. /**
  79719. * Internal only
  79720. * @hidden
  79721. */
  79722. static _SerializeValueAsString: (value: any) => string;
  79723. /**
  79724. * Internal only
  79725. * @hidden
  79726. */
  79727. static _GetTargetProperty: (target: Node | Scene) => {
  79728. name: string;
  79729. targetType: string;
  79730. value: string;
  79731. };
  79732. }
  79733. }
  79734. declare module BABYLON {
  79735. /**
  79736. * A Condition applied to an Action
  79737. */
  79738. export class Condition {
  79739. /**
  79740. * Internal only - manager for action
  79741. * @hidden
  79742. */
  79743. _actionManager: ActionManager;
  79744. /**
  79745. * Internal only
  79746. * @hidden
  79747. */
  79748. _evaluationId: number;
  79749. /**
  79750. * Internal only
  79751. * @hidden
  79752. */
  79753. _currentResult: boolean;
  79754. /**
  79755. * Creates a new Condition
  79756. * @param actionManager the manager of the action the condition is applied to
  79757. */
  79758. constructor(actionManager: ActionManager);
  79759. /**
  79760. * Check if the current condition is valid
  79761. * @returns a boolean
  79762. */
  79763. isValid(): boolean;
  79764. /**
  79765. * Internal only
  79766. * @hidden
  79767. */
  79768. _getProperty(propertyPath: string): string;
  79769. /**
  79770. * Internal only
  79771. * @hidden
  79772. */
  79773. _getEffectiveTarget(target: any, propertyPath: string): any;
  79774. /**
  79775. * Serialize placeholder for child classes
  79776. * @returns the serialized object
  79777. */
  79778. serialize(): any;
  79779. /**
  79780. * Internal only
  79781. * @hidden
  79782. */
  79783. protected _serialize(serializedCondition: any): any;
  79784. }
  79785. /**
  79786. * Defines specific conditional operators as extensions of Condition
  79787. */
  79788. export class ValueCondition extends Condition {
  79789. /** path to specify the property of the target the conditional operator uses */
  79790. propertyPath: string;
  79791. /** the value compared by the conditional operator against the current value of the property */
  79792. value: any;
  79793. /** the conditional operator, default ValueCondition.IsEqual */
  79794. operator: number;
  79795. /**
  79796. * Internal only
  79797. * @hidden
  79798. */
  79799. private static _IsEqual;
  79800. /**
  79801. * Internal only
  79802. * @hidden
  79803. */
  79804. private static _IsDifferent;
  79805. /**
  79806. * Internal only
  79807. * @hidden
  79808. */
  79809. private static _IsGreater;
  79810. /**
  79811. * Internal only
  79812. * @hidden
  79813. */
  79814. private static _IsLesser;
  79815. /**
  79816. * returns the number for IsEqual
  79817. */
  79818. static readonly IsEqual: number;
  79819. /**
  79820. * Returns the number for IsDifferent
  79821. */
  79822. static readonly IsDifferent: number;
  79823. /**
  79824. * Returns the number for IsGreater
  79825. */
  79826. static readonly IsGreater: number;
  79827. /**
  79828. * Returns the number for IsLesser
  79829. */
  79830. static readonly IsLesser: number;
  79831. /**
  79832. * Internal only The action manager for the condition
  79833. * @hidden
  79834. */
  79835. _actionManager: ActionManager;
  79836. /**
  79837. * Internal only
  79838. * @hidden
  79839. */
  79840. private _target;
  79841. /**
  79842. * Internal only
  79843. * @hidden
  79844. */
  79845. private _effectiveTarget;
  79846. /**
  79847. * Internal only
  79848. * @hidden
  79849. */
  79850. private _property;
  79851. /**
  79852. * Creates a new ValueCondition
  79853. * @param actionManager manager for the action the condition applies to
  79854. * @param target for the action
  79855. * @param propertyPath path to specify the property of the target the conditional operator uses
  79856. * @param value the value compared by the conditional operator against the current value of the property
  79857. * @param operator the conditional operator, default ValueCondition.IsEqual
  79858. */
  79859. constructor(actionManager: ActionManager, target: any,
  79860. /** path to specify the property of the target the conditional operator uses */
  79861. propertyPath: string,
  79862. /** the value compared by the conditional operator against the current value of the property */
  79863. value: any,
  79864. /** the conditional operator, default ValueCondition.IsEqual */
  79865. operator?: number);
  79866. /**
  79867. * Compares the given value with the property value for the specified conditional operator
  79868. * @returns the result of the comparison
  79869. */
  79870. isValid(): boolean;
  79871. /**
  79872. * Serialize the ValueCondition into a JSON compatible object
  79873. * @returns serialization object
  79874. */
  79875. serialize(): any;
  79876. /**
  79877. * Gets the name of the conditional operator for the ValueCondition
  79878. * @param operator the conditional operator
  79879. * @returns the name
  79880. */
  79881. static GetOperatorName(operator: number): string;
  79882. }
  79883. /**
  79884. * Defines a predicate condition as an extension of Condition
  79885. */
  79886. export class PredicateCondition extends Condition {
  79887. /** defines the predicate function used to validate the condition */
  79888. predicate: () => boolean;
  79889. /**
  79890. * Internal only - manager for action
  79891. * @hidden
  79892. */
  79893. _actionManager: ActionManager;
  79894. /**
  79895. * Creates a new PredicateCondition
  79896. * @param actionManager manager for the action the condition applies to
  79897. * @param predicate defines the predicate function used to validate the condition
  79898. */
  79899. constructor(actionManager: ActionManager,
  79900. /** defines the predicate function used to validate the condition */
  79901. predicate: () => boolean);
  79902. /**
  79903. * @returns the validity of the predicate condition
  79904. */
  79905. isValid(): boolean;
  79906. }
  79907. /**
  79908. * Defines a state condition as an extension of Condition
  79909. */
  79910. export class StateCondition extends Condition {
  79911. /** Value to compare with target state */
  79912. value: string;
  79913. /**
  79914. * Internal only - manager for action
  79915. * @hidden
  79916. */
  79917. _actionManager: ActionManager;
  79918. /**
  79919. * Internal only
  79920. * @hidden
  79921. */
  79922. private _target;
  79923. /**
  79924. * Creates a new StateCondition
  79925. * @param actionManager manager for the action the condition applies to
  79926. * @param target of the condition
  79927. * @param value to compare with target state
  79928. */
  79929. constructor(actionManager: ActionManager, target: any,
  79930. /** Value to compare with target state */
  79931. value: string);
  79932. /**
  79933. * Gets a boolean indicating if the current condition is met
  79934. * @returns the validity of the state
  79935. */
  79936. isValid(): boolean;
  79937. /**
  79938. * Serialize the StateCondition into a JSON compatible object
  79939. * @returns serialization object
  79940. */
  79941. serialize(): any;
  79942. }
  79943. }
  79944. declare module BABYLON {
  79945. /**
  79946. * This defines an action responsible to toggle a boolean once triggered.
  79947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79948. */
  79949. export class SwitchBooleanAction extends Action {
  79950. /**
  79951. * The path to the boolean property in the target object
  79952. */
  79953. propertyPath: string;
  79954. private _target;
  79955. private _effectiveTarget;
  79956. private _property;
  79957. /**
  79958. * Instantiate the action
  79959. * @param triggerOptions defines the trigger options
  79960. * @param target defines the object containing the boolean
  79961. * @param propertyPath defines the path to the boolean property in the target object
  79962. * @param condition defines the trigger related conditions
  79963. */
  79964. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  79965. /** @hidden */
  79966. _prepare(): void;
  79967. /**
  79968. * Execute the action toggle the boolean value.
  79969. */
  79970. execute(): void;
  79971. /**
  79972. * Serializes the actions and its related information.
  79973. * @param parent defines the object to serialize in
  79974. * @returns the serialized object
  79975. */
  79976. serialize(parent: any): any;
  79977. }
  79978. /**
  79979. * This defines an action responsible to set a the state field of the target
  79980. * to a desired value once triggered.
  79981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79982. */
  79983. export class SetStateAction extends Action {
  79984. /**
  79985. * The value to store in the state field.
  79986. */
  79987. value: string;
  79988. private _target;
  79989. /**
  79990. * Instantiate the action
  79991. * @param triggerOptions defines the trigger options
  79992. * @param target defines the object containing the state property
  79993. * @param value defines the value to store in the state field
  79994. * @param condition defines the trigger related conditions
  79995. */
  79996. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  79997. /**
  79998. * Execute the action and store the value on the target state property.
  79999. */
  80000. execute(): void;
  80001. /**
  80002. * Serializes the actions and its related information.
  80003. * @param parent defines the object to serialize in
  80004. * @returns the serialized object
  80005. */
  80006. serialize(parent: any): any;
  80007. }
  80008. /**
  80009. * This defines an action responsible to set a property of the target
  80010. * to a desired value once triggered.
  80011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80012. */
  80013. export class SetValueAction extends Action {
  80014. /**
  80015. * The path of the property to set in the target.
  80016. */
  80017. propertyPath: string;
  80018. /**
  80019. * The value to set in the property
  80020. */
  80021. value: any;
  80022. private _target;
  80023. private _effectiveTarget;
  80024. private _property;
  80025. /**
  80026. * Instantiate the action
  80027. * @param triggerOptions defines the trigger options
  80028. * @param target defines the object containing the property
  80029. * @param propertyPath defines the path of the property to set in the target
  80030. * @param value defines the value to set in the property
  80031. * @param condition defines the trigger related conditions
  80032. */
  80033. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  80034. /** @hidden */
  80035. _prepare(): void;
  80036. /**
  80037. * Execute the action and set the targetted property to the desired value.
  80038. */
  80039. execute(): void;
  80040. /**
  80041. * Serializes the actions and its related information.
  80042. * @param parent defines the object to serialize in
  80043. * @returns the serialized object
  80044. */
  80045. serialize(parent: any): any;
  80046. }
  80047. /**
  80048. * This defines an action responsible to increment the target value
  80049. * to a desired value once triggered.
  80050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80051. */
  80052. export class IncrementValueAction extends Action {
  80053. /**
  80054. * The path of the property to increment in the target.
  80055. */
  80056. propertyPath: string;
  80057. /**
  80058. * The value we should increment the property by.
  80059. */
  80060. value: any;
  80061. private _target;
  80062. private _effectiveTarget;
  80063. private _property;
  80064. /**
  80065. * Instantiate the action
  80066. * @param triggerOptions defines the trigger options
  80067. * @param target defines the object containing the property
  80068. * @param propertyPath defines the path of the property to increment in the target
  80069. * @param value defines the value value we should increment the property by
  80070. * @param condition defines the trigger related conditions
  80071. */
  80072. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  80073. /** @hidden */
  80074. _prepare(): void;
  80075. /**
  80076. * Execute the action and increment the target of the value amount.
  80077. */
  80078. execute(): void;
  80079. /**
  80080. * Serializes the actions and its related information.
  80081. * @param parent defines the object to serialize in
  80082. * @returns the serialized object
  80083. */
  80084. serialize(parent: any): any;
  80085. }
  80086. /**
  80087. * This defines an action responsible to start an animation once triggered.
  80088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80089. */
  80090. export class PlayAnimationAction extends Action {
  80091. /**
  80092. * Where the animation should start (animation frame)
  80093. */
  80094. from: number;
  80095. /**
  80096. * Where the animation should stop (animation frame)
  80097. */
  80098. to: number;
  80099. /**
  80100. * Define if the animation should loop or stop after the first play.
  80101. */
  80102. loop?: boolean;
  80103. private _target;
  80104. /**
  80105. * Instantiate the action
  80106. * @param triggerOptions defines the trigger options
  80107. * @param target defines the target animation or animation name
  80108. * @param from defines from where the animation should start (animation frame)
  80109. * @param end defines where the animation should stop (animation frame)
  80110. * @param loop defines if the animation should loop or stop after the first play
  80111. * @param condition defines the trigger related conditions
  80112. */
  80113. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  80114. /** @hidden */
  80115. _prepare(): void;
  80116. /**
  80117. * Execute the action and play the animation.
  80118. */
  80119. execute(): void;
  80120. /**
  80121. * Serializes the actions and its related information.
  80122. * @param parent defines the object to serialize in
  80123. * @returns the serialized object
  80124. */
  80125. serialize(parent: any): any;
  80126. }
  80127. /**
  80128. * This defines an action responsible to stop an animation once triggered.
  80129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80130. */
  80131. export class StopAnimationAction extends Action {
  80132. private _target;
  80133. /**
  80134. * Instantiate the action
  80135. * @param triggerOptions defines the trigger options
  80136. * @param target defines the target animation or animation name
  80137. * @param condition defines the trigger related conditions
  80138. */
  80139. constructor(triggerOptions: any, target: any, condition?: Condition);
  80140. /** @hidden */
  80141. _prepare(): void;
  80142. /**
  80143. * Execute the action and stop the animation.
  80144. */
  80145. execute(): void;
  80146. /**
  80147. * Serializes the actions and its related information.
  80148. * @param parent defines the object to serialize in
  80149. * @returns the serialized object
  80150. */
  80151. serialize(parent: any): any;
  80152. }
  80153. /**
  80154. * This defines an action responsible that does nothing once triggered.
  80155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80156. */
  80157. export class DoNothingAction extends Action {
  80158. /**
  80159. * Instantiate the action
  80160. * @param triggerOptions defines the trigger options
  80161. * @param condition defines the trigger related conditions
  80162. */
  80163. constructor(triggerOptions?: any, condition?: Condition);
  80164. /**
  80165. * Execute the action and do nothing.
  80166. */
  80167. execute(): void;
  80168. /**
  80169. * Serializes the actions and its related information.
  80170. * @param parent defines the object to serialize in
  80171. * @returns the serialized object
  80172. */
  80173. serialize(parent: any): any;
  80174. }
  80175. /**
  80176. * This defines an action responsible to trigger several actions once triggered.
  80177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80178. */
  80179. export class CombineAction extends Action {
  80180. /**
  80181. * The list of aggregated animations to run.
  80182. */
  80183. children: Action[];
  80184. /**
  80185. * Instantiate the action
  80186. * @param triggerOptions defines the trigger options
  80187. * @param children defines the list of aggregated animations to run
  80188. * @param condition defines the trigger related conditions
  80189. */
  80190. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  80191. /** @hidden */
  80192. _prepare(): void;
  80193. /**
  80194. * Execute the action and executes all the aggregated actions.
  80195. */
  80196. execute(evt: ActionEvent): void;
  80197. /**
  80198. * Serializes the actions and its related information.
  80199. * @param parent defines the object to serialize in
  80200. * @returns the serialized object
  80201. */
  80202. serialize(parent: any): any;
  80203. }
  80204. /**
  80205. * This defines an action responsible to run code (external event) once triggered.
  80206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80207. */
  80208. export class ExecuteCodeAction extends Action {
  80209. /**
  80210. * The callback function to run.
  80211. */
  80212. func: (evt: ActionEvent) => void;
  80213. /**
  80214. * Instantiate the action
  80215. * @param triggerOptions defines the trigger options
  80216. * @param func defines the callback function to run
  80217. * @param condition defines the trigger related conditions
  80218. */
  80219. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  80220. /**
  80221. * Execute the action and run the attached code.
  80222. */
  80223. execute(evt: ActionEvent): void;
  80224. }
  80225. /**
  80226. * This defines an action responsible to set the parent property of the target once triggered.
  80227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80228. */
  80229. export class SetParentAction extends Action {
  80230. private _parent;
  80231. private _target;
  80232. /**
  80233. * Instantiate the action
  80234. * @param triggerOptions defines the trigger options
  80235. * @param target defines the target containing the parent property
  80236. * @param parent defines from where the animation should start (animation frame)
  80237. * @param condition defines the trigger related conditions
  80238. */
  80239. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  80240. /** @hidden */
  80241. _prepare(): void;
  80242. /**
  80243. * Execute the action and set the parent property.
  80244. */
  80245. execute(): void;
  80246. /**
  80247. * Serializes the actions and its related information.
  80248. * @param parent defines the object to serialize in
  80249. * @returns the serialized object
  80250. */
  80251. serialize(parent: any): any;
  80252. }
  80253. }
  80254. declare module BABYLON {
  80255. /**
  80256. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  80257. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  80258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  80259. */
  80260. export class ActionManager extends AbstractActionManager {
  80261. /**
  80262. * Nothing
  80263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80264. */
  80265. static readonly NothingTrigger: number;
  80266. /**
  80267. * On pick
  80268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80269. */
  80270. static readonly OnPickTrigger: number;
  80271. /**
  80272. * On left pick
  80273. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80274. */
  80275. static readonly OnLeftPickTrigger: number;
  80276. /**
  80277. * On right pick
  80278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80279. */
  80280. static readonly OnRightPickTrigger: number;
  80281. /**
  80282. * On center pick
  80283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80284. */
  80285. static readonly OnCenterPickTrigger: number;
  80286. /**
  80287. * On pick down
  80288. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80289. */
  80290. static readonly OnPickDownTrigger: number;
  80291. /**
  80292. * On double pick
  80293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80294. */
  80295. static readonly OnDoublePickTrigger: number;
  80296. /**
  80297. * On pick up
  80298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80299. */
  80300. static readonly OnPickUpTrigger: number;
  80301. /**
  80302. * On pick out.
  80303. * This trigger will only be raised if you also declared a OnPickDown
  80304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80305. */
  80306. static readonly OnPickOutTrigger: number;
  80307. /**
  80308. * On long press
  80309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80310. */
  80311. static readonly OnLongPressTrigger: number;
  80312. /**
  80313. * On pointer over
  80314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80315. */
  80316. static readonly OnPointerOverTrigger: number;
  80317. /**
  80318. * On pointer out
  80319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80320. */
  80321. static readonly OnPointerOutTrigger: number;
  80322. /**
  80323. * On every frame
  80324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80325. */
  80326. static readonly OnEveryFrameTrigger: number;
  80327. /**
  80328. * On intersection enter
  80329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80330. */
  80331. static readonly OnIntersectionEnterTrigger: number;
  80332. /**
  80333. * On intersection exit
  80334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80335. */
  80336. static readonly OnIntersectionExitTrigger: number;
  80337. /**
  80338. * On key down
  80339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80340. */
  80341. static readonly OnKeyDownTrigger: number;
  80342. /**
  80343. * On key up
  80344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80345. */
  80346. static readonly OnKeyUpTrigger: number;
  80347. private _scene;
  80348. /**
  80349. * Creates a new action manager
  80350. * @param scene defines the hosting scene
  80351. */
  80352. constructor(scene: Scene);
  80353. /**
  80354. * Releases all associated resources
  80355. */
  80356. dispose(): void;
  80357. /**
  80358. * Gets hosting scene
  80359. * @returns the hosting scene
  80360. */
  80361. getScene(): Scene;
  80362. /**
  80363. * Does this action manager handles actions of any of the given triggers
  80364. * @param triggers defines the triggers to be tested
  80365. * @return a boolean indicating whether one (or more) of the triggers is handled
  80366. */
  80367. hasSpecificTriggers(triggers: number[]): boolean;
  80368. /**
  80369. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  80370. * speed.
  80371. * @param triggerA defines the trigger to be tested
  80372. * @param triggerB defines the trigger to be tested
  80373. * @return a boolean indicating whether one (or more) of the triggers is handled
  80374. */
  80375. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  80376. /**
  80377. * Does this action manager handles actions of a given trigger
  80378. * @param trigger defines the trigger to be tested
  80379. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  80380. * @return whether the trigger is handled
  80381. */
  80382. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  80383. /**
  80384. * Does this action manager has pointer triggers
  80385. */
  80386. readonly hasPointerTriggers: boolean;
  80387. /**
  80388. * Does this action manager has pick triggers
  80389. */
  80390. readonly hasPickTriggers: boolean;
  80391. /**
  80392. * Registers an action to this action manager
  80393. * @param action defines the action to be registered
  80394. * @return the action amended (prepared) after registration
  80395. */
  80396. registerAction(action: IAction): Nullable<IAction>;
  80397. /**
  80398. * Unregisters an action to this action manager
  80399. * @param action defines the action to be unregistered
  80400. * @return a boolean indicating whether the action has been unregistered
  80401. */
  80402. unregisterAction(action: IAction): Boolean;
  80403. /**
  80404. * Process a specific trigger
  80405. * @param trigger defines the trigger to process
  80406. * @param evt defines the event details to be processed
  80407. */
  80408. processTrigger(trigger: number, evt?: IActionEvent): void;
  80409. /** @hidden */
  80410. _getEffectiveTarget(target: any, propertyPath: string): any;
  80411. /** @hidden */
  80412. _getProperty(propertyPath: string): string;
  80413. /**
  80414. * Serialize this manager to a JSON object
  80415. * @param name defines the property name to store this manager
  80416. * @returns a JSON representation of this manager
  80417. */
  80418. serialize(name: string): any;
  80419. /**
  80420. * Creates a new ActionManager from a JSON data
  80421. * @param parsedActions defines the JSON data to read from
  80422. * @param object defines the hosting mesh
  80423. * @param scene defines the hosting scene
  80424. */
  80425. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  80426. /**
  80427. * Get a trigger name by index
  80428. * @param trigger defines the trigger index
  80429. * @returns a trigger name
  80430. */
  80431. static GetTriggerName(trigger: number): string;
  80432. }
  80433. }
  80434. declare module BABYLON {
  80435. /**
  80436. * Class representing a ray with position and direction
  80437. */
  80438. export class Ray {
  80439. /** origin point */
  80440. origin: Vector3;
  80441. /** direction */
  80442. direction: Vector3;
  80443. /** length of the ray */
  80444. length: number;
  80445. private static readonly TmpVector3;
  80446. private _tmpRay;
  80447. /**
  80448. * Creates a new ray
  80449. * @param origin origin point
  80450. * @param direction direction
  80451. * @param length length of the ray
  80452. */
  80453. constructor(
  80454. /** origin point */
  80455. origin: Vector3,
  80456. /** direction */
  80457. direction: Vector3,
  80458. /** length of the ray */
  80459. length?: number);
  80460. /**
  80461. * Checks if the ray intersects a box
  80462. * @param minimum bound of the box
  80463. * @param maximum bound of the box
  80464. * @param intersectionTreshold extra extend to be added to the box in all direction
  80465. * @returns if the box was hit
  80466. */
  80467. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  80468. /**
  80469. * Checks if the ray intersects a box
  80470. * @param box the bounding box to check
  80471. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  80472. * @returns if the box was hit
  80473. */
  80474. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  80475. /**
  80476. * If the ray hits a sphere
  80477. * @param sphere the bounding sphere to check
  80478. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  80479. * @returns true if it hits the sphere
  80480. */
  80481. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  80482. /**
  80483. * If the ray hits a triange
  80484. * @param vertex0 triangle vertex
  80485. * @param vertex1 triangle vertex
  80486. * @param vertex2 triangle vertex
  80487. * @returns intersection information if hit
  80488. */
  80489. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  80490. /**
  80491. * Checks if ray intersects a plane
  80492. * @param plane the plane to check
  80493. * @returns the distance away it was hit
  80494. */
  80495. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  80496. /**
  80497. * Calculate the intercept of a ray on a given axis
  80498. * @param axis to check 'x' | 'y' | 'z'
  80499. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  80500. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  80501. */
  80502. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  80503. /**
  80504. * Checks if ray intersects a mesh
  80505. * @param mesh the mesh to check
  80506. * @param fastCheck if only the bounding box should checked
  80507. * @returns picking info of the intersecton
  80508. */
  80509. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  80510. /**
  80511. * Checks if ray intersects a mesh
  80512. * @param meshes the meshes to check
  80513. * @param fastCheck if only the bounding box should checked
  80514. * @param results array to store result in
  80515. * @returns Array of picking infos
  80516. */
  80517. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  80518. private _comparePickingInfo;
  80519. private static smallnum;
  80520. private static rayl;
  80521. /**
  80522. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  80523. * @param sega the first point of the segment to test the intersection against
  80524. * @param segb the second point of the segment to test the intersection against
  80525. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  80526. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  80527. */
  80528. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  80529. /**
  80530. * Update the ray from viewport position
  80531. * @param x position
  80532. * @param y y position
  80533. * @param viewportWidth viewport width
  80534. * @param viewportHeight viewport height
  80535. * @param world world matrix
  80536. * @param view view matrix
  80537. * @param projection projection matrix
  80538. * @returns this ray updated
  80539. */
  80540. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80541. /**
  80542. * Creates a ray with origin and direction of 0,0,0
  80543. * @returns the new ray
  80544. */
  80545. static Zero(): Ray;
  80546. /**
  80547. * Creates a new ray from screen space and viewport
  80548. * @param x position
  80549. * @param y y position
  80550. * @param viewportWidth viewport width
  80551. * @param viewportHeight viewport height
  80552. * @param world world matrix
  80553. * @param view view matrix
  80554. * @param projection projection matrix
  80555. * @returns new ray
  80556. */
  80557. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  80558. /**
  80559. * 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
  80560. * transformed to the given world matrix.
  80561. * @param origin The origin point
  80562. * @param end The end point
  80563. * @param world a matrix to transform the ray to. Default is the identity matrix.
  80564. * @returns the new ray
  80565. */
  80566. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  80567. /**
  80568. * Transforms a ray by a matrix
  80569. * @param ray ray to transform
  80570. * @param matrix matrix to apply
  80571. * @returns the resulting new ray
  80572. */
  80573. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  80574. /**
  80575. * Transforms a ray by a matrix
  80576. * @param ray ray to transform
  80577. * @param matrix matrix to apply
  80578. * @param result ray to store result in
  80579. */
  80580. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  80581. /**
  80582. * Unproject a ray from screen space to object space
  80583. * @param sourceX defines the screen space x coordinate to use
  80584. * @param sourceY defines the screen space y coordinate to use
  80585. * @param viewportWidth defines the current width of the viewport
  80586. * @param viewportHeight defines the current height of the viewport
  80587. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80588. * @param view defines the view matrix to use
  80589. * @param projection defines the projection matrix to use
  80590. */
  80591. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  80592. }
  80593. /**
  80594. * Type used to define predicate used to select faces when a mesh intersection is detected
  80595. */
  80596. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  80597. interface Scene {
  80598. /** @hidden */
  80599. _tempPickingRay: Nullable<Ray>;
  80600. /** @hidden */
  80601. _cachedRayForTransform: Ray;
  80602. /** @hidden */
  80603. _pickWithRayInverseMatrix: Matrix;
  80604. /** @hidden */
  80605. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  80606. /** @hidden */
  80607. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  80608. }
  80609. }
  80610. declare module BABYLON {
  80611. /**
  80612. * Groups all the scene component constants in one place to ease maintenance.
  80613. * @hidden
  80614. */
  80615. export class SceneComponentConstants {
  80616. static readonly NAME_EFFECTLAYER: string;
  80617. static readonly NAME_LAYER: string;
  80618. static readonly NAME_LENSFLARESYSTEM: string;
  80619. static readonly NAME_BOUNDINGBOXRENDERER: string;
  80620. static readonly NAME_PARTICLESYSTEM: string;
  80621. static readonly NAME_GAMEPAD: string;
  80622. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  80623. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  80624. static readonly NAME_DEPTHRENDERER: string;
  80625. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  80626. static readonly NAME_SPRITE: string;
  80627. static readonly NAME_OUTLINERENDERER: string;
  80628. static readonly NAME_PROCEDURALTEXTURE: string;
  80629. static readonly NAME_SHADOWGENERATOR: string;
  80630. static readonly NAME_OCTREE: string;
  80631. static readonly NAME_PHYSICSENGINE: string;
  80632. static readonly NAME_AUDIO: string;
  80633. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  80634. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80635. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  80636. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  80637. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  80638. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  80639. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  80640. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  80641. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  80642. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  80643. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  80644. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  80645. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  80646. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  80647. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  80648. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  80649. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  80650. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  80651. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  80652. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  80653. static readonly STEP_AFTERRENDER_AUDIO: number;
  80654. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  80655. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  80656. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  80657. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  80658. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  80659. static readonly STEP_POINTERMOVE_SPRITE: number;
  80660. static readonly STEP_POINTERDOWN_SPRITE: number;
  80661. static readonly STEP_POINTERUP_SPRITE: number;
  80662. }
  80663. /**
  80664. * This represents a scene component.
  80665. *
  80666. * This is used to decouple the dependency the scene is having on the different workloads like
  80667. * layers, post processes...
  80668. */
  80669. export interface ISceneComponent {
  80670. /**
  80671. * The name of the component. Each component must have a unique name.
  80672. */
  80673. name: string;
  80674. /**
  80675. * The scene the component belongs to.
  80676. */
  80677. scene: Scene;
  80678. /**
  80679. * Register the component to one instance of a scene.
  80680. */
  80681. register(): void;
  80682. /**
  80683. * Rebuilds the elements related to this component in case of
  80684. * context lost for instance.
  80685. */
  80686. rebuild(): void;
  80687. /**
  80688. * Disposes the component and the associated ressources.
  80689. */
  80690. dispose(): void;
  80691. }
  80692. /**
  80693. * This represents a SERIALIZABLE scene component.
  80694. *
  80695. * This extends Scene Component to add Serialization methods on top.
  80696. */
  80697. export interface ISceneSerializableComponent extends ISceneComponent {
  80698. /**
  80699. * Adds all the elements from the container to the scene
  80700. * @param container the container holding the elements
  80701. */
  80702. addFromContainer(container: AbstractScene): void;
  80703. /**
  80704. * Removes all the elements in the container from the scene
  80705. * @param container contains the elements to remove
  80706. * @param dispose if the removed element should be disposed (default: false)
  80707. */
  80708. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  80709. /**
  80710. * Serializes the component data to the specified json object
  80711. * @param serializationObject The object to serialize to
  80712. */
  80713. serialize(serializationObject: any): void;
  80714. }
  80715. /**
  80716. * Strong typing of a Mesh related stage step action
  80717. */
  80718. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  80719. /**
  80720. * Strong typing of a Evaluate Sub Mesh related stage step action
  80721. */
  80722. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  80723. /**
  80724. * Strong typing of a Active Mesh related stage step action
  80725. */
  80726. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  80727. /**
  80728. * Strong typing of a Camera related stage step action
  80729. */
  80730. export type CameraStageAction = (camera: Camera) => void;
  80731. /**
  80732. * Strong typing of a Camera Frame buffer related stage step action
  80733. */
  80734. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  80735. /**
  80736. * Strong typing of a Render Target related stage step action
  80737. */
  80738. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  80739. /**
  80740. * Strong typing of a RenderingGroup related stage step action
  80741. */
  80742. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  80743. /**
  80744. * Strong typing of a Mesh Render related stage step action
  80745. */
  80746. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  80747. /**
  80748. * Strong typing of a simple stage step action
  80749. */
  80750. export type SimpleStageAction = () => void;
  80751. /**
  80752. * Strong typing of a render target action.
  80753. */
  80754. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  80755. /**
  80756. * Strong typing of a pointer move action.
  80757. */
  80758. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  80759. /**
  80760. * Strong typing of a pointer up/down action.
  80761. */
  80762. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  80763. /**
  80764. * Representation of a stage in the scene (Basically a list of ordered steps)
  80765. * @hidden
  80766. */
  80767. export class Stage<T extends Function> extends Array<{
  80768. index: number;
  80769. component: ISceneComponent;
  80770. action: T;
  80771. }> {
  80772. /**
  80773. * Hide ctor from the rest of the world.
  80774. * @param items The items to add.
  80775. */
  80776. private constructor();
  80777. /**
  80778. * Creates a new Stage.
  80779. * @returns A new instance of a Stage
  80780. */
  80781. static Create<T extends Function>(): Stage<T>;
  80782. /**
  80783. * Registers a step in an ordered way in the targeted stage.
  80784. * @param index Defines the position to register the step in
  80785. * @param component Defines the component attached to the step
  80786. * @param action Defines the action to launch during the step
  80787. */
  80788. registerStep(index: number, component: ISceneComponent, action: T): void;
  80789. /**
  80790. * Clears all the steps from the stage.
  80791. */
  80792. clear(): void;
  80793. }
  80794. }
  80795. declare module BABYLON {
  80796. interface Scene {
  80797. /** @hidden */
  80798. _pointerOverSprite: Nullable<Sprite>;
  80799. /** @hidden */
  80800. _pickedDownSprite: Nullable<Sprite>;
  80801. /** @hidden */
  80802. _tempSpritePickingRay: Nullable<Ray>;
  80803. /**
  80804. * All of the sprite managers added to this scene
  80805. * @see http://doc.babylonjs.com/babylon101/sprites
  80806. */
  80807. spriteManagers: Array<ISpriteManager>;
  80808. /**
  80809. * An event triggered when sprites rendering is about to start
  80810. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80811. */
  80812. onBeforeSpritesRenderingObservable: Observable<Scene>;
  80813. /**
  80814. * An event triggered when sprites rendering is done
  80815. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  80816. */
  80817. onAfterSpritesRenderingObservable: Observable<Scene>;
  80818. /** @hidden */
  80819. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80820. /** Launch a ray to try to pick a sprite in the scene
  80821. * @param x position on screen
  80822. * @param y position on screen
  80823. * @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
  80824. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80825. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80826. * @returns a PickingInfo
  80827. */
  80828. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80829. /** Use the given ray to pick a sprite in the scene
  80830. * @param ray The ray (in world space) to use to pick meshes
  80831. * @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
  80832. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  80833. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80834. * @returns a PickingInfo
  80835. */
  80836. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  80837. /** @hidden */
  80838. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80839. /** Launch a ray to try to pick sprites in the scene
  80840. * @param x position on screen
  80841. * @param y position on screen
  80842. * @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
  80843. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  80844. * @returns a PickingInfo array
  80845. */
  80846. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80847. /** Use the given ray to pick sprites in the scene
  80848. * @param ray The ray (in world space) to use to pick meshes
  80849. * @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
  80850. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  80851. * @returns a PickingInfo array
  80852. */
  80853. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  80854. /**
  80855. * Force the sprite under the pointer
  80856. * @param sprite defines the sprite to use
  80857. */
  80858. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  80859. /**
  80860. * Gets the sprite under the pointer
  80861. * @returns a Sprite or null if no sprite is under the pointer
  80862. */
  80863. getPointerOverSprite(): Nullable<Sprite>;
  80864. }
  80865. /**
  80866. * Defines the sprite scene component responsible to manage sprites
  80867. * in a given scene.
  80868. */
  80869. export class SpriteSceneComponent implements ISceneComponent {
  80870. /**
  80871. * The component name helpfull to identify the component in the list of scene components.
  80872. */
  80873. readonly name: string;
  80874. /**
  80875. * The scene the component belongs to.
  80876. */
  80877. scene: Scene;
  80878. /** @hidden */
  80879. private _spritePredicate;
  80880. /**
  80881. * Creates a new instance of the component for the given scene
  80882. * @param scene Defines the scene to register the component in
  80883. */
  80884. constructor(scene: Scene);
  80885. /**
  80886. * Registers the component in a given scene
  80887. */
  80888. register(): void;
  80889. /**
  80890. * Rebuilds the elements related to this component in case of
  80891. * context lost for instance.
  80892. */
  80893. rebuild(): void;
  80894. /**
  80895. * Disposes the component and the associated ressources.
  80896. */
  80897. dispose(): void;
  80898. private _pickSpriteButKeepRay;
  80899. private _pointerMove;
  80900. private _pointerDown;
  80901. private _pointerUp;
  80902. }
  80903. }
  80904. declare module BABYLON {
  80905. /** @hidden */
  80906. export var fogFragmentDeclaration: {
  80907. name: string;
  80908. shader: string;
  80909. };
  80910. }
  80911. declare module BABYLON {
  80912. /** @hidden */
  80913. export var fogFragment: {
  80914. name: string;
  80915. shader: string;
  80916. };
  80917. }
  80918. declare module BABYLON {
  80919. /** @hidden */
  80920. export var spritesPixelShader: {
  80921. name: string;
  80922. shader: string;
  80923. };
  80924. }
  80925. declare module BABYLON {
  80926. /** @hidden */
  80927. export var fogVertexDeclaration: {
  80928. name: string;
  80929. shader: string;
  80930. };
  80931. }
  80932. declare module BABYLON {
  80933. /** @hidden */
  80934. export var spritesVertexShader: {
  80935. name: string;
  80936. shader: string;
  80937. };
  80938. }
  80939. declare module BABYLON {
  80940. /**
  80941. * Defines the minimum interface to fullfil in order to be a sprite manager.
  80942. */
  80943. export interface ISpriteManager extends IDisposable {
  80944. /**
  80945. * Restricts the camera to viewing objects with the same layerMask.
  80946. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  80947. */
  80948. layerMask: number;
  80949. /**
  80950. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  80951. */
  80952. isPickable: boolean;
  80953. /**
  80954. * Specifies the rendering group id for this mesh (0 by default)
  80955. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  80956. */
  80957. renderingGroupId: number;
  80958. /**
  80959. * Defines the list of sprites managed by the manager.
  80960. */
  80961. sprites: Array<Sprite>;
  80962. /**
  80963. * Tests the intersection of a sprite with a specific ray.
  80964. * @param ray The ray we are sending to test the collision
  80965. * @param camera The camera space we are sending rays in
  80966. * @param predicate A predicate allowing excluding sprites from the list of object to test
  80967. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  80968. * @returns picking info or null.
  80969. */
  80970. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80971. /**
  80972. * Intersects the sprites with a ray
  80973. * @param ray defines the ray to intersect with
  80974. * @param camera defines the current active camera
  80975. * @param predicate defines a predicate used to select candidate sprites
  80976. * @returns null if no hit or a PickingInfo array
  80977. */
  80978. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80979. /**
  80980. * Renders the list of sprites on screen.
  80981. */
  80982. render(): void;
  80983. }
  80984. /**
  80985. * Class used to manage multiple sprites on the same spritesheet
  80986. * @see http://doc.babylonjs.com/babylon101/sprites
  80987. */
  80988. export class SpriteManager implements ISpriteManager {
  80989. /** defines the manager's name */
  80990. name: string;
  80991. /** Gets the list of sprites */
  80992. sprites: Sprite[];
  80993. /** Gets or sets the rendering group id (0 by default) */
  80994. renderingGroupId: number;
  80995. /** Gets or sets camera layer mask */
  80996. layerMask: number;
  80997. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  80998. fogEnabled: boolean;
  80999. /** Gets or sets a boolean indicating if the sprites are pickable */
  81000. isPickable: boolean;
  81001. /** Defines the default width of a cell in the spritesheet */
  81002. cellWidth: number;
  81003. /** Defines the default height of a cell in the spritesheet */
  81004. cellHeight: number;
  81005. /** Associative array from JSON sprite data file */
  81006. private _cellData;
  81007. /** Array of sprite names from JSON sprite data file */
  81008. private _spriteMap;
  81009. /** True when packed cell data from JSON file is ready*/
  81010. private _packedAndReady;
  81011. /**
  81012. * An event triggered when the manager is disposed.
  81013. */
  81014. onDisposeObservable: Observable<SpriteManager>;
  81015. private _onDisposeObserver;
  81016. /**
  81017. * Callback called when the manager is disposed
  81018. */
  81019. onDispose: () => void;
  81020. private _capacity;
  81021. private _fromPacked;
  81022. private _spriteTexture;
  81023. private _epsilon;
  81024. private _scene;
  81025. private _vertexData;
  81026. private _buffer;
  81027. private _vertexBuffers;
  81028. private _indexBuffer;
  81029. private _effectBase;
  81030. private _effectFog;
  81031. /**
  81032. * Gets or sets the spritesheet texture
  81033. */
  81034. texture: Texture;
  81035. /**
  81036. * Creates a new sprite manager
  81037. * @param name defines the manager's name
  81038. * @param imgUrl defines the sprite sheet url
  81039. * @param capacity defines the maximum allowed number of sprites
  81040. * @param cellSize defines the size of a sprite cell
  81041. * @param scene defines the hosting scene
  81042. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  81043. * @param samplingMode defines the smapling mode to use with spritesheet
  81044. * @param fromPacked set to false; do not alter
  81045. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  81046. */
  81047. constructor(
  81048. /** defines the manager's name */
  81049. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  81050. private _makePacked;
  81051. private _appendSpriteVertex;
  81052. /**
  81053. * Intersects the sprites with a ray
  81054. * @param ray defines the ray to intersect with
  81055. * @param camera defines the current active camera
  81056. * @param predicate defines a predicate used to select candidate sprites
  81057. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  81058. * @returns null if no hit or a PickingInfo
  81059. */
  81060. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  81061. /**
  81062. * Intersects the sprites with a ray
  81063. * @param ray defines the ray to intersect with
  81064. * @param camera defines the current active camera
  81065. * @param predicate defines a predicate used to select candidate sprites
  81066. * @returns null if no hit or a PickingInfo array
  81067. */
  81068. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  81069. /**
  81070. * Render all child sprites
  81071. */
  81072. render(): void;
  81073. /**
  81074. * Release associated resources
  81075. */
  81076. dispose(): void;
  81077. }
  81078. }
  81079. declare module BABYLON {
  81080. /**
  81081. * Class used to represent a sprite
  81082. * @see http://doc.babylonjs.com/babylon101/sprites
  81083. */
  81084. export class Sprite {
  81085. /** defines the name */
  81086. name: string;
  81087. /** Gets or sets the current world position */
  81088. position: Vector3;
  81089. /** Gets or sets the main color */
  81090. color: Color4;
  81091. /** Gets or sets the width */
  81092. width: number;
  81093. /** Gets or sets the height */
  81094. height: number;
  81095. /** Gets or sets rotation angle */
  81096. angle: number;
  81097. /** Gets or sets the cell index in the sprite sheet */
  81098. cellIndex: number;
  81099. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  81100. cellRef: string;
  81101. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  81102. invertU: number;
  81103. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  81104. invertV: number;
  81105. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  81106. disposeWhenFinishedAnimating: boolean;
  81107. /** Gets the list of attached animations */
  81108. animations: Animation[];
  81109. /** Gets or sets a boolean indicating if the sprite can be picked */
  81110. isPickable: boolean;
  81111. /**
  81112. * Gets or sets the associated action manager
  81113. */
  81114. actionManager: Nullable<ActionManager>;
  81115. private _animationStarted;
  81116. private _loopAnimation;
  81117. private _fromIndex;
  81118. private _toIndex;
  81119. private _delay;
  81120. private _direction;
  81121. private _manager;
  81122. private _time;
  81123. private _onAnimationEnd;
  81124. /**
  81125. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  81126. */
  81127. isVisible: boolean;
  81128. /**
  81129. * Gets or sets the sprite size
  81130. */
  81131. size: number;
  81132. /**
  81133. * Creates a new Sprite
  81134. * @param name defines the name
  81135. * @param manager defines the manager
  81136. */
  81137. constructor(
  81138. /** defines the name */
  81139. name: string, manager: ISpriteManager);
  81140. /**
  81141. * Starts an animation
  81142. * @param from defines the initial key
  81143. * @param to defines the end key
  81144. * @param loop defines if the animation must loop
  81145. * @param delay defines the start delay (in ms)
  81146. * @param onAnimationEnd defines a callback to call when animation ends
  81147. */
  81148. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  81149. /** Stops current animation (if any) */
  81150. stopAnimation(): void;
  81151. /** @hidden */
  81152. _animate(deltaTime: number): void;
  81153. /** Release associated resources */
  81154. dispose(): void;
  81155. }
  81156. }
  81157. declare module BABYLON {
  81158. /**
  81159. * Information about the result of picking within a scene
  81160. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  81161. */
  81162. export class PickingInfo {
  81163. /** @hidden */
  81164. _pickingUnavailable: boolean;
  81165. /**
  81166. * If the pick collided with an object
  81167. */
  81168. hit: boolean;
  81169. /**
  81170. * Distance away where the pick collided
  81171. */
  81172. distance: number;
  81173. /**
  81174. * The location of pick collision
  81175. */
  81176. pickedPoint: Nullable<Vector3>;
  81177. /**
  81178. * The mesh corresponding the the pick collision
  81179. */
  81180. pickedMesh: Nullable<AbstractMesh>;
  81181. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  81182. bu: number;
  81183. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  81184. bv: number;
  81185. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  81186. faceId: number;
  81187. /** Id of the the submesh that was picked */
  81188. subMeshId: number;
  81189. /** If a sprite was picked, this will be the sprite the pick collided with */
  81190. pickedSprite: Nullable<Sprite>;
  81191. /**
  81192. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  81193. */
  81194. originMesh: Nullable<AbstractMesh>;
  81195. /**
  81196. * The ray that was used to perform the picking.
  81197. */
  81198. ray: Nullable<Ray>;
  81199. /**
  81200. * Gets the normal correspodning to the face the pick collided with
  81201. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  81202. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  81203. * @returns The normal correspodning to the face the pick collided with
  81204. */
  81205. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  81206. /**
  81207. * Gets the texture coordinates of where the pick occured
  81208. * @returns the vector containing the coordnates of the texture
  81209. */
  81210. getTextureCoordinates(): Nullable<Vector2>;
  81211. }
  81212. }
  81213. declare module BABYLON {
  81214. /**
  81215. * Gather the list of pointer event types as constants.
  81216. */
  81217. export class PointerEventTypes {
  81218. /**
  81219. * 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.
  81220. */
  81221. static readonly POINTERDOWN: number;
  81222. /**
  81223. * The pointerup event is fired when a pointer is no longer active.
  81224. */
  81225. static readonly POINTERUP: number;
  81226. /**
  81227. * The pointermove event is fired when a pointer changes coordinates.
  81228. */
  81229. static readonly POINTERMOVE: number;
  81230. /**
  81231. * The pointerwheel event is fired when a mouse wheel has been rotated.
  81232. */
  81233. static readonly POINTERWHEEL: number;
  81234. /**
  81235. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  81236. */
  81237. static readonly POINTERPICK: number;
  81238. /**
  81239. * The pointertap event is fired when a the object has been touched and released without drag.
  81240. */
  81241. static readonly POINTERTAP: number;
  81242. /**
  81243. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  81244. */
  81245. static readonly POINTERDOUBLETAP: number;
  81246. }
  81247. /**
  81248. * Base class of pointer info types.
  81249. */
  81250. export class PointerInfoBase {
  81251. /**
  81252. * Defines the type of event (PointerEventTypes)
  81253. */
  81254. type: number;
  81255. /**
  81256. * Defines the related dom event
  81257. */
  81258. event: PointerEvent | MouseWheelEvent;
  81259. /**
  81260. * Instantiates the base class of pointers info.
  81261. * @param type Defines the type of event (PointerEventTypes)
  81262. * @param event Defines the related dom event
  81263. */
  81264. constructor(
  81265. /**
  81266. * Defines the type of event (PointerEventTypes)
  81267. */
  81268. type: number,
  81269. /**
  81270. * Defines the related dom event
  81271. */
  81272. event: PointerEvent | MouseWheelEvent);
  81273. }
  81274. /**
  81275. * This class is used to store pointer related info for the onPrePointerObservable event.
  81276. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  81277. */
  81278. export class PointerInfoPre extends PointerInfoBase {
  81279. /**
  81280. * Ray from a pointer if availible (eg. 6dof controller)
  81281. */
  81282. ray: Nullable<Ray>;
  81283. /**
  81284. * Defines the local position of the pointer on the canvas.
  81285. */
  81286. localPosition: Vector2;
  81287. /**
  81288. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  81289. */
  81290. skipOnPointerObservable: boolean;
  81291. /**
  81292. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  81293. * @param type Defines the type of event (PointerEventTypes)
  81294. * @param event Defines the related dom event
  81295. * @param localX Defines the local x coordinates of the pointer when the event occured
  81296. * @param localY Defines the local y coordinates of the pointer when the event occured
  81297. */
  81298. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  81299. }
  81300. /**
  81301. * This type contains all the data related to a pointer event in Babylon.js.
  81302. * 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.
  81303. */
  81304. export class PointerInfo extends PointerInfoBase {
  81305. /**
  81306. * Defines the picking info associated to the info (if any)\
  81307. */
  81308. pickInfo: Nullable<PickingInfo>;
  81309. /**
  81310. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  81311. * @param type Defines the type of event (PointerEventTypes)
  81312. * @param event Defines the related dom event
  81313. * @param pickInfo Defines the picking info associated to the info (if any)\
  81314. */
  81315. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  81316. /**
  81317. * Defines the picking info associated to the info (if any)\
  81318. */
  81319. pickInfo: Nullable<PickingInfo>);
  81320. }
  81321. /**
  81322. * Data relating to a touch event on the screen.
  81323. */
  81324. export interface PointerTouch {
  81325. /**
  81326. * X coordinate of touch.
  81327. */
  81328. x: number;
  81329. /**
  81330. * Y coordinate of touch.
  81331. */
  81332. y: number;
  81333. /**
  81334. * Id of touch. Unique for each finger.
  81335. */
  81336. pointerId: number;
  81337. /**
  81338. * Event type passed from DOM.
  81339. */
  81340. type: any;
  81341. }
  81342. }
  81343. declare module BABYLON {
  81344. /**
  81345. * Manage the mouse inputs to control the movement of a free camera.
  81346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81347. */
  81348. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  81349. /**
  81350. * Define if touch is enabled in the mouse input
  81351. */
  81352. touchEnabled: boolean;
  81353. /**
  81354. * Defines the camera the input is attached to.
  81355. */
  81356. camera: FreeCamera;
  81357. /**
  81358. * Defines the buttons associated with the input to handle camera move.
  81359. */
  81360. buttons: number[];
  81361. /**
  81362. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  81363. */
  81364. angularSensibility: number;
  81365. private _pointerInput;
  81366. private _onMouseMove;
  81367. private _observer;
  81368. private previousPosition;
  81369. /**
  81370. * Observable for when a pointer move event occurs containing the move offset
  81371. */
  81372. onPointerMovedObservable: Observable<{
  81373. offsetX: number;
  81374. offsetY: number;
  81375. }>;
  81376. /**
  81377. * @hidden
  81378. * If the camera should be rotated automatically based on pointer movement
  81379. */
  81380. _allowCameraRotation: boolean;
  81381. /**
  81382. * Manage the mouse inputs to control the movement of a free camera.
  81383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81384. * @param touchEnabled Defines if touch is enabled or not
  81385. */
  81386. constructor(
  81387. /**
  81388. * Define if touch is enabled in the mouse input
  81389. */
  81390. touchEnabled?: boolean);
  81391. /**
  81392. * Attach the input controls to a specific dom element to get the input from.
  81393. * @param element Defines the element the controls should be listened from
  81394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81395. */
  81396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81397. /**
  81398. * Called on JS contextmenu event.
  81399. * Override this method to provide functionality.
  81400. */
  81401. protected onContextMenu(evt: PointerEvent): void;
  81402. /**
  81403. * Detach the current controls from the specified dom element.
  81404. * @param element Defines the element to stop listening the inputs from
  81405. */
  81406. detachControl(element: Nullable<HTMLElement>): void;
  81407. /**
  81408. * Gets the class name of the current intput.
  81409. * @returns the class name
  81410. */
  81411. getClassName(): string;
  81412. /**
  81413. * Get the friendly name associated with the input class.
  81414. * @returns the input friendly name
  81415. */
  81416. getSimpleName(): string;
  81417. }
  81418. }
  81419. declare module BABYLON {
  81420. /**
  81421. * Manage the touch inputs to control the movement of a free camera.
  81422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81423. */
  81424. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  81425. /**
  81426. * Defines the camera the input is attached to.
  81427. */
  81428. camera: FreeCamera;
  81429. /**
  81430. * Defines the touch sensibility for rotation.
  81431. * The higher the faster.
  81432. */
  81433. touchAngularSensibility: number;
  81434. /**
  81435. * Defines the touch sensibility for move.
  81436. * The higher the faster.
  81437. */
  81438. touchMoveSensibility: number;
  81439. private _offsetX;
  81440. private _offsetY;
  81441. private _pointerPressed;
  81442. private _pointerInput;
  81443. private _observer;
  81444. private _onLostFocus;
  81445. /**
  81446. * Attach the input controls to a specific dom element to get the input from.
  81447. * @param element Defines the element the controls should be listened from
  81448. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81449. */
  81450. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81451. /**
  81452. * Detach the current controls from the specified dom element.
  81453. * @param element Defines the element to stop listening the inputs from
  81454. */
  81455. detachControl(element: Nullable<HTMLElement>): void;
  81456. /**
  81457. * Update the current camera state depending on the inputs that have been used this frame.
  81458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81459. */
  81460. checkInputs(): void;
  81461. /**
  81462. * Gets the class name of the current intput.
  81463. * @returns the class name
  81464. */
  81465. getClassName(): string;
  81466. /**
  81467. * Get the friendly name associated with the input class.
  81468. * @returns the input friendly name
  81469. */
  81470. getSimpleName(): string;
  81471. }
  81472. }
  81473. declare module BABYLON {
  81474. /**
  81475. * Default Inputs manager for the FreeCamera.
  81476. * It groups all the default supported inputs for ease of use.
  81477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81478. */
  81479. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  81480. /**
  81481. * @hidden
  81482. */
  81483. _mouseInput: Nullable<FreeCameraMouseInput>;
  81484. /**
  81485. * Instantiates a new FreeCameraInputsManager.
  81486. * @param camera Defines the camera the inputs belong to
  81487. */
  81488. constructor(camera: FreeCamera);
  81489. /**
  81490. * Add keyboard input support to the input manager.
  81491. * @returns the current input manager
  81492. */
  81493. addKeyboard(): FreeCameraInputsManager;
  81494. /**
  81495. * Add mouse input support to the input manager.
  81496. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  81497. * @returns the current input manager
  81498. */
  81499. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  81500. /**
  81501. * Removes the mouse input support from the manager
  81502. * @returns the current input manager
  81503. */
  81504. removeMouse(): FreeCameraInputsManager;
  81505. /**
  81506. * Add touch input support to the input manager.
  81507. * @returns the current input manager
  81508. */
  81509. addTouch(): FreeCameraInputsManager;
  81510. /**
  81511. * Remove all attached input methods from a camera
  81512. */
  81513. clear(): void;
  81514. }
  81515. }
  81516. declare module BABYLON {
  81517. /**
  81518. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81519. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  81520. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81521. */
  81522. export class FreeCamera extends TargetCamera {
  81523. /**
  81524. * Define the collision ellipsoid of the camera.
  81525. * This is helpful to simulate a camera body like the player body around the camera
  81526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  81527. */
  81528. ellipsoid: Vector3;
  81529. /**
  81530. * Define an offset for the position of the ellipsoid around the camera.
  81531. * This can be helpful to determine the center of the body near the gravity center of the body
  81532. * instead of its head.
  81533. */
  81534. ellipsoidOffset: Vector3;
  81535. /**
  81536. * Enable or disable collisions of the camera with the rest of the scene objects.
  81537. */
  81538. checkCollisions: boolean;
  81539. /**
  81540. * Enable or disable gravity on the camera.
  81541. */
  81542. applyGravity: boolean;
  81543. /**
  81544. * Define the input manager associated to the camera.
  81545. */
  81546. inputs: FreeCameraInputsManager;
  81547. /**
  81548. * Gets the input sensibility for a mouse input. (default is 2000.0)
  81549. * Higher values reduce sensitivity.
  81550. */
  81551. /**
  81552. * Sets the input sensibility for a mouse input. (default is 2000.0)
  81553. * Higher values reduce sensitivity.
  81554. */
  81555. angularSensibility: number;
  81556. /**
  81557. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81558. */
  81559. keysUp: number[];
  81560. /**
  81561. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81562. */
  81563. keysDown: number[];
  81564. /**
  81565. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81566. */
  81567. keysLeft: number[];
  81568. /**
  81569. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81570. */
  81571. keysRight: number[];
  81572. /**
  81573. * Event raised when the camera collide with a mesh in the scene.
  81574. */
  81575. onCollide: (collidedMesh: AbstractMesh) => void;
  81576. private _collider;
  81577. private _needMoveForGravity;
  81578. private _oldPosition;
  81579. private _diffPosition;
  81580. private _newPosition;
  81581. /** @hidden */
  81582. _localDirection: Vector3;
  81583. /** @hidden */
  81584. _transformedDirection: Vector3;
  81585. /**
  81586. * Instantiates a Free Camera.
  81587. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  81588. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  81589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  81590. * @param name Define the name of the camera in the scene
  81591. * @param position Define the start position of the camera in the scene
  81592. * @param scene Define the scene the camera belongs to
  81593. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81594. */
  81595. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81596. /**
  81597. * Attached controls to the current camera.
  81598. * @param element Defines the element the controls should be listened from
  81599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81600. */
  81601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81602. /**
  81603. * Detach the current controls from the camera.
  81604. * The camera will stop reacting to inputs.
  81605. * @param element Defines the element to stop listening the inputs from
  81606. */
  81607. detachControl(element: HTMLElement): void;
  81608. private _collisionMask;
  81609. /**
  81610. * Define a collision mask to limit the list of object the camera can collide with
  81611. */
  81612. collisionMask: number;
  81613. /** @hidden */
  81614. _collideWithWorld(displacement: Vector3): void;
  81615. private _onCollisionPositionChange;
  81616. /** @hidden */
  81617. _checkInputs(): void;
  81618. /** @hidden */
  81619. _decideIfNeedsToMove(): boolean;
  81620. /** @hidden */
  81621. _updatePosition(): void;
  81622. /**
  81623. * Destroy the camera and release the current resources hold by it.
  81624. */
  81625. dispose(): void;
  81626. /**
  81627. * Gets the current object class name.
  81628. * @return the class name
  81629. */
  81630. getClassName(): string;
  81631. }
  81632. }
  81633. declare module BABYLON {
  81634. /**
  81635. * Represents a gamepad control stick position
  81636. */
  81637. export class StickValues {
  81638. /**
  81639. * The x component of the control stick
  81640. */
  81641. x: number;
  81642. /**
  81643. * The y component of the control stick
  81644. */
  81645. y: number;
  81646. /**
  81647. * Initializes the gamepad x and y control stick values
  81648. * @param x The x component of the gamepad control stick value
  81649. * @param y The y component of the gamepad control stick value
  81650. */
  81651. constructor(
  81652. /**
  81653. * The x component of the control stick
  81654. */
  81655. x: number,
  81656. /**
  81657. * The y component of the control stick
  81658. */
  81659. y: number);
  81660. }
  81661. /**
  81662. * An interface which manages callbacks for gamepad button changes
  81663. */
  81664. export interface GamepadButtonChanges {
  81665. /**
  81666. * Called when a gamepad has been changed
  81667. */
  81668. changed: boolean;
  81669. /**
  81670. * Called when a gamepad press event has been triggered
  81671. */
  81672. pressChanged: boolean;
  81673. /**
  81674. * Called when a touch event has been triggered
  81675. */
  81676. touchChanged: boolean;
  81677. /**
  81678. * Called when a value has changed
  81679. */
  81680. valueChanged: boolean;
  81681. }
  81682. /**
  81683. * Represents a gamepad
  81684. */
  81685. export class Gamepad {
  81686. /**
  81687. * The id of the gamepad
  81688. */
  81689. id: string;
  81690. /**
  81691. * The index of the gamepad
  81692. */
  81693. index: number;
  81694. /**
  81695. * The browser gamepad
  81696. */
  81697. browserGamepad: any;
  81698. /**
  81699. * Specifies what type of gamepad this represents
  81700. */
  81701. type: number;
  81702. private _leftStick;
  81703. private _rightStick;
  81704. /** @hidden */
  81705. _isConnected: boolean;
  81706. private _leftStickAxisX;
  81707. private _leftStickAxisY;
  81708. private _rightStickAxisX;
  81709. private _rightStickAxisY;
  81710. /**
  81711. * Triggered when the left control stick has been changed
  81712. */
  81713. private _onleftstickchanged;
  81714. /**
  81715. * Triggered when the right control stick has been changed
  81716. */
  81717. private _onrightstickchanged;
  81718. /**
  81719. * Represents a gamepad controller
  81720. */
  81721. static GAMEPAD: number;
  81722. /**
  81723. * Represents a generic controller
  81724. */
  81725. static GENERIC: number;
  81726. /**
  81727. * Represents an XBox controller
  81728. */
  81729. static XBOX: number;
  81730. /**
  81731. * Represents a pose-enabled controller
  81732. */
  81733. static POSE_ENABLED: number;
  81734. /**
  81735. * Represents an Dual Shock controller
  81736. */
  81737. static DUALSHOCK: number;
  81738. /**
  81739. * Specifies whether the left control stick should be Y-inverted
  81740. */
  81741. protected _invertLeftStickY: boolean;
  81742. /**
  81743. * Specifies if the gamepad has been connected
  81744. */
  81745. readonly isConnected: boolean;
  81746. /**
  81747. * Initializes the gamepad
  81748. * @param id The id of the gamepad
  81749. * @param index The index of the gamepad
  81750. * @param browserGamepad The browser gamepad
  81751. * @param leftStickX The x component of the left joystick
  81752. * @param leftStickY The y component of the left joystick
  81753. * @param rightStickX The x component of the right joystick
  81754. * @param rightStickY The y component of the right joystick
  81755. */
  81756. constructor(
  81757. /**
  81758. * The id of the gamepad
  81759. */
  81760. id: string,
  81761. /**
  81762. * The index of the gamepad
  81763. */
  81764. index: number,
  81765. /**
  81766. * The browser gamepad
  81767. */
  81768. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  81769. /**
  81770. * Callback triggered when the left joystick has changed
  81771. * @param callback
  81772. */
  81773. onleftstickchanged(callback: (values: StickValues) => void): void;
  81774. /**
  81775. * Callback triggered when the right joystick has changed
  81776. * @param callback
  81777. */
  81778. onrightstickchanged(callback: (values: StickValues) => void): void;
  81779. /**
  81780. * Gets the left joystick
  81781. */
  81782. /**
  81783. * Sets the left joystick values
  81784. */
  81785. leftStick: StickValues;
  81786. /**
  81787. * Gets the right joystick
  81788. */
  81789. /**
  81790. * Sets the right joystick value
  81791. */
  81792. rightStick: StickValues;
  81793. /**
  81794. * Updates the gamepad joystick positions
  81795. */
  81796. update(): void;
  81797. /**
  81798. * Disposes the gamepad
  81799. */
  81800. dispose(): void;
  81801. }
  81802. /**
  81803. * Represents a generic gamepad
  81804. */
  81805. export class GenericPad extends Gamepad {
  81806. private _buttons;
  81807. private _onbuttondown;
  81808. private _onbuttonup;
  81809. /**
  81810. * Observable triggered when a button has been pressed
  81811. */
  81812. onButtonDownObservable: Observable<number>;
  81813. /**
  81814. * Observable triggered when a button has been released
  81815. */
  81816. onButtonUpObservable: Observable<number>;
  81817. /**
  81818. * Callback triggered when a button has been pressed
  81819. * @param callback Called when a button has been pressed
  81820. */
  81821. onbuttondown(callback: (buttonPressed: number) => void): void;
  81822. /**
  81823. * Callback triggered when a button has been released
  81824. * @param callback Called when a button has been released
  81825. */
  81826. onbuttonup(callback: (buttonReleased: number) => void): void;
  81827. /**
  81828. * Initializes the generic gamepad
  81829. * @param id The id of the generic gamepad
  81830. * @param index The index of the generic gamepad
  81831. * @param browserGamepad The browser gamepad
  81832. */
  81833. constructor(id: string, index: number, browserGamepad: any);
  81834. private _setButtonValue;
  81835. /**
  81836. * Updates the generic gamepad
  81837. */
  81838. update(): void;
  81839. /**
  81840. * Disposes the generic gamepad
  81841. */
  81842. dispose(): void;
  81843. }
  81844. }
  81845. declare module BABYLON {
  81846. interface Engine {
  81847. /**
  81848. * Creates a raw texture
  81849. * @param data defines the data to store in the texture
  81850. * @param width defines the width of the texture
  81851. * @param height defines the height of the texture
  81852. * @param format defines the format of the data
  81853. * @param generateMipMaps defines if the engine should generate the mip levels
  81854. * @param invertY defines if data must be stored with Y axis inverted
  81855. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  81856. * @param compression defines the compression used (null by default)
  81857. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81858. * @returns the raw texture inside an InternalTexture
  81859. */
  81860. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  81861. /**
  81862. * Update a raw texture
  81863. * @param texture defines the texture to update
  81864. * @param data defines the data to store in the texture
  81865. * @param format defines the format of the data
  81866. * @param invertY defines if data must be stored with Y axis inverted
  81867. */
  81868. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81869. /**
  81870. * Update a raw texture
  81871. * @param texture defines the texture to update
  81872. * @param data defines the data to store in the texture
  81873. * @param format defines the format of the data
  81874. * @param invertY defines if data must be stored with Y axis inverted
  81875. * @param compression defines the compression used (null by default)
  81876. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81877. */
  81878. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  81879. /**
  81880. * Creates a new raw cube texture
  81881. * @param data defines the array of data to use to create each face
  81882. * @param size defines the size of the textures
  81883. * @param format defines the format of the data
  81884. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81885. * @param generateMipMaps defines if the engine should generate the mip levels
  81886. * @param invertY defines if data must be stored with Y axis inverted
  81887. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81888. * @param compression defines the compression used (null by default)
  81889. * @returns the cube texture as an InternalTexture
  81890. */
  81891. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  81892. /**
  81893. * Update a raw cube texture
  81894. * @param texture defines the texture to udpdate
  81895. * @param data defines the data to store
  81896. * @param format defines the data format
  81897. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81898. * @param invertY defines if data must be stored with Y axis inverted
  81899. */
  81900. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  81901. /**
  81902. * Update a raw cube texture
  81903. * @param texture defines the texture to udpdate
  81904. * @param data defines the data to store
  81905. * @param format defines the data format
  81906. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81907. * @param invertY defines if data must be stored with Y axis inverted
  81908. * @param compression defines the compression used (null by default)
  81909. */
  81910. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  81911. /**
  81912. * Update a raw cube texture
  81913. * @param texture defines the texture to udpdate
  81914. * @param data defines the data to store
  81915. * @param format defines the data format
  81916. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  81917. * @param invertY defines if data must be stored with Y axis inverted
  81918. * @param compression defines the compression used (null by default)
  81919. * @param level defines which level of the texture to update
  81920. */
  81921. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  81922. /**
  81923. * Creates a new raw cube texture from a specified url
  81924. * @param url defines the url where the data is located
  81925. * @param scene defines the current scene
  81926. * @param size defines the size of the textures
  81927. * @param format defines the format of the data
  81928. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81929. * @param noMipmap defines if the engine should avoid generating the mip levels
  81930. * @param callback defines a callback used to extract texture data from loaded data
  81931. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81932. * @param onLoad defines a callback called when texture is loaded
  81933. * @param onError defines a callback called if there is an error
  81934. * @returns the cube texture as an InternalTexture
  81935. */
  81936. 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;
  81937. /**
  81938. * Creates a new raw cube texture from a specified url
  81939. * @param url defines the url where the data is located
  81940. * @param scene defines the current scene
  81941. * @param size defines the size of the textures
  81942. * @param format defines the format of the data
  81943. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  81944. * @param noMipmap defines if the engine should avoid generating the mip levels
  81945. * @param callback defines a callback used to extract texture data from loaded data
  81946. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  81947. * @param onLoad defines a callback called when texture is loaded
  81948. * @param onError defines a callback called if there is an error
  81949. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81950. * @param invertY defines if data must be stored with Y axis inverted
  81951. * @returns the cube texture as an InternalTexture
  81952. */
  81953. 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;
  81954. /**
  81955. * Creates a new raw 3D texture
  81956. * @param data defines the data used to create the texture
  81957. * @param width defines the width of the texture
  81958. * @param height defines the height of the texture
  81959. * @param depth defines the depth of the texture
  81960. * @param format defines the format of the texture
  81961. * @param generateMipMaps defines if the engine must generate mip levels
  81962. * @param invertY defines if data must be stored with Y axis inverted
  81963. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81964. * @param compression defines the compressed used (can be null)
  81965. * @param textureType defines the compressed used (can be null)
  81966. * @returns a new raw 3D texture (stored in an InternalTexture)
  81967. */
  81968. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  81969. /**
  81970. * Update a raw 3D texture
  81971. * @param texture defines the texture to update
  81972. * @param data defines the data to store
  81973. * @param format defines the data format
  81974. * @param invertY defines if data must be stored with Y axis inverted
  81975. */
  81976. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81977. /**
  81978. * Update a raw 3D texture
  81979. * @param texture defines the texture to update
  81980. * @param data defines the data to store
  81981. * @param format defines the data format
  81982. * @param invertY defines if data must be stored with Y axis inverted
  81983. * @param compression defines the used compression (can be null)
  81984. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81985. */
  81986. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81987. /**
  81988. * Creates a new raw 2D array texture
  81989. * @param data defines the data used to create the texture
  81990. * @param width defines the width of the texture
  81991. * @param height defines the height of the texture
  81992. * @param depth defines the number of layers of the texture
  81993. * @param format defines the format of the texture
  81994. * @param generateMipMaps defines if the engine must generate mip levels
  81995. * @param invertY defines if data must be stored with Y axis inverted
  81996. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  81997. * @param compression defines the compressed used (can be null)
  81998. * @param textureType defines the compressed used (can be null)
  81999. * @returns a new raw 2D array texture (stored in an InternalTexture)
  82000. */
  82001. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  82002. /**
  82003. * Update a raw 2D array texture
  82004. * @param texture defines the texture to update
  82005. * @param data defines the data to store
  82006. * @param format defines the data format
  82007. * @param invertY defines if data must be stored with Y axis inverted
  82008. */
  82009. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  82010. /**
  82011. * Update a raw 2D array texture
  82012. * @param texture defines the texture to update
  82013. * @param data defines the data to store
  82014. * @param format defines the data format
  82015. * @param invertY defines if data must be stored with Y axis inverted
  82016. * @param compression defines the used compression (can be null)
  82017. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  82018. */
  82019. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  82020. }
  82021. }
  82022. declare module BABYLON {
  82023. /**
  82024. * Raw texture can help creating a texture directly from an array of data.
  82025. * This can be super useful if you either get the data from an uncompressed source or
  82026. * if you wish to create your texture pixel by pixel.
  82027. */
  82028. export class RawTexture extends Texture {
  82029. /**
  82030. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82031. */
  82032. format: number;
  82033. private _engine;
  82034. /**
  82035. * Instantiates a new RawTexture.
  82036. * Raw texture can help creating a texture directly from an array of data.
  82037. * This can be super useful if you either get the data from an uncompressed source or
  82038. * if you wish to create your texture pixel by pixel.
  82039. * @param data define the array of data to use to create the texture
  82040. * @param width define the width of the texture
  82041. * @param height define the height of the texture
  82042. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82043. * @param scene define the scene the texture belongs to
  82044. * @param generateMipMaps define whether mip maps should be generated or not
  82045. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82046. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82047. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82048. */
  82049. constructor(data: ArrayBufferView, width: number, height: number,
  82050. /**
  82051. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  82052. */
  82053. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  82054. /**
  82055. * Updates the texture underlying data.
  82056. * @param data Define the new data of the texture
  82057. */
  82058. update(data: ArrayBufferView): void;
  82059. /**
  82060. * Creates a luminance texture from some data.
  82061. * @param data Define the texture data
  82062. * @param width Define the width of the texture
  82063. * @param height Define the height of the texture
  82064. * @param scene Define the scene the texture belongs to
  82065. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82066. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82067. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82068. * @returns the luminance texture
  82069. */
  82070. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82071. /**
  82072. * Creates a luminance alpha texture from some data.
  82073. * @param data Define the texture data
  82074. * @param width Define the width of the texture
  82075. * @param height Define the height of the texture
  82076. * @param scene Define the scene the texture belongs to
  82077. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82078. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82079. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82080. * @returns the luminance alpha texture
  82081. */
  82082. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82083. /**
  82084. * Creates an alpha texture from some data.
  82085. * @param data Define the texture data
  82086. * @param width Define the width of the texture
  82087. * @param height Define the height of the texture
  82088. * @param scene Define the scene the texture belongs to
  82089. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82090. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82091. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82092. * @returns the alpha texture
  82093. */
  82094. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  82095. /**
  82096. * Creates a RGB texture from some data.
  82097. * @param data Define the texture data
  82098. * @param width Define the width of the texture
  82099. * @param height Define the height of the texture
  82100. * @param scene Define the scene the texture belongs to
  82101. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82102. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82103. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82104. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82105. * @returns the RGB alpha texture
  82106. */
  82107. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82108. /**
  82109. * Creates a RGBA texture from some data.
  82110. * @param data Define the texture data
  82111. * @param width Define the width of the texture
  82112. * @param height Define the height of the texture
  82113. * @param scene Define the scene the texture belongs to
  82114. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82115. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82116. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82117. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82118. * @returns the RGBA texture
  82119. */
  82120. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82121. /**
  82122. * Creates a R texture from some data.
  82123. * @param data Define the texture data
  82124. * @param width Define the width of the texture
  82125. * @param height Define the height of the texture
  82126. * @param scene Define the scene the texture belongs to
  82127. * @param generateMipMaps Define whether or not to create mip maps for the texture
  82128. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  82129. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  82130. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  82131. * @returns the R texture
  82132. */
  82133. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  82134. }
  82135. }
  82136. declare module BABYLON {
  82137. /**
  82138. * Interface for the size containing width and height
  82139. */
  82140. export interface ISize {
  82141. /**
  82142. * Width
  82143. */
  82144. width: number;
  82145. /**
  82146. * Heighht
  82147. */
  82148. height: number;
  82149. }
  82150. /**
  82151. * Size containing widht and height
  82152. */
  82153. export class Size implements ISize {
  82154. /**
  82155. * Width
  82156. */
  82157. width: number;
  82158. /**
  82159. * Height
  82160. */
  82161. height: number;
  82162. /**
  82163. * Creates a Size object from the given width and height (floats).
  82164. * @param width width of the new size
  82165. * @param height height of the new size
  82166. */
  82167. constructor(width: number, height: number);
  82168. /**
  82169. * Returns a string with the Size width and height
  82170. * @returns a string with the Size width and height
  82171. */
  82172. toString(): string;
  82173. /**
  82174. * "Size"
  82175. * @returns the string "Size"
  82176. */
  82177. getClassName(): string;
  82178. /**
  82179. * Returns the Size hash code.
  82180. * @returns a hash code for a unique width and height
  82181. */
  82182. getHashCode(): number;
  82183. /**
  82184. * Updates the current size from the given one.
  82185. * @param src the given size
  82186. */
  82187. copyFrom(src: Size): void;
  82188. /**
  82189. * Updates in place the current Size from the given floats.
  82190. * @param width width of the new size
  82191. * @param height height of the new size
  82192. * @returns the updated Size.
  82193. */
  82194. copyFromFloats(width: number, height: number): Size;
  82195. /**
  82196. * Updates in place the current Size from the given floats.
  82197. * @param width width to set
  82198. * @param height height to set
  82199. * @returns the updated Size.
  82200. */
  82201. set(width: number, height: number): Size;
  82202. /**
  82203. * Multiplies the width and height by numbers
  82204. * @param w factor to multiple the width by
  82205. * @param h factor to multiple the height by
  82206. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  82207. */
  82208. multiplyByFloats(w: number, h: number): Size;
  82209. /**
  82210. * Clones the size
  82211. * @returns a new Size copied from the given one.
  82212. */
  82213. clone(): Size;
  82214. /**
  82215. * True if the current Size and the given one width and height are strictly equal.
  82216. * @param other the other size to compare against
  82217. * @returns True if the current Size and the given one width and height are strictly equal.
  82218. */
  82219. equals(other: Size): boolean;
  82220. /**
  82221. * The surface of the Size : width * height (float).
  82222. */
  82223. readonly surface: number;
  82224. /**
  82225. * Create a new size of zero
  82226. * @returns a new Size set to (0.0, 0.0)
  82227. */
  82228. static Zero(): Size;
  82229. /**
  82230. * Sums the width and height of two sizes
  82231. * @param otherSize size to add to this size
  82232. * @returns a new Size set as the addition result of the current Size and the given one.
  82233. */
  82234. add(otherSize: Size): Size;
  82235. /**
  82236. * Subtracts the width and height of two
  82237. * @param otherSize size to subtract to this size
  82238. * @returns a new Size set as the subtraction result of the given one from the current Size.
  82239. */
  82240. subtract(otherSize: Size): Size;
  82241. /**
  82242. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  82243. * @param start starting size to lerp between
  82244. * @param end end size to lerp between
  82245. * @param amount amount to lerp between the start and end values
  82246. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  82247. */
  82248. static Lerp(start: Size, end: Size, amount: number): Size;
  82249. }
  82250. }
  82251. declare module BABYLON {
  82252. /**
  82253. * Defines a runtime animation
  82254. */
  82255. export class RuntimeAnimation {
  82256. private _events;
  82257. /**
  82258. * The current frame of the runtime animation
  82259. */
  82260. private _currentFrame;
  82261. /**
  82262. * The animation used by the runtime animation
  82263. */
  82264. private _animation;
  82265. /**
  82266. * The target of the runtime animation
  82267. */
  82268. private _target;
  82269. /**
  82270. * The initiating animatable
  82271. */
  82272. private _host;
  82273. /**
  82274. * The original value of the runtime animation
  82275. */
  82276. private _originalValue;
  82277. /**
  82278. * The original blend value of the runtime animation
  82279. */
  82280. private _originalBlendValue;
  82281. /**
  82282. * The offsets cache of the runtime animation
  82283. */
  82284. private _offsetsCache;
  82285. /**
  82286. * The high limits cache of the runtime animation
  82287. */
  82288. private _highLimitsCache;
  82289. /**
  82290. * Specifies if the runtime animation has been stopped
  82291. */
  82292. private _stopped;
  82293. /**
  82294. * The blending factor of the runtime animation
  82295. */
  82296. private _blendingFactor;
  82297. /**
  82298. * The BabylonJS scene
  82299. */
  82300. private _scene;
  82301. /**
  82302. * The current value of the runtime animation
  82303. */
  82304. private _currentValue;
  82305. /** @hidden */
  82306. _animationState: _IAnimationState;
  82307. /**
  82308. * The active target of the runtime animation
  82309. */
  82310. private _activeTargets;
  82311. private _currentActiveTarget;
  82312. private _directTarget;
  82313. /**
  82314. * The target path of the runtime animation
  82315. */
  82316. private _targetPath;
  82317. /**
  82318. * The weight of the runtime animation
  82319. */
  82320. private _weight;
  82321. /**
  82322. * The ratio offset of the runtime animation
  82323. */
  82324. private _ratioOffset;
  82325. /**
  82326. * The previous delay of the runtime animation
  82327. */
  82328. private _previousDelay;
  82329. /**
  82330. * The previous ratio of the runtime animation
  82331. */
  82332. private _previousRatio;
  82333. private _enableBlending;
  82334. private _keys;
  82335. private _minFrame;
  82336. private _maxFrame;
  82337. private _minValue;
  82338. private _maxValue;
  82339. private _targetIsArray;
  82340. /**
  82341. * Gets the current frame of the runtime animation
  82342. */
  82343. readonly currentFrame: number;
  82344. /**
  82345. * Gets the weight of the runtime animation
  82346. */
  82347. readonly weight: number;
  82348. /**
  82349. * Gets the current value of the runtime animation
  82350. */
  82351. readonly currentValue: any;
  82352. /**
  82353. * Gets the target path of the runtime animation
  82354. */
  82355. readonly targetPath: string;
  82356. /**
  82357. * Gets the actual target of the runtime animation
  82358. */
  82359. readonly target: any;
  82360. /** @hidden */
  82361. _onLoop: () => void;
  82362. /**
  82363. * Create a new RuntimeAnimation object
  82364. * @param target defines the target of the animation
  82365. * @param animation defines the source animation object
  82366. * @param scene defines the hosting scene
  82367. * @param host defines the initiating Animatable
  82368. */
  82369. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  82370. private _preparePath;
  82371. /**
  82372. * Gets the animation from the runtime animation
  82373. */
  82374. readonly animation: Animation;
  82375. /**
  82376. * Resets the runtime animation to the beginning
  82377. * @param restoreOriginal defines whether to restore the target property to the original value
  82378. */
  82379. reset(restoreOriginal?: boolean): void;
  82380. /**
  82381. * Specifies if the runtime animation is stopped
  82382. * @returns Boolean specifying if the runtime animation is stopped
  82383. */
  82384. isStopped(): boolean;
  82385. /**
  82386. * Disposes of the runtime animation
  82387. */
  82388. dispose(): void;
  82389. /**
  82390. * Apply the interpolated value to the target
  82391. * @param currentValue defines the value computed by the animation
  82392. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  82393. */
  82394. setValue(currentValue: any, weight: number): void;
  82395. private _getOriginalValues;
  82396. private _setValue;
  82397. /**
  82398. * Gets the loop pmode of the runtime animation
  82399. * @returns Loop Mode
  82400. */
  82401. private _getCorrectLoopMode;
  82402. /**
  82403. * Move the current animation to a given frame
  82404. * @param frame defines the frame to move to
  82405. */
  82406. goToFrame(frame: number): void;
  82407. /**
  82408. * @hidden Internal use only
  82409. */
  82410. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  82411. /**
  82412. * Execute the current animation
  82413. * @param delay defines the delay to add to the current frame
  82414. * @param from defines the lower bound of the animation range
  82415. * @param to defines the upper bound of the animation range
  82416. * @param loop defines if the current animation must loop
  82417. * @param speedRatio defines the current speed ratio
  82418. * @param weight defines the weight of the animation (default is -1 so no weight)
  82419. * @param onLoop optional callback called when animation loops
  82420. * @returns a boolean indicating if the animation is running
  82421. */
  82422. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  82423. }
  82424. }
  82425. declare module BABYLON {
  82426. /**
  82427. * Class used to store an actual running animation
  82428. */
  82429. export class Animatable {
  82430. /** defines the target object */
  82431. target: any;
  82432. /** defines the starting frame number (default is 0) */
  82433. fromFrame: number;
  82434. /** defines the ending frame number (default is 100) */
  82435. toFrame: number;
  82436. /** defines if the animation must loop (default is false) */
  82437. loopAnimation: boolean;
  82438. /** defines a callback to call when animation ends if it is not looping */
  82439. onAnimationEnd?: (() => void) | null | undefined;
  82440. /** defines a callback to call when animation loops */
  82441. onAnimationLoop?: (() => void) | null | undefined;
  82442. private _localDelayOffset;
  82443. private _pausedDelay;
  82444. private _runtimeAnimations;
  82445. private _paused;
  82446. private _scene;
  82447. private _speedRatio;
  82448. private _weight;
  82449. private _syncRoot;
  82450. /**
  82451. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  82452. * This will only apply for non looping animation (default is true)
  82453. */
  82454. disposeOnEnd: boolean;
  82455. /**
  82456. * Gets a boolean indicating if the animation has started
  82457. */
  82458. animationStarted: boolean;
  82459. /**
  82460. * Observer raised when the animation ends
  82461. */
  82462. onAnimationEndObservable: Observable<Animatable>;
  82463. /**
  82464. * Observer raised when the animation loops
  82465. */
  82466. onAnimationLoopObservable: Observable<Animatable>;
  82467. /**
  82468. * Gets the root Animatable used to synchronize and normalize animations
  82469. */
  82470. readonly syncRoot: Nullable<Animatable>;
  82471. /**
  82472. * Gets the current frame of the first RuntimeAnimation
  82473. * Used to synchronize Animatables
  82474. */
  82475. readonly masterFrame: number;
  82476. /**
  82477. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  82478. */
  82479. weight: number;
  82480. /**
  82481. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  82482. */
  82483. speedRatio: number;
  82484. /**
  82485. * Creates a new Animatable
  82486. * @param scene defines the hosting scene
  82487. * @param target defines the target object
  82488. * @param fromFrame defines the starting frame number (default is 0)
  82489. * @param toFrame defines the ending frame number (default is 100)
  82490. * @param loopAnimation defines if the animation must loop (default is false)
  82491. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  82492. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  82493. * @param animations defines a group of animation to add to the new Animatable
  82494. * @param onAnimationLoop defines a callback to call when animation loops
  82495. */
  82496. constructor(scene: Scene,
  82497. /** defines the target object */
  82498. target: any,
  82499. /** defines the starting frame number (default is 0) */
  82500. fromFrame?: number,
  82501. /** defines the ending frame number (default is 100) */
  82502. toFrame?: number,
  82503. /** defines if the animation must loop (default is false) */
  82504. loopAnimation?: boolean, speedRatio?: number,
  82505. /** defines a callback to call when animation ends if it is not looping */
  82506. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  82507. /** defines a callback to call when animation loops */
  82508. onAnimationLoop?: (() => void) | null | undefined);
  82509. /**
  82510. * Synchronize and normalize current Animatable with a source Animatable
  82511. * This is useful when using animation weights and when animations are not of the same length
  82512. * @param root defines the root Animatable to synchronize with
  82513. * @returns the current Animatable
  82514. */
  82515. syncWith(root: Animatable): Animatable;
  82516. /**
  82517. * Gets the list of runtime animations
  82518. * @returns an array of RuntimeAnimation
  82519. */
  82520. getAnimations(): RuntimeAnimation[];
  82521. /**
  82522. * Adds more animations to the current animatable
  82523. * @param target defines the target of the animations
  82524. * @param animations defines the new animations to add
  82525. */
  82526. appendAnimations(target: any, animations: Animation[]): void;
  82527. /**
  82528. * Gets the source animation for a specific property
  82529. * @param property defines the propertyu to look for
  82530. * @returns null or the source animation for the given property
  82531. */
  82532. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  82533. /**
  82534. * Gets the runtime animation for a specific property
  82535. * @param property defines the propertyu to look for
  82536. * @returns null or the runtime animation for the given property
  82537. */
  82538. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  82539. /**
  82540. * Resets the animatable to its original state
  82541. */
  82542. reset(): void;
  82543. /**
  82544. * Allows the animatable to blend with current running animations
  82545. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82546. * @param blendingSpeed defines the blending speed to use
  82547. */
  82548. enableBlending(blendingSpeed: number): void;
  82549. /**
  82550. * Disable animation blending
  82551. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82552. */
  82553. disableBlending(): void;
  82554. /**
  82555. * Jump directly to a given frame
  82556. * @param frame defines the frame to jump to
  82557. */
  82558. goToFrame(frame: number): void;
  82559. /**
  82560. * Pause the animation
  82561. */
  82562. pause(): void;
  82563. /**
  82564. * Restart the animation
  82565. */
  82566. restart(): void;
  82567. private _raiseOnAnimationEnd;
  82568. /**
  82569. * Stop and delete the current animation
  82570. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  82571. * @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)
  82572. */
  82573. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  82574. /**
  82575. * Wait asynchronously for the animation to end
  82576. * @returns a promise which will be fullfilled when the animation ends
  82577. */
  82578. waitAsync(): Promise<Animatable>;
  82579. /** @hidden */
  82580. _animate(delay: number): boolean;
  82581. }
  82582. interface Scene {
  82583. /** @hidden */
  82584. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  82585. /** @hidden */
  82586. _processLateAnimationBindingsForMatrices(holder: {
  82587. totalWeight: number;
  82588. animations: RuntimeAnimation[];
  82589. originalValue: Matrix;
  82590. }): any;
  82591. /** @hidden */
  82592. _processLateAnimationBindingsForQuaternions(holder: {
  82593. totalWeight: number;
  82594. animations: RuntimeAnimation[];
  82595. originalValue: Quaternion;
  82596. }, refQuaternion: Quaternion): Quaternion;
  82597. /** @hidden */
  82598. _processLateAnimationBindings(): void;
  82599. /**
  82600. * Will start the animation sequence of a given target
  82601. * @param target defines the target
  82602. * @param from defines from which frame should animation start
  82603. * @param to defines until which frame should animation run.
  82604. * @param weight defines the weight to apply to the animation (1.0 by default)
  82605. * @param loop defines if the animation loops
  82606. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82607. * @param onAnimationEnd defines the function to be executed when the animation ends
  82608. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82609. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82610. * @param onAnimationLoop defines the callback to call when an animation loops
  82611. * @returns the animatable object created for this animation
  82612. */
  82613. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82614. /**
  82615. * Will start the animation sequence of a given target
  82616. * @param target defines the target
  82617. * @param from defines from which frame should animation start
  82618. * @param to defines until which frame should animation run.
  82619. * @param loop defines if the animation loops
  82620. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82621. * @param onAnimationEnd defines the function to be executed when the animation ends
  82622. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82623. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82624. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  82625. * @param onAnimationLoop defines the callback to call when an animation loops
  82626. * @returns the animatable object created for this animation
  82627. */
  82628. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  82629. /**
  82630. * Will start the animation sequence of a given target and its hierarchy
  82631. * @param target defines the target
  82632. * @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.
  82633. * @param from defines from which frame should animation start
  82634. * @param to defines until which frame should animation run.
  82635. * @param loop defines if the animation loops
  82636. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  82637. * @param onAnimationEnd defines the function to be executed when the animation ends
  82638. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  82639. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  82640. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  82641. * @param onAnimationLoop defines the callback to call when an animation loops
  82642. * @returns the list of created animatables
  82643. */
  82644. 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[];
  82645. /**
  82646. * Begin a new animation on a given node
  82647. * @param target defines the target where the animation will take place
  82648. * @param animations defines the list of animations to start
  82649. * @param from defines the initial value
  82650. * @param to defines the final value
  82651. * @param loop defines if you want animation to loop (off by default)
  82652. * @param speedRatio defines the speed ratio to apply to all animations
  82653. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82654. * @param onAnimationLoop defines the callback to call when an animation loops
  82655. * @returns the list of created animatables
  82656. */
  82657. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  82658. /**
  82659. * Begin a new animation on a given node and its hierarchy
  82660. * @param target defines the root node where the animation will take place
  82661. * @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.
  82662. * @param animations defines the list of animations to start
  82663. * @param from defines the initial value
  82664. * @param to defines the final value
  82665. * @param loop defines if you want animation to loop (off by default)
  82666. * @param speedRatio defines the speed ratio to apply to all animations
  82667. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  82668. * @param onAnimationLoop defines the callback to call when an animation loops
  82669. * @returns the list of animatables created for all nodes
  82670. */
  82671. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  82672. /**
  82673. * Gets the animatable associated with a specific target
  82674. * @param target defines the target of the animatable
  82675. * @returns the required animatable if found
  82676. */
  82677. getAnimatableByTarget(target: any): Nullable<Animatable>;
  82678. /**
  82679. * Gets all animatables associated with a given target
  82680. * @param target defines the target to look animatables for
  82681. * @returns an array of Animatables
  82682. */
  82683. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  82684. /**
  82685. * Stops and removes all animations that have been applied to the scene
  82686. */
  82687. stopAllAnimations(): void;
  82688. /**
  82689. * Gets the current delta time used by animation engine
  82690. */
  82691. deltaTime: number;
  82692. }
  82693. interface Bone {
  82694. /**
  82695. * Copy an animation range from another bone
  82696. * @param source defines the source bone
  82697. * @param rangeName defines the range name to copy
  82698. * @param frameOffset defines the frame offset
  82699. * @param rescaleAsRequired defines if rescaling must be applied if required
  82700. * @param skelDimensionsRatio defines the scaling ratio
  82701. * @returns true if operation was successful
  82702. */
  82703. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /**
  82708. * Class used to override all child animations of a given target
  82709. */
  82710. export class AnimationPropertiesOverride {
  82711. /**
  82712. * Gets or sets a value indicating if animation blending must be used
  82713. */
  82714. enableBlending: boolean;
  82715. /**
  82716. * Gets or sets the blending speed to use when enableBlending is true
  82717. */
  82718. blendingSpeed: number;
  82719. /**
  82720. * Gets or sets the default loop mode to use
  82721. */
  82722. loopMode: number;
  82723. }
  82724. }
  82725. declare module BABYLON {
  82726. /**
  82727. * Class used to handle skinning animations
  82728. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82729. */
  82730. export class Skeleton implements IAnimatable {
  82731. /** defines the skeleton name */
  82732. name: string;
  82733. /** defines the skeleton Id */
  82734. id: string;
  82735. /**
  82736. * Defines the list of child bones
  82737. */
  82738. bones: Bone[];
  82739. /**
  82740. * Defines an estimate of the dimension of the skeleton at rest
  82741. */
  82742. dimensionsAtRest: Vector3;
  82743. /**
  82744. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  82745. */
  82746. needInitialSkinMatrix: boolean;
  82747. /**
  82748. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  82749. */
  82750. overrideMesh: Nullable<AbstractMesh>;
  82751. /**
  82752. * Gets the list of animations attached to this skeleton
  82753. */
  82754. animations: Array<Animation>;
  82755. private _scene;
  82756. private _isDirty;
  82757. private _transformMatrices;
  82758. private _transformMatrixTexture;
  82759. private _meshesWithPoseMatrix;
  82760. private _animatables;
  82761. private _identity;
  82762. private _synchronizedWithMesh;
  82763. private _ranges;
  82764. private _lastAbsoluteTransformsUpdateId;
  82765. private _canUseTextureForBones;
  82766. private _uniqueId;
  82767. /** @hidden */
  82768. _numBonesWithLinkedTransformNode: number;
  82769. /** @hidden */
  82770. _hasWaitingData: Nullable<boolean>;
  82771. /**
  82772. * Specifies if the skeleton should be serialized
  82773. */
  82774. doNotSerialize: boolean;
  82775. private _useTextureToStoreBoneMatrices;
  82776. /**
  82777. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  82778. * Please note that this option is not available if the hardware does not support it
  82779. */
  82780. useTextureToStoreBoneMatrices: boolean;
  82781. private _animationPropertiesOverride;
  82782. /**
  82783. * Gets or sets the animation properties override
  82784. */
  82785. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82786. /**
  82787. * List of inspectable custom properties (used by the Inspector)
  82788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82789. */
  82790. inspectableCustomProperties: IInspectable[];
  82791. /**
  82792. * An observable triggered before computing the skeleton's matrices
  82793. */
  82794. onBeforeComputeObservable: Observable<Skeleton>;
  82795. /**
  82796. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  82797. */
  82798. readonly isUsingTextureForMatrices: boolean;
  82799. /**
  82800. * Gets the unique ID of this skeleton
  82801. */
  82802. readonly uniqueId: number;
  82803. /**
  82804. * Creates a new skeleton
  82805. * @param name defines the skeleton name
  82806. * @param id defines the skeleton Id
  82807. * @param scene defines the hosting scene
  82808. */
  82809. constructor(
  82810. /** defines the skeleton name */
  82811. name: string,
  82812. /** defines the skeleton Id */
  82813. id: string, scene: Scene);
  82814. /**
  82815. * Gets the current object class name.
  82816. * @return the class name
  82817. */
  82818. getClassName(): string;
  82819. /**
  82820. * Returns an array containing the root bones
  82821. * @returns an array containing the root bones
  82822. */
  82823. getChildren(): Array<Bone>;
  82824. /**
  82825. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  82826. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82827. * @returns a Float32Array containing matrices data
  82828. */
  82829. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  82830. /**
  82831. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  82832. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  82833. * @returns a raw texture containing the data
  82834. */
  82835. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  82836. /**
  82837. * Gets the current hosting scene
  82838. * @returns a scene object
  82839. */
  82840. getScene(): Scene;
  82841. /**
  82842. * Gets a string representing the current skeleton data
  82843. * @param fullDetails defines a boolean indicating if we want a verbose version
  82844. * @returns a string representing the current skeleton data
  82845. */
  82846. toString(fullDetails?: boolean): string;
  82847. /**
  82848. * Get bone's index searching by name
  82849. * @param name defines bone's name to search for
  82850. * @return the indice of the bone. Returns -1 if not found
  82851. */
  82852. getBoneIndexByName(name: string): number;
  82853. /**
  82854. * Creater a new animation range
  82855. * @param name defines the name of the range
  82856. * @param from defines the start key
  82857. * @param to defines the end key
  82858. */
  82859. createAnimationRange(name: string, from: number, to: number): void;
  82860. /**
  82861. * Delete a specific animation range
  82862. * @param name defines the name of the range
  82863. * @param deleteFrames defines if frames must be removed as well
  82864. */
  82865. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  82866. /**
  82867. * Gets a specific animation range
  82868. * @param name defines the name of the range to look for
  82869. * @returns the requested animation range or null if not found
  82870. */
  82871. getAnimationRange(name: string): Nullable<AnimationRange>;
  82872. /**
  82873. * Gets the list of all animation ranges defined on this skeleton
  82874. * @returns an array
  82875. */
  82876. getAnimationRanges(): Nullable<AnimationRange>[];
  82877. /**
  82878. * Copy animation range from a source skeleton.
  82879. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  82880. * @param source defines the source skeleton
  82881. * @param name defines the name of the range to copy
  82882. * @param rescaleAsRequired defines if rescaling must be applied if required
  82883. * @returns true if operation was successful
  82884. */
  82885. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  82886. /**
  82887. * Forces the skeleton to go to rest pose
  82888. */
  82889. returnToRest(): void;
  82890. private _getHighestAnimationFrame;
  82891. /**
  82892. * Begin a specific animation range
  82893. * @param name defines the name of the range to start
  82894. * @param loop defines if looping must be turned on (false by default)
  82895. * @param speedRatio defines the speed ratio to apply (1 by default)
  82896. * @param onAnimationEnd defines a callback which will be called when animation will end
  82897. * @returns a new animatable
  82898. */
  82899. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  82900. /** @hidden */
  82901. _markAsDirty(): void;
  82902. /** @hidden */
  82903. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82904. /** @hidden */
  82905. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  82906. private _computeTransformMatrices;
  82907. /**
  82908. * Build all resources required to render a skeleton
  82909. */
  82910. prepare(): void;
  82911. /**
  82912. * Gets the list of animatables currently running for this skeleton
  82913. * @returns an array of animatables
  82914. */
  82915. getAnimatables(): IAnimatable[];
  82916. /**
  82917. * Clone the current skeleton
  82918. * @param name defines the name of the new skeleton
  82919. * @param id defines the id of the new skeleton
  82920. * @returns the new skeleton
  82921. */
  82922. clone(name: string, id?: string): Skeleton;
  82923. /**
  82924. * Enable animation blending for this skeleton
  82925. * @param blendingSpeed defines the blending speed to apply
  82926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  82927. */
  82928. enableBlending(blendingSpeed?: number): void;
  82929. /**
  82930. * Releases all resources associated with the current skeleton
  82931. */
  82932. dispose(): void;
  82933. /**
  82934. * Serialize the skeleton in a JSON object
  82935. * @returns a JSON object
  82936. */
  82937. serialize(): any;
  82938. /**
  82939. * Creates a new skeleton from serialized data
  82940. * @param parsedSkeleton defines the serialized data
  82941. * @param scene defines the hosting scene
  82942. * @returns a new skeleton
  82943. */
  82944. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  82945. /**
  82946. * Compute all node absolute transforms
  82947. * @param forceUpdate defines if computation must be done even if cache is up to date
  82948. */
  82949. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  82950. /**
  82951. * Gets the root pose matrix
  82952. * @returns a matrix
  82953. */
  82954. getPoseMatrix(): Nullable<Matrix>;
  82955. /**
  82956. * Sorts bones per internal index
  82957. */
  82958. sortBones(): void;
  82959. private _sortBones;
  82960. }
  82961. }
  82962. declare module BABYLON {
  82963. /**
  82964. * Class used to store bone information
  82965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82966. */
  82967. export class Bone extends Node {
  82968. /**
  82969. * defines the bone name
  82970. */
  82971. name: string;
  82972. private static _tmpVecs;
  82973. private static _tmpQuat;
  82974. private static _tmpMats;
  82975. /**
  82976. * Gets the list of child bones
  82977. */
  82978. children: Bone[];
  82979. /** Gets the animations associated with this bone */
  82980. animations: Animation[];
  82981. /**
  82982. * Gets or sets bone length
  82983. */
  82984. length: number;
  82985. /**
  82986. * @hidden Internal only
  82987. * Set this value to map this bone to a different index in the transform matrices
  82988. * Set this value to -1 to exclude the bone from the transform matrices
  82989. */
  82990. _index: Nullable<number>;
  82991. private _skeleton;
  82992. private _localMatrix;
  82993. private _restPose;
  82994. private _baseMatrix;
  82995. private _absoluteTransform;
  82996. private _invertedAbsoluteTransform;
  82997. private _parent;
  82998. private _scalingDeterminant;
  82999. private _worldTransform;
  83000. private _localScaling;
  83001. private _localRotation;
  83002. private _localPosition;
  83003. private _needToDecompose;
  83004. private _needToCompose;
  83005. /** @hidden */
  83006. _linkedTransformNode: Nullable<TransformNode>;
  83007. /** @hidden */
  83008. _waitingTransformNodeId: Nullable<string>;
  83009. /** @hidden */
  83010. /** @hidden */
  83011. _matrix: Matrix;
  83012. /**
  83013. * Create a new bone
  83014. * @param name defines the bone name
  83015. * @param skeleton defines the parent skeleton
  83016. * @param parentBone defines the parent (can be null if the bone is the root)
  83017. * @param localMatrix defines the local matrix
  83018. * @param restPose defines the rest pose matrix
  83019. * @param baseMatrix defines the base matrix
  83020. * @param index defines index of the bone in the hiearchy
  83021. */
  83022. constructor(
  83023. /**
  83024. * defines the bone name
  83025. */
  83026. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  83027. /**
  83028. * Gets the current object class name.
  83029. * @return the class name
  83030. */
  83031. getClassName(): string;
  83032. /**
  83033. * Gets the parent skeleton
  83034. * @returns a skeleton
  83035. */
  83036. getSkeleton(): Skeleton;
  83037. /**
  83038. * Gets parent bone
  83039. * @returns a bone or null if the bone is the root of the bone hierarchy
  83040. */
  83041. getParent(): Nullable<Bone>;
  83042. /**
  83043. * Returns an array containing the root bones
  83044. * @returns an array containing the root bones
  83045. */
  83046. getChildren(): Array<Bone>;
  83047. /**
  83048. * Gets the node index in matrix array generated for rendering
  83049. * @returns the node index
  83050. */
  83051. getIndex(): number;
  83052. /**
  83053. * Sets the parent bone
  83054. * @param parent defines the parent (can be null if the bone is the root)
  83055. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  83056. */
  83057. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  83058. /**
  83059. * Gets the local matrix
  83060. * @returns a matrix
  83061. */
  83062. getLocalMatrix(): Matrix;
  83063. /**
  83064. * Gets the base matrix (initial matrix which remains unchanged)
  83065. * @returns a matrix
  83066. */
  83067. getBaseMatrix(): Matrix;
  83068. /**
  83069. * Gets the rest pose matrix
  83070. * @returns a matrix
  83071. */
  83072. getRestPose(): Matrix;
  83073. /**
  83074. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  83075. */
  83076. getWorldMatrix(): Matrix;
  83077. /**
  83078. * Sets the local matrix to rest pose matrix
  83079. */
  83080. returnToRest(): void;
  83081. /**
  83082. * Gets the inverse of the absolute transform matrix.
  83083. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  83084. * @returns a matrix
  83085. */
  83086. getInvertedAbsoluteTransform(): Matrix;
  83087. /**
  83088. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  83089. * @returns a matrix
  83090. */
  83091. getAbsoluteTransform(): Matrix;
  83092. /**
  83093. * Links with the given transform node.
  83094. * The local matrix of this bone is copied from the transform node every frame.
  83095. * @param transformNode defines the transform node to link to
  83096. */
  83097. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  83098. /**
  83099. * Gets the node used to drive the bone's transformation
  83100. * @returns a transform node or null
  83101. */
  83102. getTransformNode(): Nullable<TransformNode>;
  83103. /** Gets or sets current position (in local space) */
  83104. position: Vector3;
  83105. /** Gets or sets current rotation (in local space) */
  83106. rotation: Vector3;
  83107. /** Gets or sets current rotation quaternion (in local space) */
  83108. rotationQuaternion: Quaternion;
  83109. /** Gets or sets current scaling (in local space) */
  83110. scaling: Vector3;
  83111. /**
  83112. * Gets the animation properties override
  83113. */
  83114. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83115. private _decompose;
  83116. private _compose;
  83117. /**
  83118. * Update the base and local matrices
  83119. * @param matrix defines the new base or local matrix
  83120. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  83121. * @param updateLocalMatrix defines if the local matrix should be updated
  83122. */
  83123. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  83124. /** @hidden */
  83125. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  83126. /**
  83127. * Flag the bone as dirty (Forcing it to update everything)
  83128. */
  83129. markAsDirty(): void;
  83130. /** @hidden */
  83131. _markAsDirtyAndCompose(): void;
  83132. private _markAsDirtyAndDecompose;
  83133. /**
  83134. * Translate the bone in local or world space
  83135. * @param vec The amount to translate the bone
  83136. * @param space The space that the translation is in
  83137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83138. */
  83139. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83140. /**
  83141. * Set the postion of the bone in local or world space
  83142. * @param position The position to set the bone
  83143. * @param space The space that the position is in
  83144. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83145. */
  83146. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83147. /**
  83148. * Set the absolute position of the bone (world space)
  83149. * @param position The position to set the bone
  83150. * @param mesh The mesh that this bone is attached to
  83151. */
  83152. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  83153. /**
  83154. * Scale the bone on the x, y and z axes (in local space)
  83155. * @param x The amount to scale the bone on the x axis
  83156. * @param y The amount to scale the bone on the y axis
  83157. * @param z The amount to scale the bone on the z axis
  83158. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  83159. */
  83160. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  83161. /**
  83162. * Set the bone scaling in local space
  83163. * @param scale defines the scaling vector
  83164. */
  83165. setScale(scale: Vector3): void;
  83166. /**
  83167. * Gets the current scaling in local space
  83168. * @returns the current scaling vector
  83169. */
  83170. getScale(): Vector3;
  83171. /**
  83172. * Gets the current scaling in local space and stores it in a target vector
  83173. * @param result defines the target vector
  83174. */
  83175. getScaleToRef(result: Vector3): void;
  83176. /**
  83177. * Set the yaw, pitch, and roll of the bone in local or world space
  83178. * @param yaw The rotation of the bone on the y axis
  83179. * @param pitch The rotation of the bone on the x axis
  83180. * @param roll The rotation of the bone on the z axis
  83181. * @param space The space that the axes of rotation are in
  83182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83183. */
  83184. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  83185. /**
  83186. * Add a rotation to the bone on an axis in local or world space
  83187. * @param axis The axis to rotate the bone on
  83188. * @param amount The amount to rotate the bone
  83189. * @param space The space that the axis is in
  83190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83191. */
  83192. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  83193. /**
  83194. * Set the rotation of the bone to a particular axis angle in local or world space
  83195. * @param axis The axis to rotate the bone on
  83196. * @param angle The angle that the bone should be rotated to
  83197. * @param space The space that the axis is in
  83198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83199. */
  83200. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  83201. /**
  83202. * Set the euler rotation of the bone in local of world space
  83203. * @param rotation The euler rotation that the bone should be set to
  83204. * @param space The space that the rotation is in
  83205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83206. */
  83207. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  83208. /**
  83209. * Set the quaternion rotation of the bone in local of world space
  83210. * @param quat The quaternion rotation that the bone should be set to
  83211. * @param space The space that the rotation is in
  83212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83213. */
  83214. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  83215. /**
  83216. * Set the rotation matrix of the bone in local of world space
  83217. * @param rotMat The rotation matrix that the bone should be set to
  83218. * @param space The space that the rotation is in
  83219. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83220. */
  83221. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  83222. private _rotateWithMatrix;
  83223. private _getNegativeRotationToRef;
  83224. /**
  83225. * Get the position of the bone in local or world space
  83226. * @param space The space that the returned position is in
  83227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83228. * @returns The position of the bone
  83229. */
  83230. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83231. /**
  83232. * Copy the position of the bone to a vector3 in local or world space
  83233. * @param space The space that the returned position is in
  83234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83235. * @param result The vector3 to copy the position to
  83236. */
  83237. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  83238. /**
  83239. * Get the absolute position of the bone (world space)
  83240. * @param mesh The mesh that this bone is attached to
  83241. * @returns The absolute position of the bone
  83242. */
  83243. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  83244. /**
  83245. * Copy the absolute position of the bone (world space) to the result param
  83246. * @param mesh The mesh that this bone is attached to
  83247. * @param result The vector3 to copy the absolute position to
  83248. */
  83249. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  83250. /**
  83251. * Compute the absolute transforms of this bone and its children
  83252. */
  83253. computeAbsoluteTransforms(): void;
  83254. /**
  83255. * Get the world direction from an axis that is in the local space of the bone
  83256. * @param localAxis The local direction that is used to compute the world direction
  83257. * @param mesh The mesh that this bone is attached to
  83258. * @returns The world direction
  83259. */
  83260. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83261. /**
  83262. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  83263. * @param localAxis The local direction that is used to compute the world direction
  83264. * @param mesh The mesh that this bone is attached to
  83265. * @param result The vector3 that the world direction will be copied to
  83266. */
  83267. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83268. /**
  83269. * Get the euler rotation of the bone in local or world space
  83270. * @param space The space that the rotation should be in
  83271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83272. * @returns The euler rotation
  83273. */
  83274. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  83275. /**
  83276. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  83277. * @param space The space that the rotation should be in
  83278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83279. * @param result The vector3 that the rotation should be copied to
  83280. */
  83281. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83282. /**
  83283. * Get the quaternion rotation of the bone in either local or world space
  83284. * @param space The space that the rotation should be in
  83285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83286. * @returns The quaternion rotation
  83287. */
  83288. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  83289. /**
  83290. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  83291. * @param space The space that the rotation should be in
  83292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83293. * @param result The quaternion that the rotation should be copied to
  83294. */
  83295. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  83296. /**
  83297. * Get the rotation matrix of the bone in local or world space
  83298. * @param space The space that the rotation should be in
  83299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83300. * @returns The rotation matrix
  83301. */
  83302. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  83303. /**
  83304. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  83305. * @param space The space that the rotation should be in
  83306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  83307. * @param result The quaternion that the rotation should be copied to
  83308. */
  83309. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  83310. /**
  83311. * Get the world position of a point that is in the local space of the bone
  83312. * @param position The local position
  83313. * @param mesh The mesh that this bone is attached to
  83314. * @returns The world position
  83315. */
  83316. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83317. /**
  83318. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  83319. * @param position The local position
  83320. * @param mesh The mesh that this bone is attached to
  83321. * @param result The vector3 that the world position should be copied to
  83322. */
  83323. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83324. /**
  83325. * Get the local position of a point that is in world space
  83326. * @param position The world position
  83327. * @param mesh The mesh that this bone is attached to
  83328. * @returns The local position
  83329. */
  83330. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  83331. /**
  83332. * Get the local position of a point that is in world space and copy it to the result param
  83333. * @param position The world position
  83334. * @param mesh The mesh that this bone is attached to
  83335. * @param result The vector3 that the local position should be copied to
  83336. */
  83337. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  83338. }
  83339. }
  83340. declare module BABYLON {
  83341. /**
  83342. * 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.
  83343. * @see https://doc.babylonjs.com/how_to/transformnode
  83344. */
  83345. export class TransformNode extends Node {
  83346. /**
  83347. * Object will not rotate to face the camera
  83348. */
  83349. static BILLBOARDMODE_NONE: number;
  83350. /**
  83351. * Object will rotate to face the camera but only on the x axis
  83352. */
  83353. static BILLBOARDMODE_X: number;
  83354. /**
  83355. * Object will rotate to face the camera but only on the y axis
  83356. */
  83357. static BILLBOARDMODE_Y: number;
  83358. /**
  83359. * Object will rotate to face the camera but only on the z axis
  83360. */
  83361. static BILLBOARDMODE_Z: number;
  83362. /**
  83363. * Object will rotate to face the camera
  83364. */
  83365. static BILLBOARDMODE_ALL: number;
  83366. /**
  83367. * Object will rotate to face the camera's position instead of orientation
  83368. */
  83369. static BILLBOARDMODE_USE_POSITION: number;
  83370. private _forward;
  83371. private _forwardInverted;
  83372. private _up;
  83373. private _right;
  83374. private _rightInverted;
  83375. private _position;
  83376. private _rotation;
  83377. private _rotationQuaternion;
  83378. protected _scaling: Vector3;
  83379. protected _isDirty: boolean;
  83380. private _transformToBoneReferal;
  83381. private _isAbsoluteSynced;
  83382. private _billboardMode;
  83383. /**
  83384. * Gets or sets the billboard mode. Default is 0.
  83385. *
  83386. * | Value | Type | Description |
  83387. * | --- | --- | --- |
  83388. * | 0 | BILLBOARDMODE_NONE | |
  83389. * | 1 | BILLBOARDMODE_X | |
  83390. * | 2 | BILLBOARDMODE_Y | |
  83391. * | 4 | BILLBOARDMODE_Z | |
  83392. * | 7 | BILLBOARDMODE_ALL | |
  83393. *
  83394. */
  83395. billboardMode: number;
  83396. private _preserveParentRotationForBillboard;
  83397. /**
  83398. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  83399. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  83400. */
  83401. preserveParentRotationForBillboard: boolean;
  83402. /**
  83403. * 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
  83404. */
  83405. scalingDeterminant: number;
  83406. private _infiniteDistance;
  83407. /**
  83408. * Gets or sets the distance of the object to max, often used by skybox
  83409. */
  83410. infiniteDistance: boolean;
  83411. /**
  83412. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  83413. * By default the system will update normals to compensate
  83414. */
  83415. ignoreNonUniformScaling: boolean;
  83416. /**
  83417. * 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
  83418. */
  83419. reIntegrateRotationIntoRotationQuaternion: boolean;
  83420. /** @hidden */
  83421. _poseMatrix: Nullable<Matrix>;
  83422. /** @hidden */
  83423. _localMatrix: Matrix;
  83424. private _usePivotMatrix;
  83425. private _absolutePosition;
  83426. private _absoluteScaling;
  83427. private _absoluteRotationQuaternion;
  83428. private _pivotMatrix;
  83429. private _pivotMatrixInverse;
  83430. protected _postMultiplyPivotMatrix: boolean;
  83431. protected _isWorldMatrixFrozen: boolean;
  83432. /** @hidden */
  83433. _indexInSceneTransformNodesArray: number;
  83434. /**
  83435. * An event triggered after the world matrix is updated
  83436. */
  83437. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  83438. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  83439. /**
  83440. * Gets a string identifying the name of the class
  83441. * @returns "TransformNode" string
  83442. */
  83443. getClassName(): string;
  83444. /**
  83445. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  83446. */
  83447. position: Vector3;
  83448. /**
  83449. * 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)).
  83450. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  83451. */
  83452. rotation: Vector3;
  83453. /**
  83454. * 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)).
  83455. */
  83456. scaling: Vector3;
  83457. /**
  83458. * 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).
  83459. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  83460. */
  83461. rotationQuaternion: Nullable<Quaternion>;
  83462. /**
  83463. * The forward direction of that transform in world space.
  83464. */
  83465. readonly forward: Vector3;
  83466. /**
  83467. * The up direction of that transform in world space.
  83468. */
  83469. readonly up: Vector3;
  83470. /**
  83471. * The right direction of that transform in world space.
  83472. */
  83473. readonly right: Vector3;
  83474. /**
  83475. * Copies the parameter passed Matrix into the mesh Pose matrix.
  83476. * @param matrix the matrix to copy the pose from
  83477. * @returns this TransformNode.
  83478. */
  83479. updatePoseMatrix(matrix: Matrix): TransformNode;
  83480. /**
  83481. * Returns the mesh Pose matrix.
  83482. * @returns the pose matrix
  83483. */
  83484. getPoseMatrix(): Matrix;
  83485. /** @hidden */
  83486. _isSynchronized(): boolean;
  83487. /** @hidden */
  83488. _initCache(): void;
  83489. /**
  83490. * Flag the transform node as dirty (Forcing it to update everything)
  83491. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  83492. * @returns this transform node
  83493. */
  83494. markAsDirty(property: string): TransformNode;
  83495. /**
  83496. * Returns the current mesh absolute position.
  83497. * Returns a Vector3.
  83498. */
  83499. readonly absolutePosition: Vector3;
  83500. /**
  83501. * Returns the current mesh absolute scaling.
  83502. * Returns a Vector3.
  83503. */
  83504. readonly absoluteScaling: Vector3;
  83505. /**
  83506. * Returns the current mesh absolute rotation.
  83507. * Returns a Quaternion.
  83508. */
  83509. readonly absoluteRotationQuaternion: Quaternion;
  83510. /**
  83511. * Sets a new matrix to apply before all other transformation
  83512. * @param matrix defines the transform matrix
  83513. * @returns the current TransformNode
  83514. */
  83515. setPreTransformMatrix(matrix: Matrix): TransformNode;
  83516. /**
  83517. * Sets a new pivot matrix to the current node
  83518. * @param matrix defines the new pivot matrix to use
  83519. * @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
  83520. * @returns the current TransformNode
  83521. */
  83522. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  83523. /**
  83524. * Returns the mesh pivot matrix.
  83525. * Default : Identity.
  83526. * @returns the matrix
  83527. */
  83528. getPivotMatrix(): Matrix;
  83529. /**
  83530. * Instantiate (when possible) or clone that node with its hierarchy
  83531. * @param newParent defines the new parent to use for the instance (or clone)
  83532. * @param options defines options to configure how copy is done
  83533. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  83534. * @returns an instance (or a clone) of the current node with its hiearchy
  83535. */
  83536. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  83537. doNotInstantiate: boolean;
  83538. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  83539. /**
  83540. * Prevents the World matrix to be computed any longer
  83541. * @param newWorldMatrix defines an optional matrix to use as world matrix
  83542. * @returns the TransformNode.
  83543. */
  83544. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  83545. /**
  83546. * Allows back the World matrix computation.
  83547. * @returns the TransformNode.
  83548. */
  83549. unfreezeWorldMatrix(): this;
  83550. /**
  83551. * True if the World matrix has been frozen.
  83552. */
  83553. readonly isWorldMatrixFrozen: boolean;
  83554. /**
  83555. * Retuns the mesh absolute position in the World.
  83556. * @returns a Vector3.
  83557. */
  83558. getAbsolutePosition(): Vector3;
  83559. /**
  83560. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  83561. * @param absolutePosition the absolute position to set
  83562. * @returns the TransformNode.
  83563. */
  83564. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  83565. /**
  83566. * Sets the mesh position in its local space.
  83567. * @param vector3 the position to set in localspace
  83568. * @returns the TransformNode.
  83569. */
  83570. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  83571. /**
  83572. * Returns the mesh position in the local space from the current World matrix values.
  83573. * @returns a new Vector3.
  83574. */
  83575. getPositionExpressedInLocalSpace(): Vector3;
  83576. /**
  83577. * Translates the mesh along the passed Vector3 in its local space.
  83578. * @param vector3 the distance to translate in localspace
  83579. * @returns the TransformNode.
  83580. */
  83581. locallyTranslate(vector3: Vector3): TransformNode;
  83582. private static _lookAtVectorCache;
  83583. /**
  83584. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  83585. * @param targetPoint the position (must be in same space as current mesh) to look at
  83586. * @param yawCor optional yaw (y-axis) correction in radians
  83587. * @param pitchCor optional pitch (x-axis) correction in radians
  83588. * @param rollCor optional roll (z-axis) correction in radians
  83589. * @param space the choosen space of the target
  83590. * @returns the TransformNode.
  83591. */
  83592. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  83593. /**
  83594. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83595. * This Vector3 is expressed in the World space.
  83596. * @param localAxis axis to rotate
  83597. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  83598. */
  83599. getDirection(localAxis: Vector3): Vector3;
  83600. /**
  83601. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  83602. * localAxis is expressed in the mesh local space.
  83603. * result is computed in the Wordl space from the mesh World matrix.
  83604. * @param localAxis axis to rotate
  83605. * @param result the resulting transformnode
  83606. * @returns this TransformNode.
  83607. */
  83608. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  83609. /**
  83610. * Sets this transform node rotation to the given local axis.
  83611. * @param localAxis the axis in local space
  83612. * @param yawCor optional yaw (y-axis) correction in radians
  83613. * @param pitchCor optional pitch (x-axis) correction in radians
  83614. * @param rollCor optional roll (z-axis) correction in radians
  83615. * @returns this TransformNode
  83616. */
  83617. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  83618. /**
  83619. * Sets a new pivot point to the current node
  83620. * @param point defines the new pivot point to use
  83621. * @param space defines if the point is in world or local space (local by default)
  83622. * @returns the current TransformNode
  83623. */
  83624. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  83625. /**
  83626. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  83627. * @returns the pivot point
  83628. */
  83629. getPivotPoint(): Vector3;
  83630. /**
  83631. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  83632. * @param result the vector3 to store the result
  83633. * @returns this TransformNode.
  83634. */
  83635. getPivotPointToRef(result: Vector3): TransformNode;
  83636. /**
  83637. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  83638. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  83639. */
  83640. getAbsolutePivotPoint(): Vector3;
  83641. /**
  83642. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  83643. * @param result vector3 to store the result
  83644. * @returns this TransformNode.
  83645. */
  83646. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  83647. /**
  83648. * Defines the passed node as the parent of the current node.
  83649. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  83650. * @see https://doc.babylonjs.com/how_to/parenting
  83651. * @param node the node ot set as the parent
  83652. * @returns this TransformNode.
  83653. */
  83654. setParent(node: Nullable<Node>): TransformNode;
  83655. private _nonUniformScaling;
  83656. /**
  83657. * True if the scaling property of this object is non uniform eg. (1,2,1)
  83658. */
  83659. readonly nonUniformScaling: boolean;
  83660. /** @hidden */
  83661. _updateNonUniformScalingState(value: boolean): boolean;
  83662. /**
  83663. * Attach the current TransformNode to another TransformNode associated with a bone
  83664. * @param bone Bone affecting the TransformNode
  83665. * @param affectedTransformNode TransformNode associated with the bone
  83666. * @returns this object
  83667. */
  83668. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  83669. /**
  83670. * Detach the transform node if its associated with a bone
  83671. * @returns this object
  83672. */
  83673. detachFromBone(): TransformNode;
  83674. private static _rotationAxisCache;
  83675. /**
  83676. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  83677. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83678. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83679. * The passed axis is also normalized.
  83680. * @param axis the axis to rotate around
  83681. * @param amount the amount to rotate in radians
  83682. * @param space Space to rotate in (Default: local)
  83683. * @returns the TransformNode.
  83684. */
  83685. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  83686. /**
  83687. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  83688. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  83689. * The passed axis is also normalized. .
  83690. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  83691. * @param point the point to rotate around
  83692. * @param axis the axis to rotate around
  83693. * @param amount the amount to rotate in radians
  83694. * @returns the TransformNode
  83695. */
  83696. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  83697. /**
  83698. * Translates the mesh along the axis vector for the passed distance in the given space.
  83699. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  83700. * @param axis the axis to translate in
  83701. * @param distance the distance to translate
  83702. * @param space Space to rotate in (Default: local)
  83703. * @returns the TransformNode.
  83704. */
  83705. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  83706. /**
  83707. * Adds a rotation step to the mesh current rotation.
  83708. * x, y, z are Euler angles expressed in radians.
  83709. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  83710. * This means this rotation is made in the mesh local space only.
  83711. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  83712. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  83713. * ```javascript
  83714. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  83715. * ```
  83716. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  83717. * 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.
  83718. * @param x Rotation to add
  83719. * @param y Rotation to add
  83720. * @param z Rotation to add
  83721. * @returns the TransformNode.
  83722. */
  83723. addRotation(x: number, y: number, z: number): TransformNode;
  83724. /**
  83725. * @hidden
  83726. */
  83727. protected _getEffectiveParent(): Nullable<Node>;
  83728. /**
  83729. * Computes the world matrix of the node
  83730. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83731. * @returns the world matrix
  83732. */
  83733. computeWorldMatrix(force?: boolean): Matrix;
  83734. protected _afterComputeWorldMatrix(): void;
  83735. /**
  83736. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  83737. * @param func callback function to add
  83738. *
  83739. * @returns the TransformNode.
  83740. */
  83741. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83742. /**
  83743. * Removes a registered callback function.
  83744. * @param func callback function to remove
  83745. * @returns the TransformNode.
  83746. */
  83747. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  83748. /**
  83749. * Gets the position of the current mesh in camera space
  83750. * @param camera defines the camera to use
  83751. * @returns a position
  83752. */
  83753. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  83754. /**
  83755. * Returns the distance from the mesh to the active camera
  83756. * @param camera defines the camera to use
  83757. * @returns the distance
  83758. */
  83759. getDistanceToCamera(camera?: Nullable<Camera>): number;
  83760. /**
  83761. * Clone the current transform node
  83762. * @param name Name of the new clone
  83763. * @param newParent New parent for the clone
  83764. * @param doNotCloneChildren Do not clone children hierarchy
  83765. * @returns the new transform node
  83766. */
  83767. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  83768. /**
  83769. * Serializes the objects information.
  83770. * @param currentSerializationObject defines the object to serialize in
  83771. * @returns the serialized object
  83772. */
  83773. serialize(currentSerializationObject?: any): any;
  83774. /**
  83775. * Returns a new TransformNode object parsed from the source provided.
  83776. * @param parsedTransformNode is the source.
  83777. * @param scene the scne the object belongs to
  83778. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  83779. * @returns a new TransformNode object parsed from the source provided.
  83780. */
  83781. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  83782. /**
  83783. * Get all child-transformNodes of this node
  83784. * @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
  83785. * @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
  83786. * @returns an array of TransformNode
  83787. */
  83788. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  83789. /**
  83790. * Releases resources associated with this transform node.
  83791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83793. */
  83794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83795. /**
  83796. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83797. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83798. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83799. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  83800. * @returns the current mesh
  83801. */
  83802. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  83803. private _syncAbsoluteScalingAndRotation;
  83804. }
  83805. }
  83806. declare module BABYLON {
  83807. /**
  83808. * Defines the types of pose enabled controllers that are supported
  83809. */
  83810. export enum PoseEnabledControllerType {
  83811. /**
  83812. * HTC Vive
  83813. */
  83814. VIVE = 0,
  83815. /**
  83816. * Oculus Rift
  83817. */
  83818. OCULUS = 1,
  83819. /**
  83820. * Windows mixed reality
  83821. */
  83822. WINDOWS = 2,
  83823. /**
  83824. * Samsung gear VR
  83825. */
  83826. GEAR_VR = 3,
  83827. /**
  83828. * Google Daydream
  83829. */
  83830. DAYDREAM = 4,
  83831. /**
  83832. * Generic
  83833. */
  83834. GENERIC = 5
  83835. }
  83836. /**
  83837. * Defines the MutableGamepadButton interface for the state of a gamepad button
  83838. */
  83839. export interface MutableGamepadButton {
  83840. /**
  83841. * Value of the button/trigger
  83842. */
  83843. value: number;
  83844. /**
  83845. * If the button/trigger is currently touched
  83846. */
  83847. touched: boolean;
  83848. /**
  83849. * If the button/trigger is currently pressed
  83850. */
  83851. pressed: boolean;
  83852. }
  83853. /**
  83854. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  83855. * @hidden
  83856. */
  83857. export interface ExtendedGamepadButton extends GamepadButton {
  83858. /**
  83859. * If the button/trigger is currently pressed
  83860. */
  83861. readonly pressed: boolean;
  83862. /**
  83863. * If the button/trigger is currently touched
  83864. */
  83865. readonly touched: boolean;
  83866. /**
  83867. * Value of the button/trigger
  83868. */
  83869. readonly value: number;
  83870. }
  83871. /** @hidden */
  83872. export interface _GamePadFactory {
  83873. /**
  83874. * Returns wether or not the current gamepad can be created for this type of controller.
  83875. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83876. * @returns true if it can be created, otherwise false
  83877. */
  83878. canCreate(gamepadInfo: any): boolean;
  83879. /**
  83880. * Creates a new instance of the Gamepad.
  83881. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  83882. * @returns the new gamepad instance
  83883. */
  83884. create(gamepadInfo: any): Gamepad;
  83885. }
  83886. /**
  83887. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83888. */
  83889. export class PoseEnabledControllerHelper {
  83890. /** @hidden */
  83891. static _ControllerFactories: _GamePadFactory[];
  83892. /** @hidden */
  83893. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  83894. /**
  83895. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  83896. * @param vrGamepad the gamepad to initialized
  83897. * @returns a vr controller of the type the gamepad identified as
  83898. */
  83899. static InitiateController(vrGamepad: any): Gamepad;
  83900. }
  83901. /**
  83902. * Defines the PoseEnabledController object that contains state of a vr capable controller
  83903. */
  83904. export class PoseEnabledController extends Gamepad implements PoseControlled {
  83905. /**
  83906. * If the controller is used in a webXR session
  83907. */
  83908. isXR: boolean;
  83909. private _deviceRoomPosition;
  83910. private _deviceRoomRotationQuaternion;
  83911. /**
  83912. * The device position in babylon space
  83913. */
  83914. devicePosition: Vector3;
  83915. /**
  83916. * The device rotation in babylon space
  83917. */
  83918. deviceRotationQuaternion: Quaternion;
  83919. /**
  83920. * The scale factor of the device in babylon space
  83921. */
  83922. deviceScaleFactor: number;
  83923. /**
  83924. * (Likely devicePosition should be used instead) The device position in its room space
  83925. */
  83926. position: Vector3;
  83927. /**
  83928. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  83929. */
  83930. rotationQuaternion: Quaternion;
  83931. /**
  83932. * The type of controller (Eg. Windows mixed reality)
  83933. */
  83934. controllerType: PoseEnabledControllerType;
  83935. protected _calculatedPosition: Vector3;
  83936. private _calculatedRotation;
  83937. /**
  83938. * The raw pose from the device
  83939. */
  83940. rawPose: DevicePose;
  83941. private _trackPosition;
  83942. private _maxRotationDistFromHeadset;
  83943. private _draggedRoomRotation;
  83944. /**
  83945. * @hidden
  83946. */
  83947. _disableTrackPosition(fixedPosition: Vector3): void;
  83948. /**
  83949. * Internal, the mesh attached to the controller
  83950. * @hidden
  83951. */
  83952. _mesh: Nullable<AbstractMesh>;
  83953. private _poseControlledCamera;
  83954. private _leftHandSystemQuaternion;
  83955. /**
  83956. * Internal, matrix used to convert room space to babylon space
  83957. * @hidden
  83958. */
  83959. _deviceToWorld: Matrix;
  83960. /**
  83961. * Node to be used when casting a ray from the controller
  83962. * @hidden
  83963. */
  83964. _pointingPoseNode: Nullable<TransformNode>;
  83965. /**
  83966. * Name of the child mesh that can be used to cast a ray from the controller
  83967. */
  83968. static readonly POINTING_POSE: string;
  83969. /**
  83970. * Creates a new PoseEnabledController from a gamepad
  83971. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  83972. */
  83973. constructor(browserGamepad: any);
  83974. private _workingMatrix;
  83975. /**
  83976. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  83977. */
  83978. update(): void;
  83979. /**
  83980. * Updates only the pose device and mesh without doing any button event checking
  83981. */
  83982. protected _updatePoseAndMesh(): void;
  83983. /**
  83984. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  83985. * @param poseData raw pose fromthe device
  83986. */
  83987. updateFromDevice(poseData: DevicePose): void;
  83988. /**
  83989. * @hidden
  83990. */
  83991. _meshAttachedObservable: Observable<AbstractMesh>;
  83992. /**
  83993. * Attaches a mesh to the controller
  83994. * @param mesh the mesh to be attached
  83995. */
  83996. attachToMesh(mesh: AbstractMesh): void;
  83997. /**
  83998. * Attaches the controllers mesh to a camera
  83999. * @param camera the camera the mesh should be attached to
  84000. */
  84001. attachToPoseControlledCamera(camera: TargetCamera): void;
  84002. /**
  84003. * Disposes of the controller
  84004. */
  84005. dispose(): void;
  84006. /**
  84007. * The mesh that is attached to the controller
  84008. */
  84009. readonly mesh: Nullable<AbstractMesh>;
  84010. /**
  84011. * Gets the ray of the controller in the direction the controller is pointing
  84012. * @param length the length the resulting ray should be
  84013. * @returns a ray in the direction the controller is pointing
  84014. */
  84015. getForwardRay(length?: number): Ray;
  84016. }
  84017. }
  84018. declare module BABYLON {
  84019. /**
  84020. * Defines the WebVRController object that represents controllers tracked in 3D space
  84021. */
  84022. export abstract class WebVRController extends PoseEnabledController {
  84023. /**
  84024. * Internal, the default controller model for the controller
  84025. */
  84026. protected _defaultModel: Nullable<AbstractMesh>;
  84027. /**
  84028. * Fired when the trigger state has changed
  84029. */
  84030. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  84031. /**
  84032. * Fired when the main button state has changed
  84033. */
  84034. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  84035. /**
  84036. * Fired when the secondary button state has changed
  84037. */
  84038. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  84039. /**
  84040. * Fired when the pad state has changed
  84041. */
  84042. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  84043. /**
  84044. * Fired when controllers stick values have changed
  84045. */
  84046. onPadValuesChangedObservable: Observable<StickValues>;
  84047. /**
  84048. * Array of button availible on the controller
  84049. */
  84050. protected _buttons: Array<MutableGamepadButton>;
  84051. private _onButtonStateChange;
  84052. /**
  84053. * Fired when a controller button's state has changed
  84054. * @param callback the callback containing the button that was modified
  84055. */
  84056. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  84057. /**
  84058. * X and Y axis corresponding to the controllers joystick
  84059. */
  84060. pad: StickValues;
  84061. /**
  84062. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  84063. */
  84064. hand: string;
  84065. /**
  84066. * The default controller model for the controller
  84067. */
  84068. readonly defaultModel: Nullable<AbstractMesh>;
  84069. /**
  84070. * Creates a new WebVRController from a gamepad
  84071. * @param vrGamepad the gamepad that the WebVRController should be created from
  84072. */
  84073. constructor(vrGamepad: any);
  84074. /**
  84075. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  84076. */
  84077. update(): void;
  84078. /**
  84079. * Function to be called when a button is modified
  84080. */
  84081. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  84082. /**
  84083. * Loads a mesh and attaches it to the controller
  84084. * @param scene the scene the mesh should be added to
  84085. * @param meshLoaded callback for when the mesh has been loaded
  84086. */
  84087. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  84088. private _setButtonValue;
  84089. private _changes;
  84090. private _checkChanges;
  84091. /**
  84092. * Disposes of th webVRCOntroller
  84093. */
  84094. dispose(): void;
  84095. }
  84096. }
  84097. declare module BABYLON {
  84098. /**
  84099. * The HemisphericLight simulates the ambient environment light,
  84100. * so the passed direction is the light reflection direction, not the incoming direction.
  84101. */
  84102. export class HemisphericLight extends Light {
  84103. /**
  84104. * The groundColor is the light in the opposite direction to the one specified during creation.
  84105. * 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.
  84106. */
  84107. groundColor: Color3;
  84108. /**
  84109. * The light reflection direction, not the incoming direction.
  84110. */
  84111. direction: Vector3;
  84112. /**
  84113. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  84114. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  84115. * The HemisphericLight can't cast shadows.
  84116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  84117. * @param name The friendly name of the light
  84118. * @param direction The direction of the light reflection
  84119. * @param scene The scene the light belongs to
  84120. */
  84121. constructor(name: string, direction: Vector3, scene: Scene);
  84122. protected _buildUniformLayout(): void;
  84123. /**
  84124. * Returns the string "HemisphericLight".
  84125. * @return The class name
  84126. */
  84127. getClassName(): string;
  84128. /**
  84129. * Sets the HemisphericLight direction towards the passed target (Vector3).
  84130. * Returns the updated direction.
  84131. * @param target The target the direction should point to
  84132. * @return The computed direction
  84133. */
  84134. setDirectionToTarget(target: Vector3): Vector3;
  84135. /**
  84136. * Returns the shadow generator associated to the light.
  84137. * @returns Always null for hemispheric lights because it does not support shadows.
  84138. */
  84139. getShadowGenerator(): Nullable<IShadowGenerator>;
  84140. /**
  84141. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  84142. * @param effect The effect to update
  84143. * @param lightIndex The index of the light in the effect to update
  84144. * @returns The hemispheric light
  84145. */
  84146. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  84147. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  84148. /**
  84149. * Computes the world matrix of the node
  84150. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84151. * @param useWasUpdatedFlag defines a reserved property
  84152. * @returns the world matrix
  84153. */
  84154. computeWorldMatrix(): Matrix;
  84155. /**
  84156. * Returns the integer 3.
  84157. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  84158. */
  84159. getTypeID(): number;
  84160. /**
  84161. * Prepares the list of defines specific to the light type.
  84162. * @param defines the list of defines
  84163. * @param lightIndex defines the index of the light for the effect
  84164. */
  84165. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  84166. }
  84167. }
  84168. declare module BABYLON {
  84169. /** @hidden */
  84170. export var vrMultiviewToSingleviewPixelShader: {
  84171. name: string;
  84172. shader: string;
  84173. };
  84174. }
  84175. declare module BABYLON {
  84176. /**
  84177. * Renders to multiple views with a single draw call
  84178. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  84179. */
  84180. export class MultiviewRenderTarget extends RenderTargetTexture {
  84181. /**
  84182. * Creates a multiview render target
  84183. * @param scene scene used with the render target
  84184. * @param size the size of the render target (used for each view)
  84185. */
  84186. constructor(scene: Scene, size?: number | {
  84187. width: number;
  84188. height: number;
  84189. } | {
  84190. ratio: number;
  84191. });
  84192. /**
  84193. * @hidden
  84194. * @param faceIndex the face index, if its a cube texture
  84195. */
  84196. _bindFrameBuffer(faceIndex?: number): void;
  84197. /**
  84198. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84199. * @returns the view count
  84200. */
  84201. getViewCount(): number;
  84202. }
  84203. }
  84204. declare module BABYLON {
  84205. /**
  84206. * Represents a camera frustum
  84207. */
  84208. export class Frustum {
  84209. /**
  84210. * Gets the planes representing the frustum
  84211. * @param transform matrix to be applied to the returned planes
  84212. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  84213. */
  84214. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  84215. /**
  84216. * Gets the near frustum plane transformed by the transform matrix
  84217. * @param transform transformation matrix to be applied to the resulting frustum plane
  84218. * @param frustumPlane the resuling frustum plane
  84219. */
  84220. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84221. /**
  84222. * Gets the far frustum plane transformed by the transform matrix
  84223. * @param transform transformation matrix to be applied to the resulting frustum plane
  84224. * @param frustumPlane the resuling frustum plane
  84225. */
  84226. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84227. /**
  84228. * Gets the left frustum plane transformed by the transform matrix
  84229. * @param transform transformation matrix to be applied to the resulting frustum plane
  84230. * @param frustumPlane the resuling frustum plane
  84231. */
  84232. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84233. /**
  84234. * Gets the right frustum plane transformed by the transform matrix
  84235. * @param transform transformation matrix to be applied to the resulting frustum plane
  84236. * @param frustumPlane the resuling frustum plane
  84237. */
  84238. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84239. /**
  84240. * Gets the top frustum plane transformed by the transform matrix
  84241. * @param transform transformation matrix to be applied to the resulting frustum plane
  84242. * @param frustumPlane the resuling frustum plane
  84243. */
  84244. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84245. /**
  84246. * Gets the bottom frustum plane transformed by the transform matrix
  84247. * @param transform transformation matrix to be applied to the resulting frustum plane
  84248. * @param frustumPlane the resuling frustum plane
  84249. */
  84250. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  84251. /**
  84252. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  84253. * @param transform transformation matrix to be applied to the resulting frustum planes
  84254. * @param frustumPlanes the resuling frustum planes
  84255. */
  84256. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  84257. }
  84258. }
  84259. declare module BABYLON {
  84260. interface Engine {
  84261. /**
  84262. * Creates a new multiview render target
  84263. * @param width defines the width of the texture
  84264. * @param height defines the height of the texture
  84265. * @returns the created multiview texture
  84266. */
  84267. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  84268. /**
  84269. * Binds a multiview framebuffer to be drawn to
  84270. * @param multiviewTexture texture to bind
  84271. */
  84272. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  84273. }
  84274. interface Camera {
  84275. /**
  84276. * @hidden
  84277. * 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)
  84278. */
  84279. _useMultiviewToSingleView: boolean;
  84280. /**
  84281. * @hidden
  84282. * 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)
  84283. */
  84284. _multiviewTexture: Nullable<RenderTargetTexture>;
  84285. /**
  84286. * @hidden
  84287. * ensures the multiview texture of the camera exists and has the specified width/height
  84288. * @param width height to set on the multiview texture
  84289. * @param height width to set on the multiview texture
  84290. */
  84291. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  84292. }
  84293. interface Scene {
  84294. /** @hidden */
  84295. _transformMatrixR: Matrix;
  84296. /** @hidden */
  84297. _multiviewSceneUbo: Nullable<UniformBuffer>;
  84298. /** @hidden */
  84299. _createMultiviewUbo(): void;
  84300. /** @hidden */
  84301. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  84302. /** @hidden */
  84303. _renderMultiviewToSingleView(camera: Camera): void;
  84304. }
  84305. }
  84306. declare module BABYLON {
  84307. /**
  84308. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  84309. * This will not be used for webXR as it supports displaying texture arrays directly
  84310. */
  84311. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  84312. /**
  84313. * Initializes a VRMultiviewToSingleview
  84314. * @param name name of the post process
  84315. * @param camera camera to be applied to
  84316. * @param scaleFactor scaling factor to the size of the output texture
  84317. */
  84318. constructor(name: string, camera: Camera, scaleFactor: number);
  84319. }
  84320. }
  84321. declare module BABYLON {
  84322. /**
  84323. * Interface used to define additional presentation attributes
  84324. */
  84325. export interface IVRPresentationAttributes {
  84326. /**
  84327. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  84328. */
  84329. highRefreshRate: boolean;
  84330. /**
  84331. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  84332. */
  84333. foveationLevel: number;
  84334. }
  84335. interface Engine {
  84336. /** @hidden */
  84337. _vrDisplay: any;
  84338. /** @hidden */
  84339. _vrSupported: boolean;
  84340. /** @hidden */
  84341. _oldSize: Size;
  84342. /** @hidden */
  84343. _oldHardwareScaleFactor: number;
  84344. /** @hidden */
  84345. _vrExclusivePointerMode: boolean;
  84346. /** @hidden */
  84347. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  84348. /** @hidden */
  84349. _onVRDisplayPointerRestricted: () => void;
  84350. /** @hidden */
  84351. _onVRDisplayPointerUnrestricted: () => void;
  84352. /** @hidden */
  84353. _onVrDisplayConnect: Nullable<(display: any) => void>;
  84354. /** @hidden */
  84355. _onVrDisplayDisconnect: Nullable<() => void>;
  84356. /** @hidden */
  84357. _onVrDisplayPresentChange: Nullable<() => void>;
  84358. /**
  84359. * Observable signaled when VR display mode changes
  84360. */
  84361. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  84362. /**
  84363. * Observable signaled when VR request present is complete
  84364. */
  84365. onVRRequestPresentComplete: Observable<boolean>;
  84366. /**
  84367. * Observable signaled when VR request present starts
  84368. */
  84369. onVRRequestPresentStart: Observable<Engine>;
  84370. /**
  84371. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  84372. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  84373. */
  84374. isInVRExclusivePointerMode: boolean;
  84375. /**
  84376. * Gets a boolean indicating if a webVR device was detected
  84377. * @returns true if a webVR device was detected
  84378. */
  84379. isVRDevicePresent(): boolean;
  84380. /**
  84381. * Gets the current webVR device
  84382. * @returns the current webVR device (or null)
  84383. */
  84384. getVRDevice(): any;
  84385. /**
  84386. * Initializes a webVR display and starts listening to display change events
  84387. * The onVRDisplayChangedObservable will be notified upon these changes
  84388. * @returns A promise containing a VRDisplay and if vr is supported
  84389. */
  84390. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  84391. /** @hidden */
  84392. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  84393. /**
  84394. * Gets or sets the presentation attributes used to configure VR rendering
  84395. */
  84396. vrPresentationAttributes?: IVRPresentationAttributes;
  84397. /**
  84398. * Call this function to switch to webVR mode
  84399. * Will do nothing if webVR is not supported or if there is no webVR device
  84400. * @param options the webvr options provided to the camera. mainly used for multiview
  84401. * @see http://doc.babylonjs.com/how_to/webvr_camera
  84402. */
  84403. enableVR(options: WebVROptions): void;
  84404. /** @hidden */
  84405. _onVRFullScreenTriggered(): void;
  84406. }
  84407. }
  84408. declare module BABYLON {
  84409. /**
  84410. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  84411. * IMPORTANT!! The data is right-hand data.
  84412. * @export
  84413. * @interface DevicePose
  84414. */
  84415. export interface DevicePose {
  84416. /**
  84417. * The position of the device, values in array are [x,y,z].
  84418. */
  84419. readonly position: Nullable<Float32Array>;
  84420. /**
  84421. * The linearVelocity of the device, values in array are [x,y,z].
  84422. */
  84423. readonly linearVelocity: Nullable<Float32Array>;
  84424. /**
  84425. * The linearAcceleration of the device, values in array are [x,y,z].
  84426. */
  84427. readonly linearAcceleration: Nullable<Float32Array>;
  84428. /**
  84429. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  84430. */
  84431. readonly orientation: Nullable<Float32Array>;
  84432. /**
  84433. * The angularVelocity of the device, values in array are [x,y,z].
  84434. */
  84435. readonly angularVelocity: Nullable<Float32Array>;
  84436. /**
  84437. * The angularAcceleration of the device, values in array are [x,y,z].
  84438. */
  84439. readonly angularAcceleration: Nullable<Float32Array>;
  84440. }
  84441. /**
  84442. * Interface representing a pose controlled object in Babylon.
  84443. * A pose controlled object has both regular pose values as well as pose values
  84444. * from an external device such as a VR head mounted display
  84445. */
  84446. export interface PoseControlled {
  84447. /**
  84448. * The position of the object in babylon space.
  84449. */
  84450. position: Vector3;
  84451. /**
  84452. * The rotation quaternion of the object in babylon space.
  84453. */
  84454. rotationQuaternion: Quaternion;
  84455. /**
  84456. * The position of the device in babylon space.
  84457. */
  84458. devicePosition?: Vector3;
  84459. /**
  84460. * The rotation quaternion of the device in babylon space.
  84461. */
  84462. deviceRotationQuaternion: Quaternion;
  84463. /**
  84464. * The raw pose coming from the device.
  84465. */
  84466. rawPose: Nullable<DevicePose>;
  84467. /**
  84468. * The scale of the device to be used when translating from device space to babylon space.
  84469. */
  84470. deviceScaleFactor: number;
  84471. /**
  84472. * Updates the poseControlled values based on the input device pose.
  84473. * @param poseData the pose data to update the object with
  84474. */
  84475. updateFromDevice(poseData: DevicePose): void;
  84476. }
  84477. /**
  84478. * Set of options to customize the webVRCamera
  84479. */
  84480. export interface WebVROptions {
  84481. /**
  84482. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  84483. */
  84484. trackPosition?: boolean;
  84485. /**
  84486. * Sets the scale of the vrDevice in babylon space. (default: 1)
  84487. */
  84488. positionScale?: number;
  84489. /**
  84490. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  84491. */
  84492. displayName?: string;
  84493. /**
  84494. * Should the native controller meshes be initialized. (default: true)
  84495. */
  84496. controllerMeshes?: boolean;
  84497. /**
  84498. * Creating a default HemiLight only on controllers. (default: true)
  84499. */
  84500. defaultLightingOnControllers?: boolean;
  84501. /**
  84502. * If you don't want to use the default VR button of the helper. (default: false)
  84503. */
  84504. useCustomVRButton?: boolean;
  84505. /**
  84506. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  84507. */
  84508. customVRButton?: HTMLButtonElement;
  84509. /**
  84510. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  84511. */
  84512. rayLength?: number;
  84513. /**
  84514. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  84515. */
  84516. defaultHeight?: number;
  84517. /**
  84518. * If multiview should be used if availible (default: false)
  84519. */
  84520. useMultiview?: boolean;
  84521. }
  84522. /**
  84523. * This represents a WebVR camera.
  84524. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  84525. * @example http://doc.babylonjs.com/how_to/webvr_camera
  84526. */
  84527. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  84528. private webVROptions;
  84529. /**
  84530. * @hidden
  84531. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  84532. */
  84533. _vrDevice: any;
  84534. /**
  84535. * The rawPose of the vrDevice.
  84536. */
  84537. rawPose: Nullable<DevicePose>;
  84538. private _onVREnabled;
  84539. private _specsVersion;
  84540. private _attached;
  84541. private _frameData;
  84542. protected _descendants: Array<Node>;
  84543. private _deviceRoomPosition;
  84544. /** @hidden */
  84545. _deviceRoomRotationQuaternion: Quaternion;
  84546. private _standingMatrix;
  84547. /**
  84548. * Represents device position in babylon space.
  84549. */
  84550. devicePosition: Vector3;
  84551. /**
  84552. * Represents device rotation in babylon space.
  84553. */
  84554. deviceRotationQuaternion: Quaternion;
  84555. /**
  84556. * The scale of the device to be used when translating from device space to babylon space.
  84557. */
  84558. deviceScaleFactor: number;
  84559. private _deviceToWorld;
  84560. private _worldToDevice;
  84561. /**
  84562. * References to the webVR controllers for the vrDevice.
  84563. */
  84564. controllers: Array<WebVRController>;
  84565. /**
  84566. * Emits an event when a controller is attached.
  84567. */
  84568. onControllersAttachedObservable: Observable<WebVRController[]>;
  84569. /**
  84570. * Emits an event when a controller's mesh has been loaded;
  84571. */
  84572. onControllerMeshLoadedObservable: Observable<WebVRController>;
  84573. /**
  84574. * Emits an event when the HMD's pose has been updated.
  84575. */
  84576. onPoseUpdatedFromDeviceObservable: Observable<any>;
  84577. private _poseSet;
  84578. /**
  84579. * If the rig cameras be used as parent instead of this camera.
  84580. */
  84581. rigParenting: boolean;
  84582. private _lightOnControllers;
  84583. private _defaultHeight?;
  84584. /**
  84585. * Instantiates a WebVRFreeCamera.
  84586. * @param name The name of the WebVRFreeCamera
  84587. * @param position The starting anchor position for the camera
  84588. * @param scene The scene the camera belongs to
  84589. * @param webVROptions a set of customizable options for the webVRCamera
  84590. */
  84591. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  84592. /**
  84593. * Gets the device distance from the ground in meters.
  84594. * @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.
  84595. */
  84596. deviceDistanceToRoomGround(): number;
  84597. /**
  84598. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84599. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  84600. */
  84601. useStandingMatrix(callback?: (bool: boolean) => void): void;
  84602. /**
  84603. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  84604. * @returns A promise with a boolean set to if the standing matrix is supported.
  84605. */
  84606. useStandingMatrixAsync(): Promise<boolean>;
  84607. /**
  84608. * Disposes the camera
  84609. */
  84610. dispose(): void;
  84611. /**
  84612. * Gets a vrController by name.
  84613. * @param name The name of the controller to retreive
  84614. * @returns the controller matching the name specified or null if not found
  84615. */
  84616. getControllerByName(name: string): Nullable<WebVRController>;
  84617. private _leftController;
  84618. /**
  84619. * The controller corresponding to the users left hand.
  84620. */
  84621. readonly leftController: Nullable<WebVRController>;
  84622. private _rightController;
  84623. /**
  84624. * The controller corresponding to the users right hand.
  84625. */
  84626. readonly rightController: Nullable<WebVRController>;
  84627. /**
  84628. * Casts a ray forward from the vrCamera's gaze.
  84629. * @param length Length of the ray (default: 100)
  84630. * @returns the ray corresponding to the gaze
  84631. */
  84632. getForwardRay(length?: number): Ray;
  84633. /**
  84634. * @hidden
  84635. * Updates the camera based on device's frame data
  84636. */
  84637. _checkInputs(): void;
  84638. /**
  84639. * Updates the poseControlled values based on the input device pose.
  84640. * @param poseData Pose coming from the device
  84641. */
  84642. updateFromDevice(poseData: DevicePose): void;
  84643. private _htmlElementAttached;
  84644. private _detachIfAttached;
  84645. /**
  84646. * WebVR's attach control will start broadcasting frames to the device.
  84647. * Note that in certain browsers (chrome for example) this function must be called
  84648. * within a user-interaction callback. Example:
  84649. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  84650. *
  84651. * @param element html element to attach the vrDevice to
  84652. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  84653. */
  84654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84655. /**
  84656. * Detaches the camera from the html element and disables VR
  84657. *
  84658. * @param element html element to detach from
  84659. */
  84660. detachControl(element: HTMLElement): void;
  84661. /**
  84662. * @returns the name of this class
  84663. */
  84664. getClassName(): string;
  84665. /**
  84666. * Calls resetPose on the vrDisplay
  84667. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  84668. */
  84669. resetToCurrentRotation(): void;
  84670. /**
  84671. * @hidden
  84672. * Updates the rig cameras (left and right eye)
  84673. */
  84674. _updateRigCameras(): void;
  84675. private _workingVector;
  84676. private _oneVector;
  84677. private _workingMatrix;
  84678. private updateCacheCalled;
  84679. private _correctPositionIfNotTrackPosition;
  84680. /**
  84681. * @hidden
  84682. * Updates the cached values of the camera
  84683. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  84684. */
  84685. _updateCache(ignoreParentClass?: boolean): void;
  84686. /**
  84687. * @hidden
  84688. * Get current device position in babylon world
  84689. */
  84690. _computeDevicePosition(): void;
  84691. /**
  84692. * Updates the current device position and rotation in the babylon world
  84693. */
  84694. update(): void;
  84695. /**
  84696. * @hidden
  84697. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  84698. * @returns an identity matrix
  84699. */
  84700. _getViewMatrix(): Matrix;
  84701. private _tmpMatrix;
  84702. /**
  84703. * This function is called by the two RIG cameras.
  84704. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  84705. * @hidden
  84706. */
  84707. _getWebVRViewMatrix(): Matrix;
  84708. /** @hidden */
  84709. _getWebVRProjectionMatrix(): Matrix;
  84710. private _onGamepadConnectedObserver;
  84711. private _onGamepadDisconnectedObserver;
  84712. private _updateCacheWhenTrackingDisabledObserver;
  84713. /**
  84714. * Initializes the controllers and their meshes
  84715. */
  84716. initControllers(): void;
  84717. }
  84718. }
  84719. declare module BABYLON {
  84720. /**
  84721. * Size options for a post process
  84722. */
  84723. export type PostProcessOptions = {
  84724. width: number;
  84725. height: number;
  84726. };
  84727. /**
  84728. * PostProcess can be used to apply a shader to a texture after it has been rendered
  84729. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84730. */
  84731. export class PostProcess {
  84732. /** Name of the PostProcess. */
  84733. name: string;
  84734. /**
  84735. * Gets or sets the unique id of the post process
  84736. */
  84737. uniqueId: number;
  84738. /**
  84739. * Width of the texture to apply the post process on
  84740. */
  84741. width: number;
  84742. /**
  84743. * Height of the texture to apply the post process on
  84744. */
  84745. height: number;
  84746. /**
  84747. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  84748. * @hidden
  84749. */
  84750. _outputTexture: Nullable<InternalTexture>;
  84751. /**
  84752. * Sampling mode used by the shader
  84753. * See https://doc.babylonjs.com/classes/3.1/texture
  84754. */
  84755. renderTargetSamplingMode: number;
  84756. /**
  84757. * Clear color to use when screen clearing
  84758. */
  84759. clearColor: Color4;
  84760. /**
  84761. * If the buffer needs to be cleared before applying the post process. (default: true)
  84762. * Should be set to false if shader will overwrite all previous pixels.
  84763. */
  84764. autoClear: boolean;
  84765. /**
  84766. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  84767. */
  84768. alphaMode: number;
  84769. /**
  84770. * Sets the setAlphaBlendConstants of the babylon engine
  84771. */
  84772. alphaConstants: Color4;
  84773. /**
  84774. * Animations to be used for the post processing
  84775. */
  84776. animations: Animation[];
  84777. /**
  84778. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  84779. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  84780. */
  84781. enablePixelPerfectMode: boolean;
  84782. /**
  84783. * Force the postprocess to be applied without taking in account viewport
  84784. */
  84785. forceFullscreenViewport: boolean;
  84786. /**
  84787. * List of inspectable custom properties (used by the Inspector)
  84788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84789. */
  84790. inspectableCustomProperties: IInspectable[];
  84791. /**
  84792. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  84793. *
  84794. * | Value | Type | Description |
  84795. * | ----- | ----------------------------------- | ----------- |
  84796. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  84797. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  84798. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  84799. *
  84800. */
  84801. scaleMode: number;
  84802. /**
  84803. * Force textures to be a power of two (default: false)
  84804. */
  84805. alwaysForcePOT: boolean;
  84806. private _samples;
  84807. /**
  84808. * Number of sample textures (default: 1)
  84809. */
  84810. samples: number;
  84811. /**
  84812. * Modify the scale of the post process to be the same as the viewport (default: false)
  84813. */
  84814. adaptScaleToCurrentViewport: boolean;
  84815. private _camera;
  84816. private _scene;
  84817. private _engine;
  84818. private _options;
  84819. private _reusable;
  84820. private _textureType;
  84821. /**
  84822. * Smart array of input and output textures for the post process.
  84823. * @hidden
  84824. */
  84825. _textures: SmartArray<InternalTexture>;
  84826. /**
  84827. * The index in _textures that corresponds to the output texture.
  84828. * @hidden
  84829. */
  84830. _currentRenderTextureInd: number;
  84831. private _effect;
  84832. private _samplers;
  84833. private _fragmentUrl;
  84834. private _vertexUrl;
  84835. private _parameters;
  84836. private _scaleRatio;
  84837. protected _indexParameters: any;
  84838. private _shareOutputWithPostProcess;
  84839. private _texelSize;
  84840. private _forcedOutputTexture;
  84841. /**
  84842. * Returns the fragment url or shader name used in the post process.
  84843. * @returns the fragment url or name in the shader store.
  84844. */
  84845. getEffectName(): string;
  84846. /**
  84847. * An event triggered when the postprocess is activated.
  84848. */
  84849. onActivateObservable: Observable<Camera>;
  84850. private _onActivateObserver;
  84851. /**
  84852. * A function that is added to the onActivateObservable
  84853. */
  84854. onActivate: Nullable<(camera: Camera) => void>;
  84855. /**
  84856. * An event triggered when the postprocess changes its size.
  84857. */
  84858. onSizeChangedObservable: Observable<PostProcess>;
  84859. private _onSizeChangedObserver;
  84860. /**
  84861. * A function that is added to the onSizeChangedObservable
  84862. */
  84863. onSizeChanged: (postProcess: PostProcess) => void;
  84864. /**
  84865. * An event triggered when the postprocess applies its effect.
  84866. */
  84867. onApplyObservable: Observable<Effect>;
  84868. private _onApplyObserver;
  84869. /**
  84870. * A function that is added to the onApplyObservable
  84871. */
  84872. onApply: (effect: Effect) => void;
  84873. /**
  84874. * An event triggered before rendering the postprocess
  84875. */
  84876. onBeforeRenderObservable: Observable<Effect>;
  84877. private _onBeforeRenderObserver;
  84878. /**
  84879. * A function that is added to the onBeforeRenderObservable
  84880. */
  84881. onBeforeRender: (effect: Effect) => void;
  84882. /**
  84883. * An event triggered after rendering the postprocess
  84884. */
  84885. onAfterRenderObservable: Observable<Effect>;
  84886. private _onAfterRenderObserver;
  84887. /**
  84888. * A function that is added to the onAfterRenderObservable
  84889. */
  84890. onAfterRender: (efect: Effect) => void;
  84891. /**
  84892. * 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
  84893. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  84894. */
  84895. inputTexture: InternalTexture;
  84896. /**
  84897. * Gets the camera which post process is applied to.
  84898. * @returns The camera the post process is applied to.
  84899. */
  84900. getCamera(): Camera;
  84901. /**
  84902. * Gets the texel size of the postprocess.
  84903. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  84904. */
  84905. readonly texelSize: Vector2;
  84906. /**
  84907. * Creates a new instance PostProcess
  84908. * @param name The name of the PostProcess.
  84909. * @param fragmentUrl The url of the fragment shader to be used.
  84910. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  84911. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  84912. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84913. * @param camera The camera to apply the render pass to.
  84914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84915. * @param engine The engine which the post process will be applied. (default: current engine)
  84916. * @param reusable If the post process can be reused on the same frame. (default: false)
  84917. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  84918. * @param textureType Type of textures used when performing the post process. (default: 0)
  84919. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  84920. * @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
  84921. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  84922. */
  84923. constructor(
  84924. /** Name of the PostProcess. */
  84925. 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);
  84926. /**
  84927. * Gets a string idenfifying the name of the class
  84928. * @returns "PostProcess" string
  84929. */
  84930. getClassName(): string;
  84931. /**
  84932. * Gets the engine which this post process belongs to.
  84933. * @returns The engine the post process was enabled with.
  84934. */
  84935. getEngine(): Engine;
  84936. /**
  84937. * The effect that is created when initializing the post process.
  84938. * @returns The created effect corresponding the the postprocess.
  84939. */
  84940. getEffect(): Effect;
  84941. /**
  84942. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  84943. * @param postProcess The post process to share the output with.
  84944. * @returns This post process.
  84945. */
  84946. shareOutputWith(postProcess: PostProcess): PostProcess;
  84947. /**
  84948. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  84949. * This should be called if the post process that shares output with this post process is disabled/disposed.
  84950. */
  84951. useOwnOutput(): void;
  84952. /**
  84953. * Updates the effect with the current post process compile time values and recompiles the shader.
  84954. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84955. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84956. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84957. * @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
  84958. * @param onCompiled Called when the shader has been compiled.
  84959. * @param onError Called if there is an error when compiling a shader.
  84960. */
  84961. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84962. /**
  84963. * The post process is reusable if it can be used multiple times within one frame.
  84964. * @returns If the post process is reusable
  84965. */
  84966. isReusable(): boolean;
  84967. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  84968. markTextureDirty(): void;
  84969. /**
  84970. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  84971. * 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.
  84972. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  84973. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  84974. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  84975. * @returns The target texture that was bound to be written to.
  84976. */
  84977. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  84978. /**
  84979. * If the post process is supported.
  84980. */
  84981. readonly isSupported: boolean;
  84982. /**
  84983. * The aspect ratio of the output texture.
  84984. */
  84985. readonly aspectRatio: number;
  84986. /**
  84987. * Get a value indicating if the post-process is ready to be used
  84988. * @returns true if the post-process is ready (shader is compiled)
  84989. */
  84990. isReady(): boolean;
  84991. /**
  84992. * Binds all textures and uniforms to the shader, this will be run on every pass.
  84993. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  84994. */
  84995. apply(): Nullable<Effect>;
  84996. private _disposeTextures;
  84997. /**
  84998. * Disposes the post process.
  84999. * @param camera The camera to dispose the post process on.
  85000. */
  85001. dispose(camera?: Camera): void;
  85002. }
  85003. }
  85004. declare module BABYLON {
  85005. /** @hidden */
  85006. export var kernelBlurVaryingDeclaration: {
  85007. name: string;
  85008. shader: string;
  85009. };
  85010. }
  85011. declare module BABYLON {
  85012. /** @hidden */
  85013. export var kernelBlurFragment: {
  85014. name: string;
  85015. shader: string;
  85016. };
  85017. }
  85018. declare module BABYLON {
  85019. /** @hidden */
  85020. export var kernelBlurFragment2: {
  85021. name: string;
  85022. shader: string;
  85023. };
  85024. }
  85025. declare module BABYLON {
  85026. /** @hidden */
  85027. export var kernelBlurPixelShader: {
  85028. name: string;
  85029. shader: string;
  85030. };
  85031. }
  85032. declare module BABYLON {
  85033. /** @hidden */
  85034. export var kernelBlurVertex: {
  85035. name: string;
  85036. shader: string;
  85037. };
  85038. }
  85039. declare module BABYLON {
  85040. /** @hidden */
  85041. export var kernelBlurVertexShader: {
  85042. name: string;
  85043. shader: string;
  85044. };
  85045. }
  85046. declare module BABYLON {
  85047. /**
  85048. * The Blur Post Process which blurs an image based on a kernel and direction.
  85049. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  85050. */
  85051. export class BlurPostProcess extends PostProcess {
  85052. /** The direction in which to blur the image. */
  85053. direction: Vector2;
  85054. private blockCompilation;
  85055. protected _kernel: number;
  85056. protected _idealKernel: number;
  85057. protected _packedFloat: boolean;
  85058. private _staticDefines;
  85059. /**
  85060. * Sets the length in pixels of the blur sample region
  85061. */
  85062. /**
  85063. * Gets the length in pixels of the blur sample region
  85064. */
  85065. kernel: number;
  85066. /**
  85067. * Sets wether or not the blur needs to unpack/repack floats
  85068. */
  85069. /**
  85070. * Gets wether or not the blur is unpacking/repacking floats
  85071. */
  85072. packedFloat: boolean;
  85073. /**
  85074. * Creates a new instance BlurPostProcess
  85075. * @param name The name of the effect.
  85076. * @param direction The direction in which to blur the image.
  85077. * @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.
  85078. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  85079. * @param camera The camera to apply the render pass to.
  85080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  85081. * @param engine The engine which the post process will be applied. (default: current engine)
  85082. * @param reusable If the post process can be reused on the same frame. (default: false)
  85083. * @param textureType Type of textures used when performing the post process. (default: 0)
  85084. * @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)
  85085. */
  85086. constructor(name: string,
  85087. /** The direction in which to blur the image. */
  85088. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  85089. /**
  85090. * Updates the effect with the current post process compile time values and recompiles the shader.
  85091. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  85092. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  85093. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  85094. * @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
  85095. * @param onCompiled Called when the shader has been compiled.
  85096. * @param onError Called if there is an error when compiling a shader.
  85097. */
  85098. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85099. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  85100. /**
  85101. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  85102. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  85103. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  85104. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  85105. * The gaps between physical kernels are compensated for in the weighting of the samples
  85106. * @param idealKernel Ideal blur kernel.
  85107. * @return Nearest best kernel.
  85108. */
  85109. protected _nearestBestKernel(idealKernel: number): number;
  85110. /**
  85111. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  85112. * @param x The point on the Gaussian distribution to sample.
  85113. * @return the value of the Gaussian function at x.
  85114. */
  85115. protected _gaussianWeight(x: number): number;
  85116. /**
  85117. * Generates a string that can be used as a floating point number in GLSL.
  85118. * @param x Value to print.
  85119. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  85120. * @return GLSL float string.
  85121. */
  85122. protected _glslFloat(x: number, decimalFigures?: number): string;
  85123. }
  85124. }
  85125. declare module BABYLON {
  85126. /**
  85127. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85128. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85129. * You can then easily use it as a reflectionTexture on a flat surface.
  85130. * In case the surface is not a plane, please consider relying on reflection probes.
  85131. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85132. */
  85133. export class MirrorTexture extends RenderTargetTexture {
  85134. private scene;
  85135. /**
  85136. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  85137. * 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.
  85138. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85139. */
  85140. mirrorPlane: Plane;
  85141. /**
  85142. * Define the blur ratio used to blur the reflection if needed.
  85143. */
  85144. blurRatio: number;
  85145. /**
  85146. * Define the adaptive blur kernel used to blur the reflection if needed.
  85147. * This will autocompute the closest best match for the `blurKernel`
  85148. */
  85149. adaptiveBlurKernel: number;
  85150. /**
  85151. * Define the blur kernel used to blur the reflection if needed.
  85152. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85153. */
  85154. blurKernel: number;
  85155. /**
  85156. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  85157. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85158. */
  85159. blurKernelX: number;
  85160. /**
  85161. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  85162. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  85163. */
  85164. blurKernelY: number;
  85165. private _autoComputeBlurKernel;
  85166. protected _onRatioRescale(): void;
  85167. private _updateGammaSpace;
  85168. private _imageProcessingConfigChangeObserver;
  85169. private _transformMatrix;
  85170. private _mirrorMatrix;
  85171. private _savedViewMatrix;
  85172. private _blurX;
  85173. private _blurY;
  85174. private _adaptiveBlurKernel;
  85175. private _blurKernelX;
  85176. private _blurKernelY;
  85177. private _blurRatio;
  85178. /**
  85179. * Instantiates a Mirror Texture.
  85180. * Mirror texture can be used to simulate the view from a mirror in a scene.
  85181. * It will dynamically be rendered every frame to adapt to the camera point of view.
  85182. * You can then easily use it as a reflectionTexture on a flat surface.
  85183. * In case the surface is not a plane, please consider relying on reflection probes.
  85184. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  85185. * @param name
  85186. * @param size
  85187. * @param scene
  85188. * @param generateMipMaps
  85189. * @param type
  85190. * @param samplingMode
  85191. * @param generateDepthBuffer
  85192. */
  85193. constructor(name: string, size: number | {
  85194. width: number;
  85195. height: number;
  85196. } | {
  85197. ratio: number;
  85198. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  85199. private _preparePostProcesses;
  85200. /**
  85201. * Clone the mirror texture.
  85202. * @returns the cloned texture
  85203. */
  85204. clone(): MirrorTexture;
  85205. /**
  85206. * Serialize the texture to a JSON representation you could use in Parse later on
  85207. * @returns the serialized JSON representation
  85208. */
  85209. serialize(): any;
  85210. /**
  85211. * Dispose the texture and release its associated resources.
  85212. */
  85213. dispose(): void;
  85214. }
  85215. }
  85216. declare module BABYLON {
  85217. /**
  85218. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85219. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85220. */
  85221. export class Texture extends BaseTexture {
  85222. /**
  85223. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  85224. */
  85225. static SerializeBuffers: boolean;
  85226. /** @hidden */
  85227. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  85228. /** @hidden */
  85229. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  85230. /** @hidden */
  85231. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  85232. /** nearest is mag = nearest and min = nearest and mip = linear */
  85233. static readonly NEAREST_SAMPLINGMODE: number;
  85234. /** nearest is mag = nearest and min = nearest and mip = linear */
  85235. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  85236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85237. static readonly BILINEAR_SAMPLINGMODE: number;
  85238. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85239. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  85240. /** Trilinear is mag = linear and min = linear and mip = linear */
  85241. static readonly TRILINEAR_SAMPLINGMODE: number;
  85242. /** Trilinear is mag = linear and min = linear and mip = linear */
  85243. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  85244. /** mag = nearest and min = nearest and mip = nearest */
  85245. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  85246. /** mag = nearest and min = linear and mip = nearest */
  85247. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  85248. /** mag = nearest and min = linear and mip = linear */
  85249. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  85250. /** mag = nearest and min = linear and mip = none */
  85251. static readonly NEAREST_LINEAR: number;
  85252. /** mag = nearest and min = nearest and mip = none */
  85253. static readonly NEAREST_NEAREST: number;
  85254. /** mag = linear and min = nearest and mip = nearest */
  85255. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  85256. /** mag = linear and min = nearest and mip = linear */
  85257. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  85258. /** mag = linear and min = linear and mip = none */
  85259. static readonly LINEAR_LINEAR: number;
  85260. /** mag = linear and min = nearest and mip = none */
  85261. static readonly LINEAR_NEAREST: number;
  85262. /** Explicit coordinates mode */
  85263. static readonly EXPLICIT_MODE: number;
  85264. /** Spherical coordinates mode */
  85265. static readonly SPHERICAL_MODE: number;
  85266. /** Planar coordinates mode */
  85267. static readonly PLANAR_MODE: number;
  85268. /** Cubic coordinates mode */
  85269. static readonly CUBIC_MODE: number;
  85270. /** Projection coordinates mode */
  85271. static readonly PROJECTION_MODE: number;
  85272. /** Inverse Cubic coordinates mode */
  85273. static readonly SKYBOX_MODE: number;
  85274. /** Inverse Cubic coordinates mode */
  85275. static readonly INVCUBIC_MODE: number;
  85276. /** Equirectangular coordinates mode */
  85277. static readonly EQUIRECTANGULAR_MODE: number;
  85278. /** Equirectangular Fixed coordinates mode */
  85279. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  85280. /** Equirectangular Fixed Mirrored coordinates mode */
  85281. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85282. /** Texture is not repeating outside of 0..1 UVs */
  85283. static readonly CLAMP_ADDRESSMODE: number;
  85284. /** Texture is repeating outside of 0..1 UVs */
  85285. static readonly WRAP_ADDRESSMODE: number;
  85286. /** Texture is repeating and mirrored */
  85287. static readonly MIRROR_ADDRESSMODE: number;
  85288. /**
  85289. * 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
  85290. */
  85291. static UseSerializedUrlIfAny: boolean;
  85292. /**
  85293. * Define the url of the texture.
  85294. */
  85295. url: Nullable<string>;
  85296. /**
  85297. * Define an offset on the texture to offset the u coordinates of the UVs
  85298. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85299. */
  85300. uOffset: number;
  85301. /**
  85302. * Define an offset on the texture to offset the v coordinates of the UVs
  85303. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  85304. */
  85305. vOffset: number;
  85306. /**
  85307. * Define an offset on the texture to scale the u coordinates of the UVs
  85308. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85309. */
  85310. uScale: number;
  85311. /**
  85312. * Define an offset on the texture to scale the v coordinates of the UVs
  85313. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  85314. */
  85315. vScale: number;
  85316. /**
  85317. * Define an offset on the texture to rotate around the u coordinates of the UVs
  85318. * @see http://doc.babylonjs.com/how_to/more_materials
  85319. */
  85320. uAng: number;
  85321. /**
  85322. * Define an offset on the texture to rotate around the v coordinates of the UVs
  85323. * @see http://doc.babylonjs.com/how_to/more_materials
  85324. */
  85325. vAng: number;
  85326. /**
  85327. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  85328. * @see http://doc.babylonjs.com/how_to/more_materials
  85329. */
  85330. wAng: number;
  85331. /**
  85332. * Defines the center of rotation (U)
  85333. */
  85334. uRotationCenter: number;
  85335. /**
  85336. * Defines the center of rotation (V)
  85337. */
  85338. vRotationCenter: number;
  85339. /**
  85340. * Defines the center of rotation (W)
  85341. */
  85342. wRotationCenter: number;
  85343. /**
  85344. * Are mip maps generated for this texture or not.
  85345. */
  85346. readonly noMipmap: boolean;
  85347. /**
  85348. * List of inspectable custom properties (used by the Inspector)
  85349. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85350. */
  85351. inspectableCustomProperties: Nullable<IInspectable[]>;
  85352. private _noMipmap;
  85353. /** @hidden */
  85354. _invertY: boolean;
  85355. private _rowGenerationMatrix;
  85356. private _cachedTextureMatrix;
  85357. private _projectionModeMatrix;
  85358. private _t0;
  85359. private _t1;
  85360. private _t2;
  85361. private _cachedUOffset;
  85362. private _cachedVOffset;
  85363. private _cachedUScale;
  85364. private _cachedVScale;
  85365. private _cachedUAng;
  85366. private _cachedVAng;
  85367. private _cachedWAng;
  85368. private _cachedProjectionMatrixId;
  85369. private _cachedCoordinatesMode;
  85370. /** @hidden */
  85371. protected _initialSamplingMode: number;
  85372. /** @hidden */
  85373. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  85374. private _deleteBuffer;
  85375. protected _format: Nullable<number>;
  85376. private _delayedOnLoad;
  85377. private _delayedOnError;
  85378. private _mimeType?;
  85379. /**
  85380. * Observable triggered once the texture has been loaded.
  85381. */
  85382. onLoadObservable: Observable<Texture>;
  85383. protected _isBlocking: boolean;
  85384. /**
  85385. * Is the texture preventing material to render while loading.
  85386. * If false, a default texture will be used instead of the loading one during the preparation step.
  85387. */
  85388. isBlocking: boolean;
  85389. /**
  85390. * Get the current sampling mode associated with the texture.
  85391. */
  85392. readonly samplingMode: number;
  85393. /**
  85394. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  85395. */
  85396. readonly invertY: boolean;
  85397. /**
  85398. * Instantiates a new texture.
  85399. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  85400. * @see http://doc.babylonjs.com/babylon101/materials#texture
  85401. * @param url defines the url of the picture to load as a texture
  85402. * @param scene defines the scene or engine the texture will belong to
  85403. * @param noMipmap defines if the texture will require mip maps or not
  85404. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  85405. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85406. * @param onLoad defines a callback triggered when the texture has been loaded
  85407. * @param onError defines a callback triggered when an error occurred during the loading session
  85408. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  85409. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  85410. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85411. * @param mimeType defines an optional mime type information
  85412. */
  85413. 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);
  85414. /**
  85415. * Update the url (and optional buffer) of this texture if url was null during construction.
  85416. * @param url the url of the texture
  85417. * @param buffer the buffer of the texture (defaults to null)
  85418. * @param onLoad callback called when the texture is loaded (defaults to null)
  85419. */
  85420. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  85421. /**
  85422. * Finish the loading sequence of a texture flagged as delayed load.
  85423. * @hidden
  85424. */
  85425. delayLoad(): void;
  85426. private _prepareRowForTextureGeneration;
  85427. /**
  85428. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  85429. * @returns the transform matrix of the texture.
  85430. */
  85431. getTextureMatrix(uBase?: number): Matrix;
  85432. /**
  85433. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  85434. * @returns The reflection texture transform
  85435. */
  85436. getReflectionTextureMatrix(): Matrix;
  85437. /**
  85438. * Clones the texture.
  85439. * @returns the cloned texture
  85440. */
  85441. clone(): Texture;
  85442. /**
  85443. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85444. * @returns The JSON representation of the texture
  85445. */
  85446. serialize(): any;
  85447. /**
  85448. * Get the current class name of the texture useful for serialization or dynamic coding.
  85449. * @returns "Texture"
  85450. */
  85451. getClassName(): string;
  85452. /**
  85453. * Dispose the texture and release its associated resources.
  85454. */
  85455. dispose(): void;
  85456. /**
  85457. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  85458. * @param parsedTexture Define the JSON representation of the texture
  85459. * @param scene Define the scene the parsed texture should be instantiated in
  85460. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  85461. * @returns The parsed texture if successful
  85462. */
  85463. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  85464. /**
  85465. * Creates a texture from its base 64 representation.
  85466. * @param data Define the base64 payload without the data: prefix
  85467. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85468. * @param scene Define the scene the texture should belong to
  85469. * @param noMipmap Forces the texture to not create mip map information if true
  85470. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85471. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85472. * @param onLoad define a callback triggered when the texture has been loaded
  85473. * @param onError define a callback triggered when an error occurred during the loading session
  85474. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85475. * @returns the created texture
  85476. */
  85477. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  85478. /**
  85479. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  85480. * @param data Define the base64 payload without the data: prefix
  85481. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  85482. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  85483. * @param scene Define the scene the texture should belong to
  85484. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  85485. * @param noMipmap Forces the texture to not create mip map information if true
  85486. * @param invertY define if the texture needs to be inverted on the y axis during loading
  85487. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  85488. * @param onLoad define a callback triggered when the texture has been loaded
  85489. * @param onError define a callback triggered when an error occurred during the loading session
  85490. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  85491. * @returns the created texture
  85492. */
  85493. 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;
  85494. }
  85495. }
  85496. declare module BABYLON {
  85497. /**
  85498. * PostProcessManager is used to manage one or more post processes or post process pipelines
  85499. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  85500. */
  85501. export class PostProcessManager {
  85502. private _scene;
  85503. private _indexBuffer;
  85504. private _vertexBuffers;
  85505. /**
  85506. * Creates a new instance PostProcess
  85507. * @param scene The scene that the post process is associated with.
  85508. */
  85509. constructor(scene: Scene);
  85510. private _prepareBuffers;
  85511. private _buildIndexBuffer;
  85512. /**
  85513. * Rebuilds the vertex buffers of the manager.
  85514. * @hidden
  85515. */
  85516. _rebuild(): void;
  85517. /**
  85518. * Prepares a frame to be run through a post process.
  85519. * @param sourceTexture The input texture to the post procesess. (default: null)
  85520. * @param postProcesses An array of post processes to be run. (default: null)
  85521. * @returns True if the post processes were able to be run.
  85522. * @hidden
  85523. */
  85524. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  85525. /**
  85526. * Manually render a set of post processes to a texture.
  85527. * @param postProcesses An array of post processes to be run.
  85528. * @param targetTexture The target texture to render to.
  85529. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  85530. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  85531. * @param lodLevel defines which lod of the texture to render to
  85532. */
  85533. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  85534. /**
  85535. * Finalize the result of the output of the postprocesses.
  85536. * @param doNotPresent If true the result will not be displayed to the screen.
  85537. * @param targetTexture The target texture to render to.
  85538. * @param faceIndex The index of the face to bind the target texture to.
  85539. * @param postProcesses The array of post processes to render.
  85540. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  85541. * @hidden
  85542. */
  85543. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  85544. /**
  85545. * Disposes of the post process manager.
  85546. */
  85547. dispose(): void;
  85548. }
  85549. }
  85550. declare module BABYLON {
  85551. /** Interface used by value gradients (color, factor, ...) */
  85552. export interface IValueGradient {
  85553. /**
  85554. * Gets or sets the gradient value (between 0 and 1)
  85555. */
  85556. gradient: number;
  85557. }
  85558. /** Class used to store color4 gradient */
  85559. export class ColorGradient implements IValueGradient {
  85560. /**
  85561. * Gets or sets the gradient value (between 0 and 1)
  85562. */
  85563. gradient: number;
  85564. /**
  85565. * Gets or sets first associated color
  85566. */
  85567. color1: Color4;
  85568. /**
  85569. * Gets or sets second associated color
  85570. */
  85571. color2?: Color4;
  85572. /**
  85573. * Will get a color picked randomly between color1 and color2.
  85574. * If color2 is undefined then color1 will be used
  85575. * @param result defines the target Color4 to store the result in
  85576. */
  85577. getColorToRef(result: Color4): void;
  85578. }
  85579. /** Class used to store color 3 gradient */
  85580. export class Color3Gradient implements IValueGradient {
  85581. /**
  85582. * Gets or sets the gradient value (between 0 and 1)
  85583. */
  85584. gradient: number;
  85585. /**
  85586. * Gets or sets the associated color
  85587. */
  85588. color: Color3;
  85589. }
  85590. /** Class used to store factor gradient */
  85591. export class FactorGradient implements IValueGradient {
  85592. /**
  85593. * Gets or sets the gradient value (between 0 and 1)
  85594. */
  85595. gradient: number;
  85596. /**
  85597. * Gets or sets first associated factor
  85598. */
  85599. factor1: number;
  85600. /**
  85601. * Gets or sets second associated factor
  85602. */
  85603. factor2?: number;
  85604. /**
  85605. * Will get a number picked randomly between factor1 and factor2.
  85606. * If factor2 is undefined then factor1 will be used
  85607. * @returns the picked number
  85608. */
  85609. getFactor(): number;
  85610. }
  85611. /**
  85612. * Helper used to simplify some generic gradient tasks
  85613. */
  85614. export class GradientHelper {
  85615. /**
  85616. * Gets the current gradient from an array of IValueGradient
  85617. * @param ratio defines the current ratio to get
  85618. * @param gradients defines the array of IValueGradient
  85619. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  85620. */
  85621. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  85622. }
  85623. }
  85624. declare module BABYLON {
  85625. interface ThinEngine {
  85626. /**
  85627. * Creates a dynamic texture
  85628. * @param width defines the width of the texture
  85629. * @param height defines the height of the texture
  85630. * @param generateMipMaps defines if the engine should generate the mip levels
  85631. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  85632. * @returns the dynamic texture inside an InternalTexture
  85633. */
  85634. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  85635. /**
  85636. * Update the content of a dynamic texture
  85637. * @param texture defines the texture to update
  85638. * @param canvas defines the canvas containing the source
  85639. * @param invertY defines if data must be stored with Y axis inverted
  85640. * @param premulAlpha defines if alpha is stored as premultiplied
  85641. * @param format defines the format of the data
  85642. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  85643. */
  85644. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  85645. }
  85646. }
  85647. declare module BABYLON {
  85648. /**
  85649. * Helper class used to generate a canvas to manipulate images
  85650. */
  85651. export class CanvasGenerator {
  85652. /**
  85653. * Create a new canvas (or offscreen canvas depending on the context)
  85654. * @param width defines the expected width
  85655. * @param height defines the expected height
  85656. * @return a new canvas or offscreen canvas
  85657. */
  85658. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  85659. }
  85660. }
  85661. declare module BABYLON {
  85662. /**
  85663. * A class extending Texture allowing drawing on a texture
  85664. * @see http://doc.babylonjs.com/how_to/dynamictexture
  85665. */
  85666. export class DynamicTexture extends Texture {
  85667. private _generateMipMaps;
  85668. private _canvas;
  85669. private _context;
  85670. private _engine;
  85671. /**
  85672. * Creates a DynamicTexture
  85673. * @param name defines the name of the texture
  85674. * @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
  85675. * @param scene defines the scene where you want the texture
  85676. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  85677. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  85678. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  85679. */
  85680. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  85681. /**
  85682. * Get the current class name of the texture useful for serialization or dynamic coding.
  85683. * @returns "DynamicTexture"
  85684. */
  85685. getClassName(): string;
  85686. /**
  85687. * Gets the current state of canRescale
  85688. */
  85689. readonly canRescale: boolean;
  85690. private _recreate;
  85691. /**
  85692. * Scales the texture
  85693. * @param ratio the scale factor to apply to both width and height
  85694. */
  85695. scale(ratio: number): void;
  85696. /**
  85697. * Resizes the texture
  85698. * @param width the new width
  85699. * @param height the new height
  85700. */
  85701. scaleTo(width: number, height: number): void;
  85702. /**
  85703. * Gets the context of the canvas used by the texture
  85704. * @returns the canvas context of the dynamic texture
  85705. */
  85706. getContext(): CanvasRenderingContext2D;
  85707. /**
  85708. * Clears the texture
  85709. */
  85710. clear(): void;
  85711. /**
  85712. * Updates the texture
  85713. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85714. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  85715. */
  85716. update(invertY?: boolean, premulAlpha?: boolean): void;
  85717. /**
  85718. * Draws text onto the texture
  85719. * @param text defines the text to be drawn
  85720. * @param x defines the placement of the text from the left
  85721. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  85722. * @param font defines the font to be used with font-style, font-size, font-name
  85723. * @param color defines the color used for the text
  85724. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  85725. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  85726. * @param update defines whether texture is immediately update (default is true)
  85727. */
  85728. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  85729. /**
  85730. * Clones the texture
  85731. * @returns the clone of the texture.
  85732. */
  85733. clone(): DynamicTexture;
  85734. /**
  85735. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  85736. * @returns a serialized dynamic texture object
  85737. */
  85738. serialize(): any;
  85739. /** @hidden */
  85740. _rebuild(): void;
  85741. }
  85742. }
  85743. declare module BABYLON {
  85744. interface AbstractScene {
  85745. /**
  85746. * The list of procedural textures added to the scene
  85747. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85748. */
  85749. proceduralTextures: Array<ProceduralTexture>;
  85750. }
  85751. /**
  85752. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85753. * in a given scene.
  85754. */
  85755. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85756. /**
  85757. * The component name helpfull to identify the component in the list of scene components.
  85758. */
  85759. readonly name: string;
  85760. /**
  85761. * The scene the component belongs to.
  85762. */
  85763. scene: Scene;
  85764. /**
  85765. * Creates a new instance of the component for the given scene
  85766. * @param scene Defines the scene to register the component in
  85767. */
  85768. constructor(scene: Scene);
  85769. /**
  85770. * Registers the component in a given scene
  85771. */
  85772. register(): void;
  85773. /**
  85774. * Rebuilds the elements related to this component in case of
  85775. * context lost for instance.
  85776. */
  85777. rebuild(): void;
  85778. /**
  85779. * Disposes the component and the associated ressources.
  85780. */
  85781. dispose(): void;
  85782. private _beforeClear;
  85783. }
  85784. }
  85785. declare module BABYLON {
  85786. interface ThinEngine {
  85787. /**
  85788. * Creates a new render target cube texture
  85789. * @param size defines the size of the texture
  85790. * @param options defines the options used to create the texture
  85791. * @returns a new render target cube texture stored in an InternalTexture
  85792. */
  85793. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. /** @hidden */
  85798. export var proceduralVertexShader: {
  85799. name: string;
  85800. shader: string;
  85801. };
  85802. }
  85803. declare module BABYLON {
  85804. /**
  85805. * 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.
  85806. * This is the base class of any Procedural texture and contains most of the shareable code.
  85807. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85808. */
  85809. export class ProceduralTexture extends Texture {
  85810. isCube: boolean;
  85811. /**
  85812. * Define if the texture is enabled or not (disabled texture will not render)
  85813. */
  85814. isEnabled: boolean;
  85815. /**
  85816. * Define if the texture must be cleared before rendering (default is true)
  85817. */
  85818. autoClear: boolean;
  85819. /**
  85820. * Callback called when the texture is generated
  85821. */
  85822. onGenerated: () => void;
  85823. /**
  85824. * Event raised when the texture is generated
  85825. */
  85826. onGeneratedObservable: Observable<ProceduralTexture>;
  85827. /** @hidden */
  85828. _generateMipMaps: boolean;
  85829. /** @hidden **/
  85830. _effect: Effect;
  85831. /** @hidden */
  85832. _textures: {
  85833. [key: string]: Texture;
  85834. };
  85835. private _size;
  85836. private _currentRefreshId;
  85837. private _refreshRate;
  85838. private _vertexBuffers;
  85839. private _indexBuffer;
  85840. private _uniforms;
  85841. private _samplers;
  85842. private _fragment;
  85843. private _floats;
  85844. private _ints;
  85845. private _floatsArrays;
  85846. private _colors3;
  85847. private _colors4;
  85848. private _vectors2;
  85849. private _vectors3;
  85850. private _matrices;
  85851. private _fallbackTexture;
  85852. private _fallbackTextureUsed;
  85853. private _engine;
  85854. private _cachedDefines;
  85855. private _contentUpdateId;
  85856. private _contentData;
  85857. /**
  85858. * Instantiates a new procedural texture.
  85859. * 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.
  85860. * This is the base class of any Procedural texture and contains most of the shareable code.
  85861. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85862. * @param name Define the name of the texture
  85863. * @param size Define the size of the texture to create
  85864. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85865. * @param scene Define the scene the texture belongs to
  85866. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85867. * @param generateMipMaps Define if the texture should creates mip maps or not
  85868. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85869. */
  85870. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85871. /**
  85872. * The effect that is created when initializing the post process.
  85873. * @returns The created effect corresponding the the postprocess.
  85874. */
  85875. getEffect(): Effect;
  85876. /**
  85877. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85878. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85879. */
  85880. getContent(): Nullable<ArrayBufferView>;
  85881. private _createIndexBuffer;
  85882. /** @hidden */
  85883. _rebuild(): void;
  85884. /**
  85885. * Resets the texture in order to recreate its associated resources.
  85886. * This can be called in case of context loss
  85887. */
  85888. reset(): void;
  85889. protected _getDefines(): string;
  85890. /**
  85891. * Is the texture ready to be used ? (rendered at least once)
  85892. * @returns true if ready, otherwise, false.
  85893. */
  85894. isReady(): boolean;
  85895. /**
  85896. * Resets the refresh counter of the texture and start bak from scratch.
  85897. * Could be useful to regenerate the texture if it is setup to render only once.
  85898. */
  85899. resetRefreshCounter(): void;
  85900. /**
  85901. * Set the fragment shader to use in order to render the texture.
  85902. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85903. */
  85904. setFragment(fragment: any): void;
  85905. /**
  85906. * Define the refresh rate of the texture or the rendering frequency.
  85907. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85908. */
  85909. refreshRate: number;
  85910. /** @hidden */
  85911. _shouldRender(): boolean;
  85912. /**
  85913. * Get the size the texture is rendering at.
  85914. * @returns the size (texture is always squared)
  85915. */
  85916. getRenderSize(): number;
  85917. /**
  85918. * Resize the texture to new value.
  85919. * @param size Define the new size the texture should have
  85920. * @param generateMipMaps Define whether the new texture should create mip maps
  85921. */
  85922. resize(size: number, generateMipMaps: boolean): void;
  85923. private _checkUniform;
  85924. /**
  85925. * Set a texture in the shader program used to render.
  85926. * @param name Define the name of the uniform samplers as defined in the shader
  85927. * @param texture Define the texture to bind to this sampler
  85928. * @return the texture itself allowing "fluent" like uniform updates
  85929. */
  85930. setTexture(name: string, texture: Texture): ProceduralTexture;
  85931. /**
  85932. * Set a float in the shader.
  85933. * @param name Define the name of the uniform as defined in the shader
  85934. * @param value Define the value to give to the uniform
  85935. * @return the texture itself allowing "fluent" like uniform updates
  85936. */
  85937. setFloat(name: string, value: number): ProceduralTexture;
  85938. /**
  85939. * Set a int in the shader.
  85940. * @param name Define the name of the uniform as defined in the shader
  85941. * @param value Define the value to give to the uniform
  85942. * @return the texture itself allowing "fluent" like uniform updates
  85943. */
  85944. setInt(name: string, value: number): ProceduralTexture;
  85945. /**
  85946. * Set an array of floats in the shader.
  85947. * @param name Define the name of the uniform as defined in the shader
  85948. * @param value Define the value to give to the uniform
  85949. * @return the texture itself allowing "fluent" like uniform updates
  85950. */
  85951. setFloats(name: string, value: number[]): ProceduralTexture;
  85952. /**
  85953. * Set a vec3 in the shader from a Color3.
  85954. * @param name Define the name of the uniform as defined in the shader
  85955. * @param value Define the value to give to the uniform
  85956. * @return the texture itself allowing "fluent" like uniform updates
  85957. */
  85958. setColor3(name: string, value: Color3): ProceduralTexture;
  85959. /**
  85960. * Set a vec4 in the shader from a Color4.
  85961. * @param name Define the name of the uniform as defined in the shader
  85962. * @param value Define the value to give to the uniform
  85963. * @return the texture itself allowing "fluent" like uniform updates
  85964. */
  85965. setColor4(name: string, value: Color4): ProceduralTexture;
  85966. /**
  85967. * Set a vec2 in the shader from a Vector2.
  85968. * @param name Define the name of the uniform as defined in the shader
  85969. * @param value Define the value to give to the uniform
  85970. * @return the texture itself allowing "fluent" like uniform updates
  85971. */
  85972. setVector2(name: string, value: Vector2): ProceduralTexture;
  85973. /**
  85974. * Set a vec3 in the shader from a Vector3.
  85975. * @param name Define the name of the uniform as defined in the shader
  85976. * @param value Define the value to give to the uniform
  85977. * @return the texture itself allowing "fluent" like uniform updates
  85978. */
  85979. setVector3(name: string, value: Vector3): ProceduralTexture;
  85980. /**
  85981. * Set a mat4 in the shader from a MAtrix.
  85982. * @param name Define the name of the uniform as defined in the shader
  85983. * @param value Define the value to give to the uniform
  85984. * @return the texture itself allowing "fluent" like uniform updates
  85985. */
  85986. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85987. /**
  85988. * Render the texture to its associated render target.
  85989. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85990. */
  85991. render(useCameraPostProcess?: boolean): void;
  85992. /**
  85993. * Clone the texture.
  85994. * @returns the cloned texture
  85995. */
  85996. clone(): ProceduralTexture;
  85997. /**
  85998. * Dispose the texture and release its asoociated resources.
  85999. */
  86000. dispose(): void;
  86001. }
  86002. }
  86003. declare module BABYLON {
  86004. /**
  86005. * This represents the base class for particle system in Babylon.
  86006. * 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.
  86007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86008. * @example https://doc.babylonjs.com/babylon101/particles
  86009. */
  86010. export class BaseParticleSystem {
  86011. /**
  86012. * Source color is added to the destination color without alpha affecting the result
  86013. */
  86014. static BLENDMODE_ONEONE: number;
  86015. /**
  86016. * Blend current color and particle color using particle’s alpha
  86017. */
  86018. static BLENDMODE_STANDARD: number;
  86019. /**
  86020. * Add current color and particle color multiplied by particle’s alpha
  86021. */
  86022. static BLENDMODE_ADD: number;
  86023. /**
  86024. * Multiply current color with particle color
  86025. */
  86026. static BLENDMODE_MULTIPLY: number;
  86027. /**
  86028. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  86029. */
  86030. static BLENDMODE_MULTIPLYADD: number;
  86031. /**
  86032. * List of animations used by the particle system.
  86033. */
  86034. animations: Animation[];
  86035. /**
  86036. * The id of the Particle system.
  86037. */
  86038. id: string;
  86039. /**
  86040. * The friendly name of the Particle system.
  86041. */
  86042. name: string;
  86043. /**
  86044. * The rendering group used by the Particle system to chose when to render.
  86045. */
  86046. renderingGroupId: number;
  86047. /**
  86048. * The emitter represents the Mesh or position we are attaching the particle system to.
  86049. */
  86050. emitter: Nullable<AbstractMesh | Vector3>;
  86051. /**
  86052. * The maximum number of particles to emit per frame
  86053. */
  86054. emitRate: number;
  86055. /**
  86056. * If you want to launch only a few particles at once, that can be done, as well.
  86057. */
  86058. manualEmitCount: number;
  86059. /**
  86060. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86061. */
  86062. updateSpeed: number;
  86063. /**
  86064. * The amount of time the particle system is running (depends of the overall update speed).
  86065. */
  86066. targetStopDuration: number;
  86067. /**
  86068. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86069. */
  86070. disposeOnStop: boolean;
  86071. /**
  86072. * Minimum power of emitting particles.
  86073. */
  86074. minEmitPower: number;
  86075. /**
  86076. * Maximum power of emitting particles.
  86077. */
  86078. maxEmitPower: number;
  86079. /**
  86080. * Minimum life time of emitting particles.
  86081. */
  86082. minLifeTime: number;
  86083. /**
  86084. * Maximum life time of emitting particles.
  86085. */
  86086. maxLifeTime: number;
  86087. /**
  86088. * Minimum Size of emitting particles.
  86089. */
  86090. minSize: number;
  86091. /**
  86092. * Maximum Size of emitting particles.
  86093. */
  86094. maxSize: number;
  86095. /**
  86096. * Minimum scale of emitting particles on X axis.
  86097. */
  86098. minScaleX: number;
  86099. /**
  86100. * Maximum scale of emitting particles on X axis.
  86101. */
  86102. maxScaleX: number;
  86103. /**
  86104. * Minimum scale of emitting particles on Y axis.
  86105. */
  86106. minScaleY: number;
  86107. /**
  86108. * Maximum scale of emitting particles on Y axis.
  86109. */
  86110. maxScaleY: number;
  86111. /**
  86112. * Gets or sets the minimal initial rotation in radians.
  86113. */
  86114. minInitialRotation: number;
  86115. /**
  86116. * Gets or sets the maximal initial rotation in radians.
  86117. */
  86118. maxInitialRotation: number;
  86119. /**
  86120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86121. */
  86122. minAngularSpeed: number;
  86123. /**
  86124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86125. */
  86126. maxAngularSpeed: number;
  86127. /**
  86128. * The texture used to render each particle. (this can be a spritesheet)
  86129. */
  86130. particleTexture: Nullable<Texture>;
  86131. /**
  86132. * The layer mask we are rendering the particles through.
  86133. */
  86134. layerMask: number;
  86135. /**
  86136. * This can help using your own shader to render the particle system.
  86137. * The according effect will be created
  86138. */
  86139. customShader: any;
  86140. /**
  86141. * By default particle system starts as soon as they are created. This prevents the
  86142. * automatic start to happen and let you decide when to start emitting particles.
  86143. */
  86144. preventAutoStart: boolean;
  86145. private _noiseTexture;
  86146. /**
  86147. * Gets or sets a texture used to add random noise to particle positions
  86148. */
  86149. noiseTexture: Nullable<ProceduralTexture>;
  86150. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86151. noiseStrength: Vector3;
  86152. /**
  86153. * Callback triggered when the particle animation is ending.
  86154. */
  86155. onAnimationEnd: Nullable<() => void>;
  86156. /**
  86157. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  86158. */
  86159. blendMode: number;
  86160. /**
  86161. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  86162. * to override the particles.
  86163. */
  86164. forceDepthWrite: boolean;
  86165. /** 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 */
  86166. preWarmCycles: number;
  86167. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  86168. preWarmStepOffset: number;
  86169. /**
  86170. * 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)
  86171. */
  86172. spriteCellChangeSpeed: number;
  86173. /**
  86174. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86175. */
  86176. startSpriteCellID: number;
  86177. /**
  86178. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86179. */
  86180. endSpriteCellID: number;
  86181. /**
  86182. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86183. */
  86184. spriteCellWidth: number;
  86185. /**
  86186. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86187. */
  86188. spriteCellHeight: number;
  86189. /**
  86190. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86191. */
  86192. spriteRandomStartCell: boolean;
  86193. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86194. translationPivot: Vector2;
  86195. /** @hidden */
  86196. protected _isAnimationSheetEnabled: boolean;
  86197. /**
  86198. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86199. */
  86200. beginAnimationOnStart: boolean;
  86201. /**
  86202. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86203. */
  86204. beginAnimationFrom: number;
  86205. /**
  86206. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86207. */
  86208. beginAnimationTo: number;
  86209. /**
  86210. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86211. */
  86212. beginAnimationLoop: boolean;
  86213. /**
  86214. * Gets or sets a world offset applied to all particles
  86215. */
  86216. worldOffset: Vector3;
  86217. /**
  86218. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  86219. */
  86220. isAnimationSheetEnabled: boolean;
  86221. /**
  86222. * Get hosting scene
  86223. * @returns the scene
  86224. */
  86225. getScene(): Scene;
  86226. /**
  86227. * You can use gravity if you want to give an orientation to your particles.
  86228. */
  86229. gravity: Vector3;
  86230. protected _colorGradients: Nullable<Array<ColorGradient>>;
  86231. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  86232. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  86233. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  86234. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  86235. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  86236. protected _dragGradients: Nullable<Array<FactorGradient>>;
  86237. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  86238. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  86239. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  86240. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  86241. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  86242. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  86243. /**
  86244. * Defines the delay in milliseconds before starting the system (0 by default)
  86245. */
  86246. startDelay: number;
  86247. /**
  86248. * Gets the current list of drag gradients.
  86249. * You must use addDragGradient and removeDragGradient to udpate this list
  86250. * @returns the list of drag gradients
  86251. */
  86252. getDragGradients(): Nullable<Array<FactorGradient>>;
  86253. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86254. limitVelocityDamping: number;
  86255. /**
  86256. * Gets the current list of limit velocity gradients.
  86257. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86258. * @returns the list of limit velocity gradients
  86259. */
  86260. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86261. /**
  86262. * Gets the current list of color gradients.
  86263. * You must use addColorGradient and removeColorGradient to udpate this list
  86264. * @returns the list of color gradients
  86265. */
  86266. getColorGradients(): Nullable<Array<ColorGradient>>;
  86267. /**
  86268. * Gets the current list of size gradients.
  86269. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86270. * @returns the list of size gradients
  86271. */
  86272. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86273. /**
  86274. * Gets the current list of color remap gradients.
  86275. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86276. * @returns the list of color remap gradients
  86277. */
  86278. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86279. /**
  86280. * Gets the current list of alpha remap gradients.
  86281. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86282. * @returns the list of alpha remap gradients
  86283. */
  86284. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86285. /**
  86286. * Gets the current list of life time gradients.
  86287. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86288. * @returns the list of life time gradients
  86289. */
  86290. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86291. /**
  86292. * Gets the current list of angular speed gradients.
  86293. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86294. * @returns the list of angular speed gradients
  86295. */
  86296. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86297. /**
  86298. * Gets the current list of velocity gradients.
  86299. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86300. * @returns the list of velocity gradients
  86301. */
  86302. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86303. /**
  86304. * Gets the current list of start size gradients.
  86305. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86306. * @returns the list of start size gradients
  86307. */
  86308. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86309. /**
  86310. * Gets the current list of emit rate gradients.
  86311. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86312. * @returns the list of emit rate gradients
  86313. */
  86314. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86315. /**
  86316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86317. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86318. */
  86319. direction1: Vector3;
  86320. /**
  86321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86322. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86323. */
  86324. direction2: Vector3;
  86325. /**
  86326. * 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.
  86327. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86328. */
  86329. minEmitBox: Vector3;
  86330. /**
  86331. * 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.
  86332. * This only works when particleEmitterTyps is a BoxParticleEmitter
  86333. */
  86334. maxEmitBox: Vector3;
  86335. /**
  86336. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86337. */
  86338. color1: Color4;
  86339. /**
  86340. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  86341. */
  86342. color2: Color4;
  86343. /**
  86344. * Color the particle will have at the end of its lifetime
  86345. */
  86346. colorDead: Color4;
  86347. /**
  86348. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  86349. */
  86350. textureMask: Color4;
  86351. /**
  86352. * The particle emitter type defines the emitter used by the particle system.
  86353. * It can be for example box, sphere, or cone...
  86354. */
  86355. particleEmitterType: IParticleEmitterType;
  86356. /** @hidden */
  86357. _isSubEmitter: boolean;
  86358. /**
  86359. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86360. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86361. */
  86362. billboardMode: number;
  86363. protected _isBillboardBased: boolean;
  86364. /**
  86365. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86366. */
  86367. isBillboardBased: boolean;
  86368. /**
  86369. * The scene the particle system belongs to.
  86370. */
  86371. protected _scene: Scene;
  86372. /**
  86373. * Local cache of defines for image processing.
  86374. */
  86375. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  86376. /**
  86377. * Default configuration related to image processing available in the standard Material.
  86378. */
  86379. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  86380. /**
  86381. * Gets the image processing configuration used either in this material.
  86382. */
  86383. /**
  86384. * Sets the Default image processing configuration used either in the this material.
  86385. *
  86386. * If sets to null, the scene one is in use.
  86387. */
  86388. imageProcessingConfiguration: ImageProcessingConfiguration;
  86389. /**
  86390. * Attaches a new image processing configuration to the Standard Material.
  86391. * @param configuration
  86392. */
  86393. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  86394. /** @hidden */
  86395. protected _reset(): void;
  86396. /** @hidden */
  86397. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  86398. /**
  86399. * Instantiates a particle system.
  86400. * 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.
  86401. * @param name The name of the particle system
  86402. */
  86403. constructor(name: string);
  86404. /**
  86405. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86406. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86407. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86408. * @returns the emitter
  86409. */
  86410. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86411. /**
  86412. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86413. * @param radius The radius of the hemisphere to emit from
  86414. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86415. * @returns the emitter
  86416. */
  86417. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  86418. /**
  86419. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86420. * @param radius The radius of the sphere to emit from
  86421. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86422. * @returns the emitter
  86423. */
  86424. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  86425. /**
  86426. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86427. * @param radius The radius of the sphere to emit from
  86428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86430. * @returns the emitter
  86431. */
  86432. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  86433. /**
  86434. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86435. * @param radius The radius of the emission cylinder
  86436. * @param height The height of the emission cylinder
  86437. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86438. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86439. * @returns the emitter
  86440. */
  86441. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  86442. /**
  86443. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86444. * @param radius The radius of the cylinder to emit from
  86445. * @param height The height of the emission cylinder
  86446. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86449. * @returns the emitter
  86450. */
  86451. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  86452. /**
  86453. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86454. * @param radius The radius of the cone to emit from
  86455. * @param angle The base angle of the cone
  86456. * @returns the emitter
  86457. */
  86458. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  86459. /**
  86460. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86461. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86462. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86463. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86464. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86465. * @returns the emitter
  86466. */
  86467. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86468. }
  86469. }
  86470. declare module BABYLON {
  86471. /**
  86472. * Type of sub emitter
  86473. */
  86474. export enum SubEmitterType {
  86475. /**
  86476. * Attached to the particle over it's lifetime
  86477. */
  86478. ATTACHED = 0,
  86479. /**
  86480. * Created when the particle dies
  86481. */
  86482. END = 1
  86483. }
  86484. /**
  86485. * Sub emitter class used to emit particles from an existing particle
  86486. */
  86487. export class SubEmitter {
  86488. /**
  86489. * the particle system to be used by the sub emitter
  86490. */
  86491. particleSystem: ParticleSystem;
  86492. /**
  86493. * Type of the submitter (Default: END)
  86494. */
  86495. type: SubEmitterType;
  86496. /**
  86497. * 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)
  86498. * Note: This only is supported when using an emitter of type Mesh
  86499. */
  86500. inheritDirection: boolean;
  86501. /**
  86502. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  86503. */
  86504. inheritedVelocityAmount: number;
  86505. /**
  86506. * Creates a sub emitter
  86507. * @param particleSystem the particle system to be used by the sub emitter
  86508. */
  86509. constructor(
  86510. /**
  86511. * the particle system to be used by the sub emitter
  86512. */
  86513. particleSystem: ParticleSystem);
  86514. /**
  86515. * Clones the sub emitter
  86516. * @returns the cloned sub emitter
  86517. */
  86518. clone(): SubEmitter;
  86519. /**
  86520. * Serialize current object to a JSON object
  86521. * @returns the serialized object
  86522. */
  86523. serialize(): any;
  86524. /** @hidden */
  86525. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  86526. /**
  86527. * Creates a new SubEmitter from a serialized JSON version
  86528. * @param serializationObject defines the JSON object to read from
  86529. * @param scene defines the hosting scene
  86530. * @param rootUrl defines the rootUrl for data loading
  86531. * @returns a new SubEmitter
  86532. */
  86533. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  86534. /** Release associated resources */
  86535. dispose(): void;
  86536. }
  86537. }
  86538. declare module BABYLON {
  86539. /** @hidden */
  86540. export var clipPlaneFragmentDeclaration: {
  86541. name: string;
  86542. shader: string;
  86543. };
  86544. }
  86545. declare module BABYLON {
  86546. /** @hidden */
  86547. export var imageProcessingDeclaration: {
  86548. name: string;
  86549. shader: string;
  86550. };
  86551. }
  86552. declare module BABYLON {
  86553. /** @hidden */
  86554. export var imageProcessingFunctions: {
  86555. name: string;
  86556. shader: string;
  86557. };
  86558. }
  86559. declare module BABYLON {
  86560. /** @hidden */
  86561. export var clipPlaneFragment: {
  86562. name: string;
  86563. shader: string;
  86564. };
  86565. }
  86566. declare module BABYLON {
  86567. /** @hidden */
  86568. export var particlesPixelShader: {
  86569. name: string;
  86570. shader: string;
  86571. };
  86572. }
  86573. declare module BABYLON {
  86574. /** @hidden */
  86575. export var clipPlaneVertexDeclaration: {
  86576. name: string;
  86577. shader: string;
  86578. };
  86579. }
  86580. declare module BABYLON {
  86581. /** @hidden */
  86582. export var clipPlaneVertex: {
  86583. name: string;
  86584. shader: string;
  86585. };
  86586. }
  86587. declare module BABYLON {
  86588. /** @hidden */
  86589. export var particlesVertexShader: {
  86590. name: string;
  86591. shader: string;
  86592. };
  86593. }
  86594. declare module BABYLON {
  86595. /**
  86596. * This represents a particle system in Babylon.
  86597. * 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.
  86598. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  86599. * @example https://doc.babylonjs.com/babylon101/particles
  86600. */
  86601. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  86602. /**
  86603. * Billboard mode will only apply to Y axis
  86604. */
  86605. static readonly BILLBOARDMODE_Y: number;
  86606. /**
  86607. * Billboard mode will apply to all axes
  86608. */
  86609. static readonly BILLBOARDMODE_ALL: number;
  86610. /**
  86611. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  86612. */
  86613. static readonly BILLBOARDMODE_STRETCHED: number;
  86614. /**
  86615. * This function can be defined to provide custom update for active particles.
  86616. * This function will be called instead of regular update (age, position, color, etc.).
  86617. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  86618. */
  86619. updateFunction: (particles: Particle[]) => void;
  86620. private _emitterWorldMatrix;
  86621. /**
  86622. * This function can be defined to specify initial direction for every new particle.
  86623. * It by default use the emitterType defined function
  86624. */
  86625. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  86626. /**
  86627. * This function can be defined to specify initial position for every new particle.
  86628. * It by default use the emitterType defined function
  86629. */
  86630. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  86631. /**
  86632. * @hidden
  86633. */
  86634. _inheritedVelocityOffset: Vector3;
  86635. /**
  86636. * An event triggered when the system is disposed
  86637. */
  86638. onDisposeObservable: Observable<ParticleSystem>;
  86639. private _onDisposeObserver;
  86640. /**
  86641. * Sets a callback that will be triggered when the system is disposed
  86642. */
  86643. onDispose: () => void;
  86644. private _particles;
  86645. private _epsilon;
  86646. private _capacity;
  86647. private _stockParticles;
  86648. private _newPartsExcess;
  86649. private _vertexData;
  86650. private _vertexBuffer;
  86651. private _vertexBuffers;
  86652. private _spriteBuffer;
  86653. private _indexBuffer;
  86654. private _effect;
  86655. private _customEffect;
  86656. private _cachedDefines;
  86657. private _scaledColorStep;
  86658. private _colorDiff;
  86659. private _scaledDirection;
  86660. private _scaledGravity;
  86661. private _currentRenderId;
  86662. private _alive;
  86663. private _useInstancing;
  86664. private _started;
  86665. private _stopped;
  86666. private _actualFrame;
  86667. private _scaledUpdateSpeed;
  86668. private _vertexBufferSize;
  86669. /** @hidden */
  86670. _currentEmitRateGradient: Nullable<FactorGradient>;
  86671. /** @hidden */
  86672. _currentEmitRate1: number;
  86673. /** @hidden */
  86674. _currentEmitRate2: number;
  86675. /** @hidden */
  86676. _currentStartSizeGradient: Nullable<FactorGradient>;
  86677. /** @hidden */
  86678. _currentStartSize1: number;
  86679. /** @hidden */
  86680. _currentStartSize2: number;
  86681. private readonly _rawTextureWidth;
  86682. private _rampGradientsTexture;
  86683. private _useRampGradients;
  86684. /** Gets or sets a boolean indicating that ramp gradients must be used
  86685. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86686. */
  86687. useRampGradients: boolean;
  86688. /**
  86689. * 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.
  86690. * 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: [])
  86691. */
  86692. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  86693. private _subEmitters;
  86694. /**
  86695. * @hidden
  86696. * If the particle systems emitter should be disposed when the particle system is disposed
  86697. */
  86698. _disposeEmitterOnDispose: boolean;
  86699. /**
  86700. * The current active Sub-systems, this property is used by the root particle system only.
  86701. */
  86702. activeSubSystems: Array<ParticleSystem>;
  86703. private _rootParticleSystem;
  86704. /**
  86705. * Gets the current list of active particles
  86706. */
  86707. readonly particles: Particle[];
  86708. /**
  86709. * Returns the string "ParticleSystem"
  86710. * @returns a string containing the class name
  86711. */
  86712. getClassName(): string;
  86713. /**
  86714. * Instantiates a particle system.
  86715. * 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.
  86716. * @param name The name of the particle system
  86717. * @param capacity The max number of particles alive at the same time
  86718. * @param scene The scene the particle system belongs to
  86719. * @param customEffect a custom effect used to change the way particles are rendered by default
  86720. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86721. * @param epsilon Offset used to render the particles
  86722. */
  86723. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86724. private _addFactorGradient;
  86725. private _removeFactorGradient;
  86726. /**
  86727. * Adds a new life time gradient
  86728. * @param gradient defines the gradient to use (between 0 and 1)
  86729. * @param factor defines the life time factor to affect to the specified gradient
  86730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86731. * @returns the current particle system
  86732. */
  86733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86734. /**
  86735. * Remove a specific life time gradient
  86736. * @param gradient defines the gradient to remove
  86737. * @returns the current particle system
  86738. */
  86739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86740. /**
  86741. * Adds a new size gradient
  86742. * @param gradient defines the gradient to use (between 0 and 1)
  86743. * @param factor defines the size factor to affect to the specified gradient
  86744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86745. * @returns the current particle system
  86746. */
  86747. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86748. /**
  86749. * Remove a specific size gradient
  86750. * @param gradient defines the gradient to remove
  86751. * @returns the current particle system
  86752. */
  86753. removeSizeGradient(gradient: number): IParticleSystem;
  86754. /**
  86755. * Adds a new color remap gradient
  86756. * @param gradient defines the gradient to use (between 0 and 1)
  86757. * @param min defines the color remap minimal range
  86758. * @param max defines the color remap maximal range
  86759. * @returns the current particle system
  86760. */
  86761. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86762. /**
  86763. * Remove a specific color remap gradient
  86764. * @param gradient defines the gradient to remove
  86765. * @returns the current particle system
  86766. */
  86767. removeColorRemapGradient(gradient: number): IParticleSystem;
  86768. /**
  86769. * Adds a new alpha remap gradient
  86770. * @param gradient defines the gradient to use (between 0 and 1)
  86771. * @param min defines the alpha remap minimal range
  86772. * @param max defines the alpha remap maximal range
  86773. * @returns the current particle system
  86774. */
  86775. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86776. /**
  86777. * Remove a specific alpha remap gradient
  86778. * @param gradient defines the gradient to remove
  86779. * @returns the current particle system
  86780. */
  86781. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86782. /**
  86783. * Adds a new angular speed gradient
  86784. * @param gradient defines the gradient to use (between 0 and 1)
  86785. * @param factor defines the angular speed to affect to the specified gradient
  86786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86787. * @returns the current particle system
  86788. */
  86789. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86790. /**
  86791. * Remove a specific angular speed gradient
  86792. * @param gradient defines the gradient to remove
  86793. * @returns the current particle system
  86794. */
  86795. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86796. /**
  86797. * Adds a new velocity gradient
  86798. * @param gradient defines the gradient to use (between 0 and 1)
  86799. * @param factor defines the velocity to affect to the specified gradient
  86800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86801. * @returns the current particle system
  86802. */
  86803. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86804. /**
  86805. * Remove a specific velocity gradient
  86806. * @param gradient defines the gradient to remove
  86807. * @returns the current particle system
  86808. */
  86809. removeVelocityGradient(gradient: number): IParticleSystem;
  86810. /**
  86811. * Adds a new limit velocity gradient
  86812. * @param gradient defines the gradient to use (between 0 and 1)
  86813. * @param factor defines the limit velocity value to affect to the specified gradient
  86814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86815. * @returns the current particle system
  86816. */
  86817. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86818. /**
  86819. * Remove a specific limit velocity gradient
  86820. * @param gradient defines the gradient to remove
  86821. * @returns the current particle system
  86822. */
  86823. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86824. /**
  86825. * Adds a new drag gradient
  86826. * @param gradient defines the gradient to use (between 0 and 1)
  86827. * @param factor defines the drag value to affect to the specified gradient
  86828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86829. * @returns the current particle system
  86830. */
  86831. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86832. /**
  86833. * Remove a specific drag gradient
  86834. * @param gradient defines the gradient to remove
  86835. * @returns the current particle system
  86836. */
  86837. removeDragGradient(gradient: number): IParticleSystem;
  86838. /**
  86839. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86840. * @param gradient defines the gradient to use (between 0 and 1)
  86841. * @param factor defines the emit rate value to affect to the specified gradient
  86842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86843. * @returns the current particle system
  86844. */
  86845. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86846. /**
  86847. * Remove a specific emit rate gradient
  86848. * @param gradient defines the gradient to remove
  86849. * @returns the current particle system
  86850. */
  86851. removeEmitRateGradient(gradient: number): IParticleSystem;
  86852. /**
  86853. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86854. * @param gradient defines the gradient to use (between 0 and 1)
  86855. * @param factor defines the start size value to affect to the specified gradient
  86856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86857. * @returns the current particle system
  86858. */
  86859. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86860. /**
  86861. * Remove a specific start size gradient
  86862. * @param gradient defines the gradient to remove
  86863. * @returns the current particle system
  86864. */
  86865. removeStartSizeGradient(gradient: number): IParticleSystem;
  86866. private _createRampGradientTexture;
  86867. /**
  86868. * Gets the current list of ramp gradients.
  86869. * You must use addRampGradient and removeRampGradient to udpate this list
  86870. * @returns the list of ramp gradients
  86871. */
  86872. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86873. /**
  86874. * Adds a new ramp gradient used to remap particle colors
  86875. * @param gradient defines the gradient to use (between 0 and 1)
  86876. * @param color defines the color to affect to the specified gradient
  86877. * @returns the current particle system
  86878. */
  86879. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86880. /**
  86881. * Remove a specific ramp gradient
  86882. * @param gradient defines the gradient to remove
  86883. * @returns the current particle system
  86884. */
  86885. removeRampGradient(gradient: number): ParticleSystem;
  86886. /**
  86887. * Adds a new color gradient
  86888. * @param gradient defines the gradient to use (between 0 and 1)
  86889. * @param color1 defines the color to affect to the specified gradient
  86890. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86891. * @returns this particle system
  86892. */
  86893. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86894. /**
  86895. * Remove a specific color gradient
  86896. * @param gradient defines the gradient to remove
  86897. * @returns this particle system
  86898. */
  86899. removeColorGradient(gradient: number): IParticleSystem;
  86900. private _fetchR;
  86901. protected _reset(): void;
  86902. private _resetEffect;
  86903. private _createVertexBuffers;
  86904. private _createIndexBuffer;
  86905. /**
  86906. * Gets the maximum number of particles active at the same time.
  86907. * @returns The max number of active particles.
  86908. */
  86909. getCapacity(): number;
  86910. /**
  86911. * Gets whether there are still active particles in the system.
  86912. * @returns True if it is alive, otherwise false.
  86913. */
  86914. isAlive(): boolean;
  86915. /**
  86916. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86917. * @returns True if it has been started, otherwise false.
  86918. */
  86919. isStarted(): boolean;
  86920. private _prepareSubEmitterInternalArray;
  86921. /**
  86922. * Starts the particle system and begins to emit
  86923. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86924. */
  86925. start(delay?: number): void;
  86926. /**
  86927. * Stops the particle system.
  86928. * @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.
  86929. */
  86930. stop(stopSubEmitters?: boolean): void;
  86931. /**
  86932. * Remove all active particles
  86933. */
  86934. reset(): void;
  86935. /**
  86936. * @hidden (for internal use only)
  86937. */
  86938. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86939. /**
  86940. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86941. * Its lifetime will start back at 0.
  86942. */
  86943. recycleParticle: (particle: Particle) => void;
  86944. private _stopSubEmitters;
  86945. private _createParticle;
  86946. private _removeFromRoot;
  86947. private _emitFromParticle;
  86948. private _update;
  86949. /** @hidden */
  86950. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86951. /** @hidden */
  86952. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86953. /** @hidden */
  86954. private _getEffect;
  86955. /**
  86956. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86957. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86958. */
  86959. animate(preWarmOnly?: boolean): void;
  86960. private _appendParticleVertices;
  86961. /**
  86962. * Rebuilds the particle system.
  86963. */
  86964. rebuild(): void;
  86965. /**
  86966. * Is this system ready to be used/rendered
  86967. * @return true if the system is ready
  86968. */
  86969. isReady(): boolean;
  86970. private _render;
  86971. /**
  86972. * Renders the particle system in its current state.
  86973. * @returns the current number of particles
  86974. */
  86975. render(): number;
  86976. /**
  86977. * Disposes the particle system and free the associated resources
  86978. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86979. */
  86980. dispose(disposeTexture?: boolean): void;
  86981. /**
  86982. * Clones the particle system.
  86983. * @param name The name of the cloned object
  86984. * @param newEmitter The new emitter to use
  86985. * @returns the cloned particle system
  86986. */
  86987. clone(name: string, newEmitter: any): ParticleSystem;
  86988. /**
  86989. * Serializes the particle system to a JSON object.
  86990. * @returns the JSON object
  86991. */
  86992. serialize(): any;
  86993. /** @hidden */
  86994. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  86995. /** @hidden */
  86996. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86997. /**
  86998. * Parses a JSON object to create a particle system.
  86999. * @param parsedParticleSystem The JSON object to parse
  87000. * @param scene The scene to create the particle system in
  87001. * @param rootUrl The root url to use to load external dependencies like texture
  87002. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  87003. * @returns the Parsed particle system
  87004. */
  87005. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  87006. }
  87007. }
  87008. declare module BABYLON {
  87009. /**
  87010. * A particle represents one of the element emitted by a particle system.
  87011. * This is mainly define by its coordinates, direction, velocity and age.
  87012. */
  87013. export class Particle {
  87014. /**
  87015. * The particle system the particle belongs to.
  87016. */
  87017. particleSystem: ParticleSystem;
  87018. private static _Count;
  87019. /**
  87020. * Unique ID of the particle
  87021. */
  87022. id: number;
  87023. /**
  87024. * The world position of the particle in the scene.
  87025. */
  87026. position: Vector3;
  87027. /**
  87028. * The world direction of the particle in the scene.
  87029. */
  87030. direction: Vector3;
  87031. /**
  87032. * The color of the particle.
  87033. */
  87034. color: Color4;
  87035. /**
  87036. * The color change of the particle per step.
  87037. */
  87038. colorStep: Color4;
  87039. /**
  87040. * Defines how long will the life of the particle be.
  87041. */
  87042. lifeTime: number;
  87043. /**
  87044. * The current age of the particle.
  87045. */
  87046. age: number;
  87047. /**
  87048. * The current size of the particle.
  87049. */
  87050. size: number;
  87051. /**
  87052. * The current scale of the particle.
  87053. */
  87054. scale: Vector2;
  87055. /**
  87056. * The current angle of the particle.
  87057. */
  87058. angle: number;
  87059. /**
  87060. * Defines how fast is the angle changing.
  87061. */
  87062. angularSpeed: number;
  87063. /**
  87064. * Defines the cell index used by the particle to be rendered from a sprite.
  87065. */
  87066. cellIndex: number;
  87067. /**
  87068. * The information required to support color remapping
  87069. */
  87070. remapData: Vector4;
  87071. /** @hidden */
  87072. _randomCellOffset?: number;
  87073. /** @hidden */
  87074. _initialDirection: Nullable<Vector3>;
  87075. /** @hidden */
  87076. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  87077. /** @hidden */
  87078. _initialStartSpriteCellID: number;
  87079. /** @hidden */
  87080. _initialEndSpriteCellID: number;
  87081. /** @hidden */
  87082. _currentColorGradient: Nullable<ColorGradient>;
  87083. /** @hidden */
  87084. _currentColor1: Color4;
  87085. /** @hidden */
  87086. _currentColor2: Color4;
  87087. /** @hidden */
  87088. _currentSizeGradient: Nullable<FactorGradient>;
  87089. /** @hidden */
  87090. _currentSize1: number;
  87091. /** @hidden */
  87092. _currentSize2: number;
  87093. /** @hidden */
  87094. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  87095. /** @hidden */
  87096. _currentAngularSpeed1: number;
  87097. /** @hidden */
  87098. _currentAngularSpeed2: number;
  87099. /** @hidden */
  87100. _currentVelocityGradient: Nullable<FactorGradient>;
  87101. /** @hidden */
  87102. _currentVelocity1: number;
  87103. /** @hidden */
  87104. _currentVelocity2: number;
  87105. /** @hidden */
  87106. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  87107. /** @hidden */
  87108. _currentLimitVelocity1: number;
  87109. /** @hidden */
  87110. _currentLimitVelocity2: number;
  87111. /** @hidden */
  87112. _currentDragGradient: Nullable<FactorGradient>;
  87113. /** @hidden */
  87114. _currentDrag1: number;
  87115. /** @hidden */
  87116. _currentDrag2: number;
  87117. /** @hidden */
  87118. _randomNoiseCoordinates1: Vector3;
  87119. /** @hidden */
  87120. _randomNoiseCoordinates2: Vector3;
  87121. /**
  87122. * Creates a new instance Particle
  87123. * @param particleSystem the particle system the particle belongs to
  87124. */
  87125. constructor(
  87126. /**
  87127. * The particle system the particle belongs to.
  87128. */
  87129. particleSystem: ParticleSystem);
  87130. private updateCellInfoFromSystem;
  87131. /**
  87132. * Defines how the sprite cell index is updated for the particle
  87133. */
  87134. updateCellIndex(): void;
  87135. /** @hidden */
  87136. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  87137. /** @hidden */
  87138. _inheritParticleInfoToSubEmitters(): void;
  87139. /** @hidden */
  87140. _reset(): void;
  87141. /**
  87142. * Copy the properties of particle to another one.
  87143. * @param other the particle to copy the information to.
  87144. */
  87145. copyTo(other: Particle): void;
  87146. }
  87147. }
  87148. declare module BABYLON {
  87149. /**
  87150. * Particle emitter represents a volume emitting particles.
  87151. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  87152. */
  87153. export interface IParticleEmitterType {
  87154. /**
  87155. * Called by the particle System when the direction is computed for the created particle.
  87156. * @param worldMatrix is the world matrix of the particle system
  87157. * @param directionToUpdate is the direction vector to update with the result
  87158. * @param particle is the particle we are computed the direction for
  87159. */
  87160. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87161. /**
  87162. * Called by the particle System when the position is computed for the created particle.
  87163. * @param worldMatrix is the world matrix of the particle system
  87164. * @param positionToUpdate is the position vector to update with the result
  87165. * @param particle is the particle we are computed the position for
  87166. */
  87167. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87168. /**
  87169. * Clones the current emitter and returns a copy of it
  87170. * @returns the new emitter
  87171. */
  87172. clone(): IParticleEmitterType;
  87173. /**
  87174. * Called by the GPUParticleSystem to setup the update shader
  87175. * @param effect defines the update shader
  87176. */
  87177. applyToShader(effect: Effect): void;
  87178. /**
  87179. * Returns a string to use to update the GPU particles update shader
  87180. * @returns the effect defines string
  87181. */
  87182. getEffectDefines(): string;
  87183. /**
  87184. * Returns a string representing the class name
  87185. * @returns a string containing the class name
  87186. */
  87187. getClassName(): string;
  87188. /**
  87189. * Serializes the particle system to a JSON object.
  87190. * @returns the JSON object
  87191. */
  87192. serialize(): any;
  87193. /**
  87194. * Parse properties from a JSON object
  87195. * @param serializationObject defines the JSON object
  87196. */
  87197. parse(serializationObject: any): void;
  87198. }
  87199. }
  87200. declare module BABYLON {
  87201. /**
  87202. * Particle emitter emitting particles from the inside of a box.
  87203. * It emits the particles randomly between 2 given directions.
  87204. */
  87205. export class BoxParticleEmitter implements IParticleEmitterType {
  87206. /**
  87207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87208. */
  87209. direction1: Vector3;
  87210. /**
  87211. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87212. */
  87213. direction2: Vector3;
  87214. /**
  87215. * 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.
  87216. */
  87217. minEmitBox: Vector3;
  87218. /**
  87219. * 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.
  87220. */
  87221. maxEmitBox: Vector3;
  87222. /**
  87223. * Creates a new instance BoxParticleEmitter
  87224. */
  87225. constructor();
  87226. /**
  87227. * Called by the particle System when the direction is computed for the created particle.
  87228. * @param worldMatrix is the world matrix of the particle system
  87229. * @param directionToUpdate is the direction vector to update with the result
  87230. * @param particle is the particle we are computed the direction for
  87231. */
  87232. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87233. /**
  87234. * Called by the particle System when the position is computed for the created particle.
  87235. * @param worldMatrix is the world matrix of the particle system
  87236. * @param positionToUpdate is the position vector to update with the result
  87237. * @param particle is the particle we are computed the position for
  87238. */
  87239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87240. /**
  87241. * Clones the current emitter and returns a copy of it
  87242. * @returns the new emitter
  87243. */
  87244. clone(): BoxParticleEmitter;
  87245. /**
  87246. * Called by the GPUParticleSystem to setup the update shader
  87247. * @param effect defines the update shader
  87248. */
  87249. applyToShader(effect: Effect): void;
  87250. /**
  87251. * Returns a string to use to update the GPU particles update shader
  87252. * @returns a string containng the defines string
  87253. */
  87254. getEffectDefines(): string;
  87255. /**
  87256. * Returns the string "BoxParticleEmitter"
  87257. * @returns a string containing the class name
  87258. */
  87259. getClassName(): string;
  87260. /**
  87261. * Serializes the particle system to a JSON object.
  87262. * @returns the JSON object
  87263. */
  87264. serialize(): any;
  87265. /**
  87266. * Parse properties from a JSON object
  87267. * @param serializationObject defines the JSON object
  87268. */
  87269. parse(serializationObject: any): void;
  87270. }
  87271. }
  87272. declare module BABYLON {
  87273. /**
  87274. * Particle emitter emitting particles from the inside of a cone.
  87275. * It emits the particles alongside the cone volume from the base to the particle.
  87276. * The emission direction might be randomized.
  87277. */
  87278. export class ConeParticleEmitter implements IParticleEmitterType {
  87279. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87280. directionRandomizer: number;
  87281. private _radius;
  87282. private _angle;
  87283. private _height;
  87284. /**
  87285. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  87286. */
  87287. radiusRange: number;
  87288. /**
  87289. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  87290. */
  87291. heightRange: number;
  87292. /**
  87293. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  87294. */
  87295. emitFromSpawnPointOnly: boolean;
  87296. /**
  87297. * Gets or sets the radius of the emission cone
  87298. */
  87299. radius: number;
  87300. /**
  87301. * Gets or sets the angle of the emission cone
  87302. */
  87303. angle: number;
  87304. private _buildHeight;
  87305. /**
  87306. * Creates a new instance ConeParticleEmitter
  87307. * @param radius the radius of the emission cone (1 by default)
  87308. * @param angle the cone base angle (PI by default)
  87309. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  87310. */
  87311. constructor(radius?: number, angle?: number,
  87312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  87313. directionRandomizer?: number);
  87314. /**
  87315. * Called by the particle System when the direction is computed for the created particle.
  87316. * @param worldMatrix is the world matrix of the particle system
  87317. * @param directionToUpdate is the direction vector to update with the result
  87318. * @param particle is the particle we are computed the direction for
  87319. */
  87320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87321. /**
  87322. * Called by the particle System when the position is computed for the created particle.
  87323. * @param worldMatrix is the world matrix of the particle system
  87324. * @param positionToUpdate is the position vector to update with the result
  87325. * @param particle is the particle we are computed the position for
  87326. */
  87327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87328. /**
  87329. * Clones the current emitter and returns a copy of it
  87330. * @returns the new emitter
  87331. */
  87332. clone(): ConeParticleEmitter;
  87333. /**
  87334. * Called by the GPUParticleSystem to setup the update shader
  87335. * @param effect defines the update shader
  87336. */
  87337. applyToShader(effect: Effect): void;
  87338. /**
  87339. * Returns a string to use to update the GPU particles update shader
  87340. * @returns a string containng the defines string
  87341. */
  87342. getEffectDefines(): string;
  87343. /**
  87344. * Returns the string "ConeParticleEmitter"
  87345. * @returns a string containing the class name
  87346. */
  87347. getClassName(): string;
  87348. /**
  87349. * Serializes the particle system to a JSON object.
  87350. * @returns the JSON object
  87351. */
  87352. serialize(): any;
  87353. /**
  87354. * Parse properties from a JSON object
  87355. * @param serializationObject defines the JSON object
  87356. */
  87357. parse(serializationObject: any): void;
  87358. }
  87359. }
  87360. declare module BABYLON {
  87361. /**
  87362. * Particle emitter emitting particles from the inside of a cylinder.
  87363. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  87364. */
  87365. export class CylinderParticleEmitter implements IParticleEmitterType {
  87366. /**
  87367. * The radius of the emission cylinder.
  87368. */
  87369. radius: number;
  87370. /**
  87371. * The height of the emission cylinder.
  87372. */
  87373. height: number;
  87374. /**
  87375. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87376. */
  87377. radiusRange: number;
  87378. /**
  87379. * How much to randomize the particle direction [0-1].
  87380. */
  87381. directionRandomizer: number;
  87382. /**
  87383. * Creates a new instance CylinderParticleEmitter
  87384. * @param radius the radius of the emission cylinder (1 by default)
  87385. * @param height the height of the emission cylinder (1 by default)
  87386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87387. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87388. */
  87389. constructor(
  87390. /**
  87391. * The radius of the emission cylinder.
  87392. */
  87393. radius?: number,
  87394. /**
  87395. * The height of the emission cylinder.
  87396. */
  87397. height?: number,
  87398. /**
  87399. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87400. */
  87401. radiusRange?: number,
  87402. /**
  87403. * How much to randomize the particle direction [0-1].
  87404. */
  87405. directionRandomizer?: number);
  87406. /**
  87407. * Called by the particle System when the direction is computed for the created particle.
  87408. * @param worldMatrix is the world matrix of the particle system
  87409. * @param directionToUpdate is the direction vector to update with the result
  87410. * @param particle is the particle we are computed the direction for
  87411. */
  87412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87413. /**
  87414. * Called by the particle System when the position is computed for the created particle.
  87415. * @param worldMatrix is the world matrix of the particle system
  87416. * @param positionToUpdate is the position vector to update with the result
  87417. * @param particle is the particle we are computed the position for
  87418. */
  87419. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87420. /**
  87421. * Clones the current emitter and returns a copy of it
  87422. * @returns the new emitter
  87423. */
  87424. clone(): CylinderParticleEmitter;
  87425. /**
  87426. * Called by the GPUParticleSystem to setup the update shader
  87427. * @param effect defines the update shader
  87428. */
  87429. applyToShader(effect: Effect): void;
  87430. /**
  87431. * Returns a string to use to update the GPU particles update shader
  87432. * @returns a string containng the defines string
  87433. */
  87434. getEffectDefines(): string;
  87435. /**
  87436. * Returns the string "CylinderParticleEmitter"
  87437. * @returns a string containing the class name
  87438. */
  87439. getClassName(): string;
  87440. /**
  87441. * Serializes the particle system to a JSON object.
  87442. * @returns the JSON object
  87443. */
  87444. serialize(): any;
  87445. /**
  87446. * Parse properties from a JSON object
  87447. * @param serializationObject defines the JSON object
  87448. */
  87449. parse(serializationObject: any): void;
  87450. }
  87451. /**
  87452. * Particle emitter emitting particles from the inside of a cylinder.
  87453. * It emits the particles randomly between two vectors.
  87454. */
  87455. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  87456. /**
  87457. * The min limit of the emission direction.
  87458. */
  87459. direction1: Vector3;
  87460. /**
  87461. * The max limit of the emission direction.
  87462. */
  87463. direction2: Vector3;
  87464. /**
  87465. * Creates a new instance CylinderDirectedParticleEmitter
  87466. * @param radius the radius of the emission cylinder (1 by default)
  87467. * @param height the height of the emission cylinder (1 by default)
  87468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87469. * @param direction1 the min limit of the emission direction (up vector by default)
  87470. * @param direction2 the max limit of the emission direction (up vector by default)
  87471. */
  87472. constructor(radius?: number, height?: number, radiusRange?: number,
  87473. /**
  87474. * The min limit of the emission direction.
  87475. */
  87476. direction1?: Vector3,
  87477. /**
  87478. * The max limit of the emission direction.
  87479. */
  87480. direction2?: Vector3);
  87481. /**
  87482. * Called by the particle System when the direction is computed for the created particle.
  87483. * @param worldMatrix is the world matrix of the particle system
  87484. * @param directionToUpdate is the direction vector to update with the result
  87485. * @param particle is the particle we are computed the direction for
  87486. */
  87487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87488. /**
  87489. * Clones the current emitter and returns a copy of it
  87490. * @returns the new emitter
  87491. */
  87492. clone(): CylinderDirectedParticleEmitter;
  87493. /**
  87494. * Called by the GPUParticleSystem to setup the update shader
  87495. * @param effect defines the update shader
  87496. */
  87497. applyToShader(effect: Effect): void;
  87498. /**
  87499. * Returns a string to use to update the GPU particles update shader
  87500. * @returns a string containng the defines string
  87501. */
  87502. getEffectDefines(): string;
  87503. /**
  87504. * Returns the string "CylinderDirectedParticleEmitter"
  87505. * @returns a string containing the class name
  87506. */
  87507. getClassName(): string;
  87508. /**
  87509. * Serializes the particle system to a JSON object.
  87510. * @returns the JSON object
  87511. */
  87512. serialize(): any;
  87513. /**
  87514. * Parse properties from a JSON object
  87515. * @param serializationObject defines the JSON object
  87516. */
  87517. parse(serializationObject: any): void;
  87518. }
  87519. }
  87520. declare module BABYLON {
  87521. /**
  87522. * Particle emitter emitting particles from the inside of a hemisphere.
  87523. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  87524. */
  87525. export class HemisphericParticleEmitter implements IParticleEmitterType {
  87526. /**
  87527. * The radius of the emission hemisphere.
  87528. */
  87529. radius: number;
  87530. /**
  87531. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87532. */
  87533. radiusRange: number;
  87534. /**
  87535. * How much to randomize the particle direction [0-1].
  87536. */
  87537. directionRandomizer: number;
  87538. /**
  87539. * Creates a new instance HemisphericParticleEmitter
  87540. * @param radius the radius of the emission hemisphere (1 by default)
  87541. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87542. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87543. */
  87544. constructor(
  87545. /**
  87546. * The radius of the emission hemisphere.
  87547. */
  87548. radius?: number,
  87549. /**
  87550. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87551. */
  87552. radiusRange?: number,
  87553. /**
  87554. * How much to randomize the particle direction [0-1].
  87555. */
  87556. directionRandomizer?: number);
  87557. /**
  87558. * Called by the particle System when the direction is computed for the created particle.
  87559. * @param worldMatrix is the world matrix of the particle system
  87560. * @param directionToUpdate is the direction vector to update with the result
  87561. * @param particle is the particle we are computed the direction for
  87562. */
  87563. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87564. /**
  87565. * Called by the particle System when the position is computed for the created particle.
  87566. * @param worldMatrix is the world matrix of the particle system
  87567. * @param positionToUpdate is the position vector to update with the result
  87568. * @param particle is the particle we are computed the position for
  87569. */
  87570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87571. /**
  87572. * Clones the current emitter and returns a copy of it
  87573. * @returns the new emitter
  87574. */
  87575. clone(): HemisphericParticleEmitter;
  87576. /**
  87577. * Called by the GPUParticleSystem to setup the update shader
  87578. * @param effect defines the update shader
  87579. */
  87580. applyToShader(effect: Effect): void;
  87581. /**
  87582. * Returns a string to use to update the GPU particles update shader
  87583. * @returns a string containng the defines string
  87584. */
  87585. getEffectDefines(): string;
  87586. /**
  87587. * Returns the string "HemisphericParticleEmitter"
  87588. * @returns a string containing the class name
  87589. */
  87590. getClassName(): string;
  87591. /**
  87592. * Serializes the particle system to a JSON object.
  87593. * @returns the JSON object
  87594. */
  87595. serialize(): any;
  87596. /**
  87597. * Parse properties from a JSON object
  87598. * @param serializationObject defines the JSON object
  87599. */
  87600. parse(serializationObject: any): void;
  87601. }
  87602. }
  87603. declare module BABYLON {
  87604. /**
  87605. * Particle emitter emitting particles from a point.
  87606. * It emits the particles randomly between 2 given directions.
  87607. */
  87608. export class PointParticleEmitter implements IParticleEmitterType {
  87609. /**
  87610. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87611. */
  87612. direction1: Vector3;
  87613. /**
  87614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87615. */
  87616. direction2: Vector3;
  87617. /**
  87618. * Creates a new instance PointParticleEmitter
  87619. */
  87620. constructor();
  87621. /**
  87622. * Called by the particle System when the direction is computed for the created particle.
  87623. * @param worldMatrix is the world matrix of the particle system
  87624. * @param directionToUpdate is the direction vector to update with the result
  87625. * @param particle is the particle we are computed the direction for
  87626. */
  87627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87628. /**
  87629. * Called by the particle System when the position is computed for the created particle.
  87630. * @param worldMatrix is the world matrix of the particle system
  87631. * @param positionToUpdate is the position vector to update with the result
  87632. * @param particle is the particle we are computed the position for
  87633. */
  87634. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87635. /**
  87636. * Clones the current emitter and returns a copy of it
  87637. * @returns the new emitter
  87638. */
  87639. clone(): PointParticleEmitter;
  87640. /**
  87641. * Called by the GPUParticleSystem to setup the update shader
  87642. * @param effect defines the update shader
  87643. */
  87644. applyToShader(effect: Effect): void;
  87645. /**
  87646. * Returns a string to use to update the GPU particles update shader
  87647. * @returns a string containng the defines string
  87648. */
  87649. getEffectDefines(): string;
  87650. /**
  87651. * Returns the string "PointParticleEmitter"
  87652. * @returns a string containing the class name
  87653. */
  87654. getClassName(): string;
  87655. /**
  87656. * Serializes the particle system to a JSON object.
  87657. * @returns the JSON object
  87658. */
  87659. serialize(): any;
  87660. /**
  87661. * Parse properties from a JSON object
  87662. * @param serializationObject defines the JSON object
  87663. */
  87664. parse(serializationObject: any): void;
  87665. }
  87666. }
  87667. declare module BABYLON {
  87668. /**
  87669. * Particle emitter emitting particles from the inside of a sphere.
  87670. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87671. */
  87672. export class SphereParticleEmitter implements IParticleEmitterType {
  87673. /**
  87674. * The radius of the emission sphere.
  87675. */
  87676. radius: number;
  87677. /**
  87678. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87679. */
  87680. radiusRange: number;
  87681. /**
  87682. * How much to randomize the particle direction [0-1].
  87683. */
  87684. directionRandomizer: number;
  87685. /**
  87686. * Creates a new instance SphereParticleEmitter
  87687. * @param radius the radius of the emission sphere (1 by default)
  87688. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87689. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87690. */
  87691. constructor(
  87692. /**
  87693. * The radius of the emission sphere.
  87694. */
  87695. radius?: number,
  87696. /**
  87697. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87698. */
  87699. radiusRange?: number,
  87700. /**
  87701. * How much to randomize the particle direction [0-1].
  87702. */
  87703. directionRandomizer?: number);
  87704. /**
  87705. * Called by the particle System when the direction is computed for the created particle.
  87706. * @param worldMatrix is the world matrix of the particle system
  87707. * @param directionToUpdate is the direction vector to update with the result
  87708. * @param particle is the particle we are computed the direction for
  87709. */
  87710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87711. /**
  87712. * Called by the particle System when the position is computed for the created particle.
  87713. * @param worldMatrix is the world matrix of the particle system
  87714. * @param positionToUpdate is the position vector to update with the result
  87715. * @param particle is the particle we are computed the position for
  87716. */
  87717. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  87718. /**
  87719. * Clones the current emitter and returns a copy of it
  87720. * @returns the new emitter
  87721. */
  87722. clone(): SphereParticleEmitter;
  87723. /**
  87724. * Called by the GPUParticleSystem to setup the update shader
  87725. * @param effect defines the update shader
  87726. */
  87727. applyToShader(effect: Effect): void;
  87728. /**
  87729. * Returns a string to use to update the GPU particles update shader
  87730. * @returns a string containng the defines string
  87731. */
  87732. getEffectDefines(): string;
  87733. /**
  87734. * Returns the string "SphereParticleEmitter"
  87735. * @returns a string containing the class name
  87736. */
  87737. getClassName(): string;
  87738. /**
  87739. * Serializes the particle system to a JSON object.
  87740. * @returns the JSON object
  87741. */
  87742. serialize(): any;
  87743. /**
  87744. * Parse properties from a JSON object
  87745. * @param serializationObject defines the JSON object
  87746. */
  87747. parse(serializationObject: any): void;
  87748. }
  87749. /**
  87750. * Particle emitter emitting particles from the inside of a sphere.
  87751. * It emits the particles randomly between two vectors.
  87752. */
  87753. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87754. /**
  87755. * The min limit of the emission direction.
  87756. */
  87757. direction1: Vector3;
  87758. /**
  87759. * The max limit of the emission direction.
  87760. */
  87761. direction2: Vector3;
  87762. /**
  87763. * Creates a new instance SphereDirectedParticleEmitter
  87764. * @param radius the radius of the emission sphere (1 by default)
  87765. * @param direction1 the min limit of the emission direction (up vector by default)
  87766. * @param direction2 the max limit of the emission direction (up vector by default)
  87767. */
  87768. constructor(radius?: number,
  87769. /**
  87770. * The min limit of the emission direction.
  87771. */
  87772. direction1?: Vector3,
  87773. /**
  87774. * The max limit of the emission direction.
  87775. */
  87776. direction2?: Vector3);
  87777. /**
  87778. * Called by the particle System when the direction is computed for the created particle.
  87779. * @param worldMatrix is the world matrix of the particle system
  87780. * @param directionToUpdate is the direction vector to update with the result
  87781. * @param particle is the particle we are computed the direction for
  87782. */
  87783. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87784. /**
  87785. * Clones the current emitter and returns a copy of it
  87786. * @returns the new emitter
  87787. */
  87788. clone(): SphereDirectedParticleEmitter;
  87789. /**
  87790. * Called by the GPUParticleSystem to setup the update shader
  87791. * @param effect defines the update shader
  87792. */
  87793. applyToShader(effect: Effect): void;
  87794. /**
  87795. * Returns a string to use to update the GPU particles update shader
  87796. * @returns a string containng the defines string
  87797. */
  87798. getEffectDefines(): string;
  87799. /**
  87800. * Returns the string "SphereDirectedParticleEmitter"
  87801. * @returns a string containing the class name
  87802. */
  87803. getClassName(): string;
  87804. /**
  87805. * Serializes the particle system to a JSON object.
  87806. * @returns the JSON object
  87807. */
  87808. serialize(): any;
  87809. /**
  87810. * Parse properties from a JSON object
  87811. * @param serializationObject defines the JSON object
  87812. */
  87813. parse(serializationObject: any): void;
  87814. }
  87815. }
  87816. declare module BABYLON {
  87817. /**
  87818. * Interface representing a particle system in Babylon.js.
  87819. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87820. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87821. */
  87822. export interface IParticleSystem {
  87823. /**
  87824. * List of animations used by the particle system.
  87825. */
  87826. animations: Animation[];
  87827. /**
  87828. * The id of the Particle system.
  87829. */
  87830. id: string;
  87831. /**
  87832. * The name of the Particle system.
  87833. */
  87834. name: string;
  87835. /**
  87836. * The emitter represents the Mesh or position we are attaching the particle system to.
  87837. */
  87838. emitter: Nullable<AbstractMesh | Vector3>;
  87839. /**
  87840. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87841. */
  87842. isBillboardBased: boolean;
  87843. /**
  87844. * The rendering group used by the Particle system to chose when to render.
  87845. */
  87846. renderingGroupId: number;
  87847. /**
  87848. * The layer mask we are rendering the particles through.
  87849. */
  87850. layerMask: number;
  87851. /**
  87852. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87853. */
  87854. updateSpeed: number;
  87855. /**
  87856. * The amount of time the particle system is running (depends of the overall update speed).
  87857. */
  87858. targetStopDuration: number;
  87859. /**
  87860. * The texture used to render each particle. (this can be a spritesheet)
  87861. */
  87862. particleTexture: Nullable<Texture>;
  87863. /**
  87864. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87865. */
  87866. blendMode: number;
  87867. /**
  87868. * Minimum life time of emitting particles.
  87869. */
  87870. minLifeTime: number;
  87871. /**
  87872. * Maximum life time of emitting particles.
  87873. */
  87874. maxLifeTime: number;
  87875. /**
  87876. * Minimum Size of emitting particles.
  87877. */
  87878. minSize: number;
  87879. /**
  87880. * Maximum Size of emitting particles.
  87881. */
  87882. maxSize: number;
  87883. /**
  87884. * Minimum scale of emitting particles on X axis.
  87885. */
  87886. minScaleX: number;
  87887. /**
  87888. * Maximum scale of emitting particles on X axis.
  87889. */
  87890. maxScaleX: number;
  87891. /**
  87892. * Minimum scale of emitting particles on Y axis.
  87893. */
  87894. minScaleY: number;
  87895. /**
  87896. * Maximum scale of emitting particles on Y axis.
  87897. */
  87898. maxScaleY: number;
  87899. /**
  87900. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87901. */
  87902. color1: Color4;
  87903. /**
  87904. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87905. */
  87906. color2: Color4;
  87907. /**
  87908. * Color the particle will have at the end of its lifetime.
  87909. */
  87910. colorDead: Color4;
  87911. /**
  87912. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87913. */
  87914. emitRate: number;
  87915. /**
  87916. * You can use gravity if you want to give an orientation to your particles.
  87917. */
  87918. gravity: Vector3;
  87919. /**
  87920. * Minimum power of emitting particles.
  87921. */
  87922. minEmitPower: number;
  87923. /**
  87924. * Maximum power of emitting particles.
  87925. */
  87926. maxEmitPower: number;
  87927. /**
  87928. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87929. */
  87930. minAngularSpeed: number;
  87931. /**
  87932. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87933. */
  87934. maxAngularSpeed: number;
  87935. /**
  87936. * Gets or sets the minimal initial rotation in radians.
  87937. */
  87938. minInitialRotation: number;
  87939. /**
  87940. * Gets or sets the maximal initial rotation in radians.
  87941. */
  87942. maxInitialRotation: number;
  87943. /**
  87944. * The particle emitter type defines the emitter used by the particle system.
  87945. * It can be for example box, sphere, or cone...
  87946. */
  87947. particleEmitterType: Nullable<IParticleEmitterType>;
  87948. /**
  87949. * Defines the delay in milliseconds before starting the system (0 by default)
  87950. */
  87951. startDelay: number;
  87952. /**
  87953. * 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
  87954. */
  87955. preWarmCycles: number;
  87956. /**
  87957. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87958. */
  87959. preWarmStepOffset: number;
  87960. /**
  87961. * 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)
  87962. */
  87963. spriteCellChangeSpeed: number;
  87964. /**
  87965. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87966. */
  87967. startSpriteCellID: number;
  87968. /**
  87969. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87970. */
  87971. endSpriteCellID: number;
  87972. /**
  87973. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87974. */
  87975. spriteCellWidth: number;
  87976. /**
  87977. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87978. */
  87979. spriteCellHeight: number;
  87980. /**
  87981. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87982. */
  87983. spriteRandomStartCell: boolean;
  87984. /**
  87985. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87986. */
  87987. isAnimationSheetEnabled: boolean;
  87988. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87989. translationPivot: Vector2;
  87990. /**
  87991. * Gets or sets a texture used to add random noise to particle positions
  87992. */
  87993. noiseTexture: Nullable<BaseTexture>;
  87994. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87995. noiseStrength: Vector3;
  87996. /**
  87997. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87998. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87999. */
  88000. billboardMode: number;
  88001. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88002. limitVelocityDamping: number;
  88003. /**
  88004. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88005. */
  88006. beginAnimationOnStart: boolean;
  88007. /**
  88008. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88009. */
  88010. beginAnimationFrom: number;
  88011. /**
  88012. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88013. */
  88014. beginAnimationTo: number;
  88015. /**
  88016. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88017. */
  88018. beginAnimationLoop: boolean;
  88019. /**
  88020. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88021. */
  88022. disposeOnStop: boolean;
  88023. /**
  88024. * Gets the maximum number of particles active at the same time.
  88025. * @returns The max number of active particles.
  88026. */
  88027. getCapacity(): number;
  88028. /**
  88029. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88030. * @returns True if it has been started, otherwise false.
  88031. */
  88032. isStarted(): boolean;
  88033. /**
  88034. * Animates the particle system for this frame.
  88035. */
  88036. animate(): void;
  88037. /**
  88038. * Renders the particle system in its current state.
  88039. * @returns the current number of particles
  88040. */
  88041. render(): number;
  88042. /**
  88043. * Dispose the particle system and frees its associated resources.
  88044. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88045. */
  88046. dispose(disposeTexture?: boolean): void;
  88047. /**
  88048. * Clones the particle system.
  88049. * @param name The name of the cloned object
  88050. * @param newEmitter The new emitter to use
  88051. * @returns the cloned particle system
  88052. */
  88053. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  88054. /**
  88055. * Serializes the particle system to a JSON object.
  88056. * @returns the JSON object
  88057. */
  88058. serialize(): any;
  88059. /**
  88060. * Rebuild the particle system
  88061. */
  88062. rebuild(): void;
  88063. /**
  88064. * Starts the particle system and begins to emit
  88065. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  88066. */
  88067. start(delay?: number): void;
  88068. /**
  88069. * Stops the particle system.
  88070. */
  88071. stop(): void;
  88072. /**
  88073. * Remove all active particles
  88074. */
  88075. reset(): void;
  88076. /**
  88077. * Is this system ready to be used/rendered
  88078. * @return true if the system is ready
  88079. */
  88080. isReady(): boolean;
  88081. /**
  88082. * Adds a new color gradient
  88083. * @param gradient defines the gradient to use (between 0 and 1)
  88084. * @param color1 defines the color to affect to the specified gradient
  88085. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88086. * @returns the current particle system
  88087. */
  88088. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88089. /**
  88090. * Remove a specific color gradient
  88091. * @param gradient defines the gradient to remove
  88092. * @returns the current particle system
  88093. */
  88094. removeColorGradient(gradient: number): IParticleSystem;
  88095. /**
  88096. * Adds a new size gradient
  88097. * @param gradient defines the gradient to use (between 0 and 1)
  88098. * @param factor defines the size factor to affect to the specified gradient
  88099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88100. * @returns the current particle system
  88101. */
  88102. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88103. /**
  88104. * Remove a specific size gradient
  88105. * @param gradient defines the gradient to remove
  88106. * @returns the current particle system
  88107. */
  88108. removeSizeGradient(gradient: number): IParticleSystem;
  88109. /**
  88110. * Gets the current list of color gradients.
  88111. * You must use addColorGradient and removeColorGradient to udpate this list
  88112. * @returns the list of color gradients
  88113. */
  88114. getColorGradients(): Nullable<Array<ColorGradient>>;
  88115. /**
  88116. * Gets the current list of size gradients.
  88117. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88118. * @returns the list of size gradients
  88119. */
  88120. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88121. /**
  88122. * Gets the current list of angular speed gradients.
  88123. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88124. * @returns the list of angular speed gradients
  88125. */
  88126. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88127. /**
  88128. * Adds a new angular speed gradient
  88129. * @param gradient defines the gradient to use (between 0 and 1)
  88130. * @param factor defines the angular speed to affect to the specified gradient
  88131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88132. * @returns the current particle system
  88133. */
  88134. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88135. /**
  88136. * Remove a specific angular speed gradient
  88137. * @param gradient defines the gradient to remove
  88138. * @returns the current particle system
  88139. */
  88140. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88141. /**
  88142. * Gets the current list of velocity gradients.
  88143. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88144. * @returns the list of velocity gradients
  88145. */
  88146. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88147. /**
  88148. * Adds a new velocity gradient
  88149. * @param gradient defines the gradient to use (between 0 and 1)
  88150. * @param factor defines the velocity to affect to the specified gradient
  88151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88152. * @returns the current particle system
  88153. */
  88154. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88155. /**
  88156. * Remove a specific velocity gradient
  88157. * @param gradient defines the gradient to remove
  88158. * @returns the current particle system
  88159. */
  88160. removeVelocityGradient(gradient: number): IParticleSystem;
  88161. /**
  88162. * Gets the current list of limit velocity gradients.
  88163. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88164. * @returns the list of limit velocity gradients
  88165. */
  88166. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88167. /**
  88168. * Adds a new limit velocity gradient
  88169. * @param gradient defines the gradient to use (between 0 and 1)
  88170. * @param factor defines the limit velocity to affect to the specified gradient
  88171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88172. * @returns the current particle system
  88173. */
  88174. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88175. /**
  88176. * Remove a specific limit velocity gradient
  88177. * @param gradient defines the gradient to remove
  88178. * @returns the current particle system
  88179. */
  88180. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88181. /**
  88182. * Adds a new drag gradient
  88183. * @param gradient defines the gradient to use (between 0 and 1)
  88184. * @param factor defines the drag to affect to the specified gradient
  88185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88186. * @returns the current particle system
  88187. */
  88188. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88189. /**
  88190. * Remove a specific drag gradient
  88191. * @param gradient defines the gradient to remove
  88192. * @returns the current particle system
  88193. */
  88194. removeDragGradient(gradient: number): IParticleSystem;
  88195. /**
  88196. * Gets the current list of drag gradients.
  88197. * You must use addDragGradient and removeDragGradient to udpate this list
  88198. * @returns the list of drag gradients
  88199. */
  88200. getDragGradients(): Nullable<Array<FactorGradient>>;
  88201. /**
  88202. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88203. * @param gradient defines the gradient to use (between 0 and 1)
  88204. * @param factor defines the emit rate to affect to the specified gradient
  88205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88206. * @returns the current particle system
  88207. */
  88208. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88209. /**
  88210. * Remove a specific emit rate gradient
  88211. * @param gradient defines the gradient to remove
  88212. * @returns the current particle system
  88213. */
  88214. removeEmitRateGradient(gradient: number): IParticleSystem;
  88215. /**
  88216. * Gets the current list of emit rate gradients.
  88217. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88218. * @returns the list of emit rate gradients
  88219. */
  88220. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88221. /**
  88222. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88223. * @param gradient defines the gradient to use (between 0 and 1)
  88224. * @param factor defines the start size to affect to the specified gradient
  88225. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88226. * @returns the current particle system
  88227. */
  88228. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88229. /**
  88230. * Remove a specific start size gradient
  88231. * @param gradient defines the gradient to remove
  88232. * @returns the current particle system
  88233. */
  88234. removeStartSizeGradient(gradient: number): IParticleSystem;
  88235. /**
  88236. * Gets the current list of start size gradients.
  88237. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88238. * @returns the list of start size gradients
  88239. */
  88240. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88241. /**
  88242. * Adds a new life time gradient
  88243. * @param gradient defines the gradient to use (between 0 and 1)
  88244. * @param factor defines the life time factor to affect to the specified gradient
  88245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88246. * @returns the current particle system
  88247. */
  88248. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88249. /**
  88250. * Remove a specific life time gradient
  88251. * @param gradient defines the gradient to remove
  88252. * @returns the current particle system
  88253. */
  88254. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88255. /**
  88256. * Gets the current list of life time gradients.
  88257. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88258. * @returns the list of life time gradients
  88259. */
  88260. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88261. /**
  88262. * Gets the current list of color gradients.
  88263. * You must use addColorGradient and removeColorGradient to udpate this list
  88264. * @returns the list of color gradients
  88265. */
  88266. getColorGradients(): Nullable<Array<ColorGradient>>;
  88267. /**
  88268. * Adds a new ramp gradient used to remap particle colors
  88269. * @param gradient defines the gradient to use (between 0 and 1)
  88270. * @param color defines the color to affect to the specified gradient
  88271. * @returns the current particle system
  88272. */
  88273. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  88274. /**
  88275. * Gets the current list of ramp gradients.
  88276. * You must use addRampGradient and removeRampGradient to udpate this list
  88277. * @returns the list of ramp gradients
  88278. */
  88279. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88280. /** Gets or sets a boolean indicating that ramp gradients must be used
  88281. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88282. */
  88283. useRampGradients: boolean;
  88284. /**
  88285. * Adds a new color remap gradient
  88286. * @param gradient defines the gradient to use (between 0 and 1)
  88287. * @param min defines the color remap minimal range
  88288. * @param max defines the color remap maximal range
  88289. * @returns the current particle system
  88290. */
  88291. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88292. /**
  88293. * Gets the current list of color remap gradients.
  88294. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88295. * @returns the list of color remap gradients
  88296. */
  88297. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88298. /**
  88299. * Adds a new alpha remap gradient
  88300. * @param gradient defines the gradient to use (between 0 and 1)
  88301. * @param min defines the alpha remap minimal range
  88302. * @param max defines the alpha remap maximal range
  88303. * @returns the current particle system
  88304. */
  88305. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88306. /**
  88307. * Gets the current list of alpha remap gradients.
  88308. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88309. * @returns the list of alpha remap gradients
  88310. */
  88311. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88312. /**
  88313. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88316. * @returns the emitter
  88317. */
  88318. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88319. /**
  88320. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88321. * @param radius The radius of the hemisphere to emit from
  88322. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88323. * @returns the emitter
  88324. */
  88325. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  88326. /**
  88327. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88328. * @param radius The radius of the sphere to emit from
  88329. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88330. * @returns the emitter
  88331. */
  88332. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  88333. /**
  88334. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88335. * @param radius The radius of the sphere to emit from
  88336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88338. * @returns the emitter
  88339. */
  88340. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88341. /**
  88342. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88343. * @param radius The radius of the emission cylinder
  88344. * @param height The height of the emission cylinder
  88345. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88346. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88347. * @returns the emitter
  88348. */
  88349. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  88350. /**
  88351. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88352. * @param radius The radius of the cylinder to emit from
  88353. * @param height The height of the emission cylinder
  88354. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88357. * @returns the emitter
  88358. */
  88359. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  88360. /**
  88361. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88362. * @param radius The radius of the cone to emit from
  88363. * @param angle The base angle of the cone
  88364. * @returns the emitter
  88365. */
  88366. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  88367. /**
  88368. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88371. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88372. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88373. * @returns the emitter
  88374. */
  88375. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88376. /**
  88377. * Get hosting scene
  88378. * @returns the scene
  88379. */
  88380. getScene(): Scene;
  88381. }
  88382. }
  88383. declare module BABYLON {
  88384. /**
  88385. * Creates an instance based on a source mesh.
  88386. */
  88387. export class InstancedMesh extends AbstractMesh {
  88388. private _sourceMesh;
  88389. private _currentLOD;
  88390. /** @hidden */
  88391. _indexInSourceMeshInstanceArray: number;
  88392. constructor(name: string, source: Mesh);
  88393. /**
  88394. * Returns the string "InstancedMesh".
  88395. */
  88396. getClassName(): string;
  88397. /** Gets the list of lights affecting that mesh */
  88398. readonly lightSources: Light[];
  88399. _resyncLightSources(): void;
  88400. _resyncLightSource(light: Light): void;
  88401. _removeLightSource(light: Light, dispose: boolean): void;
  88402. /**
  88403. * If the source mesh receives shadows
  88404. */
  88405. readonly receiveShadows: boolean;
  88406. /**
  88407. * The material of the source mesh
  88408. */
  88409. readonly material: Nullable<Material>;
  88410. /**
  88411. * Visibility of the source mesh
  88412. */
  88413. readonly visibility: number;
  88414. /**
  88415. * Skeleton of the source mesh
  88416. */
  88417. readonly skeleton: Nullable<Skeleton>;
  88418. /**
  88419. * Rendering ground id of the source mesh
  88420. */
  88421. renderingGroupId: number;
  88422. /**
  88423. * Returns the total number of vertices (integer).
  88424. */
  88425. getTotalVertices(): number;
  88426. /**
  88427. * Returns a positive integer : the total number of indices in this mesh geometry.
  88428. * @returns the numner of indices or zero if the mesh has no geometry.
  88429. */
  88430. getTotalIndices(): number;
  88431. /**
  88432. * The source mesh of the instance
  88433. */
  88434. readonly sourceMesh: Mesh;
  88435. /**
  88436. * Is this node ready to be used/rendered
  88437. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88438. * @return {boolean} is it ready
  88439. */
  88440. isReady(completeCheck?: boolean): boolean;
  88441. /**
  88442. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88443. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88444. * @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.
  88445. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88446. */
  88447. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88448. /**
  88449. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88450. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88451. * The `data` are either a numeric array either a Float32Array.
  88452. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88453. * 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).
  88454. * Note that a new underlying VertexBuffer object is created each call.
  88455. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88456. *
  88457. * Possible `kind` values :
  88458. * - VertexBuffer.PositionKind
  88459. * - VertexBuffer.UVKind
  88460. * - VertexBuffer.UV2Kind
  88461. * - VertexBuffer.UV3Kind
  88462. * - VertexBuffer.UV4Kind
  88463. * - VertexBuffer.UV5Kind
  88464. * - VertexBuffer.UV6Kind
  88465. * - VertexBuffer.ColorKind
  88466. * - VertexBuffer.MatricesIndicesKind
  88467. * - VertexBuffer.MatricesIndicesExtraKind
  88468. * - VertexBuffer.MatricesWeightsKind
  88469. * - VertexBuffer.MatricesWeightsExtraKind
  88470. *
  88471. * Returns the Mesh.
  88472. */
  88473. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88474. /**
  88475. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88476. * If the mesh has no geometry, it is simply returned as it is.
  88477. * The `data` are either a numeric array either a Float32Array.
  88478. * No new underlying VertexBuffer object is created.
  88479. * 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.
  88480. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88481. *
  88482. * Possible `kind` values :
  88483. * - VertexBuffer.PositionKind
  88484. * - VertexBuffer.UVKind
  88485. * - VertexBuffer.UV2Kind
  88486. * - VertexBuffer.UV3Kind
  88487. * - VertexBuffer.UV4Kind
  88488. * - VertexBuffer.UV5Kind
  88489. * - VertexBuffer.UV6Kind
  88490. * - VertexBuffer.ColorKind
  88491. * - VertexBuffer.MatricesIndicesKind
  88492. * - VertexBuffer.MatricesIndicesExtraKind
  88493. * - VertexBuffer.MatricesWeightsKind
  88494. * - VertexBuffer.MatricesWeightsExtraKind
  88495. *
  88496. * Returns the Mesh.
  88497. */
  88498. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88499. /**
  88500. * Sets the mesh indices.
  88501. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88502. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88503. * This method creates a new index buffer each call.
  88504. * Returns the Mesh.
  88505. */
  88506. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88507. /**
  88508. * Boolean : True if the mesh owns the requested kind of data.
  88509. */
  88510. isVerticesDataPresent(kind: string): boolean;
  88511. /**
  88512. * Returns an array of indices (IndicesArray).
  88513. */
  88514. getIndices(): Nullable<IndicesArray>;
  88515. readonly _positions: Nullable<Vector3[]>;
  88516. /**
  88517. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88518. * This means the mesh underlying bounding box and sphere are recomputed.
  88519. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88520. * @returns the current mesh
  88521. */
  88522. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88523. /** @hidden */
  88524. _preActivate(): InstancedMesh;
  88525. /** @hidden */
  88526. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88527. /** @hidden */
  88528. _postActivate(): void;
  88529. getWorldMatrix(): Matrix;
  88530. readonly isAnInstance: boolean;
  88531. /**
  88532. * Returns the current associated LOD AbstractMesh.
  88533. */
  88534. getLOD(camera: Camera): AbstractMesh;
  88535. /** @hidden */
  88536. _syncSubMeshes(): InstancedMesh;
  88537. /** @hidden */
  88538. _generatePointsArray(): boolean;
  88539. /**
  88540. * Creates a new InstancedMesh from the current mesh.
  88541. * - name (string) : the cloned mesh name
  88542. * - newParent (optional Node) : the optional Node to parent the clone to.
  88543. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88544. *
  88545. * Returns the clone.
  88546. */
  88547. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88548. /**
  88549. * Disposes the InstancedMesh.
  88550. * Returns nothing.
  88551. */
  88552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88553. }
  88554. interface Mesh {
  88555. /**
  88556. * Register a custom buffer that will be instanced
  88557. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88558. * @param kind defines the buffer kind
  88559. * @param stride defines the stride in floats
  88560. */
  88561. registerInstancedBuffer(kind: string, stride: number): void;
  88562. /** @hidden */
  88563. _userInstancedBuffersStorage: {
  88564. data: {
  88565. [key: string]: Float32Array;
  88566. };
  88567. sizes: {
  88568. [key: string]: number;
  88569. };
  88570. vertexBuffers: {
  88571. [key: string]: Nullable<VertexBuffer>;
  88572. };
  88573. strides: {
  88574. [key: string]: number;
  88575. };
  88576. };
  88577. }
  88578. interface AbstractMesh {
  88579. /**
  88580. * Object used to store instanced buffers defined by user
  88581. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88582. */
  88583. instancedBuffers: {
  88584. [key: string]: any;
  88585. };
  88586. }
  88587. }
  88588. declare module BABYLON {
  88589. /**
  88590. * Defines the options associated with the creation of a shader material.
  88591. */
  88592. export interface IShaderMaterialOptions {
  88593. /**
  88594. * Does the material work in alpha blend mode
  88595. */
  88596. needAlphaBlending: boolean;
  88597. /**
  88598. * Does the material work in alpha test mode
  88599. */
  88600. needAlphaTesting: boolean;
  88601. /**
  88602. * The list of attribute names used in the shader
  88603. */
  88604. attributes: string[];
  88605. /**
  88606. * The list of unifrom names used in the shader
  88607. */
  88608. uniforms: string[];
  88609. /**
  88610. * The list of UBO names used in the shader
  88611. */
  88612. uniformBuffers: string[];
  88613. /**
  88614. * The list of sampler names used in the shader
  88615. */
  88616. samplers: string[];
  88617. /**
  88618. * The list of defines used in the shader
  88619. */
  88620. defines: string[];
  88621. }
  88622. /**
  88623. * 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.
  88624. *
  88625. * This returned material effects how the mesh will look based on the code in the shaders.
  88626. *
  88627. * @see http://doc.babylonjs.com/how_to/shader_material
  88628. */
  88629. export class ShaderMaterial extends Material {
  88630. private _shaderPath;
  88631. private _options;
  88632. private _textures;
  88633. private _textureArrays;
  88634. private _floats;
  88635. private _ints;
  88636. private _floatsArrays;
  88637. private _colors3;
  88638. private _colors3Arrays;
  88639. private _colors4;
  88640. private _colors4Arrays;
  88641. private _vectors2;
  88642. private _vectors3;
  88643. private _vectors4;
  88644. private _matrices;
  88645. private _matrixArrays;
  88646. private _matrices3x3;
  88647. private _matrices2x2;
  88648. private _vectors2Arrays;
  88649. private _vectors3Arrays;
  88650. private _vectors4Arrays;
  88651. private _cachedWorldViewMatrix;
  88652. private _cachedWorldViewProjectionMatrix;
  88653. private _renderId;
  88654. private _multiview;
  88655. /**
  88656. * Instantiate a new shader material.
  88657. * 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.
  88658. * This returned material effects how the mesh will look based on the code in the shaders.
  88659. * @see http://doc.babylonjs.com/how_to/shader_material
  88660. * @param name Define the name of the material in the scene
  88661. * @param scene Define the scene the material belongs to
  88662. * @param shaderPath Defines the route to the shader code in one of three ways:
  88663. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88664. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88665. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88666. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88667. * @param options Define the options used to create the shader
  88668. */
  88669. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88670. /**
  88671. * Gets the shader path used to define the shader code
  88672. * It can be modified to trigger a new compilation
  88673. */
  88674. /**
  88675. * Sets the shader path used to define the shader code
  88676. * It can be modified to trigger a new compilation
  88677. */
  88678. shaderPath: any;
  88679. /**
  88680. * Gets the options used to compile the shader.
  88681. * They can be modified to trigger a new compilation
  88682. */
  88683. readonly options: IShaderMaterialOptions;
  88684. /**
  88685. * Gets the current class name of the material e.g. "ShaderMaterial"
  88686. * Mainly use in serialization.
  88687. * @returns the class name
  88688. */
  88689. getClassName(): string;
  88690. /**
  88691. * Specifies if the material will require alpha blending
  88692. * @returns a boolean specifying if alpha blending is needed
  88693. */
  88694. needAlphaBlending(): boolean;
  88695. /**
  88696. * Specifies if this material should be rendered in alpha test mode
  88697. * @returns a boolean specifying if an alpha test is needed.
  88698. */
  88699. needAlphaTesting(): boolean;
  88700. private _checkUniform;
  88701. /**
  88702. * Set a texture in the shader.
  88703. * @param name Define the name of the uniform samplers as defined in the shader
  88704. * @param texture Define the texture to bind to this sampler
  88705. * @return the material itself allowing "fluent" like uniform updates
  88706. */
  88707. setTexture(name: string, texture: Texture): ShaderMaterial;
  88708. /**
  88709. * Set a texture array in the shader.
  88710. * @param name Define the name of the uniform sampler array as defined in the shader
  88711. * @param textures Define the list of textures to bind to this sampler
  88712. * @return the material itself allowing "fluent" like uniform updates
  88713. */
  88714. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88715. /**
  88716. * Set a float in the shader.
  88717. * @param name Define the name of the uniform as defined in the shader
  88718. * @param value Define the value to give to the uniform
  88719. * @return the material itself allowing "fluent" like uniform updates
  88720. */
  88721. setFloat(name: string, value: number): ShaderMaterial;
  88722. /**
  88723. * Set a int in the shader.
  88724. * @param name Define the name of the uniform as defined in the shader
  88725. * @param value Define the value to give to the uniform
  88726. * @return the material itself allowing "fluent" like uniform updates
  88727. */
  88728. setInt(name: string, value: number): ShaderMaterial;
  88729. /**
  88730. * Set an array of floats in the shader.
  88731. * @param name Define the name of the uniform as defined in the shader
  88732. * @param value Define the value to give to the uniform
  88733. * @return the material itself allowing "fluent" like uniform updates
  88734. */
  88735. setFloats(name: string, value: number[]): ShaderMaterial;
  88736. /**
  88737. * Set a vec3 in the shader from a Color3.
  88738. * @param name Define the name of the uniform as defined in the shader
  88739. * @param value Define the value to give to the uniform
  88740. * @return the material itself allowing "fluent" like uniform updates
  88741. */
  88742. setColor3(name: string, value: Color3): ShaderMaterial;
  88743. /**
  88744. * Set a vec3 array in the shader from a Color3 array.
  88745. * @param name Define the name of the uniform as defined in the shader
  88746. * @param value Define the value to give to the uniform
  88747. * @return the material itself allowing "fluent" like uniform updates
  88748. */
  88749. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88750. /**
  88751. * Set a vec4 in the shader from a Color4.
  88752. * @param name Define the name of the uniform as defined in the shader
  88753. * @param value Define the value to give to the uniform
  88754. * @return the material itself allowing "fluent" like uniform updates
  88755. */
  88756. setColor4(name: string, value: Color4): ShaderMaterial;
  88757. /**
  88758. * Set a vec4 array in the shader from a Color4 array.
  88759. * @param name Define the name of the uniform as defined in the shader
  88760. * @param value Define the value to give to the uniform
  88761. * @return the material itself allowing "fluent" like uniform updates
  88762. */
  88763. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88764. /**
  88765. * Set a vec2 in the shader from a Vector2.
  88766. * @param name Define the name of the uniform as defined in the shader
  88767. * @param value Define the value to give to the uniform
  88768. * @return the material itself allowing "fluent" like uniform updates
  88769. */
  88770. setVector2(name: string, value: Vector2): ShaderMaterial;
  88771. /**
  88772. * Set a vec3 in the shader from a Vector3.
  88773. * @param name Define the name of the uniform as defined in the shader
  88774. * @param value Define the value to give to the uniform
  88775. * @return the material itself allowing "fluent" like uniform updates
  88776. */
  88777. setVector3(name: string, value: Vector3): ShaderMaterial;
  88778. /**
  88779. * Set a vec4 in the shader from a Vector4.
  88780. * @param name Define the name of the uniform as defined in the shader
  88781. * @param value Define the value to give to the uniform
  88782. * @return the material itself allowing "fluent" like uniform updates
  88783. */
  88784. setVector4(name: string, value: Vector4): ShaderMaterial;
  88785. /**
  88786. * Set a mat4 in the shader from a Matrix.
  88787. * @param name Define the name of the uniform as defined in the shader
  88788. * @param value Define the value to give to the uniform
  88789. * @return the material itself allowing "fluent" like uniform updates
  88790. */
  88791. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88792. /**
  88793. * Set a float32Array in the shader from a matrix array.
  88794. * @param name Define the name of the uniform as defined in the shader
  88795. * @param value Define the value to give to the uniform
  88796. * @return the material itself allowing "fluent" like uniform updates
  88797. */
  88798. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88799. /**
  88800. * Set a mat3 in the shader from a Float32Array.
  88801. * @param name Define the name of the uniform as defined in the shader
  88802. * @param value Define the value to give to the uniform
  88803. * @return the material itself allowing "fluent" like uniform updates
  88804. */
  88805. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88806. /**
  88807. * Set a mat2 in the shader from a Float32Array.
  88808. * @param name Define the name of the uniform as defined in the shader
  88809. * @param value Define the value to give to the uniform
  88810. * @return the material itself allowing "fluent" like uniform updates
  88811. */
  88812. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88813. /**
  88814. * Set a vec2 array in the shader from a number array.
  88815. * @param name Define the name of the uniform as defined in the shader
  88816. * @param value Define the value to give to the uniform
  88817. * @return the material itself allowing "fluent" like uniform updates
  88818. */
  88819. setArray2(name: string, value: number[]): ShaderMaterial;
  88820. /**
  88821. * Set a vec3 array in the shader from a number array.
  88822. * @param name Define the name of the uniform as defined in the shader
  88823. * @param value Define the value to give to the uniform
  88824. * @return the material itself allowing "fluent" like uniform updates
  88825. */
  88826. setArray3(name: string, value: number[]): ShaderMaterial;
  88827. /**
  88828. * Set a vec4 array in the shader from a number array.
  88829. * @param name Define the name of the uniform as defined in the shader
  88830. * @param value Define the value to give to the uniform
  88831. * @return the material itself allowing "fluent" like uniform updates
  88832. */
  88833. setArray4(name: string, value: number[]): ShaderMaterial;
  88834. private _checkCache;
  88835. /**
  88836. * Specifies that the submesh is ready to be used
  88837. * @param mesh defines the mesh to check
  88838. * @param subMesh defines which submesh to check
  88839. * @param useInstances specifies that instances should be used
  88840. * @returns a boolean indicating that the submesh is ready or not
  88841. */
  88842. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88843. /**
  88844. * Checks if the material is ready to render the requested mesh
  88845. * @param mesh Define the mesh to render
  88846. * @param useInstances Define whether or not the material is used with instances
  88847. * @returns true if ready, otherwise false
  88848. */
  88849. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88850. /**
  88851. * Binds the world matrix to the material
  88852. * @param world defines the world transformation matrix
  88853. */
  88854. bindOnlyWorldMatrix(world: Matrix): void;
  88855. /**
  88856. * Binds the material to the mesh
  88857. * @param world defines the world transformation matrix
  88858. * @param mesh defines the mesh to bind the material to
  88859. */
  88860. bind(world: Matrix, mesh?: Mesh): void;
  88861. /**
  88862. * Gets the active textures from the material
  88863. * @returns an array of textures
  88864. */
  88865. getActiveTextures(): BaseTexture[];
  88866. /**
  88867. * Specifies if the material uses a texture
  88868. * @param texture defines the texture to check against the material
  88869. * @returns a boolean specifying if the material uses the texture
  88870. */
  88871. hasTexture(texture: BaseTexture): boolean;
  88872. /**
  88873. * Makes a duplicate of the material, and gives it a new name
  88874. * @param name defines the new name for the duplicated material
  88875. * @returns the cloned material
  88876. */
  88877. clone(name: string): ShaderMaterial;
  88878. /**
  88879. * Disposes the material
  88880. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88881. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88882. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88883. */
  88884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88885. /**
  88886. * Serializes this material in a JSON representation
  88887. * @returns the serialized material object
  88888. */
  88889. serialize(): any;
  88890. /**
  88891. * Creates a shader material from parsed shader material data
  88892. * @param source defines the JSON represnetation of the material
  88893. * @param scene defines the hosting scene
  88894. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88895. * @returns a new material
  88896. */
  88897. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88898. }
  88899. }
  88900. declare module BABYLON {
  88901. /** @hidden */
  88902. export var colorPixelShader: {
  88903. name: string;
  88904. shader: string;
  88905. };
  88906. }
  88907. declare module BABYLON {
  88908. /** @hidden */
  88909. export var colorVertexShader: {
  88910. name: string;
  88911. shader: string;
  88912. };
  88913. }
  88914. declare module BABYLON {
  88915. /**
  88916. * Line mesh
  88917. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88918. */
  88919. export class LinesMesh extends Mesh {
  88920. /**
  88921. * If vertex color should be applied to the mesh
  88922. */
  88923. readonly useVertexColor?: boolean | undefined;
  88924. /**
  88925. * If vertex alpha should be applied to the mesh
  88926. */
  88927. readonly useVertexAlpha?: boolean | undefined;
  88928. /**
  88929. * Color of the line (Default: White)
  88930. */
  88931. color: Color3;
  88932. /**
  88933. * Alpha of the line (Default: 1)
  88934. */
  88935. alpha: number;
  88936. /**
  88937. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88938. * This margin is expressed in world space coordinates, so its value may vary.
  88939. * Default value is 0.1
  88940. */
  88941. intersectionThreshold: number;
  88942. private _colorShader;
  88943. private color4;
  88944. /**
  88945. * Creates a new LinesMesh
  88946. * @param name defines the name
  88947. * @param scene defines the hosting scene
  88948. * @param parent defines the parent mesh if any
  88949. * @param source defines the optional source LinesMesh used to clone data from
  88950. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88951. * When false, achieved by calling a clone(), also passing False.
  88952. * This will make creation of children, recursive.
  88953. * @param useVertexColor defines if this LinesMesh supports vertex color
  88954. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88955. */
  88956. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88957. /**
  88958. * If vertex color should be applied to the mesh
  88959. */
  88960. useVertexColor?: boolean | undefined,
  88961. /**
  88962. * If vertex alpha should be applied to the mesh
  88963. */
  88964. useVertexAlpha?: boolean | undefined);
  88965. private _addClipPlaneDefine;
  88966. private _removeClipPlaneDefine;
  88967. isReady(): boolean;
  88968. /**
  88969. * Returns the string "LineMesh"
  88970. */
  88971. getClassName(): string;
  88972. /**
  88973. * @hidden
  88974. */
  88975. /**
  88976. * @hidden
  88977. */
  88978. material: Material;
  88979. /**
  88980. * @hidden
  88981. */
  88982. readonly checkCollisions: boolean;
  88983. /** @hidden */
  88984. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88985. /** @hidden */
  88986. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88987. /**
  88988. * Disposes of the line mesh
  88989. * @param doNotRecurse If children should be disposed
  88990. */
  88991. dispose(doNotRecurse?: boolean): void;
  88992. /**
  88993. * Returns a new LineMesh object cloned from the current one.
  88994. */
  88995. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  88996. /**
  88997. * Creates a new InstancedLinesMesh object from the mesh model.
  88998. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88999. * @param name defines the name of the new instance
  89000. * @returns a new InstancedLinesMesh
  89001. */
  89002. createInstance(name: string): InstancedLinesMesh;
  89003. }
  89004. /**
  89005. * Creates an instance based on a source LinesMesh
  89006. */
  89007. export class InstancedLinesMesh extends InstancedMesh {
  89008. /**
  89009. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  89010. * This margin is expressed in world space coordinates, so its value may vary.
  89011. * Initilized with the intersectionThreshold value of the source LinesMesh
  89012. */
  89013. intersectionThreshold: number;
  89014. constructor(name: string, source: LinesMesh);
  89015. /**
  89016. * Returns the string "InstancedLinesMesh".
  89017. */
  89018. getClassName(): string;
  89019. }
  89020. }
  89021. declare module BABYLON {
  89022. /** @hidden */
  89023. export var linePixelShader: {
  89024. name: string;
  89025. shader: string;
  89026. };
  89027. }
  89028. declare module BABYLON {
  89029. /** @hidden */
  89030. export var lineVertexShader: {
  89031. name: string;
  89032. shader: string;
  89033. };
  89034. }
  89035. declare module BABYLON {
  89036. interface AbstractMesh {
  89037. /**
  89038. * Gets the edgesRenderer associated with the mesh
  89039. */
  89040. edgesRenderer: Nullable<EdgesRenderer>;
  89041. }
  89042. interface LinesMesh {
  89043. /**
  89044. * Enables the edge rendering mode on the mesh.
  89045. * This mode makes the mesh edges visible
  89046. * @param epsilon defines the maximal distance between two angles to detect a face
  89047. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89048. * @returns the currentAbstractMesh
  89049. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89050. */
  89051. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89052. }
  89053. interface InstancedLinesMesh {
  89054. /**
  89055. * Enables the edge rendering mode on the mesh.
  89056. * This mode makes the mesh edges visible
  89057. * @param epsilon defines the maximal distance between two angles to detect a face
  89058. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89059. * @returns the current InstancedLinesMesh
  89060. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89061. */
  89062. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89063. }
  89064. /**
  89065. * Defines the minimum contract an Edges renderer should follow.
  89066. */
  89067. export interface IEdgesRenderer extends IDisposable {
  89068. /**
  89069. * Gets or sets a boolean indicating if the edgesRenderer is active
  89070. */
  89071. isEnabled: boolean;
  89072. /**
  89073. * Renders the edges of the attached mesh,
  89074. */
  89075. render(): void;
  89076. /**
  89077. * Checks wether or not the edges renderer is ready to render.
  89078. * @return true if ready, otherwise false.
  89079. */
  89080. isReady(): boolean;
  89081. }
  89082. /**
  89083. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89084. */
  89085. export class EdgesRenderer implements IEdgesRenderer {
  89086. /**
  89087. * Define the size of the edges with an orthographic camera
  89088. */
  89089. edgesWidthScalerForOrthographic: number;
  89090. /**
  89091. * Define the size of the edges with a perspective camera
  89092. */
  89093. edgesWidthScalerForPerspective: number;
  89094. protected _source: AbstractMesh;
  89095. protected _linesPositions: number[];
  89096. protected _linesNormals: number[];
  89097. protected _linesIndices: number[];
  89098. protected _epsilon: number;
  89099. protected _indicesCount: number;
  89100. protected _lineShader: ShaderMaterial;
  89101. protected _ib: DataBuffer;
  89102. protected _buffers: {
  89103. [key: string]: Nullable<VertexBuffer>;
  89104. };
  89105. protected _checkVerticesInsteadOfIndices: boolean;
  89106. private _meshRebuildObserver;
  89107. private _meshDisposeObserver;
  89108. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89109. isEnabled: boolean;
  89110. /**
  89111. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89112. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89113. * @param source Mesh used to create edges
  89114. * @param epsilon sum of angles in adjacency to check for edge
  89115. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89116. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89117. */
  89118. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89119. protected _prepareRessources(): void;
  89120. /** @hidden */
  89121. _rebuild(): void;
  89122. /**
  89123. * Releases the required resources for the edges renderer
  89124. */
  89125. dispose(): void;
  89126. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89127. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89128. /**
  89129. * Checks if the pair of p0 and p1 is en edge
  89130. * @param faceIndex
  89131. * @param edge
  89132. * @param faceNormals
  89133. * @param p0
  89134. * @param p1
  89135. * @private
  89136. */
  89137. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89138. /**
  89139. * push line into the position, normal and index buffer
  89140. * @protected
  89141. */
  89142. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89143. /**
  89144. * Generates lines edges from adjacencjes
  89145. * @private
  89146. */
  89147. _generateEdgesLines(): void;
  89148. /**
  89149. * Checks wether or not the edges renderer is ready to render.
  89150. * @return true if ready, otherwise false.
  89151. */
  89152. isReady(): boolean;
  89153. /**
  89154. * Renders the edges of the attached mesh,
  89155. */
  89156. render(): void;
  89157. }
  89158. /**
  89159. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89160. */
  89161. export class LineEdgesRenderer extends EdgesRenderer {
  89162. /**
  89163. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89164. * @param source LineMesh used to generate edges
  89165. * @param epsilon not important (specified angle for edge detection)
  89166. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89167. */
  89168. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89169. /**
  89170. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89171. */
  89172. _generateEdgesLines(): void;
  89173. }
  89174. }
  89175. declare module BABYLON {
  89176. /**
  89177. * This represents the object necessary to create a rendering group.
  89178. * This is exclusively used and created by the rendering manager.
  89179. * To modify the behavior, you use the available helpers in your scene or meshes.
  89180. * @hidden
  89181. */
  89182. export class RenderingGroup {
  89183. index: number;
  89184. private static _zeroVector;
  89185. private _scene;
  89186. private _opaqueSubMeshes;
  89187. private _transparentSubMeshes;
  89188. private _alphaTestSubMeshes;
  89189. private _depthOnlySubMeshes;
  89190. private _particleSystems;
  89191. private _spriteManagers;
  89192. private _opaqueSortCompareFn;
  89193. private _alphaTestSortCompareFn;
  89194. private _transparentSortCompareFn;
  89195. private _renderOpaque;
  89196. private _renderAlphaTest;
  89197. private _renderTransparent;
  89198. /** @hidden */
  89199. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89200. onBeforeTransparentRendering: () => void;
  89201. /**
  89202. * Set the opaque sort comparison function.
  89203. * If null the sub meshes will be render in the order they were created
  89204. */
  89205. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89206. /**
  89207. * Set the alpha test sort comparison function.
  89208. * If null the sub meshes will be render in the order they were created
  89209. */
  89210. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89211. /**
  89212. * Set the transparent sort comparison function.
  89213. * If null the sub meshes will be render in the order they were created
  89214. */
  89215. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  89216. /**
  89217. * Creates a new rendering group.
  89218. * @param index The rendering group index
  89219. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89220. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89221. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89222. */
  89223. 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>);
  89224. /**
  89225. * Render all the sub meshes contained in the group.
  89226. * @param customRenderFunction Used to override the default render behaviour of the group.
  89227. * @returns true if rendered some submeshes.
  89228. */
  89229. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89230. /**
  89231. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89232. * @param subMeshes The submeshes to render
  89233. */
  89234. private renderOpaqueSorted;
  89235. /**
  89236. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89237. * @param subMeshes The submeshes to render
  89238. */
  89239. private renderAlphaTestSorted;
  89240. /**
  89241. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89242. * @param subMeshes The submeshes to render
  89243. */
  89244. private renderTransparentSorted;
  89245. /**
  89246. * Renders the submeshes in a specified order.
  89247. * @param subMeshes The submeshes to sort before render
  89248. * @param sortCompareFn The comparison function use to sort
  89249. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89250. * @param transparent Specifies to activate blending if true
  89251. */
  89252. private static renderSorted;
  89253. /**
  89254. * Renders the submeshes in the order they were dispatched (no sort applied).
  89255. * @param subMeshes The submeshes to render
  89256. */
  89257. private static renderUnsorted;
  89258. /**
  89259. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89260. * are rendered back to front if in the same alpha index.
  89261. *
  89262. * @param a The first submesh
  89263. * @param b The second submesh
  89264. * @returns The result of the comparison
  89265. */
  89266. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89267. /**
  89268. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89269. * are rendered back to front.
  89270. *
  89271. * @param a The first submesh
  89272. * @param b The second submesh
  89273. * @returns The result of the comparison
  89274. */
  89275. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89276. /**
  89277. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89278. * are rendered front to back (prevent overdraw).
  89279. *
  89280. * @param a The first submesh
  89281. * @param b The second submesh
  89282. * @returns The result of the comparison
  89283. */
  89284. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89285. /**
  89286. * Resets the different lists of submeshes to prepare a new frame.
  89287. */
  89288. prepare(): void;
  89289. dispose(): void;
  89290. /**
  89291. * Inserts the submesh in its correct queue depending on its material.
  89292. * @param subMesh The submesh to dispatch
  89293. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89294. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89295. */
  89296. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89297. dispatchSprites(spriteManager: ISpriteManager): void;
  89298. dispatchParticles(particleSystem: IParticleSystem): void;
  89299. private _renderParticles;
  89300. private _renderSprites;
  89301. }
  89302. }
  89303. declare module BABYLON {
  89304. /**
  89305. * Interface describing the different options available in the rendering manager
  89306. * regarding Auto Clear between groups.
  89307. */
  89308. export interface IRenderingManagerAutoClearSetup {
  89309. /**
  89310. * Defines whether or not autoclear is enable.
  89311. */
  89312. autoClear: boolean;
  89313. /**
  89314. * Defines whether or not to autoclear the depth buffer.
  89315. */
  89316. depth: boolean;
  89317. /**
  89318. * Defines whether or not to autoclear the stencil buffer.
  89319. */
  89320. stencil: boolean;
  89321. }
  89322. /**
  89323. * This class is used by the onRenderingGroupObservable
  89324. */
  89325. export class RenderingGroupInfo {
  89326. /**
  89327. * The Scene that being rendered
  89328. */
  89329. scene: Scene;
  89330. /**
  89331. * The camera currently used for the rendering pass
  89332. */
  89333. camera: Nullable<Camera>;
  89334. /**
  89335. * The ID of the renderingGroup being processed
  89336. */
  89337. renderingGroupId: number;
  89338. }
  89339. /**
  89340. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89341. * It is enable to manage the different groups as well as the different necessary sort functions.
  89342. * This should not be used directly aside of the few static configurations
  89343. */
  89344. export class RenderingManager {
  89345. /**
  89346. * The max id used for rendering groups (not included)
  89347. */
  89348. static MAX_RENDERINGGROUPS: number;
  89349. /**
  89350. * The min id used for rendering groups (included)
  89351. */
  89352. static MIN_RENDERINGGROUPS: number;
  89353. /**
  89354. * Used to globally prevent autoclearing scenes.
  89355. */
  89356. static AUTOCLEAR: boolean;
  89357. /**
  89358. * @hidden
  89359. */
  89360. _useSceneAutoClearSetup: boolean;
  89361. private _scene;
  89362. private _renderingGroups;
  89363. private _depthStencilBufferAlreadyCleaned;
  89364. private _autoClearDepthStencil;
  89365. private _customOpaqueSortCompareFn;
  89366. private _customAlphaTestSortCompareFn;
  89367. private _customTransparentSortCompareFn;
  89368. private _renderingGroupInfo;
  89369. /**
  89370. * Instantiates a new rendering group for a particular scene
  89371. * @param scene Defines the scene the groups belongs to
  89372. */
  89373. constructor(scene: Scene);
  89374. private _clearDepthStencilBuffer;
  89375. /**
  89376. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89377. * @hidden
  89378. */
  89379. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89380. /**
  89381. * Resets the different information of the group to prepare a new frame
  89382. * @hidden
  89383. */
  89384. reset(): void;
  89385. /**
  89386. * Dispose and release the group and its associated resources.
  89387. * @hidden
  89388. */
  89389. dispose(): void;
  89390. /**
  89391. * Clear the info related to rendering groups preventing retention points during dispose.
  89392. */
  89393. freeRenderingGroups(): void;
  89394. private _prepareRenderingGroup;
  89395. /**
  89396. * Add a sprite manager to the rendering manager in order to render it this frame.
  89397. * @param spriteManager Define the sprite manager to render
  89398. */
  89399. dispatchSprites(spriteManager: ISpriteManager): void;
  89400. /**
  89401. * Add a particle system to the rendering manager in order to render it this frame.
  89402. * @param particleSystem Define the particle system to render
  89403. */
  89404. dispatchParticles(particleSystem: IParticleSystem): void;
  89405. /**
  89406. * Add a submesh to the manager in order to render it this frame
  89407. * @param subMesh The submesh to dispatch
  89408. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89409. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89410. */
  89411. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89412. /**
  89413. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89414. * This allowed control for front to back rendering or reversly depending of the special needs.
  89415. *
  89416. * @param renderingGroupId The rendering group id corresponding to its index
  89417. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89418. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89419. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89420. */
  89421. 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;
  89422. /**
  89423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89424. *
  89425. * @param renderingGroupId The rendering group id corresponding to its index
  89426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89427. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89428. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89429. */
  89430. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89431. /**
  89432. * Gets the current auto clear configuration for one rendering group of the rendering
  89433. * manager.
  89434. * @param index the rendering group index to get the information for
  89435. * @returns The auto clear setup for the requested rendering group
  89436. */
  89437. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89438. }
  89439. }
  89440. declare module BABYLON {
  89441. /**
  89442. * This Helps creating a texture that will be created from a camera in your scene.
  89443. * It is basically a dynamic texture that could be used to create special effects for instance.
  89444. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  89445. */
  89446. export class RenderTargetTexture extends Texture {
  89447. isCube: boolean;
  89448. /**
  89449. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  89450. */
  89451. static readonly REFRESHRATE_RENDER_ONCE: number;
  89452. /**
  89453. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  89454. */
  89455. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  89456. /**
  89457. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  89458. * the central point of your effect and can save a lot of performances.
  89459. */
  89460. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  89461. /**
  89462. * Use this predicate to dynamically define the list of mesh you want to render.
  89463. * If set, the renderList property will be overwritten.
  89464. */
  89465. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  89466. private _renderList;
  89467. /**
  89468. * Use this list to define the list of mesh you want to render.
  89469. */
  89470. renderList: Nullable<Array<AbstractMesh>>;
  89471. private _hookArray;
  89472. /**
  89473. * Define if particles should be rendered in your texture.
  89474. */
  89475. renderParticles: boolean;
  89476. /**
  89477. * Define if sprites should be rendered in your texture.
  89478. */
  89479. renderSprites: boolean;
  89480. /**
  89481. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  89482. */
  89483. coordinatesMode: number;
  89484. /**
  89485. * Define the camera used to render the texture.
  89486. */
  89487. activeCamera: Nullable<Camera>;
  89488. /**
  89489. * Override the render function of the texture with your own one.
  89490. */
  89491. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  89492. /**
  89493. * Define if camera post processes should be use while rendering the texture.
  89494. */
  89495. useCameraPostProcesses: boolean;
  89496. /**
  89497. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  89498. */
  89499. ignoreCameraViewport: boolean;
  89500. private _postProcessManager;
  89501. private _postProcesses;
  89502. private _resizeObserver;
  89503. /**
  89504. * An event triggered when the texture is unbind.
  89505. */
  89506. onBeforeBindObservable: Observable<RenderTargetTexture>;
  89507. /**
  89508. * An event triggered when the texture is unbind.
  89509. */
  89510. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  89511. private _onAfterUnbindObserver;
  89512. /**
  89513. * Set a after unbind callback in the texture.
  89514. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  89515. */
  89516. onAfterUnbind: () => void;
  89517. /**
  89518. * An event triggered before rendering the texture
  89519. */
  89520. onBeforeRenderObservable: Observable<number>;
  89521. private _onBeforeRenderObserver;
  89522. /**
  89523. * Set a before render callback in the texture.
  89524. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  89525. */
  89526. onBeforeRender: (faceIndex: number) => void;
  89527. /**
  89528. * An event triggered after rendering the texture
  89529. */
  89530. onAfterRenderObservable: Observable<number>;
  89531. private _onAfterRenderObserver;
  89532. /**
  89533. * Set a after render callback in the texture.
  89534. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  89535. */
  89536. onAfterRender: (faceIndex: number) => void;
  89537. /**
  89538. * An event triggered after the texture clear
  89539. */
  89540. onClearObservable: Observable<Engine>;
  89541. private _onClearObserver;
  89542. /**
  89543. * Set a clear callback in the texture.
  89544. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  89545. */
  89546. onClear: (Engine: Engine) => void;
  89547. /**
  89548. * An event triggered when the texture is resized.
  89549. */
  89550. onResizeObservable: Observable<RenderTargetTexture>;
  89551. /**
  89552. * Define the clear color of the Render Target if it should be different from the scene.
  89553. */
  89554. clearColor: Color4;
  89555. protected _size: number | {
  89556. width: number;
  89557. height: number;
  89558. };
  89559. protected _initialSizeParameter: number | {
  89560. width: number;
  89561. height: number;
  89562. } | {
  89563. ratio: number;
  89564. };
  89565. protected _sizeRatio: Nullable<number>;
  89566. /** @hidden */
  89567. _generateMipMaps: boolean;
  89568. protected _renderingManager: RenderingManager;
  89569. /** @hidden */
  89570. _waitingRenderList: string[];
  89571. protected _doNotChangeAspectRatio: boolean;
  89572. protected _currentRefreshId: number;
  89573. protected _refreshRate: number;
  89574. protected _textureMatrix: Matrix;
  89575. protected _samples: number;
  89576. protected _renderTargetOptions: RenderTargetCreationOptions;
  89577. /**
  89578. * Gets render target creation options that were used.
  89579. */
  89580. readonly renderTargetOptions: RenderTargetCreationOptions;
  89581. protected _engine: Engine;
  89582. protected _onRatioRescale(): void;
  89583. /**
  89584. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  89585. * It must define where the camera used to render the texture is set
  89586. */
  89587. boundingBoxPosition: Vector3;
  89588. private _boundingBoxSize;
  89589. /**
  89590. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  89591. * When defined, the cubemap will switch to local mode
  89592. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89593. * @example https://www.babylonjs-playground.com/#RNASML
  89594. */
  89595. boundingBoxSize: Vector3;
  89596. /**
  89597. * In case the RTT has been created with a depth texture, get the associated
  89598. * depth texture.
  89599. * Otherwise, return null.
  89600. */
  89601. depthStencilTexture: Nullable<InternalTexture>;
  89602. /**
  89603. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  89604. * or used a shadow, depth texture...
  89605. * @param name The friendly name of the texture
  89606. * @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)
  89607. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  89608. * @param generateMipMaps True if mip maps need to be generated after render.
  89609. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  89610. * @param type The type of the buffer in the RTT (int, half float, float...)
  89611. * @param isCube True if a cube texture needs to be created
  89612. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  89613. * @param generateDepthBuffer True to generate a depth buffer
  89614. * @param generateStencilBuffer True to generate a stencil buffer
  89615. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  89616. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  89617. * @param delayAllocation if the texture allocation should be delayed (default: false)
  89618. */
  89619. constructor(name: string, size: number | {
  89620. width: number;
  89621. height: number;
  89622. } | {
  89623. ratio: number;
  89624. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  89625. /**
  89626. * Creates a depth stencil texture.
  89627. * This is only available in WebGL 2 or with the depth texture extension available.
  89628. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  89629. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  89630. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  89631. */
  89632. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  89633. private _processSizeParameter;
  89634. /**
  89635. * Define the number of samples to use in case of MSAA.
  89636. * It defaults to one meaning no MSAA has been enabled.
  89637. */
  89638. samples: number;
  89639. /**
  89640. * Resets the refresh counter of the texture and start bak from scratch.
  89641. * Could be useful to regenerate the texture if it is setup to render only once.
  89642. */
  89643. resetRefreshCounter(): void;
  89644. /**
  89645. * Define the refresh rate of the texture or the rendering frequency.
  89646. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89647. */
  89648. refreshRate: number;
  89649. /**
  89650. * Adds a post process to the render target rendering passes.
  89651. * @param postProcess define the post process to add
  89652. */
  89653. addPostProcess(postProcess: PostProcess): void;
  89654. /**
  89655. * Clear all the post processes attached to the render target
  89656. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  89657. */
  89658. clearPostProcesses(dispose?: boolean): void;
  89659. /**
  89660. * Remove one of the post process from the list of attached post processes to the texture
  89661. * @param postProcess define the post process to remove from the list
  89662. */
  89663. removePostProcess(postProcess: PostProcess): void;
  89664. /** @hidden */
  89665. _shouldRender(): boolean;
  89666. /**
  89667. * Gets the actual render size of the texture.
  89668. * @returns the width of the render size
  89669. */
  89670. getRenderSize(): number;
  89671. /**
  89672. * Gets the actual render width of the texture.
  89673. * @returns the width of the render size
  89674. */
  89675. getRenderWidth(): number;
  89676. /**
  89677. * Gets the actual render height of the texture.
  89678. * @returns the height of the render size
  89679. */
  89680. getRenderHeight(): number;
  89681. /**
  89682. * Get if the texture can be rescaled or not.
  89683. */
  89684. readonly canRescale: boolean;
  89685. /**
  89686. * Resize the texture using a ratio.
  89687. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  89688. */
  89689. scale(ratio: number): void;
  89690. /**
  89691. * Get the texture reflection matrix used to rotate/transform the reflection.
  89692. * @returns the reflection matrix
  89693. */
  89694. getReflectionTextureMatrix(): Matrix;
  89695. /**
  89696. * Resize the texture to a new desired size.
  89697. * Be carrefull as it will recreate all the data in the new texture.
  89698. * @param size Define the new size. It can be:
  89699. * - a number for squared texture,
  89700. * - an object containing { width: number, height: number }
  89701. * - or an object containing a ratio { ratio: number }
  89702. */
  89703. resize(size: number | {
  89704. width: number;
  89705. height: number;
  89706. } | {
  89707. ratio: number;
  89708. }): void;
  89709. /**
  89710. * Renders all the objects from the render list into the texture.
  89711. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  89712. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  89713. */
  89714. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  89715. private _bestReflectionRenderTargetDimension;
  89716. /**
  89717. * @hidden
  89718. * @param faceIndex face index to bind to if this is a cubetexture
  89719. */
  89720. _bindFrameBuffer(faceIndex?: number): void;
  89721. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  89722. private renderToTarget;
  89723. /**
  89724. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89725. * This allowed control for front to back rendering or reversly depending of the special needs.
  89726. *
  89727. * @param renderingGroupId The rendering group id corresponding to its index
  89728. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89729. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89730. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89731. */
  89732. 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;
  89733. /**
  89734. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89735. *
  89736. * @param renderingGroupId The rendering group id corresponding to its index
  89737. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89738. */
  89739. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  89740. /**
  89741. * Clones the texture.
  89742. * @returns the cloned texture
  89743. */
  89744. clone(): RenderTargetTexture;
  89745. /**
  89746. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  89747. * @returns The JSON representation of the texture
  89748. */
  89749. serialize(): any;
  89750. /**
  89751. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  89752. */
  89753. disposeFramebufferObjects(): void;
  89754. /**
  89755. * Dispose the texture and release its associated resources.
  89756. */
  89757. dispose(): void;
  89758. /** @hidden */
  89759. _rebuild(): void;
  89760. /**
  89761. * Clear the info related to rendering groups preventing retention point in material dispose.
  89762. */
  89763. freeRenderingGroups(): void;
  89764. /**
  89765. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  89766. * @returns the view count
  89767. */
  89768. getViewCount(): number;
  89769. }
  89770. }
  89771. declare module BABYLON {
  89772. /**
  89773. * Options for compiling materials.
  89774. */
  89775. export interface IMaterialCompilationOptions {
  89776. /**
  89777. * Defines whether clip planes are enabled.
  89778. */
  89779. clipPlane: boolean;
  89780. /**
  89781. * Defines whether instances are enabled.
  89782. */
  89783. useInstances: boolean;
  89784. }
  89785. /**
  89786. * Base class for the main features of a material in Babylon.js
  89787. */
  89788. export class Material implements IAnimatable {
  89789. /**
  89790. * Returns the triangle fill mode
  89791. */
  89792. static readonly TriangleFillMode: number;
  89793. /**
  89794. * Returns the wireframe mode
  89795. */
  89796. static readonly WireFrameFillMode: number;
  89797. /**
  89798. * Returns the point fill mode
  89799. */
  89800. static readonly PointFillMode: number;
  89801. /**
  89802. * Returns the point list draw mode
  89803. */
  89804. static readonly PointListDrawMode: number;
  89805. /**
  89806. * Returns the line list draw mode
  89807. */
  89808. static readonly LineListDrawMode: number;
  89809. /**
  89810. * Returns the line loop draw mode
  89811. */
  89812. static readonly LineLoopDrawMode: number;
  89813. /**
  89814. * Returns the line strip draw mode
  89815. */
  89816. static readonly LineStripDrawMode: number;
  89817. /**
  89818. * Returns the triangle strip draw mode
  89819. */
  89820. static readonly TriangleStripDrawMode: number;
  89821. /**
  89822. * Returns the triangle fan draw mode
  89823. */
  89824. static readonly TriangleFanDrawMode: number;
  89825. /**
  89826. * Stores the clock-wise side orientation
  89827. */
  89828. static readonly ClockWiseSideOrientation: number;
  89829. /**
  89830. * Stores the counter clock-wise side orientation
  89831. */
  89832. static readonly CounterClockWiseSideOrientation: number;
  89833. /**
  89834. * The dirty texture flag value
  89835. */
  89836. static readonly TextureDirtyFlag: number;
  89837. /**
  89838. * The dirty light flag value
  89839. */
  89840. static readonly LightDirtyFlag: number;
  89841. /**
  89842. * The dirty fresnel flag value
  89843. */
  89844. static readonly FresnelDirtyFlag: number;
  89845. /**
  89846. * The dirty attribute flag value
  89847. */
  89848. static readonly AttributesDirtyFlag: number;
  89849. /**
  89850. * The dirty misc flag value
  89851. */
  89852. static readonly MiscDirtyFlag: number;
  89853. /**
  89854. * The all dirty flag value
  89855. */
  89856. static readonly AllDirtyFlag: number;
  89857. /**
  89858. * The ID of the material
  89859. */
  89860. id: string;
  89861. /**
  89862. * Gets or sets the unique id of the material
  89863. */
  89864. uniqueId: number;
  89865. /**
  89866. * The name of the material
  89867. */
  89868. name: string;
  89869. /**
  89870. * Gets or sets user defined metadata
  89871. */
  89872. metadata: any;
  89873. /**
  89874. * For internal use only. Please do not use.
  89875. */
  89876. reservedDataStore: any;
  89877. /**
  89878. * Specifies if the ready state should be checked on each call
  89879. */
  89880. checkReadyOnEveryCall: boolean;
  89881. /**
  89882. * Specifies if the ready state should be checked once
  89883. */
  89884. checkReadyOnlyOnce: boolean;
  89885. /**
  89886. * The state of the material
  89887. */
  89888. state: string;
  89889. /**
  89890. * The alpha value of the material
  89891. */
  89892. protected _alpha: number;
  89893. /**
  89894. * List of inspectable custom properties (used by the Inspector)
  89895. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89896. */
  89897. inspectableCustomProperties: IInspectable[];
  89898. /**
  89899. * Sets the alpha value of the material
  89900. */
  89901. /**
  89902. * Gets the alpha value of the material
  89903. */
  89904. alpha: number;
  89905. /**
  89906. * Specifies if back face culling is enabled
  89907. */
  89908. protected _backFaceCulling: boolean;
  89909. /**
  89910. * Sets the back-face culling state
  89911. */
  89912. /**
  89913. * Gets the back-face culling state
  89914. */
  89915. backFaceCulling: boolean;
  89916. /**
  89917. * Stores the value for side orientation
  89918. */
  89919. sideOrientation: number;
  89920. /**
  89921. * Callback triggered when the material is compiled
  89922. */
  89923. onCompiled: Nullable<(effect: Effect) => void>;
  89924. /**
  89925. * Callback triggered when an error occurs
  89926. */
  89927. onError: Nullable<(effect: Effect, errors: string) => void>;
  89928. /**
  89929. * Callback triggered to get the render target textures
  89930. */
  89931. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  89932. /**
  89933. * Gets a boolean indicating that current material needs to register RTT
  89934. */
  89935. readonly hasRenderTargetTextures: boolean;
  89936. /**
  89937. * Specifies if the material should be serialized
  89938. */
  89939. doNotSerialize: boolean;
  89940. /**
  89941. * @hidden
  89942. */
  89943. _storeEffectOnSubMeshes: boolean;
  89944. /**
  89945. * Stores the animations for the material
  89946. */
  89947. animations: Nullable<Array<Animation>>;
  89948. /**
  89949. * An event triggered when the material is disposed
  89950. */
  89951. onDisposeObservable: Observable<Material>;
  89952. /**
  89953. * An observer which watches for dispose events
  89954. */
  89955. private _onDisposeObserver;
  89956. private _onUnBindObservable;
  89957. /**
  89958. * Called during a dispose event
  89959. */
  89960. onDispose: () => void;
  89961. private _onBindObservable;
  89962. /**
  89963. * An event triggered when the material is bound
  89964. */
  89965. readonly onBindObservable: Observable<AbstractMesh>;
  89966. /**
  89967. * An observer which watches for bind events
  89968. */
  89969. private _onBindObserver;
  89970. /**
  89971. * Called during a bind event
  89972. */
  89973. onBind: (Mesh: AbstractMesh) => void;
  89974. /**
  89975. * An event triggered when the material is unbound
  89976. */
  89977. readonly onUnBindObservable: Observable<Material>;
  89978. /**
  89979. * Stores the value of the alpha mode
  89980. */
  89981. private _alphaMode;
  89982. /**
  89983. * Sets the value of the alpha mode.
  89984. *
  89985. * | Value | Type | Description |
  89986. * | --- | --- | --- |
  89987. * | 0 | ALPHA_DISABLE | |
  89988. * | 1 | ALPHA_ADD | |
  89989. * | 2 | ALPHA_COMBINE | |
  89990. * | 3 | ALPHA_SUBTRACT | |
  89991. * | 4 | ALPHA_MULTIPLY | |
  89992. * | 5 | ALPHA_MAXIMIZED | |
  89993. * | 6 | ALPHA_ONEONE | |
  89994. * | 7 | ALPHA_PREMULTIPLIED | |
  89995. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  89996. * | 9 | ALPHA_INTERPOLATE | |
  89997. * | 10 | ALPHA_SCREENMODE | |
  89998. *
  89999. */
  90000. /**
  90001. * Gets the value of the alpha mode
  90002. */
  90003. alphaMode: number;
  90004. /**
  90005. * Stores the state of the need depth pre-pass value
  90006. */
  90007. private _needDepthPrePass;
  90008. /**
  90009. * Sets the need depth pre-pass value
  90010. */
  90011. /**
  90012. * Gets the depth pre-pass value
  90013. */
  90014. needDepthPrePass: boolean;
  90015. /**
  90016. * Specifies if depth writing should be disabled
  90017. */
  90018. disableDepthWrite: boolean;
  90019. /**
  90020. * Specifies if depth writing should be forced
  90021. */
  90022. forceDepthWrite: boolean;
  90023. /**
  90024. * Specifies the depth function that should be used. 0 means the default engine function
  90025. */
  90026. depthFunction: number;
  90027. /**
  90028. * Specifies if there should be a separate pass for culling
  90029. */
  90030. separateCullingPass: boolean;
  90031. /**
  90032. * Stores the state specifing if fog should be enabled
  90033. */
  90034. private _fogEnabled;
  90035. /**
  90036. * Sets the state for enabling fog
  90037. */
  90038. /**
  90039. * Gets the value of the fog enabled state
  90040. */
  90041. fogEnabled: boolean;
  90042. /**
  90043. * Stores the size of points
  90044. */
  90045. pointSize: number;
  90046. /**
  90047. * Stores the z offset value
  90048. */
  90049. zOffset: number;
  90050. /**
  90051. * Gets a value specifying if wireframe mode is enabled
  90052. */
  90053. /**
  90054. * Sets the state of wireframe mode
  90055. */
  90056. wireframe: boolean;
  90057. /**
  90058. * Gets the value specifying if point clouds are enabled
  90059. */
  90060. /**
  90061. * Sets the state of point cloud mode
  90062. */
  90063. pointsCloud: boolean;
  90064. /**
  90065. * Gets the material fill mode
  90066. */
  90067. /**
  90068. * Sets the material fill mode
  90069. */
  90070. fillMode: number;
  90071. /**
  90072. * @hidden
  90073. * Stores the effects for the material
  90074. */
  90075. _effect: Nullable<Effect>;
  90076. /**
  90077. * @hidden
  90078. * Specifies if the material was previously ready
  90079. */
  90080. _wasPreviouslyReady: boolean;
  90081. /**
  90082. * Specifies if uniform buffers should be used
  90083. */
  90084. private _useUBO;
  90085. /**
  90086. * Stores a reference to the scene
  90087. */
  90088. private _scene;
  90089. /**
  90090. * Stores the fill mode state
  90091. */
  90092. private _fillMode;
  90093. /**
  90094. * Specifies if the depth write state should be cached
  90095. */
  90096. private _cachedDepthWriteState;
  90097. /**
  90098. * Specifies if the depth function state should be cached
  90099. */
  90100. private _cachedDepthFunctionState;
  90101. /**
  90102. * Stores the uniform buffer
  90103. */
  90104. protected _uniformBuffer: UniformBuffer;
  90105. /** @hidden */
  90106. _indexInSceneMaterialArray: number;
  90107. /** @hidden */
  90108. meshMap: Nullable<{
  90109. [id: string]: AbstractMesh | undefined;
  90110. }>;
  90111. /**
  90112. * Creates a material instance
  90113. * @param name defines the name of the material
  90114. * @param scene defines the scene to reference
  90115. * @param doNotAdd specifies if the material should be added to the scene
  90116. */
  90117. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  90118. /**
  90119. * Returns a string representation of the current material
  90120. * @param fullDetails defines a boolean indicating which levels of logging is desired
  90121. * @returns a string with material information
  90122. */
  90123. toString(fullDetails?: boolean): string;
  90124. /**
  90125. * Gets the class name of the material
  90126. * @returns a string with the class name of the material
  90127. */
  90128. getClassName(): string;
  90129. /**
  90130. * Specifies if updates for the material been locked
  90131. */
  90132. readonly isFrozen: boolean;
  90133. /**
  90134. * Locks updates for the material
  90135. */
  90136. freeze(): void;
  90137. /**
  90138. * Unlocks updates for the material
  90139. */
  90140. unfreeze(): void;
  90141. /**
  90142. * Specifies if the material is ready to be used
  90143. * @param mesh defines the mesh to check
  90144. * @param useInstances specifies if instances should be used
  90145. * @returns a boolean indicating if the material is ready to be used
  90146. */
  90147. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90148. /**
  90149. * Specifies that the submesh is ready to be used
  90150. * @param mesh defines the mesh to check
  90151. * @param subMesh defines which submesh to check
  90152. * @param useInstances specifies that instances should be used
  90153. * @returns a boolean indicating that the submesh is ready or not
  90154. */
  90155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90156. /**
  90157. * Returns the material effect
  90158. * @returns the effect associated with the material
  90159. */
  90160. getEffect(): Nullable<Effect>;
  90161. /**
  90162. * Returns the current scene
  90163. * @returns a Scene
  90164. */
  90165. getScene(): Scene;
  90166. /**
  90167. * Specifies if the material will require alpha blending
  90168. * @returns a boolean specifying if alpha blending is needed
  90169. */
  90170. needAlphaBlending(): boolean;
  90171. /**
  90172. * Specifies if the mesh will require alpha blending
  90173. * @param mesh defines the mesh to check
  90174. * @returns a boolean specifying if alpha blending is needed for the mesh
  90175. */
  90176. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  90177. /**
  90178. * Specifies if this material should be rendered in alpha test mode
  90179. * @returns a boolean specifying if an alpha test is needed.
  90180. */
  90181. needAlphaTesting(): boolean;
  90182. /**
  90183. * Gets the texture used for the alpha test
  90184. * @returns the texture to use for alpha testing
  90185. */
  90186. getAlphaTestTexture(): Nullable<BaseTexture>;
  90187. /**
  90188. * Marks the material to indicate that it needs to be re-calculated
  90189. */
  90190. markDirty(): void;
  90191. /** @hidden */
  90192. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  90193. /**
  90194. * Binds the material to the mesh
  90195. * @param world defines the world transformation matrix
  90196. * @param mesh defines the mesh to bind the material to
  90197. */
  90198. bind(world: Matrix, mesh?: Mesh): void;
  90199. /**
  90200. * Binds the submesh to the material
  90201. * @param world defines the world transformation matrix
  90202. * @param mesh defines the mesh containing the submesh
  90203. * @param subMesh defines the submesh to bind the material to
  90204. */
  90205. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  90206. /**
  90207. * Binds the world matrix to the material
  90208. * @param world defines the world transformation matrix
  90209. */
  90210. bindOnlyWorldMatrix(world: Matrix): void;
  90211. /**
  90212. * Binds the scene's uniform buffer to the effect.
  90213. * @param effect defines the effect to bind to the scene uniform buffer
  90214. * @param sceneUbo defines the uniform buffer storing scene data
  90215. */
  90216. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  90217. /**
  90218. * Binds the view matrix to the effect
  90219. * @param effect defines the effect to bind the view matrix to
  90220. */
  90221. bindView(effect: Effect): void;
  90222. /**
  90223. * Binds the view projection matrix to the effect
  90224. * @param effect defines the effect to bind the view projection matrix to
  90225. */
  90226. bindViewProjection(effect: Effect): void;
  90227. /**
  90228. * Specifies if material alpha testing should be turned on for the mesh
  90229. * @param mesh defines the mesh to check
  90230. */
  90231. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  90232. /**
  90233. * Processes to execute after binding the material to a mesh
  90234. * @param mesh defines the rendered mesh
  90235. */
  90236. protected _afterBind(mesh?: Mesh): void;
  90237. /**
  90238. * Unbinds the material from the mesh
  90239. */
  90240. unbind(): void;
  90241. /**
  90242. * Gets the active textures from the material
  90243. * @returns an array of textures
  90244. */
  90245. getActiveTextures(): BaseTexture[];
  90246. /**
  90247. * Specifies if the material uses a texture
  90248. * @param texture defines the texture to check against the material
  90249. * @returns a boolean specifying if the material uses the texture
  90250. */
  90251. hasTexture(texture: BaseTexture): boolean;
  90252. /**
  90253. * Makes a duplicate of the material, and gives it a new name
  90254. * @param name defines the new name for the duplicated material
  90255. * @returns the cloned material
  90256. */
  90257. clone(name: string): Nullable<Material>;
  90258. /**
  90259. * Gets the meshes bound to the material
  90260. * @returns an array of meshes bound to the material
  90261. */
  90262. getBindedMeshes(): AbstractMesh[];
  90263. /**
  90264. * Force shader compilation
  90265. * @param mesh defines the mesh associated with this material
  90266. * @param onCompiled defines a function to execute once the material is compiled
  90267. * @param options defines the options to configure the compilation
  90268. * @param onError defines a function to execute if the material fails compiling
  90269. */
  90270. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  90271. /**
  90272. * Force shader compilation
  90273. * @param mesh defines the mesh that will use this material
  90274. * @param options defines additional options for compiling the shaders
  90275. * @returns a promise that resolves when the compilation completes
  90276. */
  90277. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  90278. private static readonly _AllDirtyCallBack;
  90279. private static readonly _ImageProcessingDirtyCallBack;
  90280. private static readonly _TextureDirtyCallBack;
  90281. private static readonly _FresnelDirtyCallBack;
  90282. private static readonly _MiscDirtyCallBack;
  90283. private static readonly _LightsDirtyCallBack;
  90284. private static readonly _AttributeDirtyCallBack;
  90285. private static _FresnelAndMiscDirtyCallBack;
  90286. private static _TextureAndMiscDirtyCallBack;
  90287. private static readonly _DirtyCallbackArray;
  90288. private static readonly _RunDirtyCallBacks;
  90289. /**
  90290. * Marks a define in the material to indicate that it needs to be re-computed
  90291. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  90292. */
  90293. markAsDirty(flag: number): void;
  90294. /**
  90295. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  90296. * @param func defines a function which checks material defines against the submeshes
  90297. */
  90298. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  90299. /**
  90300. * Indicates that we need to re-calculated for all submeshes
  90301. */
  90302. protected _markAllSubMeshesAsAllDirty(): void;
  90303. /**
  90304. * Indicates that image processing needs to be re-calculated for all submeshes
  90305. */
  90306. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  90307. /**
  90308. * Indicates that textures need to be re-calculated for all submeshes
  90309. */
  90310. protected _markAllSubMeshesAsTexturesDirty(): void;
  90311. /**
  90312. * Indicates that fresnel needs to be re-calculated for all submeshes
  90313. */
  90314. protected _markAllSubMeshesAsFresnelDirty(): void;
  90315. /**
  90316. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  90317. */
  90318. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  90319. /**
  90320. * Indicates that lights need to be re-calculated for all submeshes
  90321. */
  90322. protected _markAllSubMeshesAsLightsDirty(): void;
  90323. /**
  90324. * Indicates that attributes need to be re-calculated for all submeshes
  90325. */
  90326. protected _markAllSubMeshesAsAttributesDirty(): void;
  90327. /**
  90328. * Indicates that misc needs to be re-calculated for all submeshes
  90329. */
  90330. protected _markAllSubMeshesAsMiscDirty(): void;
  90331. /**
  90332. * Indicates that textures and misc need to be re-calculated for all submeshes
  90333. */
  90334. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  90335. /**
  90336. * Disposes the material
  90337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90339. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90340. */
  90341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90342. /** @hidden */
  90343. private releaseVertexArrayObject;
  90344. /**
  90345. * Serializes this material
  90346. * @returns the serialized material object
  90347. */
  90348. serialize(): any;
  90349. /**
  90350. * Creates a material from parsed material data
  90351. * @param parsedMaterial defines parsed material data
  90352. * @param scene defines the hosting scene
  90353. * @param rootUrl defines the root URL to use to load textures
  90354. * @returns a new material
  90355. */
  90356. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  90357. }
  90358. }
  90359. declare module BABYLON {
  90360. /**
  90361. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90362. * separate meshes. This can be use to improve performances.
  90363. * @see http://doc.babylonjs.com/how_to/multi_materials
  90364. */
  90365. export class MultiMaterial extends Material {
  90366. private _subMaterials;
  90367. /**
  90368. * Gets or Sets the list of Materials used within the multi material.
  90369. * They need to be ordered according to the submeshes order in the associated mesh
  90370. */
  90371. subMaterials: Nullable<Material>[];
  90372. /**
  90373. * Function used to align with Node.getChildren()
  90374. * @returns the list of Materials used within the multi material
  90375. */
  90376. getChildren(): Nullable<Material>[];
  90377. /**
  90378. * Instantiates a new Multi Material
  90379. * A multi-material is used to apply different materials to different parts of the same object without the need of
  90380. * separate meshes. This can be use to improve performances.
  90381. * @see http://doc.babylonjs.com/how_to/multi_materials
  90382. * @param name Define the name in the scene
  90383. * @param scene Define the scene the material belongs to
  90384. */
  90385. constructor(name: string, scene: Scene);
  90386. private _hookArray;
  90387. /**
  90388. * Get one of the submaterial by its index in the submaterials array
  90389. * @param index The index to look the sub material at
  90390. * @returns The Material if the index has been defined
  90391. */
  90392. getSubMaterial(index: number): Nullable<Material>;
  90393. /**
  90394. * Get the list of active textures for the whole sub materials list.
  90395. * @returns All the textures that will be used during the rendering
  90396. */
  90397. getActiveTextures(): BaseTexture[];
  90398. /**
  90399. * Gets the current class name of the material e.g. "MultiMaterial"
  90400. * Mainly use in serialization.
  90401. * @returns the class name
  90402. */
  90403. getClassName(): string;
  90404. /**
  90405. * Checks if the material is ready to render the requested sub mesh
  90406. * @param mesh Define the mesh the submesh belongs to
  90407. * @param subMesh Define the sub mesh to look readyness for
  90408. * @param useInstances Define whether or not the material is used with instances
  90409. * @returns true if ready, otherwise false
  90410. */
  90411. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90412. /**
  90413. * Clones the current material and its related sub materials
  90414. * @param name Define the name of the newly cloned material
  90415. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  90416. * @returns the cloned material
  90417. */
  90418. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  90419. /**
  90420. * Serializes the materials into a JSON representation.
  90421. * @returns the JSON representation
  90422. */
  90423. serialize(): any;
  90424. /**
  90425. * Dispose the material and release its associated resources
  90426. * @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)
  90427. * @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)
  90428. * @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)
  90429. */
  90430. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  90431. /**
  90432. * Creates a MultiMaterial from parsed MultiMaterial data.
  90433. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  90434. * @param scene defines the hosting scene
  90435. * @returns a new MultiMaterial
  90436. */
  90437. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  90438. }
  90439. }
  90440. declare module BABYLON {
  90441. /**
  90442. * Base class for submeshes
  90443. */
  90444. export class BaseSubMesh {
  90445. /** @hidden */
  90446. _materialDefines: Nullable<MaterialDefines>;
  90447. /** @hidden */
  90448. _materialEffect: Nullable<Effect>;
  90449. /**
  90450. * Gets material defines used by the effect associated to the sub mesh
  90451. */
  90452. /**
  90453. * Sets material defines used by the effect associated to the sub mesh
  90454. */
  90455. materialDefines: Nullable<MaterialDefines>;
  90456. /**
  90457. * Gets associated effect
  90458. */
  90459. readonly effect: Nullable<Effect>;
  90460. /**
  90461. * Sets associated effect (effect used to render this submesh)
  90462. * @param effect defines the effect to associate with
  90463. * @param defines defines the set of defines used to compile this effect
  90464. */
  90465. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  90466. }
  90467. /**
  90468. * Defines a subdivision inside a mesh
  90469. */
  90470. export class SubMesh extends BaseSubMesh implements ICullable {
  90471. /** the material index to use */
  90472. materialIndex: number;
  90473. /** vertex index start */
  90474. verticesStart: number;
  90475. /** vertices count */
  90476. verticesCount: number;
  90477. /** index start */
  90478. indexStart: number;
  90479. /** indices count */
  90480. indexCount: number;
  90481. /** @hidden */
  90482. _linesIndexCount: number;
  90483. private _mesh;
  90484. private _renderingMesh;
  90485. private _boundingInfo;
  90486. private _linesIndexBuffer;
  90487. /** @hidden */
  90488. _lastColliderWorldVertices: Nullable<Vector3[]>;
  90489. /** @hidden */
  90490. _trianglePlanes: Plane[];
  90491. /** @hidden */
  90492. _lastColliderTransformMatrix: Nullable<Matrix>;
  90493. /** @hidden */
  90494. _renderId: number;
  90495. /** @hidden */
  90496. _alphaIndex: number;
  90497. /** @hidden */
  90498. _distanceToCamera: number;
  90499. /** @hidden */
  90500. _id: number;
  90501. private _currentMaterial;
  90502. /**
  90503. * Add a new submesh to a mesh
  90504. * @param materialIndex defines the material index to use
  90505. * @param verticesStart defines vertex index start
  90506. * @param verticesCount defines vertices count
  90507. * @param indexStart defines index start
  90508. * @param indexCount defines indices count
  90509. * @param mesh defines the parent mesh
  90510. * @param renderingMesh defines an optional rendering mesh
  90511. * @param createBoundingBox defines if bounding box should be created for this submesh
  90512. * @returns the new submesh
  90513. */
  90514. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  90515. /**
  90516. * Creates a new submesh
  90517. * @param materialIndex defines the material index to use
  90518. * @param verticesStart defines vertex index start
  90519. * @param verticesCount defines vertices count
  90520. * @param indexStart defines index start
  90521. * @param indexCount defines indices count
  90522. * @param mesh defines the parent mesh
  90523. * @param renderingMesh defines an optional rendering mesh
  90524. * @param createBoundingBox defines if bounding box should be created for this submesh
  90525. */
  90526. constructor(
  90527. /** the material index to use */
  90528. materialIndex: number,
  90529. /** vertex index start */
  90530. verticesStart: number,
  90531. /** vertices count */
  90532. verticesCount: number,
  90533. /** index start */
  90534. indexStart: number,
  90535. /** indices count */
  90536. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  90537. /**
  90538. * Returns true if this submesh covers the entire parent mesh
  90539. * @ignorenaming
  90540. */
  90541. readonly IsGlobal: boolean;
  90542. /**
  90543. * Returns the submesh BoudingInfo object
  90544. * @returns current bounding info (or mesh's one if the submesh is global)
  90545. */
  90546. getBoundingInfo(): BoundingInfo;
  90547. /**
  90548. * Sets the submesh BoundingInfo
  90549. * @param boundingInfo defines the new bounding info to use
  90550. * @returns the SubMesh
  90551. */
  90552. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  90553. /**
  90554. * Returns the mesh of the current submesh
  90555. * @return the parent mesh
  90556. */
  90557. getMesh(): AbstractMesh;
  90558. /**
  90559. * Returns the rendering mesh of the submesh
  90560. * @returns the rendering mesh (could be different from parent mesh)
  90561. */
  90562. getRenderingMesh(): Mesh;
  90563. /**
  90564. * Returns the submesh material
  90565. * @returns null or the current material
  90566. */
  90567. getMaterial(): Nullable<Material>;
  90568. /**
  90569. * Sets a new updated BoundingInfo object to the submesh
  90570. * @param data defines an optional position array to use to determine the bounding info
  90571. * @returns the SubMesh
  90572. */
  90573. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  90574. /** @hidden */
  90575. _checkCollision(collider: Collider): boolean;
  90576. /**
  90577. * Updates the submesh BoundingInfo
  90578. * @param world defines the world matrix to use to update the bounding info
  90579. * @returns the submesh
  90580. */
  90581. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  90582. /**
  90583. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90584. * @param frustumPlanes defines the frustum planes
  90585. * @returns true if the submesh is intersecting with the frustum
  90586. */
  90587. isInFrustum(frustumPlanes: Plane[]): boolean;
  90588. /**
  90589. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90590. * @param frustumPlanes defines the frustum planes
  90591. * @returns true if the submesh is inside the frustum
  90592. */
  90593. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90594. /**
  90595. * Renders the submesh
  90596. * @param enableAlphaMode defines if alpha needs to be used
  90597. * @returns the submesh
  90598. */
  90599. render(enableAlphaMode: boolean): SubMesh;
  90600. /**
  90601. * @hidden
  90602. */
  90603. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  90604. /**
  90605. * Checks if the submesh intersects with a ray
  90606. * @param ray defines the ray to test
  90607. * @returns true is the passed ray intersects the submesh bounding box
  90608. */
  90609. canIntersects(ray: Ray): boolean;
  90610. /**
  90611. * Intersects current submesh with a ray
  90612. * @param ray defines the ray to test
  90613. * @param positions defines mesh's positions array
  90614. * @param indices defines mesh's indices array
  90615. * @param fastCheck defines if only bounding info should be used
  90616. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90617. * @returns intersection info or null if no intersection
  90618. */
  90619. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  90620. /** @hidden */
  90621. private _intersectLines;
  90622. /** @hidden */
  90623. private _intersectUnIndexedLines;
  90624. /** @hidden */
  90625. private _intersectTriangles;
  90626. /** @hidden */
  90627. private _intersectUnIndexedTriangles;
  90628. /** @hidden */
  90629. _rebuild(): void;
  90630. /**
  90631. * Creates a new submesh from the passed mesh
  90632. * @param newMesh defines the new hosting mesh
  90633. * @param newRenderingMesh defines an optional rendering mesh
  90634. * @returns the new submesh
  90635. */
  90636. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  90637. /**
  90638. * Release associated resources
  90639. */
  90640. dispose(): void;
  90641. /**
  90642. * Gets the class name
  90643. * @returns the string "SubMesh".
  90644. */
  90645. getClassName(): string;
  90646. /**
  90647. * Creates a new submesh from indices data
  90648. * @param materialIndex the index of the main mesh material
  90649. * @param startIndex the index where to start the copy in the mesh indices array
  90650. * @param indexCount the number of indices to copy then from the startIndex
  90651. * @param mesh the main mesh to create the submesh from
  90652. * @param renderingMesh the optional rendering mesh
  90653. * @returns a new submesh
  90654. */
  90655. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  90656. }
  90657. }
  90658. declare module BABYLON {
  90659. /**
  90660. * Class used to represent data loading progression
  90661. */
  90662. export class SceneLoaderFlags {
  90663. private static _ForceFullSceneLoadingForIncremental;
  90664. private static _ShowLoadingScreen;
  90665. private static _CleanBoneMatrixWeights;
  90666. private static _loggingLevel;
  90667. /**
  90668. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  90669. */
  90670. static ForceFullSceneLoadingForIncremental: boolean;
  90671. /**
  90672. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  90673. */
  90674. static ShowLoadingScreen: boolean;
  90675. /**
  90676. * Defines the current logging level (while loading the scene)
  90677. * @ignorenaming
  90678. */
  90679. static loggingLevel: number;
  90680. /**
  90681. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  90682. */
  90683. static CleanBoneMatrixWeights: boolean;
  90684. }
  90685. }
  90686. declare module BABYLON {
  90687. /**
  90688. * Class used to store geometry data (vertex buffers + index buffer)
  90689. */
  90690. export class Geometry implements IGetSetVerticesData {
  90691. /**
  90692. * Gets or sets the ID of the geometry
  90693. */
  90694. id: string;
  90695. /**
  90696. * Gets or sets the unique ID of the geometry
  90697. */
  90698. uniqueId: number;
  90699. /**
  90700. * Gets the delay loading state of the geometry (none by default which means not delayed)
  90701. */
  90702. delayLoadState: number;
  90703. /**
  90704. * Gets the file containing the data to load when running in delay load state
  90705. */
  90706. delayLoadingFile: Nullable<string>;
  90707. /**
  90708. * Callback called when the geometry is updated
  90709. */
  90710. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  90711. private _scene;
  90712. private _engine;
  90713. private _meshes;
  90714. private _totalVertices;
  90715. /** @hidden */
  90716. _indices: IndicesArray;
  90717. /** @hidden */
  90718. _vertexBuffers: {
  90719. [key: string]: VertexBuffer;
  90720. };
  90721. private _isDisposed;
  90722. private _extend;
  90723. private _boundingBias;
  90724. /** @hidden */
  90725. _delayInfo: Array<string>;
  90726. private _indexBuffer;
  90727. private _indexBufferIsUpdatable;
  90728. /** @hidden */
  90729. _boundingInfo: Nullable<BoundingInfo>;
  90730. /** @hidden */
  90731. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  90732. /** @hidden */
  90733. _softwareSkinningFrameId: number;
  90734. private _vertexArrayObjects;
  90735. private _updatable;
  90736. /** @hidden */
  90737. _positions: Nullable<Vector3[]>;
  90738. /**
  90739. * 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
  90740. */
  90741. /**
  90742. * 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
  90743. */
  90744. boundingBias: Vector2;
  90745. /**
  90746. * Static function used to attach a new empty geometry to a mesh
  90747. * @param mesh defines the mesh to attach the geometry to
  90748. * @returns the new Geometry
  90749. */
  90750. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  90751. /**
  90752. * Creates a new geometry
  90753. * @param id defines the unique ID
  90754. * @param scene defines the hosting scene
  90755. * @param vertexData defines the VertexData used to get geometry data
  90756. * @param updatable defines if geometry must be updatable (false by default)
  90757. * @param mesh defines the mesh that will be associated with the geometry
  90758. */
  90759. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  90760. /**
  90761. * Gets the current extend of the geometry
  90762. */
  90763. readonly extend: {
  90764. minimum: Vector3;
  90765. maximum: Vector3;
  90766. };
  90767. /**
  90768. * Gets the hosting scene
  90769. * @returns the hosting Scene
  90770. */
  90771. getScene(): Scene;
  90772. /**
  90773. * Gets the hosting engine
  90774. * @returns the hosting Engine
  90775. */
  90776. getEngine(): Engine;
  90777. /**
  90778. * Defines if the geometry is ready to use
  90779. * @returns true if the geometry is ready to be used
  90780. */
  90781. isReady(): boolean;
  90782. /**
  90783. * Gets a value indicating that the geometry should not be serialized
  90784. */
  90785. readonly doNotSerialize: boolean;
  90786. /** @hidden */
  90787. _rebuild(): void;
  90788. /**
  90789. * Affects all geometry data in one call
  90790. * @param vertexData defines the geometry data
  90791. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  90792. */
  90793. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  90794. /**
  90795. * Set specific vertex data
  90796. * @param kind defines the data kind (Position, normal, etc...)
  90797. * @param data defines the vertex data to use
  90798. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90799. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90800. */
  90801. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  90802. /**
  90803. * Removes a specific vertex data
  90804. * @param kind defines the data kind (Position, normal, etc...)
  90805. */
  90806. removeVerticesData(kind: string): void;
  90807. /**
  90808. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  90809. * @param buffer defines the vertex buffer to use
  90810. * @param totalVertices defines the total number of vertices for position kind (could be null)
  90811. */
  90812. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  90813. /**
  90814. * Update a specific vertex buffer
  90815. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  90816. * It will do nothing if the buffer is not updatable
  90817. * @param kind defines the data kind (Position, normal, etc...)
  90818. * @param data defines the data to use
  90819. * @param offset defines the offset in the target buffer where to store the data
  90820. * @param useBytes set to true if the offset is in bytes
  90821. */
  90822. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  90823. /**
  90824. * Update a specific vertex buffer
  90825. * This function will create a new buffer if the current one is not updatable
  90826. * @param kind defines the data kind (Position, normal, etc...)
  90827. * @param data defines the data to use
  90828. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  90829. */
  90830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  90831. private _updateBoundingInfo;
  90832. /** @hidden */
  90833. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  90834. /**
  90835. * Gets total number of vertices
  90836. * @returns the total number of vertices
  90837. */
  90838. getTotalVertices(): number;
  90839. /**
  90840. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  90841. * @param kind defines the data kind (Position, normal, etc...)
  90842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90844. * @returns a float array containing vertex data
  90845. */
  90846. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90847. /**
  90848. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  90849. * @param kind defines the data kind (Position, normal, etc...)
  90850. * @returns true if the vertex buffer with the specified kind is updatable
  90851. */
  90852. isVertexBufferUpdatable(kind: string): boolean;
  90853. /**
  90854. * Gets a specific vertex buffer
  90855. * @param kind defines the data kind (Position, normal, etc...)
  90856. * @returns a VertexBuffer
  90857. */
  90858. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90859. /**
  90860. * Returns all vertex buffers
  90861. * @return an object holding all vertex buffers indexed by kind
  90862. */
  90863. getVertexBuffers(): Nullable<{
  90864. [key: string]: VertexBuffer;
  90865. }>;
  90866. /**
  90867. * Gets a boolean indicating if specific vertex buffer is present
  90868. * @param kind defines the data kind (Position, normal, etc...)
  90869. * @returns true if data is present
  90870. */
  90871. isVerticesDataPresent(kind: string): boolean;
  90872. /**
  90873. * Gets a list of all attached data kinds (Position, normal, etc...)
  90874. * @returns a list of string containing all kinds
  90875. */
  90876. getVerticesDataKinds(): string[];
  90877. /**
  90878. * Update index buffer
  90879. * @param indices defines the indices to store in the index buffer
  90880. * @param offset defines the offset in the target buffer where to store the data
  90881. * @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)
  90882. */
  90883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  90884. /**
  90885. * Creates a new index buffer
  90886. * @param indices defines the indices to store in the index buffer
  90887. * @param totalVertices defines the total number of vertices (could be null)
  90888. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90889. */
  90890. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  90891. /**
  90892. * Return the total number of indices
  90893. * @returns the total number of indices
  90894. */
  90895. getTotalIndices(): number;
  90896. /**
  90897. * Gets the index buffer array
  90898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  90899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90900. * @returns the index buffer array
  90901. */
  90902. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90903. /**
  90904. * Gets the index buffer
  90905. * @return the index buffer
  90906. */
  90907. getIndexBuffer(): Nullable<DataBuffer>;
  90908. /** @hidden */
  90909. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  90910. /**
  90911. * Release the associated resources for a specific mesh
  90912. * @param mesh defines the source mesh
  90913. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  90914. */
  90915. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  90916. /**
  90917. * Apply current geometry to a given mesh
  90918. * @param mesh defines the mesh to apply geometry to
  90919. */
  90920. applyToMesh(mesh: Mesh): void;
  90921. private _updateExtend;
  90922. private _applyToMesh;
  90923. private notifyUpdate;
  90924. /**
  90925. * Load the geometry if it was flagged as delay loaded
  90926. * @param scene defines the hosting scene
  90927. * @param onLoaded defines a callback called when the geometry is loaded
  90928. */
  90929. load(scene: Scene, onLoaded?: () => void): void;
  90930. private _queueLoad;
  90931. /**
  90932. * Invert the geometry to move from a right handed system to a left handed one.
  90933. */
  90934. toLeftHanded(): void;
  90935. /** @hidden */
  90936. _resetPointsArrayCache(): void;
  90937. /** @hidden */
  90938. _generatePointsArray(): boolean;
  90939. /**
  90940. * Gets a value indicating if the geometry is disposed
  90941. * @returns true if the geometry was disposed
  90942. */
  90943. isDisposed(): boolean;
  90944. private _disposeVertexArrayObjects;
  90945. /**
  90946. * Free all associated resources
  90947. */
  90948. dispose(): void;
  90949. /**
  90950. * Clone the current geometry into a new geometry
  90951. * @param id defines the unique ID of the new geometry
  90952. * @returns a new geometry object
  90953. */
  90954. copy(id: string): Geometry;
  90955. /**
  90956. * Serialize the current geometry info (and not the vertices data) into a JSON object
  90957. * @return a JSON representation of the current geometry data (without the vertices data)
  90958. */
  90959. serialize(): any;
  90960. private toNumberArray;
  90961. /**
  90962. * Serialize all vertices data into a JSON oject
  90963. * @returns a JSON representation of the current geometry data
  90964. */
  90965. serializeVerticeData(): any;
  90966. /**
  90967. * Extracts a clone of a mesh geometry
  90968. * @param mesh defines the source mesh
  90969. * @param id defines the unique ID of the new geometry object
  90970. * @returns the new geometry object
  90971. */
  90972. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  90973. /**
  90974. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  90975. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90976. * Be aware Math.random() could cause collisions, but:
  90977. * "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"
  90978. * @returns a string containing a new GUID
  90979. */
  90980. static RandomId(): string;
  90981. /** @hidden */
  90982. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  90983. private static _CleanMatricesWeights;
  90984. /**
  90985. * Create a new geometry from persisted data (Using .babylon file format)
  90986. * @param parsedVertexData defines the persisted data
  90987. * @param scene defines the hosting scene
  90988. * @param rootUrl defines the root url to use to load assets (like delayed data)
  90989. * @returns the new geometry object
  90990. */
  90991. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  90992. }
  90993. }
  90994. declare module BABYLON {
  90995. /**
  90996. * Define an interface for all classes that will get and set the data on vertices
  90997. */
  90998. export interface IGetSetVerticesData {
  90999. /**
  91000. * Gets a boolean indicating if specific vertex data is present
  91001. * @param kind defines the vertex data kind to use
  91002. * @returns true is data kind is present
  91003. */
  91004. isVerticesDataPresent(kind: string): boolean;
  91005. /**
  91006. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  91007. * @param kind defines the data kind (Position, normal, etc...)
  91008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  91009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91010. * @returns a float array containing vertex data
  91011. */
  91012. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  91013. /**
  91014. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  91015. * @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.
  91016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  91017. * @returns the indices array or an empty array if the mesh has no geometry
  91018. */
  91019. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  91020. /**
  91021. * Set specific vertex data
  91022. * @param kind defines the data kind (Position, normal, etc...)
  91023. * @param data defines the vertex data to use
  91024. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  91025. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  91026. */
  91027. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  91028. /**
  91029. * Update a specific associated vertex buffer
  91030. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  91031. * - VertexBuffer.PositionKind
  91032. * - VertexBuffer.UVKind
  91033. * - VertexBuffer.UV2Kind
  91034. * - VertexBuffer.UV3Kind
  91035. * - VertexBuffer.UV4Kind
  91036. * - VertexBuffer.UV5Kind
  91037. * - VertexBuffer.UV6Kind
  91038. * - VertexBuffer.ColorKind
  91039. * - VertexBuffer.MatricesIndicesKind
  91040. * - VertexBuffer.MatricesIndicesExtraKind
  91041. * - VertexBuffer.MatricesWeightsKind
  91042. * - VertexBuffer.MatricesWeightsExtraKind
  91043. * @param data defines the data source
  91044. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  91045. * @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)
  91046. */
  91047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  91048. /**
  91049. * Creates a new index buffer
  91050. * @param indices defines the indices to store in the index buffer
  91051. * @param totalVertices defines the total number of vertices (could be null)
  91052. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  91053. */
  91054. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  91055. }
  91056. /**
  91057. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  91058. */
  91059. export class VertexData {
  91060. /**
  91061. * Mesh side orientation : usually the external or front surface
  91062. */
  91063. static readonly FRONTSIDE: number;
  91064. /**
  91065. * Mesh side orientation : usually the internal or back surface
  91066. */
  91067. static readonly BACKSIDE: number;
  91068. /**
  91069. * Mesh side orientation : both internal and external or front and back surfaces
  91070. */
  91071. static readonly DOUBLESIDE: number;
  91072. /**
  91073. * Mesh side orientation : by default, `FRONTSIDE`
  91074. */
  91075. static readonly DEFAULTSIDE: number;
  91076. /**
  91077. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  91078. */
  91079. positions: Nullable<FloatArray>;
  91080. /**
  91081. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  91082. */
  91083. normals: Nullable<FloatArray>;
  91084. /**
  91085. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  91086. */
  91087. tangents: Nullable<FloatArray>;
  91088. /**
  91089. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91090. */
  91091. uvs: Nullable<FloatArray>;
  91092. /**
  91093. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91094. */
  91095. uvs2: Nullable<FloatArray>;
  91096. /**
  91097. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91098. */
  91099. uvs3: Nullable<FloatArray>;
  91100. /**
  91101. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91102. */
  91103. uvs4: Nullable<FloatArray>;
  91104. /**
  91105. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91106. */
  91107. uvs5: Nullable<FloatArray>;
  91108. /**
  91109. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  91110. */
  91111. uvs6: Nullable<FloatArray>;
  91112. /**
  91113. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  91114. */
  91115. colors: Nullable<FloatArray>;
  91116. /**
  91117. * 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).
  91118. */
  91119. matricesIndices: Nullable<FloatArray>;
  91120. /**
  91121. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  91122. */
  91123. matricesWeights: Nullable<FloatArray>;
  91124. /**
  91125. * An array extending the number of possible indices
  91126. */
  91127. matricesIndicesExtra: Nullable<FloatArray>;
  91128. /**
  91129. * An array extending the number of possible weights when the number of indices is extended
  91130. */
  91131. matricesWeightsExtra: Nullable<FloatArray>;
  91132. /**
  91133. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  91134. */
  91135. indices: Nullable<IndicesArray>;
  91136. /**
  91137. * Uses the passed data array to set the set the values for the specified kind of data
  91138. * @param data a linear array of floating numbers
  91139. * @param kind the type of data that is being set, eg positions, colors etc
  91140. */
  91141. set(data: FloatArray, kind: string): void;
  91142. /**
  91143. * Associates the vertexData to the passed Mesh.
  91144. * Sets it as updatable or not (default `false`)
  91145. * @param mesh the mesh the vertexData is applied to
  91146. * @param updatable when used and having the value true allows new data to update the vertexData
  91147. * @returns the VertexData
  91148. */
  91149. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  91150. /**
  91151. * Associates the vertexData to the passed Geometry.
  91152. * Sets it as updatable or not (default `false`)
  91153. * @param geometry the geometry the vertexData is applied to
  91154. * @param updatable when used and having the value true allows new data to update the vertexData
  91155. * @returns VertexData
  91156. */
  91157. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  91158. /**
  91159. * Updates the associated mesh
  91160. * @param mesh the mesh to be updated
  91161. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91162. * @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
  91163. * @returns VertexData
  91164. */
  91165. updateMesh(mesh: Mesh): VertexData;
  91166. /**
  91167. * Updates the associated geometry
  91168. * @param geometry the geometry to be updated
  91169. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  91170. * @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
  91171. * @returns VertexData.
  91172. */
  91173. updateGeometry(geometry: Geometry): VertexData;
  91174. private _applyTo;
  91175. private _update;
  91176. /**
  91177. * Transforms each position and each normal of the vertexData according to the passed Matrix
  91178. * @param matrix the transforming matrix
  91179. * @returns the VertexData
  91180. */
  91181. transform(matrix: Matrix): VertexData;
  91182. /**
  91183. * Merges the passed VertexData into the current one
  91184. * @param other the VertexData to be merged into the current one
  91185. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  91186. * @returns the modified VertexData
  91187. */
  91188. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  91189. private _mergeElement;
  91190. private _validate;
  91191. /**
  91192. * Serializes the VertexData
  91193. * @returns a serialized object
  91194. */
  91195. serialize(): any;
  91196. /**
  91197. * Extracts the vertexData from a mesh
  91198. * @param mesh the mesh from which to extract the VertexData
  91199. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91200. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91201. * @returns the object VertexData associated to the passed mesh
  91202. */
  91203. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91204. /**
  91205. * Extracts the vertexData from the geometry
  91206. * @param geometry the geometry from which to extract the VertexData
  91207. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91208. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91209. * @returns the object VertexData associated to the passed mesh
  91210. */
  91211. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  91212. private static _ExtractFrom;
  91213. /**
  91214. * Creates the VertexData for a Ribbon
  91215. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91216. * * pathArray array of paths, each of which an array of successive Vector3
  91217. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91218. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91219. * * 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
  91220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91221. * * 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)
  91222. * * 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)
  91223. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91224. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91225. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91226. * @returns the VertexData of the ribbon
  91227. */
  91228. static CreateRibbon(options: {
  91229. pathArray: Vector3[][];
  91230. closeArray?: boolean;
  91231. closePath?: boolean;
  91232. offset?: number;
  91233. sideOrientation?: number;
  91234. frontUVs?: Vector4;
  91235. backUVs?: Vector4;
  91236. invertUV?: boolean;
  91237. uvs?: Vector2[];
  91238. colors?: Color4[];
  91239. }): VertexData;
  91240. /**
  91241. * Creates the VertexData for a box
  91242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91243. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91244. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91245. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91246. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91247. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91248. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91250. * * 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)
  91251. * * 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)
  91252. * @returns the VertexData of the box
  91253. */
  91254. static CreateBox(options: {
  91255. size?: number;
  91256. width?: number;
  91257. height?: number;
  91258. depth?: number;
  91259. faceUV?: Vector4[];
  91260. faceColors?: Color4[];
  91261. sideOrientation?: number;
  91262. frontUVs?: Vector4;
  91263. backUVs?: Vector4;
  91264. }): VertexData;
  91265. /**
  91266. * Creates the VertexData for a tiled box
  91267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91268. * * faceTiles sets the pattern, tile size and number of tiles for a face
  91269. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91270. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91272. * @returns the VertexData of the box
  91273. */
  91274. static CreateTiledBox(options: {
  91275. pattern?: number;
  91276. width?: number;
  91277. height?: number;
  91278. depth?: number;
  91279. tileSize?: number;
  91280. tileWidth?: number;
  91281. tileHeight?: number;
  91282. alignHorizontal?: number;
  91283. alignVertical?: number;
  91284. faceUV?: Vector4[];
  91285. faceColors?: Color4[];
  91286. sideOrientation?: number;
  91287. }): VertexData;
  91288. /**
  91289. * Creates the VertexData for a tiled plane
  91290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91291. * * pattern a limited pattern arrangement depending on the number
  91292. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  91293. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  91294. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  91295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91296. * * 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)
  91297. * * 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)
  91298. * @returns the VertexData of the tiled plane
  91299. */
  91300. static CreateTiledPlane(options: {
  91301. pattern?: number;
  91302. tileSize?: number;
  91303. tileWidth?: number;
  91304. tileHeight?: number;
  91305. size?: number;
  91306. width?: number;
  91307. height?: number;
  91308. alignHorizontal?: number;
  91309. alignVertical?: number;
  91310. sideOrientation?: number;
  91311. frontUVs?: Vector4;
  91312. backUVs?: Vector4;
  91313. }): VertexData;
  91314. /**
  91315. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91317. * * segments sets the number of horizontal strips optional, default 32
  91318. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91319. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91320. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91321. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91322. * * 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
  91323. * * 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
  91324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91325. * * 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)
  91326. * * 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)
  91327. * @returns the VertexData of the ellipsoid
  91328. */
  91329. static CreateSphere(options: {
  91330. segments?: number;
  91331. diameter?: number;
  91332. diameterX?: number;
  91333. diameterY?: number;
  91334. diameterZ?: number;
  91335. arc?: number;
  91336. slice?: number;
  91337. sideOrientation?: number;
  91338. frontUVs?: Vector4;
  91339. backUVs?: Vector4;
  91340. }): VertexData;
  91341. /**
  91342. * Creates the VertexData for a cylinder, cone or prism
  91343. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91344. * * height sets the height (y direction) of the cylinder, optional, default 2
  91345. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91346. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91347. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91348. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91349. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91350. * * 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
  91351. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91352. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91353. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91354. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91356. * * 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)
  91357. * * 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)
  91358. * @returns the VertexData of the cylinder, cone or prism
  91359. */
  91360. static CreateCylinder(options: {
  91361. height?: number;
  91362. diameterTop?: number;
  91363. diameterBottom?: number;
  91364. diameter?: number;
  91365. tessellation?: number;
  91366. subdivisions?: number;
  91367. arc?: number;
  91368. faceColors?: Color4[];
  91369. faceUV?: Vector4[];
  91370. hasRings?: boolean;
  91371. enclose?: boolean;
  91372. sideOrientation?: number;
  91373. frontUVs?: Vector4;
  91374. backUVs?: Vector4;
  91375. }): VertexData;
  91376. /**
  91377. * Creates the VertexData for a torus
  91378. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91379. * * diameter the diameter of the torus, optional default 1
  91380. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91381. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91383. * * 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)
  91384. * * 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)
  91385. * @returns the VertexData of the torus
  91386. */
  91387. static CreateTorus(options: {
  91388. diameter?: number;
  91389. thickness?: number;
  91390. tessellation?: number;
  91391. sideOrientation?: number;
  91392. frontUVs?: Vector4;
  91393. backUVs?: Vector4;
  91394. }): VertexData;
  91395. /**
  91396. * Creates the VertexData of the LineSystem
  91397. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  91398. * - lines an array of lines, each line being an array of successive Vector3
  91399. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  91400. * @returns the VertexData of the LineSystem
  91401. */
  91402. static CreateLineSystem(options: {
  91403. lines: Vector3[][];
  91404. colors?: Nullable<Color4[][]>;
  91405. }): VertexData;
  91406. /**
  91407. * Create the VertexData for a DashedLines
  91408. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  91409. * - points an array successive Vector3
  91410. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  91411. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  91412. * - dashNb the intended total number of dashes, optional, default 200
  91413. * @returns the VertexData for the DashedLines
  91414. */
  91415. static CreateDashedLines(options: {
  91416. points: Vector3[];
  91417. dashSize?: number;
  91418. gapSize?: number;
  91419. dashNb?: number;
  91420. }): VertexData;
  91421. /**
  91422. * Creates the VertexData for a Ground
  91423. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91424. * - width the width (x direction) of the ground, optional, default 1
  91425. * - height the height (z direction) of the ground, optional, default 1
  91426. * - subdivisions the number of subdivisions per side, optional, default 1
  91427. * @returns the VertexData of the Ground
  91428. */
  91429. static CreateGround(options: {
  91430. width?: number;
  91431. height?: number;
  91432. subdivisions?: number;
  91433. subdivisionsX?: number;
  91434. subdivisionsY?: number;
  91435. }): VertexData;
  91436. /**
  91437. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91438. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91439. * * xmin the ground minimum X coordinate, optional, default -1
  91440. * * zmin the ground minimum Z coordinate, optional, default -1
  91441. * * xmax the ground maximum X coordinate, optional, default 1
  91442. * * zmax the ground maximum Z coordinate, optional, default 1
  91443. * * 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}
  91444. * * 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}
  91445. * @returns the VertexData of the TiledGround
  91446. */
  91447. static CreateTiledGround(options: {
  91448. xmin: number;
  91449. zmin: number;
  91450. xmax: number;
  91451. zmax: number;
  91452. subdivisions?: {
  91453. w: number;
  91454. h: number;
  91455. };
  91456. precision?: {
  91457. w: number;
  91458. h: number;
  91459. };
  91460. }): VertexData;
  91461. /**
  91462. * Creates the VertexData of the Ground designed from a heightmap
  91463. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91464. * * width the width (x direction) of the ground
  91465. * * height the height (z direction) of the ground
  91466. * * subdivisions the number of subdivisions per side
  91467. * * minHeight the minimum altitude on the ground, optional, default 0
  91468. * * maxHeight the maximum altitude on the ground, optional default 1
  91469. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91470. * * buffer the array holding the image color data
  91471. * * bufferWidth the width of image
  91472. * * bufferHeight the height of image
  91473. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91474. * @returns the VertexData of the Ground designed from a heightmap
  91475. */
  91476. static CreateGroundFromHeightMap(options: {
  91477. width: number;
  91478. height: number;
  91479. subdivisions: number;
  91480. minHeight: number;
  91481. maxHeight: number;
  91482. colorFilter: Color3;
  91483. buffer: Uint8Array;
  91484. bufferWidth: number;
  91485. bufferHeight: number;
  91486. alphaFilter: number;
  91487. }): VertexData;
  91488. /**
  91489. * Creates the VertexData for a Plane
  91490. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91491. * * size sets the width and height of the plane to the value of size, optional default 1
  91492. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91493. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91495. * * 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)
  91496. * * 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)
  91497. * @returns the VertexData of the box
  91498. */
  91499. static CreatePlane(options: {
  91500. size?: number;
  91501. width?: number;
  91502. height?: number;
  91503. sideOrientation?: number;
  91504. frontUVs?: Vector4;
  91505. backUVs?: Vector4;
  91506. }): VertexData;
  91507. /**
  91508. * Creates the VertexData of the Disc or regular Polygon
  91509. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91510. * * radius the radius of the disc, optional default 0.5
  91511. * * tessellation the number of polygon sides, optional, default 64
  91512. * * 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
  91513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91514. * * 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)
  91515. * * 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)
  91516. * @returns the VertexData of the box
  91517. */
  91518. static CreateDisc(options: {
  91519. radius?: number;
  91520. tessellation?: number;
  91521. arc?: number;
  91522. sideOrientation?: number;
  91523. frontUVs?: Vector4;
  91524. backUVs?: Vector4;
  91525. }): VertexData;
  91526. /**
  91527. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91528. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91529. * @param polygon a mesh built from polygonTriangulation.build()
  91530. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91531. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91532. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91533. * @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)
  91534. * @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)
  91535. * @returns the VertexData of the Polygon
  91536. */
  91537. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  91538. /**
  91539. * Creates the VertexData of the IcoSphere
  91540. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91541. * * radius the radius of the IcoSphere, optional default 1
  91542. * * radiusX allows stretching in the x direction, optional, default radius
  91543. * * radiusY allows stretching in the y direction, optional, default radius
  91544. * * radiusZ allows stretching in the z direction, optional, default radius
  91545. * * flat when true creates a flat shaded mesh, optional, default true
  91546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91548. * * 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)
  91549. * * 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)
  91550. * @returns the VertexData of the IcoSphere
  91551. */
  91552. static CreateIcoSphere(options: {
  91553. radius?: number;
  91554. radiusX?: number;
  91555. radiusY?: number;
  91556. radiusZ?: number;
  91557. flat?: boolean;
  91558. subdivisions?: number;
  91559. sideOrientation?: number;
  91560. frontUVs?: Vector4;
  91561. backUVs?: Vector4;
  91562. }): VertexData;
  91563. /**
  91564. * Creates the VertexData for a Polyhedron
  91565. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91566. * * type provided types are:
  91567. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91568. * * 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)
  91569. * * size the size of the IcoSphere, optional default 1
  91570. * * sizeX allows stretching in the x direction, optional, default size
  91571. * * sizeY allows stretching in the y direction, optional, default size
  91572. * * sizeZ allows stretching in the z direction, optional, default size
  91573. * * 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
  91574. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91575. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91576. * * flat when true creates a flat shaded mesh, optional, default true
  91577. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91579. * * 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)
  91580. * * 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)
  91581. * @returns the VertexData of the Polyhedron
  91582. */
  91583. static CreatePolyhedron(options: {
  91584. type?: number;
  91585. size?: number;
  91586. sizeX?: number;
  91587. sizeY?: number;
  91588. sizeZ?: number;
  91589. custom?: any;
  91590. faceUV?: Vector4[];
  91591. faceColors?: Color4[];
  91592. flat?: boolean;
  91593. sideOrientation?: number;
  91594. frontUVs?: Vector4;
  91595. backUVs?: Vector4;
  91596. }): VertexData;
  91597. /**
  91598. * Creates the VertexData for a TorusKnot
  91599. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91600. * * radius the radius of the torus knot, optional, default 2
  91601. * * tube the thickness of the tube, optional, default 0.5
  91602. * * radialSegments the number of sides on each tube segments, optional, default 32
  91603. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91604. * * p the number of windings around the z axis, optional, default 2
  91605. * * q the number of windings around the x axis, optional, default 3
  91606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91607. * * 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)
  91608. * * 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)
  91609. * @returns the VertexData of the Torus Knot
  91610. */
  91611. static CreateTorusKnot(options: {
  91612. radius?: number;
  91613. tube?: number;
  91614. radialSegments?: number;
  91615. tubularSegments?: number;
  91616. p?: number;
  91617. q?: number;
  91618. sideOrientation?: number;
  91619. frontUVs?: Vector4;
  91620. backUVs?: Vector4;
  91621. }): VertexData;
  91622. /**
  91623. * Compute normals for given positions and indices
  91624. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91625. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91626. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91627. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91628. * * facetNormals : optional array of facet normals (vector3)
  91629. * * facetPositions : optional array of facet positions (vector3)
  91630. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91631. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91632. * * bInfo : optional bounding info, required for facetPartitioning computation
  91633. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91634. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91635. * * useRightHandedSystem: optional boolean to for right handed system computation
  91636. * * depthSort : optional boolean to enable the facet depth sort computation
  91637. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91638. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91639. */
  91640. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  91641. facetNormals?: any;
  91642. facetPositions?: any;
  91643. facetPartitioning?: any;
  91644. ratio?: number;
  91645. bInfo?: any;
  91646. bbSize?: Vector3;
  91647. subDiv?: any;
  91648. useRightHandedSystem?: boolean;
  91649. depthSort?: boolean;
  91650. distanceTo?: Vector3;
  91651. depthSortedFacets?: any;
  91652. }): void;
  91653. /** @hidden */
  91654. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  91655. /**
  91656. * Applies VertexData created from the imported parameters to the geometry
  91657. * @param parsedVertexData the parsed data from an imported file
  91658. * @param geometry the geometry to apply the VertexData to
  91659. */
  91660. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  91661. }
  91662. }
  91663. declare module BABYLON {
  91664. /**
  91665. * Defines a target to use with MorphTargetManager
  91666. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91667. */
  91668. export class MorphTarget implements IAnimatable {
  91669. /** defines the name of the target */
  91670. name: string;
  91671. /**
  91672. * Gets or sets the list of animations
  91673. */
  91674. animations: Animation[];
  91675. private _scene;
  91676. private _positions;
  91677. private _normals;
  91678. private _tangents;
  91679. private _uvs;
  91680. private _influence;
  91681. private _uniqueId;
  91682. /**
  91683. * Observable raised when the influence changes
  91684. */
  91685. onInfluenceChanged: Observable<boolean>;
  91686. /** @hidden */
  91687. _onDataLayoutChanged: Observable<void>;
  91688. /**
  91689. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  91690. */
  91691. influence: number;
  91692. /**
  91693. * Gets or sets the id of the morph Target
  91694. */
  91695. id: string;
  91696. private _animationPropertiesOverride;
  91697. /**
  91698. * Gets or sets the animation properties override
  91699. */
  91700. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91701. /**
  91702. * Creates a new MorphTarget
  91703. * @param name defines the name of the target
  91704. * @param influence defines the influence to use
  91705. * @param scene defines the scene the morphtarget belongs to
  91706. */
  91707. constructor(
  91708. /** defines the name of the target */
  91709. name: string, influence?: number, scene?: Nullable<Scene>);
  91710. /**
  91711. * Gets the unique ID of this manager
  91712. */
  91713. readonly uniqueId: number;
  91714. /**
  91715. * Gets a boolean defining if the target contains position data
  91716. */
  91717. readonly hasPositions: boolean;
  91718. /**
  91719. * Gets a boolean defining if the target contains normal data
  91720. */
  91721. readonly hasNormals: boolean;
  91722. /**
  91723. * Gets a boolean defining if the target contains tangent data
  91724. */
  91725. readonly hasTangents: boolean;
  91726. /**
  91727. * Gets a boolean defining if the target contains texture coordinates data
  91728. */
  91729. readonly hasUVs: boolean;
  91730. /**
  91731. * Affects position data to this target
  91732. * @param data defines the position data to use
  91733. */
  91734. setPositions(data: Nullable<FloatArray>): void;
  91735. /**
  91736. * Gets the position data stored in this target
  91737. * @returns a FloatArray containing the position data (or null if not present)
  91738. */
  91739. getPositions(): Nullable<FloatArray>;
  91740. /**
  91741. * Affects normal data to this target
  91742. * @param data defines the normal data to use
  91743. */
  91744. setNormals(data: Nullable<FloatArray>): void;
  91745. /**
  91746. * Gets the normal data stored in this target
  91747. * @returns a FloatArray containing the normal data (or null if not present)
  91748. */
  91749. getNormals(): Nullable<FloatArray>;
  91750. /**
  91751. * Affects tangent data to this target
  91752. * @param data defines the tangent data to use
  91753. */
  91754. setTangents(data: Nullable<FloatArray>): void;
  91755. /**
  91756. * Gets the tangent data stored in this target
  91757. * @returns a FloatArray containing the tangent data (or null if not present)
  91758. */
  91759. getTangents(): Nullable<FloatArray>;
  91760. /**
  91761. * Affects texture coordinates data to this target
  91762. * @param data defines the texture coordinates data to use
  91763. */
  91764. setUVs(data: Nullable<FloatArray>): void;
  91765. /**
  91766. * Gets the texture coordinates data stored in this target
  91767. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  91768. */
  91769. getUVs(): Nullable<FloatArray>;
  91770. /**
  91771. * Clone the current target
  91772. * @returns a new MorphTarget
  91773. */
  91774. clone(): MorphTarget;
  91775. /**
  91776. * Serializes the current target into a Serialization object
  91777. * @returns the serialized object
  91778. */
  91779. serialize(): any;
  91780. /**
  91781. * Returns the string "MorphTarget"
  91782. * @returns "MorphTarget"
  91783. */
  91784. getClassName(): string;
  91785. /**
  91786. * Creates a new target from serialized data
  91787. * @param serializationObject defines the serialized data to use
  91788. * @returns a new MorphTarget
  91789. */
  91790. static Parse(serializationObject: any): MorphTarget;
  91791. /**
  91792. * Creates a MorphTarget from mesh data
  91793. * @param mesh defines the source mesh
  91794. * @param name defines the name to use for the new target
  91795. * @param influence defines the influence to attach to the target
  91796. * @returns a new MorphTarget
  91797. */
  91798. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  91799. }
  91800. }
  91801. declare module BABYLON {
  91802. /**
  91803. * This class is used to deform meshes using morphing between different targets
  91804. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  91805. */
  91806. export class MorphTargetManager {
  91807. private _targets;
  91808. private _targetInfluenceChangedObservers;
  91809. private _targetDataLayoutChangedObservers;
  91810. private _activeTargets;
  91811. private _scene;
  91812. private _influences;
  91813. private _supportsNormals;
  91814. private _supportsTangents;
  91815. private _supportsUVs;
  91816. private _vertexCount;
  91817. private _uniqueId;
  91818. private _tempInfluences;
  91819. /**
  91820. * Gets or sets a boolean indicating if normals must be morphed
  91821. */
  91822. enableNormalMorphing: boolean;
  91823. /**
  91824. * Gets or sets a boolean indicating if tangents must be morphed
  91825. */
  91826. enableTangentMorphing: boolean;
  91827. /**
  91828. * Gets or sets a boolean indicating if UV must be morphed
  91829. */
  91830. enableUVMorphing: boolean;
  91831. /**
  91832. * Creates a new MorphTargetManager
  91833. * @param scene defines the current scene
  91834. */
  91835. constructor(scene?: Nullable<Scene>);
  91836. /**
  91837. * Gets the unique ID of this manager
  91838. */
  91839. readonly uniqueId: number;
  91840. /**
  91841. * Gets the number of vertices handled by this manager
  91842. */
  91843. readonly vertexCount: number;
  91844. /**
  91845. * Gets a boolean indicating if this manager supports morphing of normals
  91846. */
  91847. readonly supportsNormals: boolean;
  91848. /**
  91849. * Gets a boolean indicating if this manager supports morphing of tangents
  91850. */
  91851. readonly supportsTangents: boolean;
  91852. /**
  91853. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  91854. */
  91855. readonly supportsUVs: boolean;
  91856. /**
  91857. * Gets the number of targets stored in this manager
  91858. */
  91859. readonly numTargets: number;
  91860. /**
  91861. * Gets the number of influencers (ie. the number of targets with influences > 0)
  91862. */
  91863. readonly numInfluencers: number;
  91864. /**
  91865. * Gets the list of influences (one per target)
  91866. */
  91867. readonly influences: Float32Array;
  91868. /**
  91869. * Gets the active target at specified index. An active target is a target with an influence > 0
  91870. * @param index defines the index to check
  91871. * @returns the requested target
  91872. */
  91873. getActiveTarget(index: number): MorphTarget;
  91874. /**
  91875. * Gets the target at specified index
  91876. * @param index defines the index to check
  91877. * @returns the requested target
  91878. */
  91879. getTarget(index: number): MorphTarget;
  91880. /**
  91881. * Add a new target to this manager
  91882. * @param target defines the target to add
  91883. */
  91884. addTarget(target: MorphTarget): void;
  91885. /**
  91886. * Removes a target from the manager
  91887. * @param target defines the target to remove
  91888. */
  91889. removeTarget(target: MorphTarget): void;
  91890. /**
  91891. * Clone the current manager
  91892. * @returns a new MorphTargetManager
  91893. */
  91894. clone(): MorphTargetManager;
  91895. /**
  91896. * Serializes the current manager into a Serialization object
  91897. * @returns the serialized object
  91898. */
  91899. serialize(): any;
  91900. private _syncActiveTargets;
  91901. /**
  91902. * Syncrhonize the targets with all the meshes using this morph target manager
  91903. */
  91904. synchronize(): void;
  91905. /**
  91906. * Creates a new MorphTargetManager from serialized data
  91907. * @param serializationObject defines the serialized data
  91908. * @param scene defines the hosting scene
  91909. * @returns the new MorphTargetManager
  91910. */
  91911. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  91912. }
  91913. }
  91914. declare module BABYLON {
  91915. /**
  91916. * Class used to represent a specific level of detail of a mesh
  91917. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  91918. */
  91919. export class MeshLODLevel {
  91920. /** Defines the distance where this level should start being displayed */
  91921. distance: number;
  91922. /** Defines the mesh to use to render this level */
  91923. mesh: Nullable<Mesh>;
  91924. /**
  91925. * Creates a new LOD level
  91926. * @param distance defines the distance where this level should star being displayed
  91927. * @param mesh defines the mesh to use to render this level
  91928. */
  91929. constructor(
  91930. /** Defines the distance where this level should start being displayed */
  91931. distance: number,
  91932. /** Defines the mesh to use to render this level */
  91933. mesh: Nullable<Mesh>);
  91934. }
  91935. }
  91936. declare module BABYLON {
  91937. /**
  91938. * Mesh representing the gorund
  91939. */
  91940. export class GroundMesh extends Mesh {
  91941. /** If octree should be generated */
  91942. generateOctree: boolean;
  91943. private _heightQuads;
  91944. /** @hidden */
  91945. _subdivisionsX: number;
  91946. /** @hidden */
  91947. _subdivisionsY: number;
  91948. /** @hidden */
  91949. _width: number;
  91950. /** @hidden */
  91951. _height: number;
  91952. /** @hidden */
  91953. _minX: number;
  91954. /** @hidden */
  91955. _maxX: number;
  91956. /** @hidden */
  91957. _minZ: number;
  91958. /** @hidden */
  91959. _maxZ: number;
  91960. constructor(name: string, scene: Scene);
  91961. /**
  91962. * "GroundMesh"
  91963. * @returns "GroundMesh"
  91964. */
  91965. getClassName(): string;
  91966. /**
  91967. * The minimum of x and y subdivisions
  91968. */
  91969. readonly subdivisions: number;
  91970. /**
  91971. * X subdivisions
  91972. */
  91973. readonly subdivisionsX: number;
  91974. /**
  91975. * Y subdivisions
  91976. */
  91977. readonly subdivisionsY: number;
  91978. /**
  91979. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  91980. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  91981. * @param chunksCount the number of subdivisions for x and y
  91982. * @param octreeBlocksSize (Default: 32)
  91983. */
  91984. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  91985. /**
  91986. * Returns a height (y) value in the Worl system :
  91987. * the ground altitude at the coordinates (x, z) expressed in the World system.
  91988. * @param x x coordinate
  91989. * @param z z coordinate
  91990. * @returns the ground y position if (x, z) are outside the ground surface.
  91991. */
  91992. getHeightAtCoordinates(x: number, z: number): number;
  91993. /**
  91994. * Returns a normalized vector (Vector3) orthogonal to the ground
  91995. * at the ground coordinates (x, z) expressed in the World system.
  91996. * @param x x coordinate
  91997. * @param z z coordinate
  91998. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  91999. */
  92000. getNormalAtCoordinates(x: number, z: number): Vector3;
  92001. /**
  92002. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  92003. * at the ground coordinates (x, z) expressed in the World system.
  92004. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  92005. * @param x x coordinate
  92006. * @param z z coordinate
  92007. * @param ref vector to store the result
  92008. * @returns the GroundMesh.
  92009. */
  92010. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  92011. /**
  92012. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  92013. * if the ground has been updated.
  92014. * This can be used in the render loop.
  92015. * @returns the GroundMesh.
  92016. */
  92017. updateCoordinateHeights(): GroundMesh;
  92018. private _getFacetAt;
  92019. private _initHeightQuads;
  92020. private _computeHeightQuads;
  92021. /**
  92022. * Serializes this ground mesh
  92023. * @param serializationObject object to write serialization to
  92024. */
  92025. serialize(serializationObject: any): void;
  92026. /**
  92027. * Parses a serialized ground mesh
  92028. * @param parsedMesh the serialized mesh
  92029. * @param scene the scene to create the ground mesh in
  92030. * @returns the created ground mesh
  92031. */
  92032. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  92033. }
  92034. }
  92035. declare module BABYLON {
  92036. /**
  92037. * Interface for Physics-Joint data
  92038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92039. */
  92040. export interface PhysicsJointData {
  92041. /**
  92042. * The main pivot of the joint
  92043. */
  92044. mainPivot?: Vector3;
  92045. /**
  92046. * The connected pivot of the joint
  92047. */
  92048. connectedPivot?: Vector3;
  92049. /**
  92050. * The main axis of the joint
  92051. */
  92052. mainAxis?: Vector3;
  92053. /**
  92054. * The connected axis of the joint
  92055. */
  92056. connectedAxis?: Vector3;
  92057. /**
  92058. * The collision of the joint
  92059. */
  92060. collision?: boolean;
  92061. /**
  92062. * Native Oimo/Cannon/Energy data
  92063. */
  92064. nativeParams?: any;
  92065. }
  92066. /**
  92067. * This is a holder class for the physics joint created by the physics plugin
  92068. * It holds a set of functions to control the underlying joint
  92069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92070. */
  92071. export class PhysicsJoint {
  92072. /**
  92073. * The type of the physics joint
  92074. */
  92075. type: number;
  92076. /**
  92077. * The data for the physics joint
  92078. */
  92079. jointData: PhysicsJointData;
  92080. private _physicsJoint;
  92081. protected _physicsPlugin: IPhysicsEnginePlugin;
  92082. /**
  92083. * Initializes the physics joint
  92084. * @param type The type of the physics joint
  92085. * @param jointData The data for the physics joint
  92086. */
  92087. constructor(
  92088. /**
  92089. * The type of the physics joint
  92090. */
  92091. type: number,
  92092. /**
  92093. * The data for the physics joint
  92094. */
  92095. jointData: PhysicsJointData);
  92096. /**
  92097. * Gets the physics joint
  92098. */
  92099. /**
  92100. * Sets the physics joint
  92101. */
  92102. physicsJoint: any;
  92103. /**
  92104. * Sets the physics plugin
  92105. */
  92106. physicsPlugin: IPhysicsEnginePlugin;
  92107. /**
  92108. * Execute a function that is physics-plugin specific.
  92109. * @param {Function} func the function that will be executed.
  92110. * It accepts two parameters: the physics world and the physics joint
  92111. */
  92112. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  92113. /**
  92114. * Distance-Joint type
  92115. */
  92116. static DistanceJoint: number;
  92117. /**
  92118. * Hinge-Joint type
  92119. */
  92120. static HingeJoint: number;
  92121. /**
  92122. * Ball-and-Socket joint type
  92123. */
  92124. static BallAndSocketJoint: number;
  92125. /**
  92126. * Wheel-Joint type
  92127. */
  92128. static WheelJoint: number;
  92129. /**
  92130. * Slider-Joint type
  92131. */
  92132. static SliderJoint: number;
  92133. /**
  92134. * Prismatic-Joint type
  92135. */
  92136. static PrismaticJoint: number;
  92137. /**
  92138. * Universal-Joint type
  92139. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  92140. */
  92141. static UniversalJoint: number;
  92142. /**
  92143. * Hinge-Joint 2 type
  92144. */
  92145. static Hinge2Joint: number;
  92146. /**
  92147. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  92148. */
  92149. static PointToPointJoint: number;
  92150. /**
  92151. * Spring-Joint type
  92152. */
  92153. static SpringJoint: number;
  92154. /**
  92155. * Lock-Joint type
  92156. */
  92157. static LockJoint: number;
  92158. }
  92159. /**
  92160. * A class representing a physics distance joint
  92161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92162. */
  92163. export class DistanceJoint extends PhysicsJoint {
  92164. /**
  92165. *
  92166. * @param jointData The data for the Distance-Joint
  92167. */
  92168. constructor(jointData: DistanceJointData);
  92169. /**
  92170. * Update the predefined distance.
  92171. * @param maxDistance The maximum preferred distance
  92172. * @param minDistance The minimum preferred distance
  92173. */
  92174. updateDistance(maxDistance: number, minDistance?: number): void;
  92175. }
  92176. /**
  92177. * Represents a Motor-Enabled Joint
  92178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92179. */
  92180. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  92181. /**
  92182. * Initializes the Motor-Enabled Joint
  92183. * @param type The type of the joint
  92184. * @param jointData The physica joint data for the joint
  92185. */
  92186. constructor(type: number, jointData: PhysicsJointData);
  92187. /**
  92188. * Set the motor values.
  92189. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92190. * @param force the force to apply
  92191. * @param maxForce max force for this motor.
  92192. */
  92193. setMotor(force?: number, maxForce?: number): void;
  92194. /**
  92195. * Set the motor's limits.
  92196. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92197. * @param upperLimit The upper limit of the motor
  92198. * @param lowerLimit The lower limit of the motor
  92199. */
  92200. setLimit(upperLimit: number, lowerLimit?: number): void;
  92201. }
  92202. /**
  92203. * This class represents a single physics Hinge-Joint
  92204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92205. */
  92206. export class HingeJoint extends MotorEnabledJoint {
  92207. /**
  92208. * Initializes the Hinge-Joint
  92209. * @param jointData The joint data for the Hinge-Joint
  92210. */
  92211. constructor(jointData: PhysicsJointData);
  92212. /**
  92213. * Set the motor values.
  92214. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92215. * @param {number} force the force to apply
  92216. * @param {number} maxForce max force for this motor.
  92217. */
  92218. setMotor(force?: number, maxForce?: number): void;
  92219. /**
  92220. * Set the motor's limits.
  92221. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92222. * @param upperLimit The upper limit of the motor
  92223. * @param lowerLimit The lower limit of the motor
  92224. */
  92225. setLimit(upperLimit: number, lowerLimit?: number): void;
  92226. }
  92227. /**
  92228. * This class represents a dual hinge physics joint (same as wheel joint)
  92229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92230. */
  92231. export class Hinge2Joint extends MotorEnabledJoint {
  92232. /**
  92233. * Initializes the Hinge2-Joint
  92234. * @param jointData The joint data for the Hinge2-Joint
  92235. */
  92236. constructor(jointData: PhysicsJointData);
  92237. /**
  92238. * Set the motor values.
  92239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92240. * @param {number} targetSpeed the speed the motor is to reach
  92241. * @param {number} maxForce max force for this motor.
  92242. * @param {motorIndex} the motor's index, 0 or 1.
  92243. */
  92244. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  92245. /**
  92246. * Set the motor limits.
  92247. * Attention, this function is plugin specific. Engines won't react 100% the same.
  92248. * @param {number} upperLimit the upper limit
  92249. * @param {number} lowerLimit lower limit
  92250. * @param {motorIndex} the motor's index, 0 or 1.
  92251. */
  92252. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92253. }
  92254. /**
  92255. * Interface for a motor enabled joint
  92256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92257. */
  92258. export interface IMotorEnabledJoint {
  92259. /**
  92260. * Physics joint
  92261. */
  92262. physicsJoint: any;
  92263. /**
  92264. * Sets the motor of the motor-enabled joint
  92265. * @param force The force of the motor
  92266. * @param maxForce The maximum force of the motor
  92267. * @param motorIndex The index of the motor
  92268. */
  92269. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  92270. /**
  92271. * Sets the limit of the motor
  92272. * @param upperLimit The upper limit of the motor
  92273. * @param lowerLimit The lower limit of the motor
  92274. * @param motorIndex The index of the motor
  92275. */
  92276. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92277. }
  92278. /**
  92279. * Joint data for a Distance-Joint
  92280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92281. */
  92282. export interface DistanceJointData extends PhysicsJointData {
  92283. /**
  92284. * Max distance the 2 joint objects can be apart
  92285. */
  92286. maxDistance: number;
  92287. }
  92288. /**
  92289. * Joint data from a spring joint
  92290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92291. */
  92292. export interface SpringJointData extends PhysicsJointData {
  92293. /**
  92294. * Length of the spring
  92295. */
  92296. length: number;
  92297. /**
  92298. * Stiffness of the spring
  92299. */
  92300. stiffness: number;
  92301. /**
  92302. * Damping of the spring
  92303. */
  92304. damping: number;
  92305. /** this callback will be called when applying the force to the impostors. */
  92306. forceApplicationCallback: () => void;
  92307. }
  92308. }
  92309. declare module BABYLON {
  92310. /**
  92311. * Holds the data for the raycast result
  92312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92313. */
  92314. export class PhysicsRaycastResult {
  92315. private _hasHit;
  92316. private _hitDistance;
  92317. private _hitNormalWorld;
  92318. private _hitPointWorld;
  92319. private _rayFromWorld;
  92320. private _rayToWorld;
  92321. /**
  92322. * Gets if there was a hit
  92323. */
  92324. readonly hasHit: boolean;
  92325. /**
  92326. * Gets the distance from the hit
  92327. */
  92328. readonly hitDistance: number;
  92329. /**
  92330. * Gets the hit normal/direction in the world
  92331. */
  92332. readonly hitNormalWorld: Vector3;
  92333. /**
  92334. * Gets the hit point in the world
  92335. */
  92336. readonly hitPointWorld: Vector3;
  92337. /**
  92338. * Gets the ray "start point" of the ray in the world
  92339. */
  92340. readonly rayFromWorld: Vector3;
  92341. /**
  92342. * Gets the ray "end point" of the ray in the world
  92343. */
  92344. readonly rayToWorld: Vector3;
  92345. /**
  92346. * Sets the hit data (normal & point in world space)
  92347. * @param hitNormalWorld defines the normal in world space
  92348. * @param hitPointWorld defines the point in world space
  92349. */
  92350. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  92351. /**
  92352. * Sets the distance from the start point to the hit point
  92353. * @param distance
  92354. */
  92355. setHitDistance(distance: number): void;
  92356. /**
  92357. * Calculates the distance manually
  92358. */
  92359. calculateHitDistance(): void;
  92360. /**
  92361. * Resets all the values to default
  92362. * @param from The from point on world space
  92363. * @param to The to point on world space
  92364. */
  92365. reset(from?: Vector3, to?: Vector3): void;
  92366. }
  92367. /**
  92368. * Interface for the size containing width and height
  92369. */
  92370. interface IXYZ {
  92371. /**
  92372. * X
  92373. */
  92374. x: number;
  92375. /**
  92376. * Y
  92377. */
  92378. y: number;
  92379. /**
  92380. * Z
  92381. */
  92382. z: number;
  92383. }
  92384. }
  92385. declare module BABYLON {
  92386. /**
  92387. * Interface used to describe a physics joint
  92388. */
  92389. export interface PhysicsImpostorJoint {
  92390. /** Defines the main impostor to which the joint is linked */
  92391. mainImpostor: PhysicsImpostor;
  92392. /** Defines the impostor that is connected to the main impostor using this joint */
  92393. connectedImpostor: PhysicsImpostor;
  92394. /** Defines the joint itself */
  92395. joint: PhysicsJoint;
  92396. }
  92397. /** @hidden */
  92398. export interface IPhysicsEnginePlugin {
  92399. world: any;
  92400. name: string;
  92401. setGravity(gravity: Vector3): void;
  92402. setTimeStep(timeStep: number): void;
  92403. getTimeStep(): number;
  92404. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  92405. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  92406. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  92407. generatePhysicsBody(impostor: PhysicsImpostor): void;
  92408. removePhysicsBody(impostor: PhysicsImpostor): void;
  92409. generateJoint(joint: PhysicsImpostorJoint): void;
  92410. removeJoint(joint: PhysicsImpostorJoint): void;
  92411. isSupported(): boolean;
  92412. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  92413. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  92414. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  92415. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  92416. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  92417. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  92418. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  92419. getBodyMass(impostor: PhysicsImpostor): number;
  92420. getBodyFriction(impostor: PhysicsImpostor): number;
  92421. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  92422. getBodyRestitution(impostor: PhysicsImpostor): number;
  92423. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  92424. getBodyPressure?(impostor: PhysicsImpostor): number;
  92425. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  92426. getBodyStiffness?(impostor: PhysicsImpostor): number;
  92427. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  92428. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  92429. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  92430. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  92431. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  92432. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92433. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  92434. sleepBody(impostor: PhysicsImpostor): void;
  92435. wakeUpBody(impostor: PhysicsImpostor): void;
  92436. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92437. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  92438. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  92439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  92440. getRadius(impostor: PhysicsImpostor): number;
  92441. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  92442. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  92443. dispose(): void;
  92444. }
  92445. /**
  92446. * Interface used to define a physics engine
  92447. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  92448. */
  92449. export interface IPhysicsEngine {
  92450. /**
  92451. * Gets the gravity vector used by the simulation
  92452. */
  92453. gravity: Vector3;
  92454. /**
  92455. * Sets the gravity vector used by the simulation
  92456. * @param gravity defines the gravity vector to use
  92457. */
  92458. setGravity(gravity: Vector3): void;
  92459. /**
  92460. * Set the time step of the physics engine.
  92461. * Default is 1/60.
  92462. * To slow it down, enter 1/600 for example.
  92463. * To speed it up, 1/30
  92464. * @param newTimeStep the new timestep to apply to this world.
  92465. */
  92466. setTimeStep(newTimeStep: number): void;
  92467. /**
  92468. * Get the time step of the physics engine.
  92469. * @returns the current time step
  92470. */
  92471. getTimeStep(): number;
  92472. /**
  92473. * Set the sub time step of the physics engine.
  92474. * Default is 0 meaning there is no sub steps
  92475. * To increase physics resolution precision, set a small value (like 1 ms)
  92476. * @param subTimeStep defines the new sub timestep used for physics resolution.
  92477. */
  92478. setSubTimeStep(subTimeStep: number): void;
  92479. /**
  92480. * Get the sub time step of the physics engine.
  92481. * @returns the current sub time step
  92482. */
  92483. getSubTimeStep(): number;
  92484. /**
  92485. * Release all resources
  92486. */
  92487. dispose(): void;
  92488. /**
  92489. * Gets the name of the current physics plugin
  92490. * @returns the name of the plugin
  92491. */
  92492. getPhysicsPluginName(): string;
  92493. /**
  92494. * Adding a new impostor for the impostor tracking.
  92495. * This will be done by the impostor itself.
  92496. * @param impostor the impostor to add
  92497. */
  92498. addImpostor(impostor: PhysicsImpostor): void;
  92499. /**
  92500. * Remove an impostor from the engine.
  92501. * This impostor and its mesh will not longer be updated by the physics engine.
  92502. * @param impostor the impostor to remove
  92503. */
  92504. removeImpostor(impostor: PhysicsImpostor): void;
  92505. /**
  92506. * Add a joint to the physics engine
  92507. * @param mainImpostor defines the main impostor to which the joint is added.
  92508. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  92509. * @param joint defines the joint that will connect both impostors.
  92510. */
  92511. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92512. /**
  92513. * Removes a joint from the simulation
  92514. * @param mainImpostor defines the impostor used with the joint
  92515. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  92516. * @param joint defines the joint to remove
  92517. */
  92518. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  92519. /**
  92520. * Gets the current plugin used to run the simulation
  92521. * @returns current plugin
  92522. */
  92523. getPhysicsPlugin(): IPhysicsEnginePlugin;
  92524. /**
  92525. * Gets the list of physic impostors
  92526. * @returns an array of PhysicsImpostor
  92527. */
  92528. getImpostors(): Array<PhysicsImpostor>;
  92529. /**
  92530. * Gets the impostor for a physics enabled object
  92531. * @param object defines the object impersonated by the impostor
  92532. * @returns the PhysicsImpostor or null if not found
  92533. */
  92534. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92535. /**
  92536. * Gets the impostor for a physics body object
  92537. * @param body defines physics body used by the impostor
  92538. * @returns the PhysicsImpostor or null if not found
  92539. */
  92540. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  92541. /**
  92542. * Does a raycast in the physics world
  92543. * @param from when should the ray start?
  92544. * @param to when should the ray end?
  92545. * @returns PhysicsRaycastResult
  92546. */
  92547. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  92548. /**
  92549. * Called by the scene. No need to call it.
  92550. * @param delta defines the timespam between frames
  92551. */
  92552. _step(delta: number): void;
  92553. }
  92554. }
  92555. declare module BABYLON {
  92556. /**
  92557. * The interface for the physics imposter parameters
  92558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92559. */
  92560. export interface PhysicsImpostorParameters {
  92561. /**
  92562. * The mass of the physics imposter
  92563. */
  92564. mass: number;
  92565. /**
  92566. * The friction of the physics imposter
  92567. */
  92568. friction?: number;
  92569. /**
  92570. * The coefficient of restitution of the physics imposter
  92571. */
  92572. restitution?: number;
  92573. /**
  92574. * The native options of the physics imposter
  92575. */
  92576. nativeOptions?: any;
  92577. /**
  92578. * Specifies if the parent should be ignored
  92579. */
  92580. ignoreParent?: boolean;
  92581. /**
  92582. * Specifies if bi-directional transformations should be disabled
  92583. */
  92584. disableBidirectionalTransformation?: boolean;
  92585. /**
  92586. * The pressure inside the physics imposter, soft object only
  92587. */
  92588. pressure?: number;
  92589. /**
  92590. * The stiffness the physics imposter, soft object only
  92591. */
  92592. stiffness?: number;
  92593. /**
  92594. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  92595. */
  92596. velocityIterations?: number;
  92597. /**
  92598. * The number of iterations used in maintaining consistent vertex positions, soft object only
  92599. */
  92600. positionIterations?: number;
  92601. /**
  92602. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  92603. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  92604. * Add to fix multiple points
  92605. */
  92606. fixedPoints?: number;
  92607. /**
  92608. * The collision margin around a soft object
  92609. */
  92610. margin?: number;
  92611. /**
  92612. * The collision margin around a soft object
  92613. */
  92614. damping?: number;
  92615. /**
  92616. * The path for a rope based on an extrusion
  92617. */
  92618. path?: any;
  92619. /**
  92620. * The shape of an extrusion used for a rope based on an extrusion
  92621. */
  92622. shape?: any;
  92623. }
  92624. /**
  92625. * Interface for a physics-enabled object
  92626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92627. */
  92628. export interface IPhysicsEnabledObject {
  92629. /**
  92630. * The position of the physics-enabled object
  92631. */
  92632. position: Vector3;
  92633. /**
  92634. * The rotation of the physics-enabled object
  92635. */
  92636. rotationQuaternion: Nullable<Quaternion>;
  92637. /**
  92638. * The scale of the physics-enabled object
  92639. */
  92640. scaling: Vector3;
  92641. /**
  92642. * The rotation of the physics-enabled object
  92643. */
  92644. rotation?: Vector3;
  92645. /**
  92646. * The parent of the physics-enabled object
  92647. */
  92648. parent?: any;
  92649. /**
  92650. * The bounding info of the physics-enabled object
  92651. * @returns The bounding info of the physics-enabled object
  92652. */
  92653. getBoundingInfo(): BoundingInfo;
  92654. /**
  92655. * Computes the world matrix
  92656. * @param force Specifies if the world matrix should be computed by force
  92657. * @returns A world matrix
  92658. */
  92659. computeWorldMatrix(force: boolean): Matrix;
  92660. /**
  92661. * Gets the world matrix
  92662. * @returns A world matrix
  92663. */
  92664. getWorldMatrix?(): Matrix;
  92665. /**
  92666. * Gets the child meshes
  92667. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  92668. * @returns An array of abstract meshes
  92669. */
  92670. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  92671. /**
  92672. * Gets the vertex data
  92673. * @param kind The type of vertex data
  92674. * @returns A nullable array of numbers, or a float32 array
  92675. */
  92676. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  92677. /**
  92678. * Gets the indices from the mesh
  92679. * @returns A nullable array of index arrays
  92680. */
  92681. getIndices?(): Nullable<IndicesArray>;
  92682. /**
  92683. * Gets the scene from the mesh
  92684. * @returns the indices array or null
  92685. */
  92686. getScene?(): Scene;
  92687. /**
  92688. * Gets the absolute position from the mesh
  92689. * @returns the absolute position
  92690. */
  92691. getAbsolutePosition(): Vector3;
  92692. /**
  92693. * Gets the absolute pivot point from the mesh
  92694. * @returns the absolute pivot point
  92695. */
  92696. getAbsolutePivotPoint(): Vector3;
  92697. /**
  92698. * Rotates the mesh
  92699. * @param axis The axis of rotation
  92700. * @param amount The amount of rotation
  92701. * @param space The space of the rotation
  92702. * @returns The rotation transform node
  92703. */
  92704. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92705. /**
  92706. * Translates the mesh
  92707. * @param axis The axis of translation
  92708. * @param distance The distance of translation
  92709. * @param space The space of the translation
  92710. * @returns The transform node
  92711. */
  92712. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92713. /**
  92714. * Sets the absolute position of the mesh
  92715. * @param absolutePosition The absolute position of the mesh
  92716. * @returns The transform node
  92717. */
  92718. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92719. /**
  92720. * Gets the class name of the mesh
  92721. * @returns The class name
  92722. */
  92723. getClassName(): string;
  92724. }
  92725. /**
  92726. * Represents a physics imposter
  92727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  92728. */
  92729. export class PhysicsImpostor {
  92730. /**
  92731. * The physics-enabled object used as the physics imposter
  92732. */
  92733. object: IPhysicsEnabledObject;
  92734. /**
  92735. * The type of the physics imposter
  92736. */
  92737. type: number;
  92738. private _options;
  92739. private _scene?;
  92740. /**
  92741. * The default object size of the imposter
  92742. */
  92743. static DEFAULT_OBJECT_SIZE: Vector3;
  92744. /**
  92745. * The identity quaternion of the imposter
  92746. */
  92747. static IDENTITY_QUATERNION: Quaternion;
  92748. /** @hidden */
  92749. _pluginData: any;
  92750. private _physicsEngine;
  92751. private _physicsBody;
  92752. private _bodyUpdateRequired;
  92753. private _onBeforePhysicsStepCallbacks;
  92754. private _onAfterPhysicsStepCallbacks;
  92755. /** @hidden */
  92756. _onPhysicsCollideCallbacks: Array<{
  92757. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  92758. otherImpostors: Array<PhysicsImpostor>;
  92759. }>;
  92760. private _deltaPosition;
  92761. private _deltaRotation;
  92762. private _deltaRotationConjugated;
  92763. /** @hidden */
  92764. _isFromLine: boolean;
  92765. private _parent;
  92766. private _isDisposed;
  92767. private static _tmpVecs;
  92768. private static _tmpQuat;
  92769. /**
  92770. * Specifies if the physics imposter is disposed
  92771. */
  92772. readonly isDisposed: boolean;
  92773. /**
  92774. * Gets the mass of the physics imposter
  92775. */
  92776. mass: number;
  92777. /**
  92778. * Gets the coefficient of friction
  92779. */
  92780. /**
  92781. * Sets the coefficient of friction
  92782. */
  92783. friction: number;
  92784. /**
  92785. * Gets the coefficient of restitution
  92786. */
  92787. /**
  92788. * Sets the coefficient of restitution
  92789. */
  92790. restitution: number;
  92791. /**
  92792. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  92793. */
  92794. /**
  92795. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  92796. */
  92797. pressure: number;
  92798. /**
  92799. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92800. */
  92801. /**
  92802. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  92803. */
  92804. stiffness: number;
  92805. /**
  92806. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92807. */
  92808. /**
  92809. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  92810. */
  92811. velocityIterations: number;
  92812. /**
  92813. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92814. */
  92815. /**
  92816. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  92817. */
  92818. positionIterations: number;
  92819. /**
  92820. * The unique id of the physics imposter
  92821. * set by the physics engine when adding this impostor to the array
  92822. */
  92823. uniqueId: number;
  92824. /**
  92825. * @hidden
  92826. */
  92827. soft: boolean;
  92828. /**
  92829. * @hidden
  92830. */
  92831. segments: number;
  92832. private _joints;
  92833. /**
  92834. * Initializes the physics imposter
  92835. * @param object The physics-enabled object used as the physics imposter
  92836. * @param type The type of the physics imposter
  92837. * @param _options The options for the physics imposter
  92838. * @param _scene The Babylon scene
  92839. */
  92840. constructor(
  92841. /**
  92842. * The physics-enabled object used as the physics imposter
  92843. */
  92844. object: IPhysicsEnabledObject,
  92845. /**
  92846. * The type of the physics imposter
  92847. */
  92848. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  92849. /**
  92850. * This function will completly initialize this impostor.
  92851. * It will create a new body - but only if this mesh has no parent.
  92852. * If it has, this impostor will not be used other than to define the impostor
  92853. * of the child mesh.
  92854. * @hidden
  92855. */
  92856. _init(): void;
  92857. private _getPhysicsParent;
  92858. /**
  92859. * Should a new body be generated.
  92860. * @returns boolean specifying if body initialization is required
  92861. */
  92862. isBodyInitRequired(): boolean;
  92863. /**
  92864. * Sets the updated scaling
  92865. * @param updated Specifies if the scaling is updated
  92866. */
  92867. setScalingUpdated(): void;
  92868. /**
  92869. * Force a regeneration of this or the parent's impostor's body.
  92870. * Use under cautious - This will remove all joints already implemented.
  92871. */
  92872. forceUpdate(): void;
  92873. /**
  92874. * Gets the body that holds this impostor. Either its own, or its parent.
  92875. */
  92876. /**
  92877. * Set the physics body. Used mainly by the physics engine/plugin
  92878. */
  92879. physicsBody: any;
  92880. /**
  92881. * Get the parent of the physics imposter
  92882. * @returns Physics imposter or null
  92883. */
  92884. /**
  92885. * Sets the parent of the physics imposter
  92886. */
  92887. parent: Nullable<PhysicsImpostor>;
  92888. /**
  92889. * Resets the update flags
  92890. */
  92891. resetUpdateFlags(): void;
  92892. /**
  92893. * Gets the object extend size
  92894. * @returns the object extend size
  92895. */
  92896. getObjectExtendSize(): Vector3;
  92897. /**
  92898. * Gets the object center
  92899. * @returns The object center
  92900. */
  92901. getObjectCenter(): Vector3;
  92902. /**
  92903. * Get a specific parametes from the options parameter
  92904. * @param paramName The object parameter name
  92905. * @returns The object parameter
  92906. */
  92907. getParam(paramName: string): any;
  92908. /**
  92909. * Sets a specific parameter in the options given to the physics plugin
  92910. * @param paramName The parameter name
  92911. * @param value The value of the parameter
  92912. */
  92913. setParam(paramName: string, value: number): void;
  92914. /**
  92915. * Specifically change the body's mass option. Won't recreate the physics body object
  92916. * @param mass The mass of the physics imposter
  92917. */
  92918. setMass(mass: number): void;
  92919. /**
  92920. * Gets the linear velocity
  92921. * @returns linear velocity or null
  92922. */
  92923. getLinearVelocity(): Nullable<Vector3>;
  92924. /**
  92925. * Sets the linear velocity
  92926. * @param velocity linear velocity or null
  92927. */
  92928. setLinearVelocity(velocity: Nullable<Vector3>): void;
  92929. /**
  92930. * Gets the angular velocity
  92931. * @returns angular velocity or null
  92932. */
  92933. getAngularVelocity(): Nullable<Vector3>;
  92934. /**
  92935. * Sets the angular velocity
  92936. * @param velocity The velocity or null
  92937. */
  92938. setAngularVelocity(velocity: Nullable<Vector3>): void;
  92939. /**
  92940. * Execute a function with the physics plugin native code
  92941. * Provide a function the will have two variables - the world object and the physics body object
  92942. * @param func The function to execute with the physics plugin native code
  92943. */
  92944. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  92945. /**
  92946. * Register a function that will be executed before the physics world is stepping forward
  92947. * @param func The function to execute before the physics world is stepped forward
  92948. */
  92949. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92950. /**
  92951. * Unregister a function that will be executed before the physics world is stepping forward
  92952. * @param func The function to execute before the physics world is stepped forward
  92953. */
  92954. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92955. /**
  92956. * Register a function that will be executed after the physics step
  92957. * @param func The function to execute after physics step
  92958. */
  92959. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92960. /**
  92961. * Unregisters a function that will be executed after the physics step
  92962. * @param func The function to execute after physics step
  92963. */
  92964. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  92965. /**
  92966. * register a function that will be executed when this impostor collides against a different body
  92967. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  92968. * @param func Callback that is executed on collision
  92969. */
  92970. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  92971. /**
  92972. * Unregisters the physics imposter on contact
  92973. * @param collideAgainst The physics object to collide against
  92974. * @param func Callback to execute on collision
  92975. */
  92976. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  92977. private _tmpQuat;
  92978. private _tmpQuat2;
  92979. /**
  92980. * Get the parent rotation
  92981. * @returns The parent rotation
  92982. */
  92983. getParentsRotation(): Quaternion;
  92984. /**
  92985. * this function is executed by the physics engine.
  92986. */
  92987. beforeStep: () => void;
  92988. /**
  92989. * this function is executed by the physics engine
  92990. */
  92991. afterStep: () => void;
  92992. /**
  92993. * Legacy collision detection event support
  92994. */
  92995. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  92996. /**
  92997. * event and body object due to cannon's event-based architecture.
  92998. */
  92999. onCollide: (e: {
  93000. body: any;
  93001. }) => void;
  93002. /**
  93003. * Apply a force
  93004. * @param force The force to apply
  93005. * @param contactPoint The contact point for the force
  93006. * @returns The physics imposter
  93007. */
  93008. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  93009. /**
  93010. * Apply an impulse
  93011. * @param force The impulse force
  93012. * @param contactPoint The contact point for the impulse force
  93013. * @returns The physics imposter
  93014. */
  93015. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  93016. /**
  93017. * A help function to create a joint
  93018. * @param otherImpostor A physics imposter used to create a joint
  93019. * @param jointType The type of joint
  93020. * @param jointData The data for the joint
  93021. * @returns The physics imposter
  93022. */
  93023. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  93024. /**
  93025. * Add a joint to this impostor with a different impostor
  93026. * @param otherImpostor A physics imposter used to add a joint
  93027. * @param joint The joint to add
  93028. * @returns The physics imposter
  93029. */
  93030. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  93031. /**
  93032. * Add an anchor to a cloth impostor
  93033. * @param otherImpostor rigid impostor to anchor to
  93034. * @param width ratio across width from 0 to 1
  93035. * @param height ratio up height from 0 to 1
  93036. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  93037. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  93038. * @returns impostor the soft imposter
  93039. */
  93040. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  93041. /**
  93042. * Add a hook to a rope impostor
  93043. * @param otherImpostor rigid impostor to anchor to
  93044. * @param length ratio across rope from 0 to 1
  93045. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  93046. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  93047. * @returns impostor the rope imposter
  93048. */
  93049. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  93050. /**
  93051. * Will keep this body still, in a sleep mode.
  93052. * @returns the physics imposter
  93053. */
  93054. sleep(): PhysicsImpostor;
  93055. /**
  93056. * Wake the body up.
  93057. * @returns The physics imposter
  93058. */
  93059. wakeUp(): PhysicsImpostor;
  93060. /**
  93061. * Clones the physics imposter
  93062. * @param newObject The physics imposter clones to this physics-enabled object
  93063. * @returns A nullable physics imposter
  93064. */
  93065. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93066. /**
  93067. * Disposes the physics imposter
  93068. */
  93069. dispose(): void;
  93070. /**
  93071. * Sets the delta position
  93072. * @param position The delta position amount
  93073. */
  93074. setDeltaPosition(position: Vector3): void;
  93075. /**
  93076. * Sets the delta rotation
  93077. * @param rotation The delta rotation amount
  93078. */
  93079. setDeltaRotation(rotation: Quaternion): void;
  93080. /**
  93081. * Gets the box size of the physics imposter and stores the result in the input parameter
  93082. * @param result Stores the box size
  93083. * @returns The physics imposter
  93084. */
  93085. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  93086. /**
  93087. * Gets the radius of the physics imposter
  93088. * @returns Radius of the physics imposter
  93089. */
  93090. getRadius(): number;
  93091. /**
  93092. * Sync a bone with this impostor
  93093. * @param bone The bone to sync to the impostor.
  93094. * @param boneMesh The mesh that the bone is influencing.
  93095. * @param jointPivot The pivot of the joint / bone in local space.
  93096. * @param distToJoint Optional distance from the impostor to the joint.
  93097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  93098. */
  93099. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  93100. /**
  93101. * Sync impostor to a bone
  93102. * @param bone The bone that the impostor will be synced to.
  93103. * @param boneMesh The mesh that the bone is influencing.
  93104. * @param jointPivot The pivot of the joint / bone in local space.
  93105. * @param distToJoint Optional distance from the impostor to the joint.
  93106. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  93107. * @param boneAxis Optional vector3 axis the bone is aligned with
  93108. */
  93109. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  93110. /**
  93111. * No-Imposter type
  93112. */
  93113. static NoImpostor: number;
  93114. /**
  93115. * Sphere-Imposter type
  93116. */
  93117. static SphereImpostor: number;
  93118. /**
  93119. * Box-Imposter type
  93120. */
  93121. static BoxImpostor: number;
  93122. /**
  93123. * Plane-Imposter type
  93124. */
  93125. static PlaneImpostor: number;
  93126. /**
  93127. * Mesh-imposter type
  93128. */
  93129. static MeshImpostor: number;
  93130. /**
  93131. * Capsule-Impostor type (Ammo.js plugin only)
  93132. */
  93133. static CapsuleImpostor: number;
  93134. /**
  93135. * Cylinder-Imposter type
  93136. */
  93137. static CylinderImpostor: number;
  93138. /**
  93139. * Particle-Imposter type
  93140. */
  93141. static ParticleImpostor: number;
  93142. /**
  93143. * Heightmap-Imposter type
  93144. */
  93145. static HeightmapImpostor: number;
  93146. /**
  93147. * ConvexHull-Impostor type (Ammo.js plugin only)
  93148. */
  93149. static ConvexHullImpostor: number;
  93150. /**
  93151. * Custom-Imposter type (Ammo.js plugin only)
  93152. */
  93153. static CustomImpostor: number;
  93154. /**
  93155. * Rope-Imposter type
  93156. */
  93157. static RopeImpostor: number;
  93158. /**
  93159. * Cloth-Imposter type
  93160. */
  93161. static ClothImpostor: number;
  93162. /**
  93163. * Softbody-Imposter type
  93164. */
  93165. static SoftbodyImpostor: number;
  93166. }
  93167. }
  93168. declare module BABYLON {
  93169. /**
  93170. * @hidden
  93171. **/
  93172. export class _CreationDataStorage {
  93173. closePath?: boolean;
  93174. closeArray?: boolean;
  93175. idx: number[];
  93176. dashSize: number;
  93177. gapSize: number;
  93178. path3D: Path3D;
  93179. pathArray: Vector3[][];
  93180. arc: number;
  93181. radius: number;
  93182. cap: number;
  93183. tessellation: number;
  93184. }
  93185. /**
  93186. * @hidden
  93187. **/
  93188. class _InstanceDataStorage {
  93189. visibleInstances: any;
  93190. batchCache: _InstancesBatch;
  93191. instancesBufferSize: number;
  93192. instancesBuffer: Nullable<Buffer>;
  93193. instancesData: Float32Array;
  93194. overridenInstanceCount: number;
  93195. isFrozen: boolean;
  93196. previousBatch: Nullable<_InstancesBatch>;
  93197. hardwareInstancedRendering: boolean;
  93198. sideOrientation: number;
  93199. manualUpdate: boolean;
  93200. }
  93201. /**
  93202. * @hidden
  93203. **/
  93204. export class _InstancesBatch {
  93205. mustReturn: boolean;
  93206. visibleInstances: Nullable<InstancedMesh[]>[];
  93207. renderSelf: boolean[];
  93208. hardwareInstancedRendering: boolean[];
  93209. }
  93210. /**
  93211. * Class used to represent renderable models
  93212. */
  93213. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  93214. /**
  93215. * Mesh side orientation : usually the external or front surface
  93216. */
  93217. static readonly FRONTSIDE: number;
  93218. /**
  93219. * Mesh side orientation : usually the internal or back surface
  93220. */
  93221. static readonly BACKSIDE: number;
  93222. /**
  93223. * Mesh side orientation : both internal and external or front and back surfaces
  93224. */
  93225. static readonly DOUBLESIDE: number;
  93226. /**
  93227. * Mesh side orientation : by default, `FRONTSIDE`
  93228. */
  93229. static readonly DEFAULTSIDE: number;
  93230. /**
  93231. * Mesh cap setting : no cap
  93232. */
  93233. static readonly NO_CAP: number;
  93234. /**
  93235. * Mesh cap setting : one cap at the beginning of the mesh
  93236. */
  93237. static readonly CAP_START: number;
  93238. /**
  93239. * Mesh cap setting : one cap at the end of the mesh
  93240. */
  93241. static readonly CAP_END: number;
  93242. /**
  93243. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  93244. */
  93245. static readonly CAP_ALL: number;
  93246. /**
  93247. * Mesh pattern setting : no flip or rotate
  93248. */
  93249. static readonly NO_FLIP: number;
  93250. /**
  93251. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  93252. */
  93253. static readonly FLIP_TILE: number;
  93254. /**
  93255. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  93256. */
  93257. static readonly ROTATE_TILE: number;
  93258. /**
  93259. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  93260. */
  93261. static readonly FLIP_ROW: number;
  93262. /**
  93263. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  93264. */
  93265. static readonly ROTATE_ROW: number;
  93266. /**
  93267. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  93268. */
  93269. static readonly FLIP_N_ROTATE_TILE: number;
  93270. /**
  93271. * Mesh pattern setting : rotate pattern and rotate
  93272. */
  93273. static readonly FLIP_N_ROTATE_ROW: number;
  93274. /**
  93275. * Mesh tile positioning : part tiles same on left/right or top/bottom
  93276. */
  93277. static readonly CENTER: number;
  93278. /**
  93279. * Mesh tile positioning : part tiles on left
  93280. */
  93281. static readonly LEFT: number;
  93282. /**
  93283. * Mesh tile positioning : part tiles on right
  93284. */
  93285. static readonly RIGHT: number;
  93286. /**
  93287. * Mesh tile positioning : part tiles on top
  93288. */
  93289. static readonly TOP: number;
  93290. /**
  93291. * Mesh tile positioning : part tiles on bottom
  93292. */
  93293. static readonly BOTTOM: number;
  93294. /**
  93295. * Gets the default side orientation.
  93296. * @param orientation the orientation to value to attempt to get
  93297. * @returns the default orientation
  93298. * @hidden
  93299. */
  93300. static _GetDefaultSideOrientation(orientation?: number): number;
  93301. private _internalMeshDataInfo;
  93302. /**
  93303. * An event triggered before rendering the mesh
  93304. */
  93305. readonly onBeforeRenderObservable: Observable<Mesh>;
  93306. /**
  93307. * An event triggered before binding the mesh
  93308. */
  93309. readonly onBeforeBindObservable: Observable<Mesh>;
  93310. /**
  93311. * An event triggered after rendering the mesh
  93312. */
  93313. readonly onAfterRenderObservable: Observable<Mesh>;
  93314. /**
  93315. * An event triggered before drawing the mesh
  93316. */
  93317. readonly onBeforeDrawObservable: Observable<Mesh>;
  93318. private _onBeforeDrawObserver;
  93319. /**
  93320. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  93321. */
  93322. onBeforeDraw: () => void;
  93323. readonly hasInstances: boolean;
  93324. /**
  93325. * Gets the delay loading state of the mesh (when delay loading is turned on)
  93326. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  93327. */
  93328. delayLoadState: number;
  93329. /**
  93330. * Gets the list of instances created from this mesh
  93331. * it is not supposed to be modified manually.
  93332. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  93333. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93334. */
  93335. instances: InstancedMesh[];
  93336. /**
  93337. * Gets the file containing delay loading data for this mesh
  93338. */
  93339. delayLoadingFile: string;
  93340. /** @hidden */
  93341. _binaryInfo: any;
  93342. /**
  93343. * User defined function used to change how LOD level selection is done
  93344. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93345. */
  93346. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  93347. /**
  93348. * Gets or sets the morph target manager
  93349. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93350. */
  93351. morphTargetManager: Nullable<MorphTargetManager>;
  93352. /** @hidden */
  93353. _creationDataStorage: Nullable<_CreationDataStorage>;
  93354. /** @hidden */
  93355. _geometry: Nullable<Geometry>;
  93356. /** @hidden */
  93357. _delayInfo: Array<string>;
  93358. /** @hidden */
  93359. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  93360. /** @hidden */
  93361. _instanceDataStorage: _InstanceDataStorage;
  93362. private _effectiveMaterial;
  93363. /** @hidden */
  93364. _shouldGenerateFlatShading: boolean;
  93365. /** @hidden */
  93366. _originalBuilderSideOrientation: number;
  93367. /**
  93368. * Use this property to change the original side orientation defined at construction time
  93369. */
  93370. overrideMaterialSideOrientation: Nullable<number>;
  93371. /**
  93372. * Gets the source mesh (the one used to clone this one from)
  93373. */
  93374. readonly source: Nullable<Mesh>;
  93375. /**
  93376. * Gets or sets a boolean indicating that this mesh does not use index buffer
  93377. */
  93378. isUnIndexed: boolean;
  93379. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  93380. readonly worldMatrixInstancedBuffer: Float32Array;
  93381. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  93382. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  93383. /**
  93384. * @constructor
  93385. * @param name The value used by scene.getMeshByName() to do a lookup.
  93386. * @param scene The scene to add this mesh to.
  93387. * @param parent The parent of this mesh, if it has one
  93388. * @param source An optional Mesh from which geometry is shared, cloned.
  93389. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  93390. * When false, achieved by calling a clone(), also passing False.
  93391. * This will make creation of children, recursive.
  93392. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  93393. */
  93394. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  93395. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  93396. doNotInstantiate: boolean;
  93397. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  93398. /**
  93399. * Gets the class name
  93400. * @returns the string "Mesh".
  93401. */
  93402. getClassName(): string;
  93403. /** @hidden */
  93404. readonly _isMesh: boolean;
  93405. /**
  93406. * Returns a description of this mesh
  93407. * @param fullDetails define if full details about this mesh must be used
  93408. * @returns a descriptive string representing this mesh
  93409. */
  93410. toString(fullDetails?: boolean): string;
  93411. /** @hidden */
  93412. _unBindEffect(): void;
  93413. /**
  93414. * Gets a boolean indicating if this mesh has LOD
  93415. */
  93416. readonly hasLODLevels: boolean;
  93417. /**
  93418. * Gets the list of MeshLODLevel associated with the current mesh
  93419. * @returns an array of MeshLODLevel
  93420. */
  93421. getLODLevels(): MeshLODLevel[];
  93422. private _sortLODLevels;
  93423. /**
  93424. * Add a mesh as LOD level triggered at the given distance.
  93425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93426. * @param distance The distance from the center of the object to show this level
  93427. * @param mesh The mesh to be added as LOD level (can be null)
  93428. * @return This mesh (for chaining)
  93429. */
  93430. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  93431. /**
  93432. * Returns the LOD level mesh at the passed distance or null if not found.
  93433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93434. * @param distance The distance from the center of the object to show this level
  93435. * @returns a Mesh or `null`
  93436. */
  93437. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  93438. /**
  93439. * Remove a mesh from the LOD array
  93440. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93441. * @param mesh defines the mesh to be removed
  93442. * @return This mesh (for chaining)
  93443. */
  93444. removeLODLevel(mesh: Mesh): Mesh;
  93445. /**
  93446. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  93447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  93448. * @param camera defines the camera to use to compute distance
  93449. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  93450. * @return This mesh (for chaining)
  93451. */
  93452. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  93453. /**
  93454. * Gets the mesh internal Geometry object
  93455. */
  93456. readonly geometry: Nullable<Geometry>;
  93457. /**
  93458. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  93459. * @returns the total number of vertices
  93460. */
  93461. getTotalVertices(): number;
  93462. /**
  93463. * Returns the content of an associated vertex buffer
  93464. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93465. * - VertexBuffer.PositionKind
  93466. * - VertexBuffer.UVKind
  93467. * - VertexBuffer.UV2Kind
  93468. * - VertexBuffer.UV3Kind
  93469. * - VertexBuffer.UV4Kind
  93470. * - VertexBuffer.UV5Kind
  93471. * - VertexBuffer.UV6Kind
  93472. * - VertexBuffer.ColorKind
  93473. * - VertexBuffer.MatricesIndicesKind
  93474. * - VertexBuffer.MatricesIndicesExtraKind
  93475. * - VertexBuffer.MatricesWeightsKind
  93476. * - VertexBuffer.MatricesWeightsExtraKind
  93477. * @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
  93478. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  93479. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  93480. */
  93481. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93482. /**
  93483. * Returns the mesh VertexBuffer object from the requested `kind`
  93484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93485. * - VertexBuffer.PositionKind
  93486. * - VertexBuffer.NormalKind
  93487. * - VertexBuffer.UVKind
  93488. * - VertexBuffer.UV2Kind
  93489. * - VertexBuffer.UV3Kind
  93490. * - VertexBuffer.UV4Kind
  93491. * - VertexBuffer.UV5Kind
  93492. * - VertexBuffer.UV6Kind
  93493. * - VertexBuffer.ColorKind
  93494. * - VertexBuffer.MatricesIndicesKind
  93495. * - VertexBuffer.MatricesIndicesExtraKind
  93496. * - VertexBuffer.MatricesWeightsKind
  93497. * - VertexBuffer.MatricesWeightsExtraKind
  93498. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  93499. */
  93500. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93501. /**
  93502. * Tests if a specific vertex buffer is associated with this mesh
  93503. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93504. * - VertexBuffer.PositionKind
  93505. * - VertexBuffer.NormalKind
  93506. * - VertexBuffer.UVKind
  93507. * - VertexBuffer.UV2Kind
  93508. * - VertexBuffer.UV3Kind
  93509. * - VertexBuffer.UV4Kind
  93510. * - VertexBuffer.UV5Kind
  93511. * - VertexBuffer.UV6Kind
  93512. * - VertexBuffer.ColorKind
  93513. * - VertexBuffer.MatricesIndicesKind
  93514. * - VertexBuffer.MatricesIndicesExtraKind
  93515. * - VertexBuffer.MatricesWeightsKind
  93516. * - VertexBuffer.MatricesWeightsExtraKind
  93517. * @returns a boolean
  93518. */
  93519. isVerticesDataPresent(kind: string): boolean;
  93520. /**
  93521. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  93522. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  93523. * - VertexBuffer.PositionKind
  93524. * - VertexBuffer.UVKind
  93525. * - VertexBuffer.UV2Kind
  93526. * - VertexBuffer.UV3Kind
  93527. * - VertexBuffer.UV4Kind
  93528. * - VertexBuffer.UV5Kind
  93529. * - VertexBuffer.UV6Kind
  93530. * - VertexBuffer.ColorKind
  93531. * - VertexBuffer.MatricesIndicesKind
  93532. * - VertexBuffer.MatricesIndicesExtraKind
  93533. * - VertexBuffer.MatricesWeightsKind
  93534. * - VertexBuffer.MatricesWeightsExtraKind
  93535. * @returns a boolean
  93536. */
  93537. isVertexBufferUpdatable(kind: string): boolean;
  93538. /**
  93539. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  93540. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  93541. * - VertexBuffer.PositionKind
  93542. * - VertexBuffer.NormalKind
  93543. * - VertexBuffer.UVKind
  93544. * - VertexBuffer.UV2Kind
  93545. * - VertexBuffer.UV3Kind
  93546. * - VertexBuffer.UV4Kind
  93547. * - VertexBuffer.UV5Kind
  93548. * - VertexBuffer.UV6Kind
  93549. * - VertexBuffer.ColorKind
  93550. * - VertexBuffer.MatricesIndicesKind
  93551. * - VertexBuffer.MatricesIndicesExtraKind
  93552. * - VertexBuffer.MatricesWeightsKind
  93553. * - VertexBuffer.MatricesWeightsExtraKind
  93554. * @returns an array of strings
  93555. */
  93556. getVerticesDataKinds(): string[];
  93557. /**
  93558. * Returns a positive integer : the total number of indices in this mesh geometry.
  93559. * @returns the numner of indices or zero if the mesh has no geometry.
  93560. */
  93561. getTotalIndices(): number;
  93562. /**
  93563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93564. * @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.
  93565. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93566. * @returns the indices array or an empty array if the mesh has no geometry
  93567. */
  93568. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93569. readonly isBlocked: boolean;
  93570. /**
  93571. * Determine if the current mesh is ready to be rendered
  93572. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93573. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  93574. * @returns true if all associated assets are ready (material, textures, shaders)
  93575. */
  93576. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  93577. /**
  93578. * 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.
  93579. */
  93580. readonly areNormalsFrozen: boolean;
  93581. /**
  93582. * 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.
  93583. * @returns the current mesh
  93584. */
  93585. freezeNormals(): Mesh;
  93586. /**
  93587. * 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
  93588. * @returns the current mesh
  93589. */
  93590. unfreezeNormals(): Mesh;
  93591. /**
  93592. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  93593. */
  93594. overridenInstanceCount: number;
  93595. /** @hidden */
  93596. _preActivate(): Mesh;
  93597. /** @hidden */
  93598. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93599. /** @hidden */
  93600. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  93601. /**
  93602. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93603. * This means the mesh underlying bounding box and sphere are recomputed.
  93604. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93605. * @returns the current mesh
  93606. */
  93607. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  93608. /** @hidden */
  93609. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  93610. /**
  93611. * This function will subdivide the mesh into multiple submeshes
  93612. * @param count defines the expected number of submeshes
  93613. */
  93614. subdivide(count: number): void;
  93615. /**
  93616. * Copy a FloatArray into a specific associated vertex buffer
  93617. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93618. * - VertexBuffer.PositionKind
  93619. * - VertexBuffer.UVKind
  93620. * - VertexBuffer.UV2Kind
  93621. * - VertexBuffer.UV3Kind
  93622. * - VertexBuffer.UV4Kind
  93623. * - VertexBuffer.UV5Kind
  93624. * - VertexBuffer.UV6Kind
  93625. * - VertexBuffer.ColorKind
  93626. * - VertexBuffer.MatricesIndicesKind
  93627. * - VertexBuffer.MatricesIndicesExtraKind
  93628. * - VertexBuffer.MatricesWeightsKind
  93629. * - VertexBuffer.MatricesWeightsExtraKind
  93630. * @param data defines the data source
  93631. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93632. * @param stride defines the data stride size (can be null)
  93633. * @returns the current mesh
  93634. */
  93635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93636. /**
  93637. * Delete a vertex buffer associated with this mesh
  93638. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  93639. * - VertexBuffer.PositionKind
  93640. * - VertexBuffer.UVKind
  93641. * - VertexBuffer.UV2Kind
  93642. * - VertexBuffer.UV3Kind
  93643. * - VertexBuffer.UV4Kind
  93644. * - VertexBuffer.UV5Kind
  93645. * - VertexBuffer.UV6Kind
  93646. * - VertexBuffer.ColorKind
  93647. * - VertexBuffer.MatricesIndicesKind
  93648. * - VertexBuffer.MatricesIndicesExtraKind
  93649. * - VertexBuffer.MatricesWeightsKind
  93650. * - VertexBuffer.MatricesWeightsExtraKind
  93651. */
  93652. removeVerticesData(kind: string): void;
  93653. /**
  93654. * Flags an associated vertex buffer as updatable
  93655. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  93656. * - VertexBuffer.PositionKind
  93657. * - VertexBuffer.UVKind
  93658. * - VertexBuffer.UV2Kind
  93659. * - VertexBuffer.UV3Kind
  93660. * - VertexBuffer.UV4Kind
  93661. * - VertexBuffer.UV5Kind
  93662. * - VertexBuffer.UV6Kind
  93663. * - VertexBuffer.ColorKind
  93664. * - VertexBuffer.MatricesIndicesKind
  93665. * - VertexBuffer.MatricesIndicesExtraKind
  93666. * - VertexBuffer.MatricesWeightsKind
  93667. * - VertexBuffer.MatricesWeightsExtraKind
  93668. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  93669. */
  93670. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  93671. /**
  93672. * Sets the mesh global Vertex Buffer
  93673. * @param buffer defines the buffer to use
  93674. * @returns the current mesh
  93675. */
  93676. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  93677. /**
  93678. * Update a specific associated vertex buffer
  93679. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93680. * - VertexBuffer.PositionKind
  93681. * - VertexBuffer.UVKind
  93682. * - VertexBuffer.UV2Kind
  93683. * - VertexBuffer.UV3Kind
  93684. * - VertexBuffer.UV4Kind
  93685. * - VertexBuffer.UV5Kind
  93686. * - VertexBuffer.UV6Kind
  93687. * - VertexBuffer.ColorKind
  93688. * - VertexBuffer.MatricesIndicesKind
  93689. * - VertexBuffer.MatricesIndicesExtraKind
  93690. * - VertexBuffer.MatricesWeightsKind
  93691. * - VertexBuffer.MatricesWeightsExtraKind
  93692. * @param data defines the data source
  93693. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93694. * @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)
  93695. * @returns the current mesh
  93696. */
  93697. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93698. /**
  93699. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  93700. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  93701. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  93702. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  93703. * @returns the current mesh
  93704. */
  93705. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  93706. /**
  93707. * Creates a un-shared specific occurence of the geometry for the mesh.
  93708. * @returns the current mesh
  93709. */
  93710. makeGeometryUnique(): Mesh;
  93711. /**
  93712. * Set the index buffer of this mesh
  93713. * @param indices defines the source data
  93714. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  93715. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  93716. * @returns the current mesh
  93717. */
  93718. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  93719. /**
  93720. * Update the current index buffer
  93721. * @param indices defines the source data
  93722. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93723. * @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)
  93724. * @returns the current mesh
  93725. */
  93726. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93727. /**
  93728. * Invert the geometry to move from a right handed system to a left handed one.
  93729. * @returns the current mesh
  93730. */
  93731. toLeftHanded(): Mesh;
  93732. /** @hidden */
  93733. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  93734. /** @hidden */
  93735. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  93736. /**
  93737. * Registers for this mesh a javascript function called just before the rendering process
  93738. * @param func defines the function to call before rendering this mesh
  93739. * @returns the current mesh
  93740. */
  93741. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93742. /**
  93743. * Disposes a previously registered javascript function called before the rendering
  93744. * @param func defines the function to remove
  93745. * @returns the current mesh
  93746. */
  93747. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  93748. /**
  93749. * Registers for this mesh a javascript function called just after the rendering is complete
  93750. * @param func defines the function to call after rendering this mesh
  93751. * @returns the current mesh
  93752. */
  93753. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93754. /**
  93755. * Disposes a previously registered javascript function called after the rendering.
  93756. * @param func defines the function to remove
  93757. * @returns the current mesh
  93758. */
  93759. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  93760. /** @hidden */
  93761. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  93762. /** @hidden */
  93763. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  93764. /** @hidden */
  93765. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  93766. /** @hidden */
  93767. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  93768. /** @hidden */
  93769. _rebuild(): void;
  93770. /** @hidden */
  93771. _freeze(): void;
  93772. /** @hidden */
  93773. _unFreeze(): void;
  93774. /**
  93775. * 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
  93776. * @param subMesh defines the subMesh to render
  93777. * @param enableAlphaMode defines if alpha mode can be changed
  93778. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  93779. * @returns the current mesh
  93780. */
  93781. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  93782. private _onBeforeDraw;
  93783. /**
  93784. * Renormalize the mesh and patch it up if there are no weights
  93785. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  93786. * However in the case of zero weights then we set just a single influence to 1.
  93787. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  93788. */
  93789. cleanMatrixWeights(): void;
  93790. private normalizeSkinFourWeights;
  93791. private normalizeSkinWeightsAndExtra;
  93792. /**
  93793. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  93794. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  93795. * the user know there was an issue with importing the mesh
  93796. * @returns a validation object with skinned, valid and report string
  93797. */
  93798. validateSkinning(): {
  93799. skinned: boolean;
  93800. valid: boolean;
  93801. report: string;
  93802. };
  93803. /** @hidden */
  93804. _checkDelayState(): Mesh;
  93805. private _queueLoad;
  93806. /**
  93807. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93808. * A mesh is in the frustum if its bounding box intersects the frustum
  93809. * @param frustumPlanes defines the frustum to test
  93810. * @returns true if the mesh is in the frustum planes
  93811. */
  93812. isInFrustum(frustumPlanes: Plane[]): boolean;
  93813. /**
  93814. * Sets the mesh material by the material or multiMaterial `id` property
  93815. * @param id is a string identifying the material or the multiMaterial
  93816. * @returns the current mesh
  93817. */
  93818. setMaterialByID(id: string): Mesh;
  93819. /**
  93820. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  93821. * @returns an array of IAnimatable
  93822. */
  93823. getAnimatables(): IAnimatable[];
  93824. /**
  93825. * Modifies the mesh geometry according to the passed transformation matrix.
  93826. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  93827. * The mesh normals are modified using the same transformation.
  93828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93829. * @param transform defines the transform matrix to use
  93830. * @see http://doc.babylonjs.com/resources/baking_transformations
  93831. * @returns the current mesh
  93832. */
  93833. bakeTransformIntoVertices(transform: Matrix): Mesh;
  93834. /**
  93835. * Modifies the mesh geometry according to its own current World Matrix.
  93836. * The mesh World Matrix is then reset.
  93837. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  93838. * Note that, under the hood, this method sets a new VertexBuffer each call.
  93839. * @see http://doc.babylonjs.com/resources/baking_transformations
  93840. * @returns the current mesh
  93841. */
  93842. bakeCurrentTransformIntoVertices(): Mesh;
  93843. /** @hidden */
  93844. readonly _positions: Nullable<Vector3[]>;
  93845. /** @hidden */
  93846. _resetPointsArrayCache(): Mesh;
  93847. /** @hidden */
  93848. _generatePointsArray(): boolean;
  93849. /**
  93850. * Returns a new Mesh object generated from the current mesh properties.
  93851. * This method must not get confused with createInstance()
  93852. * @param name is a string, the name given to the new mesh
  93853. * @param newParent can be any Node object (default `null`)
  93854. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  93855. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  93856. * @returns a new mesh
  93857. */
  93858. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  93859. /**
  93860. * Releases resources associated with this mesh.
  93861. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93862. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93863. */
  93864. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93865. /** @hidden */
  93866. _disposeInstanceSpecificData(): void;
  93867. /**
  93868. * Modifies the mesh geometry according to a displacement map.
  93869. * 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.
  93870. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93871. * @param url is a string, the URL from the image file is to be downloaded.
  93872. * @param minHeight is the lower limit of the displacement.
  93873. * @param maxHeight is the upper limit of the displacement.
  93874. * @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.
  93875. * @param uvOffset is an optional vector2 used to offset UV.
  93876. * @param uvScale is an optional vector2 used to scale UV.
  93877. * @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.
  93878. * @returns the Mesh.
  93879. */
  93880. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93881. /**
  93882. * Modifies the mesh geometry according to a displacementMap buffer.
  93883. * 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.
  93884. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  93885. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  93886. * @param heightMapWidth is the width of the buffer image.
  93887. * @param heightMapHeight is the height of the buffer image.
  93888. * @param minHeight is the lower limit of the displacement.
  93889. * @param maxHeight is the upper limit of the displacement.
  93890. * @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.
  93891. * @param uvOffset is an optional vector2 used to offset UV.
  93892. * @param uvScale is an optional vector2 used to scale UV.
  93893. * @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.
  93894. * @returns the Mesh.
  93895. */
  93896. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  93897. /**
  93898. * Modify the mesh to get a flat shading rendering.
  93899. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  93900. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  93901. * @returns current mesh
  93902. */
  93903. convertToFlatShadedMesh(): Mesh;
  93904. /**
  93905. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  93906. * In other words, more vertices, no more indices and a single bigger VBO.
  93907. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  93908. * @returns current mesh
  93909. */
  93910. convertToUnIndexedMesh(): Mesh;
  93911. /**
  93912. * Inverses facet orientations.
  93913. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93914. * @param flipNormals will also inverts the normals
  93915. * @returns current mesh
  93916. */
  93917. flipFaces(flipNormals?: boolean): Mesh;
  93918. /**
  93919. * Increase the number of facets and hence vertices in a mesh
  93920. * Vertex normals are interpolated from existing vertex normals
  93921. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93922. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  93923. */
  93924. increaseVertices(numberPerEdge: number): void;
  93925. /**
  93926. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  93927. * This will undo any application of covertToFlatShadedMesh
  93928. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  93929. */
  93930. forceSharedVertices(): void;
  93931. /** @hidden */
  93932. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  93933. /** @hidden */
  93934. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  93935. /**
  93936. * Creates a new InstancedMesh object from the mesh model.
  93937. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93938. * @param name defines the name of the new instance
  93939. * @returns a new InstancedMesh
  93940. */
  93941. createInstance(name: string): InstancedMesh;
  93942. /**
  93943. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  93944. * After this call, all the mesh instances have the same submeshes than the current mesh.
  93945. * @returns the current mesh
  93946. */
  93947. synchronizeInstances(): Mesh;
  93948. /**
  93949. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  93950. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  93951. * This should be used together with the simplification to avoid disappearing triangles.
  93952. * @param successCallback an optional success callback to be called after the optimization finished.
  93953. * @returns the current mesh
  93954. */
  93955. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  93956. /**
  93957. * Serialize current mesh
  93958. * @param serializationObject defines the object which will receive the serialization data
  93959. */
  93960. serialize(serializationObject: any): void;
  93961. /** @hidden */
  93962. _syncGeometryWithMorphTargetManager(): void;
  93963. /** @hidden */
  93964. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  93965. /**
  93966. * Returns a new Mesh object parsed from the source provided.
  93967. * @param parsedMesh is the source
  93968. * @param scene defines the hosting scene
  93969. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  93970. * @returns a new Mesh
  93971. */
  93972. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  93973. /**
  93974. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  93975. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93976. * @param name defines the name of the mesh to create
  93977. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  93978. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  93979. * @param closePath creates a seam between the first and the last points of each path of the path array
  93980. * @param offset is taken in account only if the `pathArray` is containing a single path
  93981. * @param scene defines the hosting scene
  93982. * @param updatable defines if the mesh must be flagged as updatable
  93983. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93984. * @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)
  93985. * @returns a new Mesh
  93986. */
  93987. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93988. /**
  93989. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  93990. * @param name defines the name of the mesh to create
  93991. * @param radius sets the radius size (float) of the polygon (default 0.5)
  93992. * @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
  93993. * @param scene defines the hosting scene
  93994. * @param updatable defines if the mesh must be flagged as updatable
  93995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93996. * @returns a new Mesh
  93997. */
  93998. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  93999. /**
  94000. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  94001. * @param name defines the name of the mesh to create
  94002. * @param size sets the size (float) of each box side (default 1)
  94003. * @param scene defines the hosting scene
  94004. * @param updatable defines if the mesh must be flagged as updatable
  94005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94006. * @returns a new Mesh
  94007. */
  94008. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  94009. /**
  94010. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  94011. * @param name defines the name of the mesh to create
  94012. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  94013. * @param diameter sets the diameter size (float) of the sphere (default 1)
  94014. * @param scene defines the hosting scene
  94015. * @param updatable defines if the mesh must be flagged as updatable
  94016. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94017. * @returns a new Mesh
  94018. */
  94019. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94020. /**
  94021. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  94022. * @param name defines the name of the mesh to create
  94023. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  94024. * @param diameter sets the diameter size (float) of the sphere (default 1)
  94025. * @param scene defines the hosting scene
  94026. * @returns a new Mesh
  94027. */
  94028. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  94029. /**
  94030. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  94031. * @param name defines the name of the mesh to create
  94032. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  94033. * @param diameterTop set the top cap diameter (floats, default 1)
  94034. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  94035. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  94036. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  94037. * @param scene defines the hosting scene
  94038. * @param updatable defines if the mesh must be flagged as updatable
  94039. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94040. * @returns a new Mesh
  94041. */
  94042. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  94043. /**
  94044. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  94045. * @param name defines the name of the mesh to create
  94046. * @param diameter sets the diameter size (float) of the torus (default 1)
  94047. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  94048. * @param tessellation sets the number of torus sides (postive integer, default 16)
  94049. * @param scene defines the hosting scene
  94050. * @param updatable defines if the mesh must be flagged as updatable
  94051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94052. * @returns a new Mesh
  94053. */
  94054. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94055. /**
  94056. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  94057. * @param name defines the name of the mesh to create
  94058. * @param radius sets the global radius size (float) of the torus knot (default 2)
  94059. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  94060. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  94061. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  94062. * @param p the number of windings on X axis (positive integers, default 2)
  94063. * @param q the number of windings on Y axis (positive integers, default 3)
  94064. * @param scene defines the hosting scene
  94065. * @param updatable defines if the mesh must be flagged as updatable
  94066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94067. * @returns a new Mesh
  94068. */
  94069. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94070. /**
  94071. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  94072. * @param name defines the name of the mesh to create
  94073. * @param points is an array successive Vector3
  94074. * @param scene defines the hosting scene
  94075. * @param updatable defines if the mesh must be flagged as updatable
  94076. * @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).
  94077. * @returns a new Mesh
  94078. */
  94079. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  94080. /**
  94081. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  94082. * @param name defines the name of the mesh to create
  94083. * @param points is an array successive Vector3
  94084. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  94085. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  94086. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  94087. * @param scene defines the hosting scene
  94088. * @param updatable defines if the mesh must be flagged as updatable
  94089. * @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)
  94090. * @returns a new Mesh
  94091. */
  94092. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  94093. /**
  94094. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  94095. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  94096. * 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.
  94097. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94098. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94099. * Remember you can only change the shape positions, not their number when updating a polygon.
  94100. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  94101. * @param name defines the name of the mesh to create
  94102. * @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
  94103. * @param scene defines the hosting scene
  94104. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  94105. * @param updatable defines if the mesh must be flagged as updatable
  94106. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94107. * @param earcutInjection can be used to inject your own earcut reference
  94108. * @returns a new Mesh
  94109. */
  94110. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  94111. /**
  94112. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  94113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  94114. * @param name defines the name of the mesh to create
  94115. * @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
  94116. * @param depth defines the height of extrusion
  94117. * @param scene defines the hosting scene
  94118. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  94119. * @param updatable defines if the mesh must be flagged as updatable
  94120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94121. * @param earcutInjection can be used to inject your own earcut reference
  94122. * @returns a new Mesh
  94123. */
  94124. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  94125. /**
  94126. * Creates an extruded shape mesh.
  94127. * 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
  94128. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94129. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94130. * @param name defines the name of the mesh to create
  94131. * @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
  94132. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94133. * @param scale is the value to scale the shape
  94134. * @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
  94135. * @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
  94136. * @param scene defines the hosting scene
  94137. * @param updatable defines if the mesh must be flagged as updatable
  94138. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94139. * @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)
  94140. * @returns a new Mesh
  94141. */
  94142. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94143. /**
  94144. * Creates an custom extruded shape mesh.
  94145. * The custom extrusion is a parametric shape.
  94146. * It has no predefined shape. Its final shape will depend on the input parameters.
  94147. * Please consider using the same method from the MeshBuilder class instead
  94148. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  94149. * @param name defines the name of the mesh to create
  94150. * @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
  94151. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  94152. * @param scaleFunction is a custom Javascript function called on each path point
  94153. * @param rotationFunction is a custom Javascript function called on each path point
  94154. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  94155. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  94156. * @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
  94157. * @param scene defines the hosting scene
  94158. * @param updatable defines if the mesh must be flagged as updatable
  94159. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94160. * @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)
  94161. * @returns a new Mesh
  94162. */
  94163. 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;
  94164. /**
  94165. * Creates lathe mesh.
  94166. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  94167. * Please consider using the same method from the MeshBuilder class instead
  94168. * @param name defines the name of the mesh to create
  94169. * @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
  94170. * @param radius is the radius value of the lathe
  94171. * @param tessellation is the side number of the lathe.
  94172. * @param scene defines the hosting scene
  94173. * @param updatable defines if the mesh must be flagged as updatable
  94174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94175. * @returns a new Mesh
  94176. */
  94177. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94178. /**
  94179. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  94180. * @param name defines the name of the mesh to create
  94181. * @param size sets the size (float) of both sides of the plane at once (default 1)
  94182. * @param scene defines the hosting scene
  94183. * @param updatable defines if the mesh must be flagged as updatable
  94184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94185. * @returns a new Mesh
  94186. */
  94187. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  94188. /**
  94189. * Creates a ground mesh.
  94190. * Please consider using the same method from the MeshBuilder class instead
  94191. * @param name defines the name of the mesh to create
  94192. * @param width set the width of the ground
  94193. * @param height set the height of the ground
  94194. * @param subdivisions sets the number of subdivisions per side
  94195. * @param scene defines the hosting scene
  94196. * @param updatable defines if the mesh must be flagged as updatable
  94197. * @returns a new Mesh
  94198. */
  94199. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  94200. /**
  94201. * Creates a tiled ground mesh.
  94202. * Please consider using the same method from the MeshBuilder class instead
  94203. * @param name defines the name of the mesh to create
  94204. * @param xmin set the ground minimum X coordinate
  94205. * @param zmin set the ground minimum Y coordinate
  94206. * @param xmax set the ground maximum X coordinate
  94207. * @param zmax set the ground maximum Z coordinate
  94208. * @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
  94209. * @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
  94210. * @param scene defines the hosting scene
  94211. * @param updatable defines if the mesh must be flagged as updatable
  94212. * @returns a new Mesh
  94213. */
  94214. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  94215. w: number;
  94216. h: number;
  94217. }, precision: {
  94218. w: number;
  94219. h: number;
  94220. }, scene: Scene, updatable?: boolean): Mesh;
  94221. /**
  94222. * Creates a ground mesh from a height map.
  94223. * Please consider using the same method from the MeshBuilder class instead
  94224. * @see http://doc.babylonjs.com/babylon101/height_map
  94225. * @param name defines the name of the mesh to create
  94226. * @param url sets the URL of the height map image resource
  94227. * @param width set the ground width size
  94228. * @param height set the ground height size
  94229. * @param subdivisions sets the number of subdivision per side
  94230. * @param minHeight is the minimum altitude on the ground
  94231. * @param maxHeight is the maximum altitude on the ground
  94232. * @param scene defines the hosting scene
  94233. * @param updatable defines if the mesh must be flagged as updatable
  94234. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  94235. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94236. * @returns a new Mesh
  94237. */
  94238. 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;
  94239. /**
  94240. * Creates a tube mesh.
  94241. * The tube is a parametric shape.
  94242. * It has no predefined shape. Its final shape will depend on the input parameters.
  94243. * Please consider using the same method from the MeshBuilder class instead
  94244. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  94245. * @param name defines the name of the mesh to create
  94246. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  94247. * @param radius sets the tube radius size
  94248. * @param tessellation is the number of sides on the tubular surface
  94249. * @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
  94250. * @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
  94251. * @param scene defines the hosting scene
  94252. * @param updatable defines if the mesh must be flagged as updatable
  94253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  94254. * @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)
  94255. * @returns a new Mesh
  94256. */
  94257. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  94258. (i: number, distance: number): number;
  94259. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  94260. /**
  94261. * Creates a polyhedron mesh.
  94262. * Please consider using the same method from the MeshBuilder class instead.
  94263. * * 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
  94264. * * The parameter `size` (positive float, default 1) sets the polygon size
  94265. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  94266. * * 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`
  94267. * * 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
  94268. * * 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)`)
  94269. * * 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
  94270. * * 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
  94271. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94272. * * If you create a double-sided mesh, you can choose what parts of 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
  94273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94274. * @param name defines the name of the mesh to create
  94275. * @param options defines the options used to create the mesh
  94276. * @param scene defines the hosting scene
  94277. * @returns a new Mesh
  94278. */
  94279. static CreatePolyhedron(name: string, options: {
  94280. type?: number;
  94281. size?: number;
  94282. sizeX?: number;
  94283. sizeY?: number;
  94284. sizeZ?: number;
  94285. custom?: any;
  94286. faceUV?: Vector4[];
  94287. faceColors?: Color4[];
  94288. updatable?: boolean;
  94289. sideOrientation?: number;
  94290. }, scene: Scene): Mesh;
  94291. /**
  94292. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  94293. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  94294. * * 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`)
  94295. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  94296. * * 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
  94297. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  94298. * * If you create a double-sided mesh, you can choose what parts of 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
  94299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94300. * @param name defines the name of the mesh
  94301. * @param options defines the options used to create the mesh
  94302. * @param scene defines the hosting scene
  94303. * @returns a new Mesh
  94304. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  94305. */
  94306. static CreateIcoSphere(name: string, options: {
  94307. radius?: number;
  94308. flat?: boolean;
  94309. subdivisions?: number;
  94310. sideOrientation?: number;
  94311. updatable?: boolean;
  94312. }, scene: Scene): Mesh;
  94313. /**
  94314. * Creates a decal mesh.
  94315. * Please consider using the same method from the MeshBuilder class instead.
  94316. * A decal is a mesh usually applied as a model onto the surface of another mesh
  94317. * @param name defines the name of the mesh
  94318. * @param sourceMesh defines the mesh receiving the decal
  94319. * @param position sets the position of the decal in world coordinates
  94320. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  94321. * @param size sets the decal scaling
  94322. * @param angle sets the angle to rotate the decal
  94323. * @returns a new Mesh
  94324. */
  94325. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  94326. /**
  94327. * Prepare internal position array for software CPU skinning
  94328. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  94329. */
  94330. setPositionsForCPUSkinning(): Float32Array;
  94331. /**
  94332. * Prepare internal normal array for software CPU skinning
  94333. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  94334. */
  94335. setNormalsForCPUSkinning(): Float32Array;
  94336. /**
  94337. * Updates the vertex buffer by applying transformation from the bones
  94338. * @param skeleton defines the skeleton to apply to current mesh
  94339. * @returns the current mesh
  94340. */
  94341. applySkeleton(skeleton: Skeleton): Mesh;
  94342. /**
  94343. * 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
  94344. * @param meshes defines the list of meshes to scan
  94345. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  94346. */
  94347. static MinMax(meshes: AbstractMesh[]): {
  94348. min: Vector3;
  94349. max: Vector3;
  94350. };
  94351. /**
  94352. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  94353. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  94354. * @returns a vector3
  94355. */
  94356. static Center(meshesOrMinMaxVector: {
  94357. min: Vector3;
  94358. max: Vector3;
  94359. } | AbstractMesh[]): Vector3;
  94360. /**
  94361. * Merge the array of meshes into a single mesh for performance reasons.
  94362. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  94363. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  94364. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  94365. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  94366. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  94367. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  94368. * @returns a new mesh
  94369. */
  94370. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  94371. /** @hidden */
  94372. addInstance(instance: InstancedMesh): void;
  94373. /** @hidden */
  94374. removeInstance(instance: InstancedMesh): void;
  94375. }
  94376. }
  94377. declare module BABYLON {
  94378. /**
  94379. * This is the base class of all the camera used in the application.
  94380. * @see http://doc.babylonjs.com/features/cameras
  94381. */
  94382. export class Camera extends Node {
  94383. /** @hidden */
  94384. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  94385. /**
  94386. * This is the default projection mode used by the cameras.
  94387. * It helps recreating a feeling of perspective and better appreciate depth.
  94388. * This is the best way to simulate real life cameras.
  94389. */
  94390. static readonly PERSPECTIVE_CAMERA: number;
  94391. /**
  94392. * This helps creating camera with an orthographic mode.
  94393. * 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.
  94394. */
  94395. static readonly ORTHOGRAPHIC_CAMERA: number;
  94396. /**
  94397. * This is the default FOV mode for perspective cameras.
  94398. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  94399. */
  94400. static readonly FOVMODE_VERTICAL_FIXED: number;
  94401. /**
  94402. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  94403. */
  94404. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  94405. /**
  94406. * This specifies ther is no need for a camera rig.
  94407. * Basically only one eye is rendered corresponding to the camera.
  94408. */
  94409. static readonly RIG_MODE_NONE: number;
  94410. /**
  94411. * Simulates a camera Rig with one blue eye and one red eye.
  94412. * This can be use with 3d blue and red glasses.
  94413. */
  94414. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  94415. /**
  94416. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  94417. */
  94418. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  94419. /**
  94420. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  94421. */
  94422. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  94423. /**
  94424. * Defines that both eyes of the camera will be rendered over under each other.
  94425. */
  94426. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  94427. /**
  94428. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  94429. */
  94430. static readonly RIG_MODE_VR: number;
  94431. /**
  94432. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  94433. */
  94434. static readonly RIG_MODE_WEBVR: number;
  94435. /**
  94436. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  94437. */
  94438. static readonly RIG_MODE_CUSTOM: number;
  94439. /**
  94440. * Defines if by default attaching controls should prevent the default javascript event to continue.
  94441. */
  94442. static ForceAttachControlToAlwaysPreventDefault: boolean;
  94443. /**
  94444. * Define the input manager associated with the camera.
  94445. */
  94446. inputs: CameraInputsManager<Camera>;
  94447. /** @hidden */
  94448. _position: Vector3;
  94449. /**
  94450. * Define the current local position of the camera in the scene
  94451. */
  94452. position: Vector3;
  94453. /**
  94454. * The vector the camera should consider as up.
  94455. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  94456. */
  94457. upVector: Vector3;
  94458. /**
  94459. * Define the current limit on the left side for an orthographic camera
  94460. * In scene unit
  94461. */
  94462. orthoLeft: Nullable<number>;
  94463. /**
  94464. * Define the current limit on the right side for an orthographic camera
  94465. * In scene unit
  94466. */
  94467. orthoRight: Nullable<number>;
  94468. /**
  94469. * Define the current limit on the bottom side for an orthographic camera
  94470. * In scene unit
  94471. */
  94472. orthoBottom: Nullable<number>;
  94473. /**
  94474. * Define the current limit on the top side for an orthographic camera
  94475. * In scene unit
  94476. */
  94477. orthoTop: Nullable<number>;
  94478. /**
  94479. * Field Of View is set in Radians. (default is 0.8)
  94480. */
  94481. fov: number;
  94482. /**
  94483. * Define the minimum distance the camera can see from.
  94484. * This is important to note that the depth buffer are not infinite and the closer it starts
  94485. * the more your scene might encounter depth fighting issue.
  94486. */
  94487. minZ: number;
  94488. /**
  94489. * Define the maximum distance the camera can see to.
  94490. * This is important to note that the depth buffer are not infinite and the further it end
  94491. * the more your scene might encounter depth fighting issue.
  94492. */
  94493. maxZ: number;
  94494. /**
  94495. * Define the default inertia of the camera.
  94496. * This helps giving a smooth feeling to the camera movement.
  94497. */
  94498. inertia: number;
  94499. /**
  94500. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  94501. */
  94502. mode: number;
  94503. /**
  94504. * Define wether the camera is intermediate.
  94505. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  94506. */
  94507. isIntermediate: boolean;
  94508. /**
  94509. * Define the viewport of the camera.
  94510. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  94511. */
  94512. viewport: Viewport;
  94513. /**
  94514. * Restricts the camera to viewing objects with the same layerMask.
  94515. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  94516. */
  94517. layerMask: number;
  94518. /**
  94519. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  94520. */
  94521. fovMode: number;
  94522. /**
  94523. * Rig mode of the camera.
  94524. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  94525. * This is normally controlled byt the camera themselves as internal use.
  94526. */
  94527. cameraRigMode: number;
  94528. /**
  94529. * Defines the distance between both "eyes" in case of a RIG
  94530. */
  94531. interaxialDistance: number;
  94532. /**
  94533. * Defines if stereoscopic rendering is done side by side or over under.
  94534. */
  94535. isStereoscopicSideBySide: boolean;
  94536. /**
  94537. * 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
  94538. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  94539. * else in the scene. (Eg. security camera)
  94540. *
  94541. * 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)
  94542. */
  94543. customRenderTargets: RenderTargetTexture[];
  94544. /**
  94545. * When set, the camera will render to this render target instead of the default canvas
  94546. *
  94547. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  94548. */
  94549. outputRenderTarget: Nullable<RenderTargetTexture>;
  94550. /**
  94551. * Observable triggered when the camera view matrix has changed.
  94552. */
  94553. onViewMatrixChangedObservable: Observable<Camera>;
  94554. /**
  94555. * Observable triggered when the camera Projection matrix has changed.
  94556. */
  94557. onProjectionMatrixChangedObservable: Observable<Camera>;
  94558. /**
  94559. * Observable triggered when the inputs have been processed.
  94560. */
  94561. onAfterCheckInputsObservable: Observable<Camera>;
  94562. /**
  94563. * Observable triggered when reset has been called and applied to the camera.
  94564. */
  94565. onRestoreStateObservable: Observable<Camera>;
  94566. /** @hidden */
  94567. _cameraRigParams: any;
  94568. /** @hidden */
  94569. _rigCameras: Camera[];
  94570. /** @hidden */
  94571. _rigPostProcess: Nullable<PostProcess>;
  94572. protected _webvrViewMatrix: Matrix;
  94573. /** @hidden */
  94574. _skipRendering: boolean;
  94575. /** @hidden */
  94576. _projectionMatrix: Matrix;
  94577. /** @hidden */
  94578. _postProcesses: Nullable<PostProcess>[];
  94579. /** @hidden */
  94580. _activeMeshes: SmartArray<AbstractMesh>;
  94581. protected _globalPosition: Vector3;
  94582. /** @hidden */
  94583. _computedViewMatrix: Matrix;
  94584. private _doNotComputeProjectionMatrix;
  94585. private _transformMatrix;
  94586. private _frustumPlanes;
  94587. private _refreshFrustumPlanes;
  94588. private _storedFov;
  94589. private _stateStored;
  94590. /**
  94591. * Instantiates a new camera object.
  94592. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  94593. * @see http://doc.babylonjs.com/features/cameras
  94594. * @param name Defines the name of the camera in the scene
  94595. * @param position Defines the position of the camera
  94596. * @param scene Defines the scene the camera belongs too
  94597. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  94598. */
  94599. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94600. /**
  94601. * Store current camera state (fov, position, etc..)
  94602. * @returns the camera
  94603. */
  94604. storeState(): Camera;
  94605. /**
  94606. * Restores the camera state values if it has been stored. You must call storeState() first
  94607. */
  94608. protected _restoreStateValues(): boolean;
  94609. /**
  94610. * Restored camera state. You must call storeState() first.
  94611. * @returns true if restored and false otherwise
  94612. */
  94613. restoreState(): boolean;
  94614. /**
  94615. * Gets the class name of the camera.
  94616. * @returns the class name
  94617. */
  94618. getClassName(): string;
  94619. /** @hidden */
  94620. readonly _isCamera: boolean;
  94621. /**
  94622. * Gets a string representation of the camera useful for debug purpose.
  94623. * @param fullDetails Defines that a more verboe level of logging is required
  94624. * @returns the string representation
  94625. */
  94626. toString(fullDetails?: boolean): string;
  94627. /**
  94628. * Gets the current world space position of the camera.
  94629. */
  94630. readonly globalPosition: Vector3;
  94631. /**
  94632. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  94633. * @returns the active meshe list
  94634. */
  94635. getActiveMeshes(): SmartArray<AbstractMesh>;
  94636. /**
  94637. * Check wether a mesh is part of the current active mesh list of the camera
  94638. * @param mesh Defines the mesh to check
  94639. * @returns true if active, false otherwise
  94640. */
  94641. isActiveMesh(mesh: Mesh): boolean;
  94642. /**
  94643. * Is this camera ready to be used/rendered
  94644. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  94645. * @return true if the camera is ready
  94646. */
  94647. isReady(completeCheck?: boolean): boolean;
  94648. /** @hidden */
  94649. _initCache(): void;
  94650. /** @hidden */
  94651. _updateCache(ignoreParentClass?: boolean): void;
  94652. /** @hidden */
  94653. _isSynchronized(): boolean;
  94654. /** @hidden */
  94655. _isSynchronizedViewMatrix(): boolean;
  94656. /** @hidden */
  94657. _isSynchronizedProjectionMatrix(): boolean;
  94658. /**
  94659. * Attach the input controls to a specific dom element to get the input from.
  94660. * @param element Defines the element the controls should be listened from
  94661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94662. */
  94663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94664. /**
  94665. * Detach the current controls from the specified dom element.
  94666. * @param element Defines the element to stop listening the inputs from
  94667. */
  94668. detachControl(element: HTMLElement): void;
  94669. /**
  94670. * Update the camera state according to the different inputs gathered during the frame.
  94671. */
  94672. update(): void;
  94673. /** @hidden */
  94674. _checkInputs(): void;
  94675. /** @hidden */
  94676. readonly rigCameras: Camera[];
  94677. /**
  94678. * Gets the post process used by the rig cameras
  94679. */
  94680. readonly rigPostProcess: Nullable<PostProcess>;
  94681. /**
  94682. * Internal, gets the first post proces.
  94683. * @returns the first post process to be run on this camera.
  94684. */
  94685. _getFirstPostProcess(): Nullable<PostProcess>;
  94686. private _cascadePostProcessesToRigCams;
  94687. /**
  94688. * Attach a post process to the camera.
  94689. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94690. * @param postProcess The post process to attach to the camera
  94691. * @param insertAt The position of the post process in case several of them are in use in the scene
  94692. * @returns the position the post process has been inserted at
  94693. */
  94694. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  94695. /**
  94696. * Detach a post process to the camera.
  94697. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  94698. * @param postProcess The post process to detach from the camera
  94699. */
  94700. detachPostProcess(postProcess: PostProcess): void;
  94701. /**
  94702. * Gets the current world matrix of the camera
  94703. */
  94704. getWorldMatrix(): Matrix;
  94705. /** @hidden */
  94706. _getViewMatrix(): Matrix;
  94707. /**
  94708. * Gets the current view matrix of the camera.
  94709. * @param force forces the camera to recompute the matrix without looking at the cached state
  94710. * @returns the view matrix
  94711. */
  94712. getViewMatrix(force?: boolean): Matrix;
  94713. /**
  94714. * Freeze the projection matrix.
  94715. * It will prevent the cache check of the camera projection compute and can speed up perf
  94716. * if no parameter of the camera are meant to change
  94717. * @param projection Defines manually a projection if necessary
  94718. */
  94719. freezeProjectionMatrix(projection?: Matrix): void;
  94720. /**
  94721. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  94722. */
  94723. unfreezeProjectionMatrix(): void;
  94724. /**
  94725. * Gets the current projection matrix of the camera.
  94726. * @param force forces the camera to recompute the matrix without looking at the cached state
  94727. * @returns the projection matrix
  94728. */
  94729. getProjectionMatrix(force?: boolean): Matrix;
  94730. /**
  94731. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  94732. * @returns a Matrix
  94733. */
  94734. getTransformationMatrix(): Matrix;
  94735. private _updateFrustumPlanes;
  94736. /**
  94737. * Checks if a cullable object (mesh...) is in the camera frustum
  94738. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  94739. * @param target The object to check
  94740. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  94741. * @returns true if the object is in frustum otherwise false
  94742. */
  94743. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  94744. /**
  94745. * Checks if a cullable object (mesh...) is in the camera frustum
  94746. * Unlike isInFrustum this cheks the full bounding box
  94747. * @param target The object to check
  94748. * @returns true if the object is in frustum otherwise false
  94749. */
  94750. isCompletelyInFrustum(target: ICullable): boolean;
  94751. /**
  94752. * Gets a ray in the forward direction from the camera.
  94753. * @param length Defines the length of the ray to create
  94754. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  94755. * @param origin Defines the start point of the ray which defaults to the camera position
  94756. * @returns the forward ray
  94757. */
  94758. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  94759. /**
  94760. * Releases resources associated with this node.
  94761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94763. */
  94764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94765. /** @hidden */
  94766. _isLeftCamera: boolean;
  94767. /**
  94768. * Gets the left camera of a rig setup in case of Rigged Camera
  94769. */
  94770. readonly isLeftCamera: boolean;
  94771. /** @hidden */
  94772. _isRightCamera: boolean;
  94773. /**
  94774. * Gets the right camera of a rig setup in case of Rigged Camera
  94775. */
  94776. readonly isRightCamera: boolean;
  94777. /**
  94778. * Gets the left camera of a rig setup in case of Rigged Camera
  94779. */
  94780. readonly leftCamera: Nullable<FreeCamera>;
  94781. /**
  94782. * Gets the right camera of a rig setup in case of Rigged Camera
  94783. */
  94784. readonly rightCamera: Nullable<FreeCamera>;
  94785. /**
  94786. * Gets the left camera target of a rig setup in case of Rigged Camera
  94787. * @returns the target position
  94788. */
  94789. getLeftTarget(): Nullable<Vector3>;
  94790. /**
  94791. * Gets the right camera target of a rig setup in case of Rigged Camera
  94792. * @returns the target position
  94793. */
  94794. getRightTarget(): Nullable<Vector3>;
  94795. /**
  94796. * @hidden
  94797. */
  94798. setCameraRigMode(mode: number, rigParams: any): void;
  94799. /** @hidden */
  94800. static _setStereoscopicRigMode(camera: Camera): void;
  94801. /** @hidden */
  94802. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  94803. /** @hidden */
  94804. static _setVRRigMode(camera: Camera, rigParams: any): void;
  94805. /** @hidden */
  94806. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  94807. /** @hidden */
  94808. _getVRProjectionMatrix(): Matrix;
  94809. protected _updateCameraRotationMatrix(): void;
  94810. protected _updateWebVRCameraRotationMatrix(): void;
  94811. /**
  94812. * This function MUST be overwritten by the different WebVR cameras available.
  94813. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94814. * @hidden
  94815. */
  94816. _getWebVRProjectionMatrix(): Matrix;
  94817. /**
  94818. * This function MUST be overwritten by the different WebVR cameras available.
  94819. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  94820. * @hidden
  94821. */
  94822. _getWebVRViewMatrix(): Matrix;
  94823. /** @hidden */
  94824. setCameraRigParameter(name: string, value: any): void;
  94825. /**
  94826. * needs to be overridden by children so sub has required properties to be copied
  94827. * @hidden
  94828. */
  94829. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  94830. /**
  94831. * May need to be overridden by children
  94832. * @hidden
  94833. */
  94834. _updateRigCameras(): void;
  94835. /** @hidden */
  94836. _setupInputs(): void;
  94837. /**
  94838. * Serialiaze the camera setup to a json represention
  94839. * @returns the JSON representation
  94840. */
  94841. serialize(): any;
  94842. /**
  94843. * Clones the current camera.
  94844. * @param name The cloned camera name
  94845. * @returns the cloned camera
  94846. */
  94847. clone(name: string): Camera;
  94848. /**
  94849. * Gets the direction of the camera relative to a given local axis.
  94850. * @param localAxis Defines the reference axis to provide a relative direction.
  94851. * @return the direction
  94852. */
  94853. getDirection(localAxis: Vector3): Vector3;
  94854. /**
  94855. * Returns the current camera absolute rotation
  94856. */
  94857. readonly absoluteRotation: Quaternion;
  94858. /**
  94859. * Gets the direction of the camera relative to a given local axis into a passed vector.
  94860. * @param localAxis Defines the reference axis to provide a relative direction.
  94861. * @param result Defines the vector to store the result in
  94862. */
  94863. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  94864. /**
  94865. * Gets a camera constructor for a given camera type
  94866. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  94867. * @param name The name of the camera the result will be able to instantiate
  94868. * @param scene The scene the result will construct the camera in
  94869. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  94870. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  94871. * @returns a factory method to construc the camera
  94872. */
  94873. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  94874. /**
  94875. * Compute the world matrix of the camera.
  94876. * @returns the camera world matrix
  94877. */
  94878. computeWorldMatrix(): Matrix;
  94879. /**
  94880. * Parse a JSON and creates the camera from the parsed information
  94881. * @param parsedCamera The JSON to parse
  94882. * @param scene The scene to instantiate the camera in
  94883. * @returns the newly constructed camera
  94884. */
  94885. static Parse(parsedCamera: any, scene: Scene): Camera;
  94886. }
  94887. }
  94888. declare module BABYLON {
  94889. /**
  94890. * Class containing static functions to help procedurally build meshes
  94891. */
  94892. export class DiscBuilder {
  94893. /**
  94894. * Creates a plane polygonal mesh. By default, this is a disc
  94895. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  94896. * * 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
  94897. * * 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
  94898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94901. * @param name defines the name of the mesh
  94902. * @param options defines the options used to create the mesh
  94903. * @param scene defines the hosting scene
  94904. * @returns the plane polygonal mesh
  94905. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  94906. */
  94907. static CreateDisc(name: string, options: {
  94908. radius?: number;
  94909. tessellation?: number;
  94910. arc?: number;
  94911. updatable?: boolean;
  94912. sideOrientation?: number;
  94913. frontUVs?: Vector4;
  94914. backUVs?: Vector4;
  94915. }, scene?: Nullable<Scene>): Mesh;
  94916. }
  94917. }
  94918. declare module BABYLON {
  94919. /**
  94920. * This represents all the required information to add a fresnel effect on a material:
  94921. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94922. */
  94923. export class FresnelParameters {
  94924. private _isEnabled;
  94925. /**
  94926. * Define if the fresnel effect is enable or not.
  94927. */
  94928. isEnabled: boolean;
  94929. /**
  94930. * Define the color used on edges (grazing angle)
  94931. */
  94932. leftColor: Color3;
  94933. /**
  94934. * Define the color used on center
  94935. */
  94936. rightColor: Color3;
  94937. /**
  94938. * Define bias applied to computed fresnel term
  94939. */
  94940. bias: number;
  94941. /**
  94942. * Defined the power exponent applied to fresnel term
  94943. */
  94944. power: number;
  94945. /**
  94946. * Clones the current fresnel and its valuues
  94947. * @returns a clone fresnel configuration
  94948. */
  94949. clone(): FresnelParameters;
  94950. /**
  94951. * Serializes the current fresnel parameters to a JSON representation.
  94952. * @return the JSON serialization
  94953. */
  94954. serialize(): any;
  94955. /**
  94956. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94957. * @param parsedFresnelParameters Define the JSON representation
  94958. * @returns the parsed parameters
  94959. */
  94960. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94961. }
  94962. }
  94963. declare module BABYLON {
  94964. /**
  94965. * Base class of materials working in push mode in babylon JS
  94966. * @hidden
  94967. */
  94968. export class PushMaterial extends Material {
  94969. protected _activeEffect: Effect;
  94970. protected _normalMatrix: Matrix;
  94971. /**
  94972. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  94973. * This means that the material can keep using a previous shader while a new one is being compiled.
  94974. * This is mostly used when shader parallel compilation is supported (true by default)
  94975. */
  94976. allowShaderHotSwapping: boolean;
  94977. constructor(name: string, scene: Scene);
  94978. getEffect(): Effect;
  94979. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94980. /**
  94981. * Binds the given world matrix to the active effect
  94982. *
  94983. * @param world the matrix to bind
  94984. */
  94985. bindOnlyWorldMatrix(world: Matrix): void;
  94986. /**
  94987. * Binds the given normal matrix to the active effect
  94988. *
  94989. * @param normalMatrix the matrix to bind
  94990. */
  94991. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94992. bind(world: Matrix, mesh?: Mesh): void;
  94993. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94994. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94995. }
  94996. }
  94997. declare module BABYLON {
  94998. /**
  94999. * This groups all the flags used to control the materials channel.
  95000. */
  95001. export class MaterialFlags {
  95002. private static _DiffuseTextureEnabled;
  95003. /**
  95004. * Are diffuse textures enabled in the application.
  95005. */
  95006. static DiffuseTextureEnabled: boolean;
  95007. private static _AmbientTextureEnabled;
  95008. /**
  95009. * Are ambient textures enabled in the application.
  95010. */
  95011. static AmbientTextureEnabled: boolean;
  95012. private static _OpacityTextureEnabled;
  95013. /**
  95014. * Are opacity textures enabled in the application.
  95015. */
  95016. static OpacityTextureEnabled: boolean;
  95017. private static _ReflectionTextureEnabled;
  95018. /**
  95019. * Are reflection textures enabled in the application.
  95020. */
  95021. static ReflectionTextureEnabled: boolean;
  95022. private static _EmissiveTextureEnabled;
  95023. /**
  95024. * Are emissive textures enabled in the application.
  95025. */
  95026. static EmissiveTextureEnabled: boolean;
  95027. private static _SpecularTextureEnabled;
  95028. /**
  95029. * Are specular textures enabled in the application.
  95030. */
  95031. static SpecularTextureEnabled: boolean;
  95032. private static _BumpTextureEnabled;
  95033. /**
  95034. * Are bump textures enabled in the application.
  95035. */
  95036. static BumpTextureEnabled: boolean;
  95037. private static _LightmapTextureEnabled;
  95038. /**
  95039. * Are lightmap textures enabled in the application.
  95040. */
  95041. static LightmapTextureEnabled: boolean;
  95042. private static _RefractionTextureEnabled;
  95043. /**
  95044. * Are refraction textures enabled in the application.
  95045. */
  95046. static RefractionTextureEnabled: boolean;
  95047. private static _ColorGradingTextureEnabled;
  95048. /**
  95049. * Are color grading textures enabled in the application.
  95050. */
  95051. static ColorGradingTextureEnabled: boolean;
  95052. private static _FresnelEnabled;
  95053. /**
  95054. * Are fresnels enabled in the application.
  95055. */
  95056. static FresnelEnabled: boolean;
  95057. private static _ClearCoatTextureEnabled;
  95058. /**
  95059. * Are clear coat textures enabled in the application.
  95060. */
  95061. static ClearCoatTextureEnabled: boolean;
  95062. private static _ClearCoatBumpTextureEnabled;
  95063. /**
  95064. * Are clear coat bump textures enabled in the application.
  95065. */
  95066. static ClearCoatBumpTextureEnabled: boolean;
  95067. private static _ClearCoatTintTextureEnabled;
  95068. /**
  95069. * Are clear coat tint textures enabled in the application.
  95070. */
  95071. static ClearCoatTintTextureEnabled: boolean;
  95072. private static _SheenTextureEnabled;
  95073. /**
  95074. * Are sheen textures enabled in the application.
  95075. */
  95076. static SheenTextureEnabled: boolean;
  95077. private static _AnisotropicTextureEnabled;
  95078. /**
  95079. * Are anisotropic textures enabled in the application.
  95080. */
  95081. static AnisotropicTextureEnabled: boolean;
  95082. private static _ThicknessTextureEnabled;
  95083. /**
  95084. * Are thickness textures enabled in the application.
  95085. */
  95086. static ThicknessTextureEnabled: boolean;
  95087. }
  95088. }
  95089. declare module BABYLON {
  95090. /** @hidden */
  95091. export var defaultFragmentDeclaration: {
  95092. name: string;
  95093. shader: string;
  95094. };
  95095. }
  95096. declare module BABYLON {
  95097. /** @hidden */
  95098. export var defaultUboDeclaration: {
  95099. name: string;
  95100. shader: string;
  95101. };
  95102. }
  95103. declare module BABYLON {
  95104. /** @hidden */
  95105. export var lightFragmentDeclaration: {
  95106. name: string;
  95107. shader: string;
  95108. };
  95109. }
  95110. declare module BABYLON {
  95111. /** @hidden */
  95112. export var lightUboDeclaration: {
  95113. name: string;
  95114. shader: string;
  95115. };
  95116. }
  95117. declare module BABYLON {
  95118. /** @hidden */
  95119. export var lightsFragmentFunctions: {
  95120. name: string;
  95121. shader: string;
  95122. };
  95123. }
  95124. declare module BABYLON {
  95125. /** @hidden */
  95126. export var shadowsFragmentFunctions: {
  95127. name: string;
  95128. shader: string;
  95129. };
  95130. }
  95131. declare module BABYLON {
  95132. /** @hidden */
  95133. export var fresnelFunction: {
  95134. name: string;
  95135. shader: string;
  95136. };
  95137. }
  95138. declare module BABYLON {
  95139. /** @hidden */
  95140. export var reflectionFunction: {
  95141. name: string;
  95142. shader: string;
  95143. };
  95144. }
  95145. declare module BABYLON {
  95146. /** @hidden */
  95147. export var bumpFragmentFunctions: {
  95148. name: string;
  95149. shader: string;
  95150. };
  95151. }
  95152. declare module BABYLON {
  95153. /** @hidden */
  95154. export var logDepthDeclaration: {
  95155. name: string;
  95156. shader: string;
  95157. };
  95158. }
  95159. declare module BABYLON {
  95160. /** @hidden */
  95161. export var bumpFragment: {
  95162. name: string;
  95163. shader: string;
  95164. };
  95165. }
  95166. declare module BABYLON {
  95167. /** @hidden */
  95168. export var depthPrePass: {
  95169. name: string;
  95170. shader: string;
  95171. };
  95172. }
  95173. declare module BABYLON {
  95174. /** @hidden */
  95175. export var lightFragment: {
  95176. name: string;
  95177. shader: string;
  95178. };
  95179. }
  95180. declare module BABYLON {
  95181. /** @hidden */
  95182. export var logDepthFragment: {
  95183. name: string;
  95184. shader: string;
  95185. };
  95186. }
  95187. declare module BABYLON {
  95188. /** @hidden */
  95189. export var defaultPixelShader: {
  95190. name: string;
  95191. shader: string;
  95192. };
  95193. }
  95194. declare module BABYLON {
  95195. /** @hidden */
  95196. export var defaultVertexDeclaration: {
  95197. name: string;
  95198. shader: string;
  95199. };
  95200. }
  95201. declare module BABYLON {
  95202. /** @hidden */
  95203. export var bumpVertexDeclaration: {
  95204. name: string;
  95205. shader: string;
  95206. };
  95207. }
  95208. declare module BABYLON {
  95209. /** @hidden */
  95210. export var bumpVertex: {
  95211. name: string;
  95212. shader: string;
  95213. };
  95214. }
  95215. declare module BABYLON {
  95216. /** @hidden */
  95217. export var fogVertex: {
  95218. name: string;
  95219. shader: string;
  95220. };
  95221. }
  95222. declare module BABYLON {
  95223. /** @hidden */
  95224. export var shadowsVertex: {
  95225. name: string;
  95226. shader: string;
  95227. };
  95228. }
  95229. declare module BABYLON {
  95230. /** @hidden */
  95231. export var pointCloudVertex: {
  95232. name: string;
  95233. shader: string;
  95234. };
  95235. }
  95236. declare module BABYLON {
  95237. /** @hidden */
  95238. export var logDepthVertex: {
  95239. name: string;
  95240. shader: string;
  95241. };
  95242. }
  95243. declare module BABYLON {
  95244. /** @hidden */
  95245. export var defaultVertexShader: {
  95246. name: string;
  95247. shader: string;
  95248. };
  95249. }
  95250. declare module BABYLON {
  95251. /** @hidden */
  95252. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  95253. MAINUV1: boolean;
  95254. MAINUV2: boolean;
  95255. DIFFUSE: boolean;
  95256. DIFFUSEDIRECTUV: number;
  95257. AMBIENT: boolean;
  95258. AMBIENTDIRECTUV: number;
  95259. OPACITY: boolean;
  95260. OPACITYDIRECTUV: number;
  95261. OPACITYRGB: boolean;
  95262. REFLECTION: boolean;
  95263. EMISSIVE: boolean;
  95264. EMISSIVEDIRECTUV: number;
  95265. SPECULAR: boolean;
  95266. SPECULARDIRECTUV: number;
  95267. BUMP: boolean;
  95268. BUMPDIRECTUV: number;
  95269. PARALLAX: boolean;
  95270. PARALLAXOCCLUSION: boolean;
  95271. SPECULAROVERALPHA: boolean;
  95272. CLIPPLANE: boolean;
  95273. CLIPPLANE2: boolean;
  95274. CLIPPLANE3: boolean;
  95275. CLIPPLANE4: boolean;
  95276. ALPHATEST: boolean;
  95277. DEPTHPREPASS: boolean;
  95278. ALPHAFROMDIFFUSE: boolean;
  95279. POINTSIZE: boolean;
  95280. FOG: boolean;
  95281. SPECULARTERM: boolean;
  95282. DIFFUSEFRESNEL: boolean;
  95283. OPACITYFRESNEL: boolean;
  95284. REFLECTIONFRESNEL: boolean;
  95285. REFRACTIONFRESNEL: boolean;
  95286. EMISSIVEFRESNEL: boolean;
  95287. FRESNEL: boolean;
  95288. NORMAL: boolean;
  95289. UV1: boolean;
  95290. UV2: boolean;
  95291. VERTEXCOLOR: boolean;
  95292. VERTEXALPHA: boolean;
  95293. NUM_BONE_INFLUENCERS: number;
  95294. BonesPerMesh: number;
  95295. BONETEXTURE: boolean;
  95296. INSTANCES: boolean;
  95297. GLOSSINESS: boolean;
  95298. ROUGHNESS: boolean;
  95299. EMISSIVEASILLUMINATION: boolean;
  95300. LINKEMISSIVEWITHDIFFUSE: boolean;
  95301. REFLECTIONFRESNELFROMSPECULAR: boolean;
  95302. LIGHTMAP: boolean;
  95303. LIGHTMAPDIRECTUV: number;
  95304. OBJECTSPACE_NORMALMAP: boolean;
  95305. USELIGHTMAPASSHADOWMAP: boolean;
  95306. REFLECTIONMAP_3D: boolean;
  95307. REFLECTIONMAP_SPHERICAL: boolean;
  95308. REFLECTIONMAP_PLANAR: boolean;
  95309. REFLECTIONMAP_CUBIC: boolean;
  95310. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  95311. REFLECTIONMAP_PROJECTION: boolean;
  95312. REFLECTIONMAP_SKYBOX: boolean;
  95313. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  95314. REFLECTIONMAP_EXPLICIT: boolean;
  95315. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  95316. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  95317. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  95318. INVERTCUBICMAP: boolean;
  95319. LOGARITHMICDEPTH: boolean;
  95320. REFRACTION: boolean;
  95321. REFRACTIONMAP_3D: boolean;
  95322. REFLECTIONOVERALPHA: boolean;
  95323. TWOSIDEDLIGHTING: boolean;
  95324. SHADOWFLOAT: boolean;
  95325. MORPHTARGETS: boolean;
  95326. MORPHTARGETS_NORMAL: boolean;
  95327. MORPHTARGETS_TANGENT: boolean;
  95328. MORPHTARGETS_UV: boolean;
  95329. NUM_MORPH_INFLUENCERS: number;
  95330. NONUNIFORMSCALING: boolean;
  95331. PREMULTIPLYALPHA: boolean;
  95332. IMAGEPROCESSING: boolean;
  95333. VIGNETTE: boolean;
  95334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  95335. VIGNETTEBLENDMODEOPAQUE: boolean;
  95336. TONEMAPPING: boolean;
  95337. TONEMAPPING_ACES: boolean;
  95338. CONTRAST: boolean;
  95339. COLORCURVES: boolean;
  95340. COLORGRADING: boolean;
  95341. COLORGRADING3D: boolean;
  95342. SAMPLER3DGREENDEPTH: boolean;
  95343. SAMPLER3DBGRMAP: boolean;
  95344. IMAGEPROCESSINGPOSTPROCESS: boolean;
  95345. MULTIVIEW: boolean;
  95346. /**
  95347. * If the reflection texture on this material is in linear color space
  95348. * @hidden
  95349. */
  95350. IS_REFLECTION_LINEAR: boolean;
  95351. /**
  95352. * If the refraction texture on this material is in linear color space
  95353. * @hidden
  95354. */
  95355. IS_REFRACTION_LINEAR: boolean;
  95356. EXPOSURE: boolean;
  95357. constructor();
  95358. setReflectionMode(modeToEnable: string): void;
  95359. }
  95360. /**
  95361. * This is the default material used in Babylon. It is the best trade off between quality
  95362. * and performances.
  95363. * @see http://doc.babylonjs.com/babylon101/materials
  95364. */
  95365. export class StandardMaterial extends PushMaterial {
  95366. private _diffuseTexture;
  95367. /**
  95368. * The basic texture of the material as viewed under a light.
  95369. */
  95370. diffuseTexture: Nullable<BaseTexture>;
  95371. private _ambientTexture;
  95372. /**
  95373. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  95374. */
  95375. ambientTexture: Nullable<BaseTexture>;
  95376. private _opacityTexture;
  95377. /**
  95378. * Define the transparency of the material from a texture.
  95379. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  95380. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  95381. */
  95382. opacityTexture: Nullable<BaseTexture>;
  95383. private _reflectionTexture;
  95384. /**
  95385. * Define the texture used to display the reflection.
  95386. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95387. */
  95388. reflectionTexture: Nullable<BaseTexture>;
  95389. private _emissiveTexture;
  95390. /**
  95391. * Define texture of the material as if self lit.
  95392. * This will be mixed in the final result even in the absence of light.
  95393. */
  95394. emissiveTexture: Nullable<BaseTexture>;
  95395. private _specularTexture;
  95396. /**
  95397. * Define how the color and intensity of the highlight given by the light in the material.
  95398. */
  95399. specularTexture: Nullable<BaseTexture>;
  95400. private _bumpTexture;
  95401. /**
  95402. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  95403. * 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.
  95404. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  95405. */
  95406. bumpTexture: Nullable<BaseTexture>;
  95407. private _lightmapTexture;
  95408. /**
  95409. * Complex lighting can be computationally expensive to compute at runtime.
  95410. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  95411. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  95412. */
  95413. lightmapTexture: Nullable<BaseTexture>;
  95414. private _refractionTexture;
  95415. /**
  95416. * Define the texture used to display the refraction.
  95417. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95418. */
  95419. refractionTexture: Nullable<BaseTexture>;
  95420. /**
  95421. * The color of the material lit by the environmental background lighting.
  95422. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  95423. */
  95424. ambientColor: Color3;
  95425. /**
  95426. * The basic color of the material as viewed under a light.
  95427. */
  95428. diffuseColor: Color3;
  95429. /**
  95430. * Define how the color and intensity of the highlight given by the light in the material.
  95431. */
  95432. specularColor: Color3;
  95433. /**
  95434. * Define the color of the material as if self lit.
  95435. * This will be mixed in the final result even in the absence of light.
  95436. */
  95437. emissiveColor: Color3;
  95438. /**
  95439. * Defines how sharp are the highlights in the material.
  95440. * The bigger the value the sharper giving a more glossy feeling to the result.
  95441. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  95442. */
  95443. specularPower: number;
  95444. private _useAlphaFromDiffuseTexture;
  95445. /**
  95446. * Does the transparency come from the diffuse texture alpha channel.
  95447. */
  95448. useAlphaFromDiffuseTexture: boolean;
  95449. private _useEmissiveAsIllumination;
  95450. /**
  95451. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  95452. */
  95453. useEmissiveAsIllumination: boolean;
  95454. private _linkEmissiveWithDiffuse;
  95455. /**
  95456. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  95457. * the emissive level when the final color is close to one.
  95458. */
  95459. linkEmissiveWithDiffuse: boolean;
  95460. private _useSpecularOverAlpha;
  95461. /**
  95462. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  95463. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  95464. */
  95465. useSpecularOverAlpha: boolean;
  95466. private _useReflectionOverAlpha;
  95467. /**
  95468. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  95469. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  95470. */
  95471. useReflectionOverAlpha: boolean;
  95472. private _disableLighting;
  95473. /**
  95474. * Does lights from the scene impacts this material.
  95475. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  95476. */
  95477. disableLighting: boolean;
  95478. private _useObjectSpaceNormalMap;
  95479. /**
  95480. * Allows using an object space normal map (instead of tangent space).
  95481. */
  95482. useObjectSpaceNormalMap: boolean;
  95483. private _useParallax;
  95484. /**
  95485. * Is parallax enabled or not.
  95486. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95487. */
  95488. useParallax: boolean;
  95489. private _useParallaxOcclusion;
  95490. /**
  95491. * Is parallax occlusion enabled or not.
  95492. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  95493. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  95494. */
  95495. useParallaxOcclusion: boolean;
  95496. /**
  95497. * 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.
  95498. */
  95499. parallaxScaleBias: number;
  95500. private _roughness;
  95501. /**
  95502. * Helps to define how blurry the reflections should appears in the material.
  95503. */
  95504. roughness: number;
  95505. /**
  95506. * In case of refraction, define the value of the index of refraction.
  95507. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95508. */
  95509. indexOfRefraction: number;
  95510. /**
  95511. * Invert the refraction texture alongside the y axis.
  95512. * It can be useful with procedural textures or probe for instance.
  95513. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  95514. */
  95515. invertRefractionY: boolean;
  95516. /**
  95517. * Defines the alpha limits in alpha test mode.
  95518. */
  95519. alphaCutOff: number;
  95520. private _useLightmapAsShadowmap;
  95521. /**
  95522. * In case of light mapping, define whether the map contains light or shadow informations.
  95523. */
  95524. useLightmapAsShadowmap: boolean;
  95525. private _diffuseFresnelParameters;
  95526. /**
  95527. * Define the diffuse fresnel parameters of the material.
  95528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95529. */
  95530. diffuseFresnelParameters: FresnelParameters;
  95531. private _opacityFresnelParameters;
  95532. /**
  95533. * Define the opacity fresnel parameters of the material.
  95534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95535. */
  95536. opacityFresnelParameters: FresnelParameters;
  95537. private _reflectionFresnelParameters;
  95538. /**
  95539. * Define the reflection fresnel parameters of the material.
  95540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95541. */
  95542. reflectionFresnelParameters: FresnelParameters;
  95543. private _refractionFresnelParameters;
  95544. /**
  95545. * Define the refraction fresnel parameters of the material.
  95546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95547. */
  95548. refractionFresnelParameters: FresnelParameters;
  95549. private _emissiveFresnelParameters;
  95550. /**
  95551. * Define the emissive fresnel parameters of the material.
  95552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95553. */
  95554. emissiveFresnelParameters: FresnelParameters;
  95555. private _useReflectionFresnelFromSpecular;
  95556. /**
  95557. * If true automatically deducts the fresnels values from the material specularity.
  95558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  95559. */
  95560. useReflectionFresnelFromSpecular: boolean;
  95561. private _useGlossinessFromSpecularMapAlpha;
  95562. /**
  95563. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  95564. */
  95565. useGlossinessFromSpecularMapAlpha: boolean;
  95566. private _maxSimultaneousLights;
  95567. /**
  95568. * Defines the maximum number of lights that can be used in the material
  95569. */
  95570. maxSimultaneousLights: number;
  95571. private _invertNormalMapX;
  95572. /**
  95573. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  95574. */
  95575. invertNormalMapX: boolean;
  95576. private _invertNormalMapY;
  95577. /**
  95578. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  95579. */
  95580. invertNormalMapY: boolean;
  95581. private _twoSidedLighting;
  95582. /**
  95583. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  95584. */
  95585. twoSidedLighting: boolean;
  95586. /**
  95587. * Default configuration related to image processing available in the standard Material.
  95588. */
  95589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  95590. /**
  95591. * Gets the image processing configuration used either in this material.
  95592. */
  95593. /**
  95594. * Sets the Default image processing configuration used either in the this material.
  95595. *
  95596. * If sets to null, the scene one is in use.
  95597. */
  95598. imageProcessingConfiguration: ImageProcessingConfiguration;
  95599. /**
  95600. * Keep track of the image processing observer to allow dispose and replace.
  95601. */
  95602. private _imageProcessingObserver;
  95603. /**
  95604. * Attaches a new image processing configuration to the Standard Material.
  95605. * @param configuration
  95606. */
  95607. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  95608. /**
  95609. * Gets wether the color curves effect is enabled.
  95610. */
  95611. /**
  95612. * Sets wether the color curves effect is enabled.
  95613. */
  95614. cameraColorCurvesEnabled: boolean;
  95615. /**
  95616. * Gets wether the color grading effect is enabled.
  95617. */
  95618. /**
  95619. * Gets wether the color grading effect is enabled.
  95620. */
  95621. cameraColorGradingEnabled: boolean;
  95622. /**
  95623. * Gets wether tonemapping is enabled or not.
  95624. */
  95625. /**
  95626. * Sets wether tonemapping is enabled or not
  95627. */
  95628. cameraToneMappingEnabled: boolean;
  95629. /**
  95630. * The camera exposure used on this material.
  95631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95632. * This corresponds to a photographic exposure.
  95633. */
  95634. /**
  95635. * The camera exposure used on this material.
  95636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  95637. * This corresponds to a photographic exposure.
  95638. */
  95639. cameraExposure: number;
  95640. /**
  95641. * Gets The camera contrast used on this material.
  95642. */
  95643. /**
  95644. * Sets The camera contrast used on this material.
  95645. */
  95646. cameraContrast: number;
  95647. /**
  95648. * Gets the Color Grading 2D Lookup Texture.
  95649. */
  95650. /**
  95651. * Sets the Color Grading 2D Lookup Texture.
  95652. */
  95653. cameraColorGradingTexture: Nullable<BaseTexture>;
  95654. /**
  95655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95657. * 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;
  95658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95659. */
  95660. /**
  95661. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  95662. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  95663. * 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;
  95664. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  95665. */
  95666. cameraColorCurves: Nullable<ColorCurves>;
  95667. /**
  95668. * Custom callback helping to override the default shader used in the material.
  95669. */
  95670. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  95671. protected _renderTargets: SmartArray<RenderTargetTexture>;
  95672. protected _worldViewProjectionMatrix: Matrix;
  95673. protected _globalAmbientColor: Color3;
  95674. protected _useLogarithmicDepth: boolean;
  95675. protected _rebuildInParallel: boolean;
  95676. /**
  95677. * Instantiates a new standard material.
  95678. * This is the default material used in Babylon. It is the best trade off between quality
  95679. * and performances.
  95680. * @see http://doc.babylonjs.com/babylon101/materials
  95681. * @param name Define the name of the material in the scene
  95682. * @param scene Define the scene the material belong to
  95683. */
  95684. constructor(name: string, scene: Scene);
  95685. /**
  95686. * Gets a boolean indicating that current material needs to register RTT
  95687. */
  95688. readonly hasRenderTargetTextures: boolean;
  95689. /**
  95690. * Gets the current class name of the material e.g. "StandardMaterial"
  95691. * Mainly use in serialization.
  95692. * @returns the class name
  95693. */
  95694. getClassName(): string;
  95695. /**
  95696. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  95697. * You can try switching to logarithmic depth.
  95698. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  95699. */
  95700. useLogarithmicDepth: boolean;
  95701. /**
  95702. * Specifies if the material will require alpha blending
  95703. * @returns a boolean specifying if alpha blending is needed
  95704. */
  95705. needAlphaBlending(): boolean;
  95706. /**
  95707. * Specifies if this material should be rendered in alpha test mode
  95708. * @returns a boolean specifying if an alpha test is needed.
  95709. */
  95710. needAlphaTesting(): boolean;
  95711. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  95712. /**
  95713. * Get the texture used for alpha test purpose.
  95714. * @returns the diffuse texture in case of the standard material.
  95715. */
  95716. getAlphaTestTexture(): Nullable<BaseTexture>;
  95717. /**
  95718. * Get if the submesh is ready to be used and all its information available.
  95719. * Child classes can use it to update shaders
  95720. * @param mesh defines the mesh to check
  95721. * @param subMesh defines which submesh to check
  95722. * @param useInstances specifies that instances should be used
  95723. * @returns a boolean indicating that the submesh is ready or not
  95724. */
  95725. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  95726. /**
  95727. * Builds the material UBO layouts.
  95728. * Used internally during the effect preparation.
  95729. */
  95730. buildUniformLayout(): void;
  95731. /**
  95732. * Unbinds the material from the mesh
  95733. */
  95734. unbind(): void;
  95735. /**
  95736. * Binds the submesh to this material by preparing the effect and shader to draw
  95737. * @param world defines the world transformation matrix
  95738. * @param mesh defines the mesh containing the submesh
  95739. * @param subMesh defines the submesh to bind the material to
  95740. */
  95741. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95742. /**
  95743. * Get the list of animatables in the material.
  95744. * @returns the list of animatables object used in the material
  95745. */
  95746. getAnimatables(): IAnimatable[];
  95747. /**
  95748. * Gets the active textures from the material
  95749. * @returns an array of textures
  95750. */
  95751. getActiveTextures(): BaseTexture[];
  95752. /**
  95753. * Specifies if the material uses a texture
  95754. * @param texture defines the texture to check against the material
  95755. * @returns a boolean specifying if the material uses the texture
  95756. */
  95757. hasTexture(texture: BaseTexture): boolean;
  95758. /**
  95759. * Disposes the material
  95760. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95761. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95762. */
  95763. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  95764. /**
  95765. * Makes a duplicate of the material, and gives it a new name
  95766. * @param name defines the new name for the duplicated material
  95767. * @returns the cloned material
  95768. */
  95769. clone(name: string): StandardMaterial;
  95770. /**
  95771. * Serializes this material in a JSON representation
  95772. * @returns the serialized material object
  95773. */
  95774. serialize(): any;
  95775. /**
  95776. * Creates a standard material from parsed material data
  95777. * @param source defines the JSON representation of the material
  95778. * @param scene defines the hosting scene
  95779. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  95780. * @returns a new standard material
  95781. */
  95782. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  95783. /**
  95784. * Are diffuse textures enabled in the application.
  95785. */
  95786. static DiffuseTextureEnabled: boolean;
  95787. /**
  95788. * Are ambient textures enabled in the application.
  95789. */
  95790. static AmbientTextureEnabled: boolean;
  95791. /**
  95792. * Are opacity textures enabled in the application.
  95793. */
  95794. static OpacityTextureEnabled: boolean;
  95795. /**
  95796. * Are reflection textures enabled in the application.
  95797. */
  95798. static ReflectionTextureEnabled: boolean;
  95799. /**
  95800. * Are emissive textures enabled in the application.
  95801. */
  95802. static EmissiveTextureEnabled: boolean;
  95803. /**
  95804. * Are specular textures enabled in the application.
  95805. */
  95806. static SpecularTextureEnabled: boolean;
  95807. /**
  95808. * Are bump textures enabled in the application.
  95809. */
  95810. static BumpTextureEnabled: boolean;
  95811. /**
  95812. * Are lightmap textures enabled in the application.
  95813. */
  95814. static LightmapTextureEnabled: boolean;
  95815. /**
  95816. * Are refraction textures enabled in the application.
  95817. */
  95818. static RefractionTextureEnabled: boolean;
  95819. /**
  95820. * Are color grading textures enabled in the application.
  95821. */
  95822. static ColorGradingTextureEnabled: boolean;
  95823. /**
  95824. * Are fresnels enabled in the application.
  95825. */
  95826. static FresnelEnabled: boolean;
  95827. }
  95828. }
  95829. declare module BABYLON {
  95830. /**
  95831. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  95832. *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.
  95833. * The SPS is also a particle system. It provides some methods to manage the particles.
  95834. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  95835. *
  95836. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  95837. */
  95838. export class SolidParticleSystem implements IDisposable {
  95839. /**
  95840. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  95841. * Example : var p = SPS.particles[i];
  95842. */
  95843. particles: SolidParticle[];
  95844. /**
  95845. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  95846. */
  95847. nbParticles: number;
  95848. /**
  95849. * If the particles must ever face the camera (default false). Useful for planar particles.
  95850. */
  95851. billboard: boolean;
  95852. /**
  95853. * Recompute normals when adding a shape
  95854. */
  95855. recomputeNormals: boolean;
  95856. /**
  95857. * This a counter ofr your own usage. It's not set by any SPS functions.
  95858. */
  95859. counter: number;
  95860. /**
  95861. * The SPS name. This name is also given to the underlying mesh.
  95862. */
  95863. name: string;
  95864. /**
  95865. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  95866. */
  95867. mesh: Mesh;
  95868. /**
  95869. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  95870. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  95871. */
  95872. vars: any;
  95873. /**
  95874. * This array is populated when the SPS is set as 'pickable'.
  95875. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  95876. * Each element of this array is an object `{idx: int, faceId: int}`.
  95877. * `idx` is the picked particle index in the `SPS.particles` array
  95878. * `faceId` is the picked face index counted within this particle.
  95879. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  95880. */
  95881. pickedParticles: {
  95882. idx: number;
  95883. faceId: number;
  95884. }[];
  95885. /**
  95886. * This array is populated when `enableDepthSort` is set to true.
  95887. * Each element of this array is an instance of the class DepthSortedParticle.
  95888. */
  95889. depthSortedParticles: DepthSortedParticle[];
  95890. /**
  95891. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  95892. * @hidden
  95893. */
  95894. _bSphereOnly: boolean;
  95895. /**
  95896. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  95897. * @hidden
  95898. */
  95899. _bSphereRadiusFactor: number;
  95900. private _scene;
  95901. private _positions;
  95902. private _indices;
  95903. private _normals;
  95904. private _colors;
  95905. private _uvs;
  95906. private _indices32;
  95907. private _positions32;
  95908. private _normals32;
  95909. private _fixedNormal32;
  95910. private _colors32;
  95911. private _uvs32;
  95912. private _index;
  95913. private _updatable;
  95914. private _pickable;
  95915. private _isVisibilityBoxLocked;
  95916. private _alwaysVisible;
  95917. private _depthSort;
  95918. private _expandable;
  95919. private _shapeCounter;
  95920. private _copy;
  95921. private _color;
  95922. private _computeParticleColor;
  95923. private _computeParticleTexture;
  95924. private _computeParticleRotation;
  95925. private _computeParticleVertex;
  95926. private _computeBoundingBox;
  95927. private _depthSortParticles;
  95928. private _camera;
  95929. private _mustUnrotateFixedNormals;
  95930. private _particlesIntersect;
  95931. private _needs32Bits;
  95932. private _isNotBuilt;
  95933. private _lastParticleId;
  95934. private _idxOfId;
  95935. private _multimaterialEnabled;
  95936. private _useModelMaterial;
  95937. private _indicesByMaterial;
  95938. private _materialIndexes;
  95939. private _depthSortFunction;
  95940. private _materialSortFunction;
  95941. private _materials;
  95942. private _multimaterial;
  95943. private _materialIndexesById;
  95944. private _defaultMaterial;
  95945. private _autoUpdateSubMeshes;
  95946. /**
  95947. * Creates a SPS (Solid Particle System) object.
  95948. * @param name (String) is the SPS name, this will be the underlying mesh name.
  95949. * @param scene (Scene) is the scene in which the SPS is added.
  95950. * @param options defines the options of the sps e.g.
  95951. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  95952. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  95953. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  95954. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  95955. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  95956. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  95957. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  95958. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  95959. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  95960. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  95961. */
  95962. constructor(name: string, scene: Scene, options?: {
  95963. updatable?: boolean;
  95964. isPickable?: boolean;
  95965. enableDepthSort?: boolean;
  95966. particleIntersection?: boolean;
  95967. boundingSphereOnly?: boolean;
  95968. bSphereRadiusFactor?: number;
  95969. expandable?: boolean;
  95970. useModelMaterial?: boolean;
  95971. enableMultiMaterial?: boolean;
  95972. });
  95973. /**
  95974. * Builds the SPS underlying mesh. Returns a standard Mesh.
  95975. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  95976. * @returns the created mesh
  95977. */
  95978. buildMesh(): Mesh;
  95979. /**
  95980. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  95981. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  95982. * Thus the particles generated from `digest()` have their property `position` set yet.
  95983. * @param mesh ( Mesh ) is the mesh to be digested
  95984. * @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
  95985. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  95986. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  95987. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  95988. * @returns the current SPS
  95989. */
  95990. digest(mesh: Mesh, options?: {
  95991. facetNb?: number;
  95992. number?: number;
  95993. delta?: number;
  95994. storage?: [];
  95995. }): SolidParticleSystem;
  95996. /**
  95997. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  95998. * @hidden
  95999. */
  96000. private _unrotateFixedNormals;
  96001. /**
  96002. * Resets the temporary working copy particle
  96003. * @hidden
  96004. */
  96005. private _resetCopy;
  96006. /**
  96007. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  96008. * @param p the current index in the positions array to be updated
  96009. * @param ind the current index in the indices array
  96010. * @param shape a Vector3 array, the shape geometry
  96011. * @param positions the positions array to be updated
  96012. * @param meshInd the shape indices array
  96013. * @param indices the indices array to be updated
  96014. * @param meshUV the shape uv array
  96015. * @param uvs the uv array to be updated
  96016. * @param meshCol the shape color array
  96017. * @param colors the color array to be updated
  96018. * @param meshNor the shape normals array
  96019. * @param normals the normals array to be updated
  96020. * @param idx the particle index
  96021. * @param idxInShape the particle index in its shape
  96022. * @param options the addShape() method passed options
  96023. * @model the particle model
  96024. * @hidden
  96025. */
  96026. private _meshBuilder;
  96027. /**
  96028. * Returns a shape Vector3 array from positions float array
  96029. * @param positions float array
  96030. * @returns a vector3 array
  96031. * @hidden
  96032. */
  96033. private _posToShape;
  96034. /**
  96035. * Returns a shapeUV array from a float uvs (array deep copy)
  96036. * @param uvs as a float array
  96037. * @returns a shapeUV array
  96038. * @hidden
  96039. */
  96040. private _uvsToShapeUV;
  96041. /**
  96042. * Adds a new particle object in the particles array
  96043. * @param idx particle index in particles array
  96044. * @param id particle id
  96045. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  96046. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  96047. * @param model particle ModelShape object
  96048. * @param shapeId model shape identifier
  96049. * @param idxInShape index of the particle in the current model
  96050. * @param bInfo model bounding info object
  96051. * @param storage target storage array, if any
  96052. * @hidden
  96053. */
  96054. private _addParticle;
  96055. /**
  96056. * Adds some particles to the SPS from the model shape. Returns the shape id.
  96057. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  96058. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  96059. * @param nb (positive integer) the number of particles to be created from this model
  96060. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  96061. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  96062. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  96063. * @returns the number of shapes in the system
  96064. */
  96065. addShape(mesh: Mesh, nb: number, options?: {
  96066. positionFunction?: any;
  96067. vertexFunction?: any;
  96068. storage?: [];
  96069. }): number;
  96070. /**
  96071. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  96072. * @hidden
  96073. */
  96074. private _rebuildParticle;
  96075. /**
  96076. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  96077. * @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.
  96078. * @returns the SPS.
  96079. */
  96080. rebuildMesh(reset?: boolean): SolidParticleSystem;
  96081. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  96082. * Returns an array with the removed particles.
  96083. * 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.
  96084. * The SPS can't be empty so at least one particle needs to remain in place.
  96085. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  96086. * @param start index of the first particle to remove
  96087. * @param end index of the last particle to remove (included)
  96088. * @returns an array populated with the removed particles
  96089. */
  96090. removeParticles(start: number, end: number): SolidParticle[];
  96091. /**
  96092. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  96093. * @param solidParticleArray an array populated with Solid Particles objects
  96094. * @returns the SPS
  96095. */
  96096. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  96097. /**
  96098. * Creates a new particle and modifies the SPS mesh geometry :
  96099. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  96100. * - calls _addParticle() to populate the particle array
  96101. * factorized code from addShape() and insertParticlesFromArray()
  96102. * @param idx particle index in the particles array
  96103. * @param i particle index in its shape
  96104. * @param modelShape particle ModelShape object
  96105. * @param shape shape vertex array
  96106. * @param meshInd shape indices array
  96107. * @param meshUV shape uv array
  96108. * @param meshCol shape color array
  96109. * @param meshNor shape normals array
  96110. * @param bbInfo shape bounding info
  96111. * @param storage target particle storage
  96112. * @options addShape() passed options
  96113. * @hidden
  96114. */
  96115. private _insertNewParticle;
  96116. /**
  96117. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  96118. * This method calls `updateParticle()` for each particle of the SPS.
  96119. * For an animated SPS, it is usually called within the render loop.
  96120. * 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.
  96121. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  96122. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  96123. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  96124. * @returns the SPS.
  96125. */
  96126. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  96127. /**
  96128. * Disposes the SPS.
  96129. */
  96130. dispose(): void;
  96131. /**
  96132. * Returns a SolidParticle object from its identifier : particle.id
  96133. * @param id (integer) the particle Id
  96134. * @returns the searched particle or null if not found in the SPS.
  96135. */
  96136. getParticleById(id: number): Nullable<SolidParticle>;
  96137. /**
  96138. * Returns a new array populated with the particles having the passed shapeId.
  96139. * @param shapeId (integer) the shape identifier
  96140. * @returns a new solid particle array
  96141. */
  96142. getParticlesByShapeId(shapeId: number): SolidParticle[];
  96143. /**
  96144. * Populates the passed array "ref" with the particles having the passed shapeId.
  96145. * @param shapeId the shape identifier
  96146. * @returns the SPS
  96147. * @param ref
  96148. */
  96149. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  96150. /**
  96151. * Computes the required SubMeshes according the materials assigned to the particles.
  96152. * @returns the solid particle system.
  96153. * Does nothing if called before the SPS mesh is built.
  96154. */
  96155. computeSubMeshes(): SolidParticleSystem;
  96156. /**
  96157. * Sorts the solid particles by material when MultiMaterial is enabled.
  96158. * Updates the indices32 array.
  96159. * Updates the indicesByMaterial array.
  96160. * Updates the mesh indices array.
  96161. * @returns the SPS
  96162. * @hidden
  96163. */
  96164. private _sortParticlesByMaterial;
  96165. /**
  96166. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  96167. * @hidden
  96168. */
  96169. private _setMaterialIndexesById;
  96170. /**
  96171. * Returns an array with unique values of Materials from the passed array
  96172. * @param array the material array to be checked and filtered
  96173. * @hidden
  96174. */
  96175. private _filterUniqueMaterialId;
  96176. /**
  96177. * Sets a new Standard Material as _defaultMaterial if not already set.
  96178. * @hidden
  96179. */
  96180. private _setDefaultMaterial;
  96181. /**
  96182. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  96183. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96184. * @returns the SPS.
  96185. */
  96186. refreshVisibleSize(): SolidParticleSystem;
  96187. /**
  96188. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  96189. * @param size the size (float) of the visibility box
  96190. * note : this doesn't lock the SPS mesh bounding box.
  96191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96192. */
  96193. setVisibilityBox(size: number): void;
  96194. /**
  96195. * Gets whether the SPS as always visible or not
  96196. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96197. */
  96198. /**
  96199. * Sets the SPS as always visible or not
  96200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96201. */
  96202. isAlwaysVisible: boolean;
  96203. /**
  96204. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96205. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96206. */
  96207. /**
  96208. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  96209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  96210. */
  96211. isVisibilityBoxLocked: boolean;
  96212. /**
  96213. * Tells to `setParticles()` to compute the particle rotations or not.
  96214. * Default value : true. The SPS is faster when it's set to false.
  96215. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96216. */
  96217. /**
  96218. * Gets if `setParticles()` computes the particle rotations or not.
  96219. * Default value : true. The SPS is faster when it's set to false.
  96220. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  96221. */
  96222. computeParticleRotation: boolean;
  96223. /**
  96224. * Tells to `setParticles()` to compute the particle colors or not.
  96225. * Default value : true. The SPS is faster when it's set to false.
  96226. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96227. */
  96228. /**
  96229. * Gets if `setParticles()` computes the particle colors or not.
  96230. * Default value : true. The SPS is faster when it's set to false.
  96231. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  96232. */
  96233. computeParticleColor: boolean;
  96234. /**
  96235. * Gets if `setParticles()` computes the particle textures or not.
  96236. * Default value : true. The SPS is faster when it's set to false.
  96237. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  96238. */
  96239. computeParticleTexture: boolean;
  96240. /**
  96241. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  96242. * Default value : false. The SPS is faster when it's set to false.
  96243. * Note : the particle custom vertex positions aren't stored values.
  96244. */
  96245. /**
  96246. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  96247. * Default value : false. The SPS is faster when it's set to false.
  96248. * Note : the particle custom vertex positions aren't stored values.
  96249. */
  96250. computeParticleVertex: boolean;
  96251. /**
  96252. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  96253. */
  96254. /**
  96255. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  96256. */
  96257. computeBoundingBox: boolean;
  96258. /**
  96259. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  96260. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96261. * Default : `true`
  96262. */
  96263. /**
  96264. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  96265. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  96266. * Default : `true`
  96267. */
  96268. depthSortParticles: boolean;
  96269. /**
  96270. * Gets if the SPS is created as expandable at construction time.
  96271. * Default : `false`
  96272. */
  96273. readonly expandable: boolean;
  96274. /**
  96275. * Gets if the SPS supports the Multi Materials
  96276. */
  96277. readonly multimaterialEnabled: boolean;
  96278. /**
  96279. * Gets if the SPS uses the model materials for its own multimaterial.
  96280. */
  96281. readonly useModelMaterial: boolean;
  96282. /**
  96283. * The SPS used material array.
  96284. */
  96285. readonly materials: Material[];
  96286. /**
  96287. * Sets the SPS MultiMaterial from the passed materials.
  96288. * Note : the passed array is internally copied and not used then by reference.
  96289. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  96290. */
  96291. setMultiMaterial(materials: Material[]): void;
  96292. /**
  96293. * The SPS computed multimaterial object
  96294. */
  96295. multimaterial: MultiMaterial;
  96296. /**
  96297. * If the subMeshes must be updated on the next call to setParticles()
  96298. */
  96299. autoUpdateSubMeshes: boolean;
  96300. /**
  96301. * This function does nothing. It may be overwritten to set all the particle first values.
  96302. * The SPS doesn't call this function, you may have to call it by your own.
  96303. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96304. */
  96305. initParticles(): void;
  96306. /**
  96307. * This function does nothing. It may be overwritten to recycle a particle.
  96308. * The SPS doesn't call this function, you may have to call it by your own.
  96309. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96310. * @param particle The particle to recycle
  96311. * @returns the recycled particle
  96312. */
  96313. recycleParticle(particle: SolidParticle): SolidParticle;
  96314. /**
  96315. * Updates a particle : this function should be overwritten by the user.
  96316. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  96317. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  96318. * @example : just set a particle position or velocity and recycle conditions
  96319. * @param particle The particle to update
  96320. * @returns the updated particle
  96321. */
  96322. updateParticle(particle: SolidParticle): SolidParticle;
  96323. /**
  96324. * Updates a vertex of a particle : it can be overwritten by the user.
  96325. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  96326. * @param particle the current particle
  96327. * @param vertex the current index of the current particle
  96328. * @param pt the index of the current vertex in the particle shape
  96329. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  96330. * @example : just set a vertex particle position
  96331. * @returns the updated vertex
  96332. */
  96333. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  96334. /**
  96335. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  96336. * This does nothing and may be overwritten by the user.
  96337. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96338. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96339. * @param update the boolean update value actually passed to setParticles()
  96340. */
  96341. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96342. /**
  96343. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  96344. * This will be passed three parameters.
  96345. * This does nothing and may be overwritten by the user.
  96346. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96347. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  96348. * @param update the boolean update value actually passed to setParticles()
  96349. */
  96350. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  96351. }
  96352. }
  96353. declare module BABYLON {
  96354. /**
  96355. * Represents one particle of a solid particle system.
  96356. */
  96357. export class SolidParticle {
  96358. /**
  96359. * particle global index
  96360. */
  96361. idx: number;
  96362. /**
  96363. * particle identifier
  96364. */
  96365. id: number;
  96366. /**
  96367. * The color of the particle
  96368. */
  96369. color: Nullable<Color4>;
  96370. /**
  96371. * The world space position of the particle.
  96372. */
  96373. position: Vector3;
  96374. /**
  96375. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  96376. */
  96377. rotation: Vector3;
  96378. /**
  96379. * The world space rotation quaternion of the particle.
  96380. */
  96381. rotationQuaternion: Nullable<Quaternion>;
  96382. /**
  96383. * The scaling of the particle.
  96384. */
  96385. scaling: Vector3;
  96386. /**
  96387. * The uvs of the particle.
  96388. */
  96389. uvs: Vector4;
  96390. /**
  96391. * The current speed of the particle.
  96392. */
  96393. velocity: Vector3;
  96394. /**
  96395. * The pivot point in the particle local space.
  96396. */
  96397. pivot: Vector3;
  96398. /**
  96399. * Must the particle be translated from its pivot point in its local space ?
  96400. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  96401. * Default : false
  96402. */
  96403. translateFromPivot: boolean;
  96404. /**
  96405. * Is the particle active or not ?
  96406. */
  96407. alive: boolean;
  96408. /**
  96409. * Is the particle visible or not ?
  96410. */
  96411. isVisible: boolean;
  96412. /**
  96413. * Index of this particle in the global "positions" array (Internal use)
  96414. * @hidden
  96415. */
  96416. _pos: number;
  96417. /**
  96418. * @hidden Index of this particle in the global "indices" array (Internal use)
  96419. */
  96420. _ind: number;
  96421. /**
  96422. * @hidden ModelShape of this particle (Internal use)
  96423. */
  96424. _model: ModelShape;
  96425. /**
  96426. * ModelShape id of this particle
  96427. */
  96428. shapeId: number;
  96429. /**
  96430. * Index of the particle in its shape id
  96431. */
  96432. idxInShape: number;
  96433. /**
  96434. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  96435. */
  96436. _modelBoundingInfo: BoundingInfo;
  96437. /**
  96438. * @hidden Particle BoundingInfo object (Internal use)
  96439. */
  96440. _boundingInfo: BoundingInfo;
  96441. /**
  96442. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  96443. */
  96444. _sps: SolidParticleSystem;
  96445. /**
  96446. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  96447. */
  96448. _stillInvisible: boolean;
  96449. /**
  96450. * @hidden Last computed particle rotation matrix
  96451. */
  96452. _rotationMatrix: number[];
  96453. /**
  96454. * Parent particle Id, if any.
  96455. * Default null.
  96456. */
  96457. parentId: Nullable<number>;
  96458. /**
  96459. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  96460. */
  96461. materialIndex: Nullable<number>;
  96462. /**
  96463. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  96464. * The possible values are :
  96465. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96466. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96467. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96468. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96469. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96470. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  96471. * */
  96472. cullingStrategy: number;
  96473. /**
  96474. * @hidden Internal global position in the SPS.
  96475. */
  96476. _globalPosition: Vector3;
  96477. /**
  96478. * Creates a Solid Particle object.
  96479. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  96480. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  96481. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  96482. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  96483. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  96484. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  96485. * @param shapeId (integer) is the model shape identifier in the SPS.
  96486. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  96487. * @param sps defines the sps it is associated to
  96488. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  96489. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  96490. */
  96491. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  96492. /**
  96493. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  96494. * @param target the particle target
  96495. * @returns the current particle
  96496. */
  96497. copyToRef(target: SolidParticle): SolidParticle;
  96498. /**
  96499. * Legacy support, changed scale to scaling
  96500. */
  96501. /**
  96502. * Legacy support, changed scale to scaling
  96503. */
  96504. scale: Vector3;
  96505. /**
  96506. * Legacy support, changed quaternion to rotationQuaternion
  96507. */
  96508. /**
  96509. * Legacy support, changed quaternion to rotationQuaternion
  96510. */
  96511. quaternion: Nullable<Quaternion>;
  96512. /**
  96513. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  96514. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  96515. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  96516. * @returns true if it intersects
  96517. */
  96518. intersectsMesh(target: Mesh | SolidParticle): boolean;
  96519. /**
  96520. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  96521. * A particle is in the frustum if its bounding box intersects the frustum
  96522. * @param frustumPlanes defines the frustum to test
  96523. * @returns true if the particle is in the frustum planes
  96524. */
  96525. isInFrustum(frustumPlanes: Plane[]): boolean;
  96526. /**
  96527. * get the rotation matrix of the particle
  96528. * @hidden
  96529. */
  96530. getRotationMatrix(m: Matrix): void;
  96531. }
  96532. /**
  96533. * Represents the shape of the model used by one particle of a solid particle system.
  96534. * SPS internal tool, don't use it manually.
  96535. */
  96536. export class ModelShape {
  96537. /**
  96538. * The shape id
  96539. * @hidden
  96540. */
  96541. shapeID: number;
  96542. /**
  96543. * flat array of model positions (internal use)
  96544. * @hidden
  96545. */
  96546. _shape: Vector3[];
  96547. /**
  96548. * flat array of model UVs (internal use)
  96549. * @hidden
  96550. */
  96551. _shapeUV: number[];
  96552. /**
  96553. * color array of the model
  96554. * @hidden
  96555. */
  96556. _shapeColors: number[];
  96557. /**
  96558. * indices array of the model
  96559. * @hidden
  96560. */
  96561. _indices: number[];
  96562. /**
  96563. * normals array of the model
  96564. * @hidden
  96565. */
  96566. _normals: number[];
  96567. /**
  96568. * length of the shape in the model indices array (internal use)
  96569. * @hidden
  96570. */
  96571. _indicesLength: number;
  96572. /**
  96573. * Custom position function (internal use)
  96574. * @hidden
  96575. */
  96576. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  96577. /**
  96578. * Custom vertex function (internal use)
  96579. * @hidden
  96580. */
  96581. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  96582. /**
  96583. * Model material (internal use)
  96584. * @hidden
  96585. */
  96586. _material: Nullable<Material>;
  96587. /**
  96588. * 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.
  96589. * SPS internal tool, don't use it manually.
  96590. * @hidden
  96591. */
  96592. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  96593. }
  96594. /**
  96595. * Represents a Depth Sorted Particle in the solid particle system.
  96596. * @hidden
  96597. */
  96598. export class DepthSortedParticle {
  96599. /**
  96600. * Index of the particle in the "indices" array
  96601. */
  96602. ind: number;
  96603. /**
  96604. * Length of the particle shape in the "indices" array
  96605. */
  96606. indicesLength: number;
  96607. /**
  96608. * Squared distance from the particle to the camera
  96609. */
  96610. sqDistance: number;
  96611. /**
  96612. * Material index when used with MultiMaterials
  96613. */
  96614. materialIndex: number;
  96615. /**
  96616. * Creates a new sorted particle
  96617. * @param materialIndex
  96618. */
  96619. constructor(ind: number, indLength: number, materialIndex: number);
  96620. }
  96621. }
  96622. declare module BABYLON {
  96623. /**
  96624. * @hidden
  96625. */
  96626. export class _MeshCollisionData {
  96627. _checkCollisions: boolean;
  96628. _collisionMask: number;
  96629. _collisionGroup: number;
  96630. _collider: Nullable<Collider>;
  96631. _oldPositionForCollisions: Vector3;
  96632. _diffPositionForCollisions: Vector3;
  96633. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  96634. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  96635. }
  96636. }
  96637. declare module BABYLON {
  96638. /** @hidden */
  96639. class _FacetDataStorage {
  96640. facetPositions: Vector3[];
  96641. facetNormals: Vector3[];
  96642. facetPartitioning: number[][];
  96643. facetNb: number;
  96644. partitioningSubdivisions: number;
  96645. partitioningBBoxRatio: number;
  96646. facetDataEnabled: boolean;
  96647. facetParameters: any;
  96648. bbSize: Vector3;
  96649. subDiv: {
  96650. max: number;
  96651. X: number;
  96652. Y: number;
  96653. Z: number;
  96654. };
  96655. facetDepthSort: boolean;
  96656. facetDepthSortEnabled: boolean;
  96657. depthSortedIndices: IndicesArray;
  96658. depthSortedFacets: {
  96659. ind: number;
  96660. sqDistance: number;
  96661. }[];
  96662. facetDepthSortFunction: (f1: {
  96663. ind: number;
  96664. sqDistance: number;
  96665. }, f2: {
  96666. ind: number;
  96667. sqDistance: number;
  96668. }) => number;
  96669. facetDepthSortFrom: Vector3;
  96670. facetDepthSortOrigin: Vector3;
  96671. invertedMatrix: Matrix;
  96672. }
  96673. /**
  96674. * @hidden
  96675. **/
  96676. class _InternalAbstractMeshDataInfo {
  96677. _hasVertexAlpha: boolean;
  96678. _useVertexColors: boolean;
  96679. _numBoneInfluencers: number;
  96680. _applyFog: boolean;
  96681. _receiveShadows: boolean;
  96682. _facetData: _FacetDataStorage;
  96683. _visibility: number;
  96684. _skeleton: Nullable<Skeleton>;
  96685. _layerMask: number;
  96686. _computeBonesUsingShaders: boolean;
  96687. _isActive: boolean;
  96688. _onlyForInstances: boolean;
  96689. _isActiveIntermediate: boolean;
  96690. _onlyForInstancesIntermediate: boolean;
  96691. _actAsRegularMesh: boolean;
  96692. }
  96693. /**
  96694. * Class used to store all common mesh properties
  96695. */
  96696. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  96697. /** No occlusion */
  96698. static OCCLUSION_TYPE_NONE: number;
  96699. /** Occlusion set to optimisitic */
  96700. static OCCLUSION_TYPE_OPTIMISTIC: number;
  96701. /** Occlusion set to strict */
  96702. static OCCLUSION_TYPE_STRICT: number;
  96703. /** Use an accurante occlusion algorithm */
  96704. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  96705. /** Use a conservative occlusion algorithm */
  96706. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  96707. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  96708. * Test order :
  96709. * Is the bounding sphere outside the frustum ?
  96710. * If not, are the bounding box vertices outside the frustum ?
  96711. * It not, then the cullable object is in the frustum.
  96712. */
  96713. static readonly CULLINGSTRATEGY_STANDARD: number;
  96714. /** Culling strategy : Bounding Sphere Only.
  96715. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  96716. * It's also less accurate than the standard because some not visible objects can still be selected.
  96717. * Test : is the bounding sphere outside the frustum ?
  96718. * If not, then the cullable object is in the frustum.
  96719. */
  96720. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  96721. /** Culling strategy : Optimistic Inclusion.
  96722. * This in an inclusion test first, then the standard exclusion test.
  96723. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  96724. * 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.
  96725. * Anyway, it's as accurate as the standard strategy.
  96726. * Test :
  96727. * Is the cullable object bounding sphere center in the frustum ?
  96728. * If not, apply the default culling strategy.
  96729. */
  96730. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  96731. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  96732. * This in an inclusion test first, then the bounding sphere only exclusion test.
  96733. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  96734. * 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.
  96735. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  96736. * Test :
  96737. * Is the cullable object bounding sphere center in the frustum ?
  96738. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  96739. */
  96740. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  96741. /**
  96742. * No billboard
  96743. */
  96744. static readonly BILLBOARDMODE_NONE: number;
  96745. /** Billboard on X axis */
  96746. static readonly BILLBOARDMODE_X: number;
  96747. /** Billboard on Y axis */
  96748. static readonly BILLBOARDMODE_Y: number;
  96749. /** Billboard on Z axis */
  96750. static readonly BILLBOARDMODE_Z: number;
  96751. /** Billboard on all axes */
  96752. static readonly BILLBOARDMODE_ALL: number;
  96753. /** Billboard on using position instead of orientation */
  96754. static readonly BILLBOARDMODE_USE_POSITION: number;
  96755. /** @hidden */
  96756. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  96757. /**
  96758. * The culling strategy to use to check whether the mesh must be rendered or not.
  96759. * This value can be changed at any time and will be used on the next render mesh selection.
  96760. * The possible values are :
  96761. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  96762. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  96763. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  96764. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  96765. * Please read each static variable documentation to get details about the culling process.
  96766. * */
  96767. cullingStrategy: number;
  96768. /**
  96769. * Gets the number of facets in the mesh
  96770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96771. */
  96772. readonly facetNb: number;
  96773. /**
  96774. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  96775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96776. */
  96777. partitioningSubdivisions: number;
  96778. /**
  96779. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  96780. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  96781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  96782. */
  96783. partitioningBBoxRatio: number;
  96784. /**
  96785. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  96786. * Works only for updatable meshes.
  96787. * Doesn't work with multi-materials
  96788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96789. */
  96790. mustDepthSortFacets: boolean;
  96791. /**
  96792. * The location (Vector3) where the facet depth sort must be computed from.
  96793. * By default, the active camera position.
  96794. * Used only when facet depth sort is enabled
  96795. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  96796. */
  96797. facetDepthSortFrom: Vector3;
  96798. /**
  96799. * gets a boolean indicating if facetData is enabled
  96800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  96801. */
  96802. readonly isFacetDataEnabled: boolean;
  96803. /** @hidden */
  96804. _updateNonUniformScalingState(value: boolean): boolean;
  96805. /**
  96806. * An event triggered when this mesh collides with another one
  96807. */
  96808. onCollideObservable: Observable<AbstractMesh>;
  96809. /** Set a function to call when this mesh collides with another one */
  96810. onCollide: () => void;
  96811. /**
  96812. * An event triggered when the collision's position changes
  96813. */
  96814. onCollisionPositionChangeObservable: Observable<Vector3>;
  96815. /** Set a function to call when the collision's position changes */
  96816. onCollisionPositionChange: () => void;
  96817. /**
  96818. * An event triggered when material is changed
  96819. */
  96820. onMaterialChangedObservable: Observable<AbstractMesh>;
  96821. /**
  96822. * Gets or sets the orientation for POV movement & rotation
  96823. */
  96824. definedFacingForward: boolean;
  96825. /** @hidden */
  96826. _occlusionQuery: Nullable<WebGLQuery>;
  96827. /** @hidden */
  96828. _renderingGroup: Nullable<RenderingGroup>;
  96829. /**
  96830. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96831. */
  96832. /**
  96833. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  96834. */
  96835. visibility: number;
  96836. /** Gets or sets the alpha index used to sort transparent meshes
  96837. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  96838. */
  96839. alphaIndex: number;
  96840. /**
  96841. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  96842. */
  96843. isVisible: boolean;
  96844. /**
  96845. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  96846. */
  96847. isPickable: boolean;
  96848. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  96849. showSubMeshesBoundingBox: boolean;
  96850. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  96851. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  96852. */
  96853. isBlocker: boolean;
  96854. /**
  96855. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  96856. */
  96857. enablePointerMoveEvents: boolean;
  96858. /**
  96859. * Specifies the rendering group id for this mesh (0 by default)
  96860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  96861. */
  96862. renderingGroupId: number;
  96863. private _material;
  96864. /** Gets or sets current material */
  96865. material: Nullable<Material>;
  96866. /**
  96867. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  96868. * @see http://doc.babylonjs.com/babylon101/shadows
  96869. */
  96870. receiveShadows: boolean;
  96871. /** Defines color to use when rendering outline */
  96872. outlineColor: Color3;
  96873. /** Define width to use when rendering outline */
  96874. outlineWidth: number;
  96875. /** Defines color to use when rendering overlay */
  96876. overlayColor: Color3;
  96877. /** Defines alpha to use when rendering overlay */
  96878. overlayAlpha: number;
  96879. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  96880. hasVertexAlpha: boolean;
  96881. /** 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) */
  96882. useVertexColors: boolean;
  96883. /**
  96884. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  96885. */
  96886. computeBonesUsingShaders: boolean;
  96887. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  96888. numBoneInfluencers: number;
  96889. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  96890. applyFog: boolean;
  96891. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  96892. useOctreeForRenderingSelection: boolean;
  96893. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  96894. useOctreeForPicking: boolean;
  96895. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  96896. useOctreeForCollisions: boolean;
  96897. /**
  96898. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  96899. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  96900. */
  96901. layerMask: number;
  96902. /**
  96903. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  96904. */
  96905. alwaysSelectAsActiveMesh: boolean;
  96906. /**
  96907. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  96908. */
  96909. doNotSyncBoundingInfo: boolean;
  96910. /**
  96911. * Gets or sets the current action manager
  96912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96913. */
  96914. actionManager: Nullable<AbstractActionManager>;
  96915. private _meshCollisionData;
  96916. /**
  96917. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  96918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96919. */
  96920. ellipsoid: Vector3;
  96921. /**
  96922. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  96923. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96924. */
  96925. ellipsoidOffset: Vector3;
  96926. /**
  96927. * Gets or sets a collision mask used to mask collisions (default is -1).
  96928. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96929. */
  96930. collisionMask: number;
  96931. /**
  96932. * Gets or sets the current collision group mask (-1 by default).
  96933. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  96934. */
  96935. collisionGroup: number;
  96936. /**
  96937. * Defines edge width used when edgesRenderer is enabled
  96938. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96939. */
  96940. edgesWidth: number;
  96941. /**
  96942. * Defines edge color used when edgesRenderer is enabled
  96943. * @see https://www.babylonjs-playground.com/#10OJSG#13
  96944. */
  96945. edgesColor: Color4;
  96946. /** @hidden */
  96947. _edgesRenderer: Nullable<IEdgesRenderer>;
  96948. /** @hidden */
  96949. _masterMesh: Nullable<AbstractMesh>;
  96950. /** @hidden */
  96951. _boundingInfo: Nullable<BoundingInfo>;
  96952. /** @hidden */
  96953. _renderId: number;
  96954. /**
  96955. * Gets or sets the list of subMeshes
  96956. * @see http://doc.babylonjs.com/how_to/multi_materials
  96957. */
  96958. subMeshes: SubMesh[];
  96959. /** @hidden */
  96960. _intersectionsInProgress: AbstractMesh[];
  96961. /** @hidden */
  96962. _unIndexed: boolean;
  96963. /** @hidden */
  96964. _lightSources: Light[];
  96965. /** Gets the list of lights affecting that mesh */
  96966. readonly lightSources: Light[];
  96967. /** @hidden */
  96968. readonly _positions: Nullable<Vector3[]>;
  96969. /** @hidden */
  96970. _waitingData: {
  96971. lods: Nullable<any>;
  96972. actions: Nullable<any>;
  96973. freezeWorldMatrix: Nullable<boolean>;
  96974. };
  96975. /** @hidden */
  96976. _bonesTransformMatrices: Nullable<Float32Array>;
  96977. /** @hidden */
  96978. _transformMatrixTexture: Nullable<RawTexture>;
  96979. /**
  96980. * Gets or sets a skeleton to apply skining transformations
  96981. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96982. */
  96983. skeleton: Nullable<Skeleton>;
  96984. /**
  96985. * An event triggered when the mesh is rebuilt.
  96986. */
  96987. onRebuildObservable: Observable<AbstractMesh>;
  96988. /**
  96989. * Creates a new AbstractMesh
  96990. * @param name defines the name of the mesh
  96991. * @param scene defines the hosting scene
  96992. */
  96993. constructor(name: string, scene?: Nullable<Scene>);
  96994. /**
  96995. * Returns the string "AbstractMesh"
  96996. * @returns "AbstractMesh"
  96997. */
  96998. getClassName(): string;
  96999. /**
  97000. * Gets a string representation of the current mesh
  97001. * @param fullDetails defines a boolean indicating if full details must be included
  97002. * @returns a string representation of the current mesh
  97003. */
  97004. toString(fullDetails?: boolean): string;
  97005. /**
  97006. * @hidden
  97007. */
  97008. protected _getEffectiveParent(): Nullable<Node>;
  97009. /** @hidden */
  97010. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97011. /** @hidden */
  97012. _rebuild(): void;
  97013. /** @hidden */
  97014. _resyncLightSources(): void;
  97015. /** @hidden */
  97016. _resyncLightSource(light: Light): void;
  97017. /** @hidden */
  97018. _unBindEffect(): void;
  97019. /** @hidden */
  97020. _removeLightSource(light: Light, dispose: boolean): void;
  97021. private _markSubMeshesAsDirty;
  97022. /** @hidden */
  97023. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  97024. /** @hidden */
  97025. _markSubMeshesAsAttributesDirty(): void;
  97026. /** @hidden */
  97027. _markSubMeshesAsMiscDirty(): void;
  97028. /**
  97029. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  97030. */
  97031. scaling: Vector3;
  97032. /**
  97033. * Returns true if the mesh is blocked. Implemented by child classes
  97034. */
  97035. readonly isBlocked: boolean;
  97036. /**
  97037. * Returns the mesh itself by default. Implemented by child classes
  97038. * @param camera defines the camera to use to pick the right LOD level
  97039. * @returns the currentAbstractMesh
  97040. */
  97041. getLOD(camera: Camera): Nullable<AbstractMesh>;
  97042. /**
  97043. * Returns 0 by default. Implemented by child classes
  97044. * @returns an integer
  97045. */
  97046. getTotalVertices(): number;
  97047. /**
  97048. * Returns a positive integer : the total number of indices in this mesh geometry.
  97049. * @returns the numner of indices or zero if the mesh has no geometry.
  97050. */
  97051. getTotalIndices(): number;
  97052. /**
  97053. * Returns null by default. Implemented by child classes
  97054. * @returns null
  97055. */
  97056. getIndices(): Nullable<IndicesArray>;
  97057. /**
  97058. * Returns the array of the requested vertex data kind. Implemented by child classes
  97059. * @param kind defines the vertex data kind to use
  97060. * @returns null
  97061. */
  97062. getVerticesData(kind: string): Nullable<FloatArray>;
  97063. /**
  97064. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97065. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97066. * Note that a new underlying VertexBuffer object is created each call.
  97067. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97068. * @param kind defines vertex data kind:
  97069. * * VertexBuffer.PositionKind
  97070. * * VertexBuffer.UVKind
  97071. * * VertexBuffer.UV2Kind
  97072. * * VertexBuffer.UV3Kind
  97073. * * VertexBuffer.UV4Kind
  97074. * * VertexBuffer.UV5Kind
  97075. * * VertexBuffer.UV6Kind
  97076. * * VertexBuffer.ColorKind
  97077. * * VertexBuffer.MatricesIndicesKind
  97078. * * VertexBuffer.MatricesIndicesExtraKind
  97079. * * VertexBuffer.MatricesWeightsKind
  97080. * * VertexBuffer.MatricesWeightsExtraKind
  97081. * @param data defines the data source
  97082. * @param updatable defines if the data must be flagged as updatable (or static)
  97083. * @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
  97084. * @returns the current mesh
  97085. */
  97086. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97087. /**
  97088. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97089. * If the mesh has no geometry, it is simply returned as it is.
  97090. * @param kind defines vertex data kind:
  97091. * * VertexBuffer.PositionKind
  97092. * * VertexBuffer.UVKind
  97093. * * VertexBuffer.UV2Kind
  97094. * * VertexBuffer.UV3Kind
  97095. * * VertexBuffer.UV4Kind
  97096. * * VertexBuffer.UV5Kind
  97097. * * VertexBuffer.UV6Kind
  97098. * * VertexBuffer.ColorKind
  97099. * * VertexBuffer.MatricesIndicesKind
  97100. * * VertexBuffer.MatricesIndicesExtraKind
  97101. * * VertexBuffer.MatricesWeightsKind
  97102. * * VertexBuffer.MatricesWeightsExtraKind
  97103. * @param data defines the data source
  97104. * @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
  97105. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  97106. * @returns the current mesh
  97107. */
  97108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97109. /**
  97110. * Sets the mesh indices,
  97111. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97112. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  97113. * @param totalVertices Defines the total number of vertices
  97114. * @returns the current mesh
  97115. */
  97116. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  97117. /**
  97118. * Gets a boolean indicating if specific vertex data is present
  97119. * @param kind defines the vertex data kind to use
  97120. * @returns true is data kind is present
  97121. */
  97122. isVerticesDataPresent(kind: string): boolean;
  97123. /**
  97124. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  97125. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  97126. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  97127. * @returns a BoundingInfo
  97128. */
  97129. getBoundingInfo(): BoundingInfo;
  97130. /**
  97131. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  97132. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  97133. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  97134. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  97135. * @returns the current mesh
  97136. */
  97137. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  97138. /**
  97139. * Overwrite the current bounding info
  97140. * @param boundingInfo defines the new bounding info
  97141. * @returns the current mesh
  97142. */
  97143. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  97144. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  97145. readonly useBones: boolean;
  97146. /** @hidden */
  97147. _preActivate(): void;
  97148. /** @hidden */
  97149. _preActivateForIntermediateRendering(renderId: number): void;
  97150. /** @hidden */
  97151. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97152. /** @hidden */
  97153. _postActivate(): void;
  97154. /** @hidden */
  97155. _freeze(): void;
  97156. /** @hidden */
  97157. _unFreeze(): void;
  97158. /**
  97159. * Gets the current world matrix
  97160. * @returns a Matrix
  97161. */
  97162. getWorldMatrix(): Matrix;
  97163. /** @hidden */
  97164. _getWorldMatrixDeterminant(): number;
  97165. /**
  97166. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  97167. */
  97168. readonly isAnInstance: boolean;
  97169. /**
  97170. * Gets a boolean indicating if this mesh has instances
  97171. */
  97172. readonly hasInstances: boolean;
  97173. /**
  97174. * Perform relative position change from the point of view of behind the front of the mesh.
  97175. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97176. * Supports definition of mesh facing forward or backward
  97177. * @param amountRight defines the distance on the right axis
  97178. * @param amountUp defines the distance on the up axis
  97179. * @param amountForward defines the distance on the forward axis
  97180. * @returns the current mesh
  97181. */
  97182. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  97183. /**
  97184. * Calculate relative position change from the point of view of behind the front of the mesh.
  97185. * This is performed taking into account the meshes current rotation, so you do not have to care.
  97186. * Supports definition of mesh facing forward or backward
  97187. * @param amountRight defines the distance on the right axis
  97188. * @param amountUp defines the distance on the up axis
  97189. * @param amountForward defines the distance on the forward axis
  97190. * @returns the new displacement vector
  97191. */
  97192. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  97193. /**
  97194. * Perform relative rotation change from the point of view of behind the front of the mesh.
  97195. * Supports definition of mesh facing forward or backward
  97196. * @param flipBack defines the flip
  97197. * @param twirlClockwise defines the twirl
  97198. * @param tiltRight defines the tilt
  97199. * @returns the current mesh
  97200. */
  97201. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  97202. /**
  97203. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  97204. * Supports definition of mesh facing forward or backward.
  97205. * @param flipBack defines the flip
  97206. * @param twirlClockwise defines the twirl
  97207. * @param tiltRight defines the tilt
  97208. * @returns the new rotation vector
  97209. */
  97210. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  97211. /**
  97212. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97213. * This means the mesh underlying bounding box and sphere are recomputed.
  97214. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97215. * @returns the current mesh
  97216. */
  97217. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  97218. /** @hidden */
  97219. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  97220. /** @hidden */
  97221. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  97222. /** @hidden */
  97223. _updateBoundingInfo(): AbstractMesh;
  97224. /** @hidden */
  97225. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  97226. /** @hidden */
  97227. protected _afterComputeWorldMatrix(): void;
  97228. /** @hidden */
  97229. readonly _effectiveMesh: AbstractMesh;
  97230. /**
  97231. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  97232. * A mesh is in the frustum if its bounding box intersects the frustum
  97233. * @param frustumPlanes defines the frustum to test
  97234. * @returns true if the mesh is in the frustum planes
  97235. */
  97236. isInFrustum(frustumPlanes: Plane[]): boolean;
  97237. /**
  97238. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  97239. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  97240. * @param frustumPlanes defines the frustum to test
  97241. * @returns true if the mesh is completely in the frustum planes
  97242. */
  97243. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  97244. /**
  97245. * True if the mesh intersects another mesh or a SolidParticle object
  97246. * @param mesh defines a target mesh or SolidParticle to test
  97247. * @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)
  97248. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  97249. * @returns true if there is an intersection
  97250. */
  97251. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  97252. /**
  97253. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  97254. * @param point defines the point to test
  97255. * @returns true if there is an intersection
  97256. */
  97257. intersectsPoint(point: Vector3): boolean;
  97258. /**
  97259. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  97260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97261. */
  97262. checkCollisions: boolean;
  97263. /**
  97264. * Gets Collider object used to compute collisions (not physics)
  97265. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97266. */
  97267. readonly collider: Nullable<Collider>;
  97268. /**
  97269. * Move the mesh using collision engine
  97270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97271. * @param displacement defines the requested displacement vector
  97272. * @returns the current mesh
  97273. */
  97274. moveWithCollisions(displacement: Vector3): AbstractMesh;
  97275. private _onCollisionPositionChange;
  97276. /** @hidden */
  97277. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  97278. /** @hidden */
  97279. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  97280. /** @hidden */
  97281. _checkCollision(collider: Collider): AbstractMesh;
  97282. /** @hidden */
  97283. _generatePointsArray(): boolean;
  97284. /**
  97285. * Checks if the passed Ray intersects with the mesh
  97286. * @param ray defines the ray to use
  97287. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  97288. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97289. * @returns the picking info
  97290. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  97291. */
  97292. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  97293. /**
  97294. * Clones the current mesh
  97295. * @param name defines the mesh name
  97296. * @param newParent defines the new mesh parent
  97297. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  97298. * @returns the new mesh
  97299. */
  97300. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  97301. /**
  97302. * Disposes all the submeshes of the current meshnp
  97303. * @returns the current mesh
  97304. */
  97305. releaseSubMeshes(): AbstractMesh;
  97306. /**
  97307. * Releases resources associated with this abstract mesh.
  97308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97310. */
  97311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97312. /**
  97313. * Adds the passed mesh as a child to the current mesh
  97314. * @param mesh defines the child mesh
  97315. * @returns the current mesh
  97316. */
  97317. addChild(mesh: AbstractMesh): AbstractMesh;
  97318. /**
  97319. * Removes the passed mesh from the current mesh children list
  97320. * @param mesh defines the child mesh
  97321. * @returns the current mesh
  97322. */
  97323. removeChild(mesh: AbstractMesh): AbstractMesh;
  97324. /** @hidden */
  97325. private _initFacetData;
  97326. /**
  97327. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  97328. * This method can be called within the render loop.
  97329. * 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
  97330. * @returns the current mesh
  97331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97332. */
  97333. updateFacetData(): AbstractMesh;
  97334. /**
  97335. * Returns the facetLocalNormals array.
  97336. * The normals are expressed in the mesh local spac
  97337. * @returns an array of Vector3
  97338. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97339. */
  97340. getFacetLocalNormals(): Vector3[];
  97341. /**
  97342. * Returns the facetLocalPositions array.
  97343. * The facet positions are expressed in the mesh local space
  97344. * @returns an array of Vector3
  97345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97346. */
  97347. getFacetLocalPositions(): Vector3[];
  97348. /**
  97349. * Returns the facetLocalPartioning array
  97350. * @returns an array of array of numbers
  97351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97352. */
  97353. getFacetLocalPartitioning(): number[][];
  97354. /**
  97355. * Returns the i-th facet position in the world system.
  97356. * This method allocates a new Vector3 per call
  97357. * @param i defines the facet index
  97358. * @returns a new Vector3
  97359. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97360. */
  97361. getFacetPosition(i: number): Vector3;
  97362. /**
  97363. * Sets the reference Vector3 with the i-th facet position in the world system
  97364. * @param i defines the facet index
  97365. * @param ref defines the target vector
  97366. * @returns the current mesh
  97367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97368. */
  97369. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  97370. /**
  97371. * Returns the i-th facet normal in the world system.
  97372. * This method allocates a new Vector3 per call
  97373. * @param i defines the facet index
  97374. * @returns a new Vector3
  97375. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97376. */
  97377. getFacetNormal(i: number): Vector3;
  97378. /**
  97379. * Sets the reference Vector3 with the i-th facet normal in the world system
  97380. * @param i defines the facet index
  97381. * @param ref defines the target vector
  97382. * @returns the current mesh
  97383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97384. */
  97385. getFacetNormalToRef(i: number, ref: Vector3): this;
  97386. /**
  97387. * 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)
  97388. * @param x defines x coordinate
  97389. * @param y defines y coordinate
  97390. * @param z defines z coordinate
  97391. * @returns the array of facet indexes
  97392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97393. */
  97394. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  97395. /**
  97396. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  97397. * @param projected sets as the (x,y,z) world projection on the facet
  97398. * @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
  97399. * @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
  97400. * @param x defines x coordinate
  97401. * @param y defines y coordinate
  97402. * @param z defines z coordinate
  97403. * @returns the face index if found (or null instead)
  97404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97405. */
  97406. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  97407. /**
  97408. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  97409. * @param projected sets as the (x,y,z) local projection on the facet
  97410. * @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
  97411. * @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
  97412. * @param x defines x coordinate
  97413. * @param y defines y coordinate
  97414. * @param z defines z coordinate
  97415. * @returns the face index if found (or null instead)
  97416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97417. */
  97418. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  97419. /**
  97420. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  97421. * @returns the parameters
  97422. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97423. */
  97424. getFacetDataParameters(): any;
  97425. /**
  97426. * Disables the feature FacetData and frees the related memory
  97427. * @returns the current mesh
  97428. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  97429. */
  97430. disableFacetData(): AbstractMesh;
  97431. /**
  97432. * Updates the AbstractMesh indices array
  97433. * @param indices defines the data source
  97434. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97435. * @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)
  97436. * @returns the current mesh
  97437. */
  97438. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97439. /**
  97440. * Creates new normals data for the mesh
  97441. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  97442. * @returns the current mesh
  97443. */
  97444. createNormals(updatable: boolean): AbstractMesh;
  97445. /**
  97446. * Align the mesh with a normal
  97447. * @param normal defines the normal to use
  97448. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  97449. * @returns the current mesh
  97450. */
  97451. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  97452. /** @hidden */
  97453. _checkOcclusionQuery(): boolean;
  97454. /**
  97455. * Disables the mesh edge rendering mode
  97456. * @returns the currentAbstractMesh
  97457. */
  97458. disableEdgesRendering(): AbstractMesh;
  97459. /**
  97460. * Enables the edge rendering mode on the mesh.
  97461. * This mode makes the mesh edges visible
  97462. * @param epsilon defines the maximal distance between two angles to detect a face
  97463. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97464. * @returns the currentAbstractMesh
  97465. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97466. */
  97467. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97468. }
  97469. }
  97470. declare module BABYLON {
  97471. /**
  97472. * Interface used to define ActionEvent
  97473. */
  97474. export interface IActionEvent {
  97475. /** The mesh or sprite that triggered the action */
  97476. source: any;
  97477. /** The X mouse cursor position at the time of the event */
  97478. pointerX: number;
  97479. /** The Y mouse cursor position at the time of the event */
  97480. pointerY: number;
  97481. /** The mesh that is currently pointed at (can be null) */
  97482. meshUnderPointer: Nullable<AbstractMesh>;
  97483. /** the original (browser) event that triggered the ActionEvent */
  97484. sourceEvent?: any;
  97485. /** additional data for the event */
  97486. additionalData?: any;
  97487. }
  97488. /**
  97489. * ActionEvent is the event being sent when an action is triggered.
  97490. */
  97491. export class ActionEvent implements IActionEvent {
  97492. /** The mesh or sprite that triggered the action */
  97493. source: any;
  97494. /** The X mouse cursor position at the time of the event */
  97495. pointerX: number;
  97496. /** The Y mouse cursor position at the time of the event */
  97497. pointerY: number;
  97498. /** The mesh that is currently pointed at (can be null) */
  97499. meshUnderPointer: Nullable<AbstractMesh>;
  97500. /** the original (browser) event that triggered the ActionEvent */
  97501. sourceEvent?: any;
  97502. /** additional data for the event */
  97503. additionalData?: any;
  97504. /**
  97505. * Creates a new ActionEvent
  97506. * @param source The mesh or sprite that triggered the action
  97507. * @param pointerX The X mouse cursor position at the time of the event
  97508. * @param pointerY The Y mouse cursor position at the time of the event
  97509. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  97510. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  97511. * @param additionalData additional data for the event
  97512. */
  97513. constructor(
  97514. /** The mesh or sprite that triggered the action */
  97515. source: any,
  97516. /** The X mouse cursor position at the time of the event */
  97517. pointerX: number,
  97518. /** The Y mouse cursor position at the time of the event */
  97519. pointerY: number,
  97520. /** The mesh that is currently pointed at (can be null) */
  97521. meshUnderPointer: Nullable<AbstractMesh>,
  97522. /** the original (browser) event that triggered the ActionEvent */
  97523. sourceEvent?: any,
  97524. /** additional data for the event */
  97525. additionalData?: any);
  97526. /**
  97527. * Helper function to auto-create an ActionEvent from a source mesh.
  97528. * @param source The source mesh that triggered the event
  97529. * @param evt The original (browser) event
  97530. * @param additionalData additional data for the event
  97531. * @returns the new ActionEvent
  97532. */
  97533. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  97534. /**
  97535. * Helper function to auto-create an ActionEvent from a source sprite
  97536. * @param source The source sprite that triggered the event
  97537. * @param scene Scene associated with the sprite
  97538. * @param evt The original (browser) event
  97539. * @param additionalData additional data for the event
  97540. * @returns the new ActionEvent
  97541. */
  97542. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  97543. /**
  97544. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  97545. * @param scene the scene where the event occurred
  97546. * @param evt The original (browser) event
  97547. * @returns the new ActionEvent
  97548. */
  97549. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  97550. /**
  97551. * Helper function to auto-create an ActionEvent from a primitive
  97552. * @param prim defines the target primitive
  97553. * @param pointerPos defines the pointer position
  97554. * @param evt The original (browser) event
  97555. * @param additionalData additional data for the event
  97556. * @returns the new ActionEvent
  97557. */
  97558. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  97559. }
  97560. }
  97561. declare module BABYLON {
  97562. /**
  97563. * Abstract class used to decouple action Manager from scene and meshes.
  97564. * Do not instantiate.
  97565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97566. */
  97567. export abstract class AbstractActionManager implements IDisposable {
  97568. /** Gets the list of active triggers */
  97569. static Triggers: {
  97570. [key: string]: number;
  97571. };
  97572. /** Gets the cursor to use when hovering items */
  97573. hoverCursor: string;
  97574. /** Gets the list of actions */
  97575. actions: IAction[];
  97576. /**
  97577. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  97578. */
  97579. isRecursive: boolean;
  97580. /**
  97581. * Releases all associated resources
  97582. */
  97583. abstract dispose(): void;
  97584. /**
  97585. * Does this action manager has pointer triggers
  97586. */
  97587. abstract readonly hasPointerTriggers: boolean;
  97588. /**
  97589. * Does this action manager has pick triggers
  97590. */
  97591. abstract readonly hasPickTriggers: boolean;
  97592. /**
  97593. * Process a specific trigger
  97594. * @param trigger defines the trigger to process
  97595. * @param evt defines the event details to be processed
  97596. */
  97597. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  97598. /**
  97599. * Does this action manager handles actions of any of the given triggers
  97600. * @param triggers defines the triggers to be tested
  97601. * @return a boolean indicating whether one (or more) of the triggers is handled
  97602. */
  97603. abstract hasSpecificTriggers(triggers: number[]): boolean;
  97604. /**
  97605. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  97606. * speed.
  97607. * @param triggerA defines the trigger to be tested
  97608. * @param triggerB defines the trigger to be tested
  97609. * @return a boolean indicating whether one (or more) of the triggers is handled
  97610. */
  97611. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  97612. /**
  97613. * Does this action manager handles actions of a given trigger
  97614. * @param trigger defines the trigger to be tested
  97615. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  97616. * @return whether the trigger is handled
  97617. */
  97618. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  97619. /**
  97620. * Serialize this manager to a JSON object
  97621. * @param name defines the property name to store this manager
  97622. * @returns a JSON representation of this manager
  97623. */
  97624. abstract serialize(name: string): any;
  97625. /**
  97626. * Registers an action to this action manager
  97627. * @param action defines the action to be registered
  97628. * @return the action amended (prepared) after registration
  97629. */
  97630. abstract registerAction(action: IAction): Nullable<IAction>;
  97631. /**
  97632. * Unregisters an action to this action manager
  97633. * @param action defines the action to be unregistered
  97634. * @return a boolean indicating whether the action has been unregistered
  97635. */
  97636. abstract unregisterAction(action: IAction): Boolean;
  97637. /**
  97638. * Does exist one action manager with at least one trigger
  97639. **/
  97640. static readonly HasTriggers: boolean;
  97641. /**
  97642. * Does exist one action manager with at least one pick trigger
  97643. **/
  97644. static readonly HasPickTriggers: boolean;
  97645. /**
  97646. * Does exist one action manager that handles actions of a given trigger
  97647. * @param trigger defines the trigger to be tested
  97648. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  97649. **/
  97650. static HasSpecificTrigger(trigger: number): boolean;
  97651. }
  97652. }
  97653. declare module BABYLON {
  97654. /**
  97655. * Defines how a node can be built from a string name.
  97656. */
  97657. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  97658. /**
  97659. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  97660. */
  97661. export class Node implements IBehaviorAware<Node> {
  97662. /** @hidden */
  97663. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  97664. private static _NodeConstructors;
  97665. /**
  97666. * Add a new node constructor
  97667. * @param type defines the type name of the node to construct
  97668. * @param constructorFunc defines the constructor function
  97669. */
  97670. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  97671. /**
  97672. * Returns a node constructor based on type name
  97673. * @param type defines the type name
  97674. * @param name defines the new node name
  97675. * @param scene defines the hosting scene
  97676. * @param options defines optional options to transmit to constructors
  97677. * @returns the new constructor or null
  97678. */
  97679. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  97680. /**
  97681. * Gets or sets the name of the node
  97682. */
  97683. name: string;
  97684. /**
  97685. * Gets or sets the id of the node
  97686. */
  97687. id: string;
  97688. /**
  97689. * Gets or sets the unique id of the node
  97690. */
  97691. uniqueId: number;
  97692. /**
  97693. * Gets or sets a string used to store user defined state for the node
  97694. */
  97695. state: string;
  97696. /**
  97697. * Gets or sets an object used to store user defined information for the node
  97698. */
  97699. metadata: any;
  97700. /**
  97701. * For internal use only. Please do not use.
  97702. */
  97703. reservedDataStore: any;
  97704. /**
  97705. * List of inspectable custom properties (used by the Inspector)
  97706. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97707. */
  97708. inspectableCustomProperties: IInspectable[];
  97709. private _doNotSerialize;
  97710. /**
  97711. * Gets or sets a boolean used to define if the node must be serialized
  97712. */
  97713. doNotSerialize: boolean;
  97714. /** @hidden */
  97715. _isDisposed: boolean;
  97716. /**
  97717. * Gets a list of Animations associated with the node
  97718. */
  97719. animations: Animation[];
  97720. protected _ranges: {
  97721. [name: string]: Nullable<AnimationRange>;
  97722. };
  97723. /**
  97724. * Callback raised when the node is ready to be used
  97725. */
  97726. onReady: Nullable<(node: Node) => void>;
  97727. private _isEnabled;
  97728. private _isParentEnabled;
  97729. private _isReady;
  97730. /** @hidden */
  97731. _currentRenderId: number;
  97732. private _parentUpdateId;
  97733. /** @hidden */
  97734. _childUpdateId: number;
  97735. /** @hidden */
  97736. _waitingParentId: Nullable<string>;
  97737. /** @hidden */
  97738. _scene: Scene;
  97739. /** @hidden */
  97740. _cache: any;
  97741. private _parentNode;
  97742. private _children;
  97743. /** @hidden */
  97744. _worldMatrix: Matrix;
  97745. /** @hidden */
  97746. _worldMatrixDeterminant: number;
  97747. /** @hidden */
  97748. _worldMatrixDeterminantIsDirty: boolean;
  97749. /** @hidden */
  97750. private _sceneRootNodesIndex;
  97751. /**
  97752. * Gets a boolean indicating if the node has been disposed
  97753. * @returns true if the node was disposed
  97754. */
  97755. isDisposed(): boolean;
  97756. /**
  97757. * Gets or sets the parent of the node (without keeping the current position in the scene)
  97758. * @see https://doc.babylonjs.com/how_to/parenting
  97759. */
  97760. parent: Nullable<Node>;
  97761. /** @hidden */
  97762. _addToSceneRootNodes(): void;
  97763. /** @hidden */
  97764. _removeFromSceneRootNodes(): void;
  97765. private _animationPropertiesOverride;
  97766. /**
  97767. * Gets or sets the animation properties override
  97768. */
  97769. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  97770. /**
  97771. * Gets a string idenfifying the name of the class
  97772. * @returns "Node" string
  97773. */
  97774. getClassName(): string;
  97775. /** @hidden */
  97776. readonly _isNode: boolean;
  97777. /**
  97778. * An event triggered when the mesh is disposed
  97779. */
  97780. onDisposeObservable: Observable<Node>;
  97781. private _onDisposeObserver;
  97782. /**
  97783. * Sets a callback that will be raised when the node will be disposed
  97784. */
  97785. onDispose: () => void;
  97786. /**
  97787. * Creates a new Node
  97788. * @param name the name and id to be given to this node
  97789. * @param scene the scene this node will be added to
  97790. */
  97791. constructor(name: string, scene?: Nullable<Scene>);
  97792. /**
  97793. * Gets the scene of the node
  97794. * @returns a scene
  97795. */
  97796. getScene(): Scene;
  97797. /**
  97798. * Gets the engine of the node
  97799. * @returns a Engine
  97800. */
  97801. getEngine(): Engine;
  97802. private _behaviors;
  97803. /**
  97804. * Attach a behavior to the node
  97805. * @see http://doc.babylonjs.com/features/behaviour
  97806. * @param behavior defines the behavior to attach
  97807. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  97808. * @returns the current Node
  97809. */
  97810. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  97811. /**
  97812. * Remove an attached behavior
  97813. * @see http://doc.babylonjs.com/features/behaviour
  97814. * @param behavior defines the behavior to attach
  97815. * @returns the current Node
  97816. */
  97817. removeBehavior(behavior: Behavior<Node>): Node;
  97818. /**
  97819. * Gets the list of attached behaviors
  97820. * @see http://doc.babylonjs.com/features/behaviour
  97821. */
  97822. readonly behaviors: Behavior<Node>[];
  97823. /**
  97824. * Gets an attached behavior by name
  97825. * @param name defines the name of the behavior to look for
  97826. * @see http://doc.babylonjs.com/features/behaviour
  97827. * @returns null if behavior was not found else the requested behavior
  97828. */
  97829. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  97830. /**
  97831. * Returns the latest update of the World matrix
  97832. * @returns a Matrix
  97833. */
  97834. getWorldMatrix(): Matrix;
  97835. /** @hidden */
  97836. _getWorldMatrixDeterminant(): number;
  97837. /**
  97838. * Returns directly the latest state of the mesh World matrix.
  97839. * A Matrix is returned.
  97840. */
  97841. readonly worldMatrixFromCache: Matrix;
  97842. /** @hidden */
  97843. _initCache(): void;
  97844. /** @hidden */
  97845. updateCache(force?: boolean): void;
  97846. /** @hidden */
  97847. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  97848. /** @hidden */
  97849. _updateCache(ignoreParentClass?: boolean): void;
  97850. /** @hidden */
  97851. _isSynchronized(): boolean;
  97852. /** @hidden */
  97853. _markSyncedWithParent(): void;
  97854. /** @hidden */
  97855. isSynchronizedWithParent(): boolean;
  97856. /** @hidden */
  97857. isSynchronized(): boolean;
  97858. /**
  97859. * Is this node ready to be used/rendered
  97860. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97861. * @return true if the node is ready
  97862. */
  97863. isReady(completeCheck?: boolean): boolean;
  97864. /**
  97865. * Is this node enabled?
  97866. * 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
  97867. * @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
  97868. * @return whether this node (and its parent) is enabled
  97869. */
  97870. isEnabled(checkAncestors?: boolean): boolean;
  97871. /** @hidden */
  97872. protected _syncParentEnabledState(): void;
  97873. /**
  97874. * Set the enabled state of this node
  97875. * @param value defines the new enabled state
  97876. */
  97877. setEnabled(value: boolean): void;
  97878. /**
  97879. * Is this node a descendant of the given node?
  97880. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  97881. * @param ancestor defines the parent node to inspect
  97882. * @returns a boolean indicating if this node is a descendant of the given node
  97883. */
  97884. isDescendantOf(ancestor: Node): boolean;
  97885. /** @hidden */
  97886. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  97887. /**
  97888. * Will return all nodes that have this node as ascendant
  97889. * @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
  97890. * @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
  97891. * @return all children nodes of all types
  97892. */
  97893. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  97894. /**
  97895. * Get all child-meshes of this node
  97896. * @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)
  97897. * @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
  97898. * @returns an array of AbstractMesh
  97899. */
  97900. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  97901. /**
  97902. * Get all direct children of this node
  97903. * @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
  97904. * @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)
  97905. * @returns an array of Node
  97906. */
  97907. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  97908. /** @hidden */
  97909. _setReady(state: boolean): void;
  97910. /**
  97911. * Get an animation by name
  97912. * @param name defines the name of the animation to look for
  97913. * @returns null if not found else the requested animation
  97914. */
  97915. getAnimationByName(name: string): Nullable<Animation>;
  97916. /**
  97917. * Creates an animation range for this node
  97918. * @param name defines the name of the range
  97919. * @param from defines the starting key
  97920. * @param to defines the end key
  97921. */
  97922. createAnimationRange(name: string, from: number, to: number): void;
  97923. /**
  97924. * Delete a specific animation range
  97925. * @param name defines the name of the range to delete
  97926. * @param deleteFrames defines if animation frames from the range must be deleted as well
  97927. */
  97928. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97929. /**
  97930. * Get an animation range by name
  97931. * @param name defines the name of the animation range to look for
  97932. * @returns null if not found else the requested animation range
  97933. */
  97934. getAnimationRange(name: string): Nullable<AnimationRange>;
  97935. /**
  97936. * Gets the list of all animation ranges defined on this node
  97937. * @returns an array
  97938. */
  97939. getAnimationRanges(): Nullable<AnimationRange>[];
  97940. /**
  97941. * Will start the animation sequence
  97942. * @param name defines the range frames for animation sequence
  97943. * @param loop defines if the animation should loop (false by default)
  97944. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  97945. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  97946. * @returns the object created for this animation. If range does not exist, it will return null
  97947. */
  97948. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97949. /**
  97950. * Serialize animation ranges into a JSON compatible object
  97951. * @returns serialization object
  97952. */
  97953. serializeAnimationRanges(): any;
  97954. /**
  97955. * Computes the world matrix of the node
  97956. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97957. * @returns the world matrix
  97958. */
  97959. computeWorldMatrix(force?: boolean): Matrix;
  97960. /**
  97961. * Releases resources associated with this node.
  97962. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  97963. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  97964. */
  97965. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97966. /**
  97967. * Parse animation range data from a serialization object and store them into a given node
  97968. * @param node defines where to store the animation ranges
  97969. * @param parsedNode defines the serialization object to read data from
  97970. * @param scene defines the hosting scene
  97971. */
  97972. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  97973. /**
  97974. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  97975. * @param includeDescendants Include bounding info from descendants as well (true by default)
  97976. * @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
  97977. * @returns the new bounding vectors
  97978. */
  97979. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  97980. min: Vector3;
  97981. max: Vector3;
  97982. };
  97983. }
  97984. }
  97985. declare module BABYLON {
  97986. /**
  97987. * @hidden
  97988. */
  97989. export class _IAnimationState {
  97990. key: number;
  97991. repeatCount: number;
  97992. workValue?: any;
  97993. loopMode?: number;
  97994. offsetValue?: any;
  97995. highLimitValue?: any;
  97996. }
  97997. /**
  97998. * Class used to store any kind of animation
  97999. */
  98000. export class Animation {
  98001. /**Name of the animation */
  98002. name: string;
  98003. /**Property to animate */
  98004. targetProperty: string;
  98005. /**The frames per second of the animation */
  98006. framePerSecond: number;
  98007. /**The data type of the animation */
  98008. dataType: number;
  98009. /**The loop mode of the animation */
  98010. loopMode?: number | undefined;
  98011. /**Specifies if blending should be enabled */
  98012. enableBlending?: boolean | undefined;
  98013. /**
  98014. * Use matrix interpolation instead of using direct key value when animating matrices
  98015. */
  98016. static AllowMatricesInterpolation: boolean;
  98017. /**
  98018. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  98019. */
  98020. static AllowMatrixDecomposeForInterpolation: boolean;
  98021. /**
  98022. * Stores the key frames of the animation
  98023. */
  98024. private _keys;
  98025. /**
  98026. * Stores the easing function of the animation
  98027. */
  98028. private _easingFunction;
  98029. /**
  98030. * @hidden Internal use only
  98031. */
  98032. _runtimeAnimations: RuntimeAnimation[];
  98033. /**
  98034. * The set of event that will be linked to this animation
  98035. */
  98036. private _events;
  98037. /**
  98038. * Stores an array of target property paths
  98039. */
  98040. targetPropertyPath: string[];
  98041. /**
  98042. * Stores the blending speed of the animation
  98043. */
  98044. blendingSpeed: number;
  98045. /**
  98046. * Stores the animation ranges for the animation
  98047. */
  98048. private _ranges;
  98049. /**
  98050. * @hidden Internal use
  98051. */
  98052. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  98053. /**
  98054. * Sets up an animation
  98055. * @param property The property to animate
  98056. * @param animationType The animation type to apply
  98057. * @param framePerSecond The frames per second of the animation
  98058. * @param easingFunction The easing function used in the animation
  98059. * @returns The created animation
  98060. */
  98061. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  98062. /**
  98063. * Create and start an animation on a node
  98064. * @param name defines the name of the global animation that will be run on all nodes
  98065. * @param node defines the root node where the animation will take place
  98066. * @param targetProperty defines property to animate
  98067. * @param framePerSecond defines the number of frame per second yo use
  98068. * @param totalFrame defines the number of frames in total
  98069. * @param from defines the initial value
  98070. * @param to defines the final value
  98071. * @param loopMode defines which loop mode you want to use (off by default)
  98072. * @param easingFunction defines the easing function to use (linear by default)
  98073. * @param onAnimationEnd defines the callback to call when animation end
  98074. * @returns the animatable created for this animation
  98075. */
  98076. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  98077. /**
  98078. * Create and start an animation on a node and its descendants
  98079. * @param name defines the name of the global animation that will be run on all nodes
  98080. * @param node defines the root node where the animation will take place
  98081. * @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
  98082. * @param targetProperty defines property to animate
  98083. * @param framePerSecond defines the number of frame per second to use
  98084. * @param totalFrame defines the number of frames in total
  98085. * @param from defines the initial value
  98086. * @param to defines the final value
  98087. * @param loopMode defines which loop mode you want to use (off by default)
  98088. * @param easingFunction defines the easing function to use (linear by default)
  98089. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  98090. * @returns the list of animatables created for all nodes
  98091. * @example https://www.babylonjs-playground.com/#MH0VLI
  98092. */
  98093. 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[]>;
  98094. /**
  98095. * Creates a new animation, merges it with the existing animations and starts it
  98096. * @param name Name of the animation
  98097. * @param node Node which contains the scene that begins the animations
  98098. * @param targetProperty Specifies which property to animate
  98099. * @param framePerSecond The frames per second of the animation
  98100. * @param totalFrame The total number of frames
  98101. * @param from The frame at the beginning of the animation
  98102. * @param to The frame at the end of the animation
  98103. * @param loopMode Specifies the loop mode of the animation
  98104. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  98105. * @param onAnimationEnd Callback to run once the animation is complete
  98106. * @returns Nullable animation
  98107. */
  98108. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  98109. /**
  98110. * Transition property of an host to the target Value
  98111. * @param property The property to transition
  98112. * @param targetValue The target Value of the property
  98113. * @param host The object where the property to animate belongs
  98114. * @param scene Scene used to run the animation
  98115. * @param frameRate Framerate (in frame/s) to use
  98116. * @param transition The transition type we want to use
  98117. * @param duration The duration of the animation, in milliseconds
  98118. * @param onAnimationEnd Callback trigger at the end of the animation
  98119. * @returns Nullable animation
  98120. */
  98121. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  98122. /**
  98123. * Return the array of runtime animations currently using this animation
  98124. */
  98125. readonly runtimeAnimations: RuntimeAnimation[];
  98126. /**
  98127. * Specifies if any of the runtime animations are currently running
  98128. */
  98129. readonly hasRunningRuntimeAnimations: boolean;
  98130. /**
  98131. * Initializes the animation
  98132. * @param name Name of the animation
  98133. * @param targetProperty Property to animate
  98134. * @param framePerSecond The frames per second of the animation
  98135. * @param dataType The data type of the animation
  98136. * @param loopMode The loop mode of the animation
  98137. * @param enableBlending Specifies if blending should be enabled
  98138. */
  98139. constructor(
  98140. /**Name of the animation */
  98141. name: string,
  98142. /**Property to animate */
  98143. targetProperty: string,
  98144. /**The frames per second of the animation */
  98145. framePerSecond: number,
  98146. /**The data type of the animation */
  98147. dataType: number,
  98148. /**The loop mode of the animation */
  98149. loopMode?: number | undefined,
  98150. /**Specifies if blending should be enabled */
  98151. enableBlending?: boolean | undefined);
  98152. /**
  98153. * Converts the animation to a string
  98154. * @param fullDetails support for multiple levels of logging within scene loading
  98155. * @returns String form of the animation
  98156. */
  98157. toString(fullDetails?: boolean): string;
  98158. /**
  98159. * Add an event to this animation
  98160. * @param event Event to add
  98161. */
  98162. addEvent(event: AnimationEvent): void;
  98163. /**
  98164. * Remove all events found at the given frame
  98165. * @param frame The frame to remove events from
  98166. */
  98167. removeEvents(frame: number): void;
  98168. /**
  98169. * Retrieves all the events from the animation
  98170. * @returns Events from the animation
  98171. */
  98172. getEvents(): AnimationEvent[];
  98173. /**
  98174. * Creates an animation range
  98175. * @param name Name of the animation range
  98176. * @param from Starting frame of the animation range
  98177. * @param to Ending frame of the animation
  98178. */
  98179. createRange(name: string, from: number, to: number): void;
  98180. /**
  98181. * Deletes an animation range by name
  98182. * @param name Name of the animation range to delete
  98183. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  98184. */
  98185. deleteRange(name: string, deleteFrames?: boolean): void;
  98186. /**
  98187. * Gets the animation range by name, or null if not defined
  98188. * @param name Name of the animation range
  98189. * @returns Nullable animation range
  98190. */
  98191. getRange(name: string): Nullable<AnimationRange>;
  98192. /**
  98193. * Gets the key frames from the animation
  98194. * @returns The key frames of the animation
  98195. */
  98196. getKeys(): Array<IAnimationKey>;
  98197. /**
  98198. * Gets the highest frame rate of the animation
  98199. * @returns Highest frame rate of the animation
  98200. */
  98201. getHighestFrame(): number;
  98202. /**
  98203. * Gets the easing function of the animation
  98204. * @returns Easing function of the animation
  98205. */
  98206. getEasingFunction(): IEasingFunction;
  98207. /**
  98208. * Sets the easing function of the animation
  98209. * @param easingFunction A custom mathematical formula for animation
  98210. */
  98211. setEasingFunction(easingFunction: EasingFunction): void;
  98212. /**
  98213. * Interpolates a scalar linearly
  98214. * @param startValue Start value of the animation curve
  98215. * @param endValue End value of the animation curve
  98216. * @param gradient Scalar amount to interpolate
  98217. * @returns Interpolated scalar value
  98218. */
  98219. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  98220. /**
  98221. * Interpolates a scalar cubically
  98222. * @param startValue Start value of the animation curve
  98223. * @param outTangent End tangent of the animation
  98224. * @param endValue End value of the animation curve
  98225. * @param inTangent Start tangent of the animation curve
  98226. * @param gradient Scalar amount to interpolate
  98227. * @returns Interpolated scalar value
  98228. */
  98229. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  98230. /**
  98231. * Interpolates a quaternion using a spherical linear interpolation
  98232. * @param startValue Start value of the animation curve
  98233. * @param endValue End value of the animation curve
  98234. * @param gradient Scalar amount to interpolate
  98235. * @returns Interpolated quaternion value
  98236. */
  98237. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  98238. /**
  98239. * Interpolates a quaternion cubically
  98240. * @param startValue Start value of the animation curve
  98241. * @param outTangent End tangent of the animation curve
  98242. * @param endValue End value of the animation curve
  98243. * @param inTangent Start tangent of the animation curve
  98244. * @param gradient Scalar amount to interpolate
  98245. * @returns Interpolated quaternion value
  98246. */
  98247. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  98248. /**
  98249. * Interpolates a Vector3 linearl
  98250. * @param startValue Start value of the animation curve
  98251. * @param endValue End value of the animation curve
  98252. * @param gradient Scalar amount to interpolate
  98253. * @returns Interpolated scalar value
  98254. */
  98255. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  98256. /**
  98257. * Interpolates a Vector3 cubically
  98258. * @param startValue Start value of the animation curve
  98259. * @param outTangent End tangent of the animation
  98260. * @param endValue End value of the animation curve
  98261. * @param inTangent Start tangent of the animation curve
  98262. * @param gradient Scalar amount to interpolate
  98263. * @returns InterpolatedVector3 value
  98264. */
  98265. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  98266. /**
  98267. * Interpolates a Vector2 linearly
  98268. * @param startValue Start value of the animation curve
  98269. * @param endValue End value of the animation curve
  98270. * @param gradient Scalar amount to interpolate
  98271. * @returns Interpolated Vector2 value
  98272. */
  98273. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  98274. /**
  98275. * Interpolates a Vector2 cubically
  98276. * @param startValue Start value of the animation curve
  98277. * @param outTangent End tangent of the animation
  98278. * @param endValue End value of the animation curve
  98279. * @param inTangent Start tangent of the animation curve
  98280. * @param gradient Scalar amount to interpolate
  98281. * @returns Interpolated Vector2 value
  98282. */
  98283. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  98284. /**
  98285. * Interpolates a size linearly
  98286. * @param startValue Start value of the animation curve
  98287. * @param endValue End value of the animation curve
  98288. * @param gradient Scalar amount to interpolate
  98289. * @returns Interpolated Size value
  98290. */
  98291. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  98292. /**
  98293. * Interpolates a Color3 linearly
  98294. * @param startValue Start value of the animation curve
  98295. * @param endValue End value of the animation curve
  98296. * @param gradient Scalar amount to interpolate
  98297. * @returns Interpolated Color3 value
  98298. */
  98299. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  98300. /**
  98301. * Interpolates a Color4 linearly
  98302. * @param startValue Start value of the animation curve
  98303. * @param endValue End value of the animation curve
  98304. * @param gradient Scalar amount to interpolate
  98305. * @returns Interpolated Color3 value
  98306. */
  98307. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  98308. /**
  98309. * @hidden Internal use only
  98310. */
  98311. _getKeyValue(value: any): any;
  98312. /**
  98313. * @hidden Internal use only
  98314. */
  98315. _interpolate(currentFrame: number, state: _IAnimationState): any;
  98316. /**
  98317. * Defines the function to use to interpolate matrices
  98318. * @param startValue defines the start matrix
  98319. * @param endValue defines the end matrix
  98320. * @param gradient defines the gradient between both matrices
  98321. * @param result defines an optional target matrix where to store the interpolation
  98322. * @returns the interpolated matrix
  98323. */
  98324. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  98325. /**
  98326. * Makes a copy of the animation
  98327. * @returns Cloned animation
  98328. */
  98329. clone(): Animation;
  98330. /**
  98331. * Sets the key frames of the animation
  98332. * @param values The animation key frames to set
  98333. */
  98334. setKeys(values: Array<IAnimationKey>): void;
  98335. /**
  98336. * Serializes the animation to an object
  98337. * @returns Serialized object
  98338. */
  98339. serialize(): any;
  98340. /**
  98341. * Float animation type
  98342. */
  98343. static readonly ANIMATIONTYPE_FLOAT: number;
  98344. /**
  98345. * Vector3 animation type
  98346. */
  98347. static readonly ANIMATIONTYPE_VECTOR3: number;
  98348. /**
  98349. * Quaternion animation type
  98350. */
  98351. static readonly ANIMATIONTYPE_QUATERNION: number;
  98352. /**
  98353. * Matrix animation type
  98354. */
  98355. static readonly ANIMATIONTYPE_MATRIX: number;
  98356. /**
  98357. * Color3 animation type
  98358. */
  98359. static readonly ANIMATIONTYPE_COLOR3: number;
  98360. /**
  98361. * Color3 animation type
  98362. */
  98363. static readonly ANIMATIONTYPE_COLOR4: number;
  98364. /**
  98365. * Vector2 animation type
  98366. */
  98367. static readonly ANIMATIONTYPE_VECTOR2: number;
  98368. /**
  98369. * Size animation type
  98370. */
  98371. static readonly ANIMATIONTYPE_SIZE: number;
  98372. /**
  98373. * Relative Loop Mode
  98374. */
  98375. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  98376. /**
  98377. * Cycle Loop Mode
  98378. */
  98379. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  98380. /**
  98381. * Constant Loop Mode
  98382. */
  98383. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  98384. /** @hidden */
  98385. static _UniversalLerp(left: any, right: any, amount: number): any;
  98386. /**
  98387. * Parses an animation object and creates an animation
  98388. * @param parsedAnimation Parsed animation object
  98389. * @returns Animation object
  98390. */
  98391. static Parse(parsedAnimation: any): Animation;
  98392. /**
  98393. * Appends the serialized animations from the source animations
  98394. * @param source Source containing the animations
  98395. * @param destination Target to store the animations
  98396. */
  98397. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98398. }
  98399. }
  98400. declare module BABYLON {
  98401. /**
  98402. * Interface containing an array of animations
  98403. */
  98404. export interface IAnimatable {
  98405. /**
  98406. * Array of animations
  98407. */
  98408. animations: Nullable<Array<Animation>>;
  98409. }
  98410. }
  98411. declare module BABYLON {
  98412. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  98413. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98414. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98415. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98416. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98417. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98418. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98419. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98420. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98421. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98422. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98423. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98424. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98425. /**
  98426. * Decorator used to define property that can be serialized as reference to a camera
  98427. * @param sourceName defines the name of the property to decorate
  98428. */
  98429. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  98430. /**
  98431. * Class used to help serialization objects
  98432. */
  98433. export class SerializationHelper {
  98434. /** @hidden */
  98435. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  98436. /** @hidden */
  98437. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  98438. /** @hidden */
  98439. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  98440. /** @hidden */
  98441. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  98442. /**
  98443. * Appends the serialized animations from the source animations
  98444. * @param source Source containing the animations
  98445. * @param destination Target to store the animations
  98446. */
  98447. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  98448. /**
  98449. * Static function used to serialized a specific entity
  98450. * @param entity defines the entity to serialize
  98451. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  98452. * @returns a JSON compatible object representing the serialization of the entity
  98453. */
  98454. static Serialize<T>(entity: T, serializationObject?: any): any;
  98455. /**
  98456. * Creates a new entity from a serialization data object
  98457. * @param creationFunction defines a function used to instanciated the new entity
  98458. * @param source defines the source serialization data
  98459. * @param scene defines the hosting scene
  98460. * @param rootUrl defines the root url for resources
  98461. * @returns a new entity
  98462. */
  98463. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  98464. /**
  98465. * Clones an object
  98466. * @param creationFunction defines the function used to instanciate the new object
  98467. * @param source defines the source object
  98468. * @returns the cloned object
  98469. */
  98470. static Clone<T>(creationFunction: () => T, source: T): T;
  98471. /**
  98472. * Instanciates a new object based on a source one (some data will be shared between both object)
  98473. * @param creationFunction defines the function used to instanciate the new object
  98474. * @param source defines the source object
  98475. * @returns the new object
  98476. */
  98477. static Instanciate<T>(creationFunction: () => T, source: T): T;
  98478. }
  98479. }
  98480. declare module BABYLON {
  98481. /**
  98482. * Class used to manipulate GUIDs
  98483. */
  98484. export class GUID {
  98485. /**
  98486. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98487. * Be aware Math.random() could cause collisions, but:
  98488. * "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"
  98489. * @returns a pseudo random id
  98490. */
  98491. static RandomId(): string;
  98492. }
  98493. }
  98494. declare module BABYLON {
  98495. /**
  98496. * Base class of all the textures in babylon.
  98497. * It groups all the common properties the materials, post process, lights... might need
  98498. * in order to make a correct use of the texture.
  98499. */
  98500. export class BaseTexture implements IAnimatable {
  98501. /**
  98502. * Default anisotropic filtering level for the application.
  98503. * It is set to 4 as a good tradeoff between perf and quality.
  98504. */
  98505. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  98506. /**
  98507. * Gets or sets the unique id of the texture
  98508. */
  98509. uniqueId: number;
  98510. /**
  98511. * Define the name of the texture.
  98512. */
  98513. name: string;
  98514. /**
  98515. * Gets or sets an object used to store user defined information.
  98516. */
  98517. metadata: any;
  98518. /**
  98519. * For internal use only. Please do not use.
  98520. */
  98521. reservedDataStore: any;
  98522. private _hasAlpha;
  98523. /**
  98524. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  98525. */
  98526. hasAlpha: boolean;
  98527. /**
  98528. * Defines if the alpha value should be determined via the rgb values.
  98529. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  98530. */
  98531. getAlphaFromRGB: boolean;
  98532. /**
  98533. * Intensity or strength of the texture.
  98534. * It is commonly used by materials to fine tune the intensity of the texture
  98535. */
  98536. level: number;
  98537. /**
  98538. * Define the UV chanel to use starting from 0 and defaulting to 0.
  98539. * This is part of the texture as textures usually maps to one uv set.
  98540. */
  98541. coordinatesIndex: number;
  98542. private _coordinatesMode;
  98543. /**
  98544. * How a texture is mapped.
  98545. *
  98546. * | Value | Type | Description |
  98547. * | ----- | ----------------------------------- | ----------- |
  98548. * | 0 | EXPLICIT_MODE | |
  98549. * | 1 | SPHERICAL_MODE | |
  98550. * | 2 | PLANAR_MODE | |
  98551. * | 3 | CUBIC_MODE | |
  98552. * | 4 | PROJECTION_MODE | |
  98553. * | 5 | SKYBOX_MODE | |
  98554. * | 6 | INVCUBIC_MODE | |
  98555. * | 7 | EQUIRECTANGULAR_MODE | |
  98556. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  98557. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  98558. */
  98559. coordinatesMode: number;
  98560. /**
  98561. * | Value | Type | Description |
  98562. * | ----- | ------------------ | ----------- |
  98563. * | 0 | CLAMP_ADDRESSMODE | |
  98564. * | 1 | WRAP_ADDRESSMODE | |
  98565. * | 2 | MIRROR_ADDRESSMODE | |
  98566. */
  98567. wrapU: number;
  98568. /**
  98569. * | Value | Type | Description |
  98570. * | ----- | ------------------ | ----------- |
  98571. * | 0 | CLAMP_ADDRESSMODE | |
  98572. * | 1 | WRAP_ADDRESSMODE | |
  98573. * | 2 | MIRROR_ADDRESSMODE | |
  98574. */
  98575. wrapV: number;
  98576. /**
  98577. * | Value | Type | Description |
  98578. * | ----- | ------------------ | ----------- |
  98579. * | 0 | CLAMP_ADDRESSMODE | |
  98580. * | 1 | WRAP_ADDRESSMODE | |
  98581. * | 2 | MIRROR_ADDRESSMODE | |
  98582. */
  98583. wrapR: number;
  98584. /**
  98585. * With compliant hardware and browser (supporting anisotropic filtering)
  98586. * this defines the level of anisotropic filtering in the texture.
  98587. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  98588. */
  98589. anisotropicFilteringLevel: number;
  98590. /**
  98591. * Define if the texture is a cube texture or if false a 2d texture.
  98592. */
  98593. isCube: boolean;
  98594. /**
  98595. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  98596. */
  98597. is3D: boolean;
  98598. /**
  98599. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  98600. */
  98601. is2DArray: boolean;
  98602. /**
  98603. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  98604. * HDR texture are usually stored in linear space.
  98605. * This only impacts the PBR and Background materials
  98606. */
  98607. gammaSpace: boolean;
  98608. /**
  98609. * Gets or sets whether or not the texture contains RGBD data.
  98610. */
  98611. isRGBD: boolean;
  98612. /**
  98613. * Is Z inverted in the texture (useful in a cube texture).
  98614. */
  98615. invertZ: boolean;
  98616. /**
  98617. * Are mip maps generated for this texture or not.
  98618. */
  98619. readonly noMipmap: boolean;
  98620. /**
  98621. * @hidden
  98622. */
  98623. lodLevelInAlpha: boolean;
  98624. /**
  98625. * With prefiltered texture, defined the offset used during the prefiltering steps.
  98626. */
  98627. lodGenerationOffset: number;
  98628. /**
  98629. * With prefiltered texture, defined the scale used during the prefiltering steps.
  98630. */
  98631. lodGenerationScale: number;
  98632. /**
  98633. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  98634. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  98635. * average roughness values.
  98636. */
  98637. linearSpecularLOD: boolean;
  98638. /**
  98639. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  98640. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  98641. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  98642. */
  98643. irradianceTexture: Nullable<BaseTexture>;
  98644. /**
  98645. * Define if the texture is a render target.
  98646. */
  98647. isRenderTarget: boolean;
  98648. /**
  98649. * Define the unique id of the texture in the scene.
  98650. */
  98651. readonly uid: string;
  98652. /**
  98653. * Return a string representation of the texture.
  98654. * @returns the texture as a string
  98655. */
  98656. toString(): string;
  98657. /**
  98658. * Get the class name of the texture.
  98659. * @returns "BaseTexture"
  98660. */
  98661. getClassName(): string;
  98662. /**
  98663. * Define the list of animation attached to the texture.
  98664. */
  98665. animations: Animation[];
  98666. /**
  98667. * An event triggered when the texture is disposed.
  98668. */
  98669. onDisposeObservable: Observable<BaseTexture>;
  98670. private _onDisposeObserver;
  98671. /**
  98672. * Callback triggered when the texture has been disposed.
  98673. * Kept for back compatibility, you can use the onDisposeObservable instead.
  98674. */
  98675. onDispose: () => void;
  98676. /**
  98677. * Define the current state of the loading sequence when in delayed load mode.
  98678. */
  98679. delayLoadState: number;
  98680. private _scene;
  98681. /** @hidden */
  98682. _texture: Nullable<InternalTexture>;
  98683. private _uid;
  98684. /**
  98685. * Define if the texture is preventinga material to render or not.
  98686. * If not and the texture is not ready, the engine will use a default black texture instead.
  98687. */
  98688. readonly isBlocking: boolean;
  98689. /**
  98690. * Instantiates a new BaseTexture.
  98691. * Base class of all the textures in babylon.
  98692. * It groups all the common properties the materials, post process, lights... might need
  98693. * in order to make a correct use of the texture.
  98694. * @param scene Define the scene the texture blongs to
  98695. */
  98696. constructor(scene: Nullable<Scene>);
  98697. /**
  98698. * Get the scene the texture belongs to.
  98699. * @returns the scene or null if undefined
  98700. */
  98701. getScene(): Nullable<Scene>;
  98702. /**
  98703. * Get the texture transform matrix used to offset tile the texture for istance.
  98704. * @returns the transformation matrix
  98705. */
  98706. getTextureMatrix(): Matrix;
  98707. /**
  98708. * Get the texture reflection matrix used to rotate/transform the reflection.
  98709. * @returns the reflection matrix
  98710. */
  98711. getReflectionTextureMatrix(): Matrix;
  98712. /**
  98713. * Get the underlying lower level texture from Babylon.
  98714. * @returns the insternal texture
  98715. */
  98716. getInternalTexture(): Nullable<InternalTexture>;
  98717. /**
  98718. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  98719. * @returns true if ready or not blocking
  98720. */
  98721. isReadyOrNotBlocking(): boolean;
  98722. /**
  98723. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  98724. * @returns true if fully ready
  98725. */
  98726. isReady(): boolean;
  98727. private _cachedSize;
  98728. /**
  98729. * Get the size of the texture.
  98730. * @returns the texture size.
  98731. */
  98732. getSize(): ISize;
  98733. /**
  98734. * Get the base size of the texture.
  98735. * It can be different from the size if the texture has been resized for POT for instance
  98736. * @returns the base size
  98737. */
  98738. getBaseSize(): ISize;
  98739. /**
  98740. * Update the sampling mode of the texture.
  98741. * Default is Trilinear mode.
  98742. *
  98743. * | Value | Type | Description |
  98744. * | ----- | ------------------ | ----------- |
  98745. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  98746. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  98747. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  98748. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  98749. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  98750. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  98751. * | 7 | NEAREST_LINEAR | |
  98752. * | 8 | NEAREST_NEAREST | |
  98753. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  98754. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  98755. * | 11 | LINEAR_LINEAR | |
  98756. * | 12 | LINEAR_NEAREST | |
  98757. *
  98758. * > _mag_: magnification filter (close to the viewer)
  98759. * > _min_: minification filter (far from the viewer)
  98760. * > _mip_: filter used between mip map levels
  98761. *@param samplingMode Define the new sampling mode of the texture
  98762. */
  98763. updateSamplingMode(samplingMode: number): void;
  98764. /**
  98765. * Scales the texture if is `canRescale()`
  98766. * @param ratio the resize factor we want to use to rescale
  98767. */
  98768. scale(ratio: number): void;
  98769. /**
  98770. * Get if the texture can rescale.
  98771. */
  98772. readonly canRescale: boolean;
  98773. /** @hidden */
  98774. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  98775. /** @hidden */
  98776. _rebuild(): void;
  98777. /**
  98778. * Triggers the load sequence in delayed load mode.
  98779. */
  98780. delayLoad(): void;
  98781. /**
  98782. * Clones the texture.
  98783. * @returns the cloned texture
  98784. */
  98785. clone(): Nullable<BaseTexture>;
  98786. /**
  98787. * Get the texture underlying type (INT, FLOAT...)
  98788. */
  98789. readonly textureType: number;
  98790. /**
  98791. * Get the texture underlying format (RGB, RGBA...)
  98792. */
  98793. readonly textureFormat: number;
  98794. /**
  98795. * Indicates that textures need to be re-calculated for all materials
  98796. */
  98797. protected _markAllSubMeshesAsTexturesDirty(): void;
  98798. /**
  98799. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  98800. * This will returns an RGBA array buffer containing either in values (0-255) or
  98801. * float values (0-1) depending of the underlying buffer type.
  98802. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  98803. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  98804. * @param buffer defines a user defined buffer to fill with data (can be null)
  98805. * @returns The Array buffer containing the pixels data.
  98806. */
  98807. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  98808. /**
  98809. * Release and destroy the underlying lower level texture aka internalTexture.
  98810. */
  98811. releaseInternalTexture(): void;
  98812. /** @hidden */
  98813. readonly _lodTextureHigh: Nullable<BaseTexture>;
  98814. /** @hidden */
  98815. readonly _lodTextureMid: Nullable<BaseTexture>;
  98816. /** @hidden */
  98817. readonly _lodTextureLow: Nullable<BaseTexture>;
  98818. /**
  98819. * Dispose the texture and release its associated resources.
  98820. */
  98821. dispose(): void;
  98822. /**
  98823. * Serialize the texture into a JSON representation that can be parsed later on.
  98824. * @returns the JSON representation of the texture
  98825. */
  98826. serialize(): any;
  98827. /**
  98828. * Helper function to be called back once a list of texture contains only ready textures.
  98829. * @param textures Define the list of textures to wait for
  98830. * @param callback Define the callback triggered once the entire list will be ready
  98831. */
  98832. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  98833. }
  98834. }
  98835. declare module BABYLON {
  98836. /**
  98837. * Options to be used when creating an effect.
  98838. */
  98839. export interface IEffectCreationOptions {
  98840. /**
  98841. * Atrributes that will be used in the shader.
  98842. */
  98843. attributes: string[];
  98844. /**
  98845. * Uniform varible names that will be set in the shader.
  98846. */
  98847. uniformsNames: string[];
  98848. /**
  98849. * Uniform buffer variable names that will be set in the shader.
  98850. */
  98851. uniformBuffersNames: string[];
  98852. /**
  98853. * Sampler texture variable names that will be set in the shader.
  98854. */
  98855. samplers: string[];
  98856. /**
  98857. * Define statements that will be set in the shader.
  98858. */
  98859. defines: any;
  98860. /**
  98861. * Possible fallbacks for this effect to improve performance when needed.
  98862. */
  98863. fallbacks: Nullable<IEffectFallbacks>;
  98864. /**
  98865. * Callback that will be called when the shader is compiled.
  98866. */
  98867. onCompiled: Nullable<(effect: Effect) => void>;
  98868. /**
  98869. * Callback that will be called if an error occurs during shader compilation.
  98870. */
  98871. onError: Nullable<(effect: Effect, errors: string) => void>;
  98872. /**
  98873. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98874. */
  98875. indexParameters?: any;
  98876. /**
  98877. * Max number of lights that can be used in the shader.
  98878. */
  98879. maxSimultaneousLights?: number;
  98880. /**
  98881. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  98882. */
  98883. transformFeedbackVaryings?: Nullable<string[]>;
  98884. }
  98885. /**
  98886. * Effect containing vertex and fragment shader that can be executed on an object.
  98887. */
  98888. export class Effect implements IDisposable {
  98889. /**
  98890. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  98891. */
  98892. static ShadersRepository: string;
  98893. /**
  98894. * Name of the effect.
  98895. */
  98896. name: any;
  98897. /**
  98898. * String container all the define statements that should be set on the shader.
  98899. */
  98900. defines: string;
  98901. /**
  98902. * Callback that will be called when the shader is compiled.
  98903. */
  98904. onCompiled: Nullable<(effect: Effect) => void>;
  98905. /**
  98906. * Callback that will be called if an error occurs during shader compilation.
  98907. */
  98908. onError: Nullable<(effect: Effect, errors: string) => void>;
  98909. /**
  98910. * Callback that will be called when effect is bound.
  98911. */
  98912. onBind: Nullable<(effect: Effect) => void>;
  98913. /**
  98914. * Unique ID of the effect.
  98915. */
  98916. uniqueId: number;
  98917. /**
  98918. * Observable that will be called when the shader is compiled.
  98919. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  98920. */
  98921. onCompileObservable: Observable<Effect>;
  98922. /**
  98923. * Observable that will be called if an error occurs during shader compilation.
  98924. */
  98925. onErrorObservable: Observable<Effect>;
  98926. /** @hidden */
  98927. _onBindObservable: Nullable<Observable<Effect>>;
  98928. /**
  98929. * Observable that will be called when effect is bound.
  98930. */
  98931. readonly onBindObservable: Observable<Effect>;
  98932. /** @hidden */
  98933. _bonesComputationForcedToCPU: boolean;
  98934. private static _uniqueIdSeed;
  98935. private _engine;
  98936. private _uniformBuffersNames;
  98937. private _uniformsNames;
  98938. private _samplerList;
  98939. private _samplers;
  98940. private _isReady;
  98941. private _compilationError;
  98942. private _allFallbacksProcessed;
  98943. private _attributesNames;
  98944. private _attributes;
  98945. private _attributeLocationByName;
  98946. private _uniforms;
  98947. /**
  98948. * Key for the effect.
  98949. * @hidden
  98950. */
  98951. _key: string;
  98952. private _indexParameters;
  98953. private _fallbacks;
  98954. private _vertexSourceCode;
  98955. private _fragmentSourceCode;
  98956. private _vertexSourceCodeOverride;
  98957. private _fragmentSourceCodeOverride;
  98958. private _transformFeedbackVaryings;
  98959. /**
  98960. * Compiled shader to webGL program.
  98961. * @hidden
  98962. */
  98963. _pipelineContext: Nullable<IPipelineContext>;
  98964. private _valueCache;
  98965. private static _baseCache;
  98966. /**
  98967. * Instantiates an effect.
  98968. * An effect can be used to create/manage/execute vertex and fragment shaders.
  98969. * @param baseName Name of the effect.
  98970. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  98971. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  98972. * @param samplers List of sampler variables that will be passed to the shader.
  98973. * @param engine Engine to be used to render the effect
  98974. * @param defines Define statements to be added to the shader.
  98975. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  98976. * @param onCompiled Callback that will be called when the shader is compiled.
  98977. * @param onError Callback that will be called if an error occurs during shader compilation.
  98978. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  98979. */
  98980. 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);
  98981. private _useFinalCode;
  98982. /**
  98983. * Unique key for this effect
  98984. */
  98985. readonly key: string;
  98986. /**
  98987. * If the effect has been compiled and prepared.
  98988. * @returns if the effect is compiled and prepared.
  98989. */
  98990. isReady(): boolean;
  98991. private _isReadyInternal;
  98992. /**
  98993. * The engine the effect was initialized with.
  98994. * @returns the engine.
  98995. */
  98996. getEngine(): Engine;
  98997. /**
  98998. * The pipeline context for this effect
  98999. * @returns the associated pipeline context
  99000. */
  99001. getPipelineContext(): Nullable<IPipelineContext>;
  99002. /**
  99003. * The set of names of attribute variables for the shader.
  99004. * @returns An array of attribute names.
  99005. */
  99006. getAttributesNames(): string[];
  99007. /**
  99008. * Returns the attribute at the given index.
  99009. * @param index The index of the attribute.
  99010. * @returns The location of the attribute.
  99011. */
  99012. getAttributeLocation(index: number): number;
  99013. /**
  99014. * Returns the attribute based on the name of the variable.
  99015. * @param name of the attribute to look up.
  99016. * @returns the attribute location.
  99017. */
  99018. getAttributeLocationByName(name: string): number;
  99019. /**
  99020. * The number of attributes.
  99021. * @returns the numnber of attributes.
  99022. */
  99023. getAttributesCount(): number;
  99024. /**
  99025. * Gets the index of a uniform variable.
  99026. * @param uniformName of the uniform to look up.
  99027. * @returns the index.
  99028. */
  99029. getUniformIndex(uniformName: string): number;
  99030. /**
  99031. * Returns the attribute based on the name of the variable.
  99032. * @param uniformName of the uniform to look up.
  99033. * @returns the location of the uniform.
  99034. */
  99035. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  99036. /**
  99037. * Returns an array of sampler variable names
  99038. * @returns The array of sampler variable neames.
  99039. */
  99040. getSamplers(): string[];
  99041. /**
  99042. * The error from the last compilation.
  99043. * @returns the error string.
  99044. */
  99045. getCompilationError(): string;
  99046. /**
  99047. * Gets a boolean indicating that all fallbacks were used during compilation
  99048. * @returns true if all fallbacks were used
  99049. */
  99050. allFallbacksProcessed(): boolean;
  99051. /**
  99052. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  99053. * @param func The callback to be used.
  99054. */
  99055. executeWhenCompiled(func: (effect: Effect) => void): void;
  99056. private _checkIsReady;
  99057. private _loadShader;
  99058. /**
  99059. * Recompiles the webGL program
  99060. * @param vertexSourceCode The source code for the vertex shader.
  99061. * @param fragmentSourceCode The source code for the fragment shader.
  99062. * @param onCompiled Callback called when completed.
  99063. * @param onError Callback called on error.
  99064. * @hidden
  99065. */
  99066. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  99067. /**
  99068. * Prepares the effect
  99069. * @hidden
  99070. */
  99071. _prepareEffect(): void;
  99072. private _processCompilationErrors;
  99073. /**
  99074. * Checks if the effect is supported. (Must be called after compilation)
  99075. */
  99076. readonly isSupported: boolean;
  99077. /**
  99078. * Binds a texture to the engine to be used as output of the shader.
  99079. * @param channel Name of the output variable.
  99080. * @param texture Texture to bind.
  99081. * @hidden
  99082. */
  99083. _bindTexture(channel: string, texture: InternalTexture): void;
  99084. /**
  99085. * Sets a texture on the engine to be used in the shader.
  99086. * @param channel Name of the sampler variable.
  99087. * @param texture Texture to set.
  99088. */
  99089. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  99090. /**
  99091. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  99092. * @param channel Name of the sampler variable.
  99093. * @param texture Texture to set.
  99094. */
  99095. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  99096. /**
  99097. * Sets an array of textures on the engine to be used in the shader.
  99098. * @param channel Name of the variable.
  99099. * @param textures Textures to set.
  99100. */
  99101. setTextureArray(channel: string, textures: BaseTexture[]): void;
  99102. /**
  99103. * 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)
  99104. * @param channel Name of the sampler variable.
  99105. * @param postProcess Post process to get the input texture from.
  99106. */
  99107. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  99108. /**
  99109. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  99110. * 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)
  99111. * @param channel Name of the sampler variable.
  99112. * @param postProcess Post process to get the output texture from.
  99113. */
  99114. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  99115. /** @hidden */
  99116. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  99117. /** @hidden */
  99118. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  99119. /** @hidden */
  99120. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  99121. /** @hidden */
  99122. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  99123. /**
  99124. * Binds a buffer to a uniform.
  99125. * @param buffer Buffer to bind.
  99126. * @param name Name of the uniform variable to bind to.
  99127. */
  99128. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  99129. /**
  99130. * Binds block to a uniform.
  99131. * @param blockName Name of the block to bind.
  99132. * @param index Index to bind.
  99133. */
  99134. bindUniformBlock(blockName: string, index: number): void;
  99135. /**
  99136. * Sets an interger value on a uniform variable.
  99137. * @param uniformName Name of the variable.
  99138. * @param value Value to be set.
  99139. * @returns this effect.
  99140. */
  99141. setInt(uniformName: string, value: number): Effect;
  99142. /**
  99143. * Sets an int array on a uniform variable.
  99144. * @param uniformName Name of the variable.
  99145. * @param array array to be set.
  99146. * @returns this effect.
  99147. */
  99148. setIntArray(uniformName: string, array: Int32Array): Effect;
  99149. /**
  99150. * 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)
  99151. * @param uniformName Name of the variable.
  99152. * @param array array to be set.
  99153. * @returns this effect.
  99154. */
  99155. setIntArray2(uniformName: string, array: Int32Array): Effect;
  99156. /**
  99157. * 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)
  99158. * @param uniformName Name of the variable.
  99159. * @param array array to be set.
  99160. * @returns this effect.
  99161. */
  99162. setIntArray3(uniformName: string, array: Int32Array): Effect;
  99163. /**
  99164. * 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)
  99165. * @param uniformName Name of the variable.
  99166. * @param array array to be set.
  99167. * @returns this effect.
  99168. */
  99169. setIntArray4(uniformName: string, array: Int32Array): Effect;
  99170. /**
  99171. * Sets an float array on a uniform variable.
  99172. * @param uniformName Name of the variable.
  99173. * @param array array to be set.
  99174. * @returns this effect.
  99175. */
  99176. setFloatArray(uniformName: string, array: Float32Array): Effect;
  99177. /**
  99178. * 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)
  99179. * @param uniformName Name of the variable.
  99180. * @param array array to be set.
  99181. * @returns this effect.
  99182. */
  99183. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  99184. /**
  99185. * 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)
  99186. * @param uniformName Name of the variable.
  99187. * @param array array to be set.
  99188. * @returns this effect.
  99189. */
  99190. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  99191. /**
  99192. * 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)
  99193. * @param uniformName Name of the variable.
  99194. * @param array array to be set.
  99195. * @returns this effect.
  99196. */
  99197. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  99198. /**
  99199. * Sets an array on a uniform variable.
  99200. * @param uniformName Name of the variable.
  99201. * @param array array to be set.
  99202. * @returns this effect.
  99203. */
  99204. setArray(uniformName: string, array: number[]): Effect;
  99205. /**
  99206. * 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)
  99207. * @param uniformName Name of the variable.
  99208. * @param array array to be set.
  99209. * @returns this effect.
  99210. */
  99211. setArray2(uniformName: string, array: number[]): Effect;
  99212. /**
  99213. * 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)
  99214. * @param uniformName Name of the variable.
  99215. * @param array array to be set.
  99216. * @returns this effect.
  99217. */
  99218. setArray3(uniformName: string, array: number[]): Effect;
  99219. /**
  99220. * 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)
  99221. * @param uniformName Name of the variable.
  99222. * @param array array to be set.
  99223. * @returns this effect.
  99224. */
  99225. setArray4(uniformName: string, array: number[]): Effect;
  99226. /**
  99227. * Sets matrices on a uniform variable.
  99228. * @param uniformName Name of the variable.
  99229. * @param matrices matrices to be set.
  99230. * @returns this effect.
  99231. */
  99232. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  99233. /**
  99234. * Sets matrix on a uniform variable.
  99235. * @param uniformName Name of the variable.
  99236. * @param matrix matrix to be set.
  99237. * @returns this effect.
  99238. */
  99239. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  99240. /**
  99241. * 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)
  99242. * @param uniformName Name of the variable.
  99243. * @param matrix matrix to be set.
  99244. * @returns this effect.
  99245. */
  99246. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  99247. /**
  99248. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  99249. * @param uniformName Name of the variable.
  99250. * @param matrix matrix to be set.
  99251. * @returns this effect.
  99252. */
  99253. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  99254. /**
  99255. * Sets a float on a uniform variable.
  99256. * @param uniformName Name of the variable.
  99257. * @param value value to be set.
  99258. * @returns this effect.
  99259. */
  99260. setFloat(uniformName: string, value: number): Effect;
  99261. /**
  99262. * Sets a boolean on a uniform variable.
  99263. * @param uniformName Name of the variable.
  99264. * @param bool value to be set.
  99265. * @returns this effect.
  99266. */
  99267. setBool(uniformName: string, bool: boolean): Effect;
  99268. /**
  99269. * Sets a Vector2 on a uniform variable.
  99270. * @param uniformName Name of the variable.
  99271. * @param vector2 vector2 to be set.
  99272. * @returns this effect.
  99273. */
  99274. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  99275. /**
  99276. * Sets a float2 on a uniform variable.
  99277. * @param uniformName Name of the variable.
  99278. * @param x First float in float2.
  99279. * @param y Second float in float2.
  99280. * @returns this effect.
  99281. */
  99282. setFloat2(uniformName: string, x: number, y: number): Effect;
  99283. /**
  99284. * Sets a Vector3 on a uniform variable.
  99285. * @param uniformName Name of the variable.
  99286. * @param vector3 Value to be set.
  99287. * @returns this effect.
  99288. */
  99289. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  99290. /**
  99291. * Sets a float3 on a uniform variable.
  99292. * @param uniformName Name of the variable.
  99293. * @param x First float in float3.
  99294. * @param y Second float in float3.
  99295. * @param z Third float in float3.
  99296. * @returns this effect.
  99297. */
  99298. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  99299. /**
  99300. * Sets a Vector4 on a uniform variable.
  99301. * @param uniformName Name of the variable.
  99302. * @param vector4 Value to be set.
  99303. * @returns this effect.
  99304. */
  99305. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  99306. /**
  99307. * Sets a float4 on a uniform variable.
  99308. * @param uniformName Name of the variable.
  99309. * @param x First float in float4.
  99310. * @param y Second float in float4.
  99311. * @param z Third float in float4.
  99312. * @param w Fourth float in float4.
  99313. * @returns this effect.
  99314. */
  99315. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  99316. /**
  99317. * Sets a Color3 on a uniform variable.
  99318. * @param uniformName Name of the variable.
  99319. * @param color3 Value to be set.
  99320. * @returns this effect.
  99321. */
  99322. setColor3(uniformName: string, color3: IColor3Like): Effect;
  99323. /**
  99324. * Sets a Color4 on a uniform variable.
  99325. * @param uniformName Name of the variable.
  99326. * @param color3 Value to be set.
  99327. * @param alpha Alpha value to be set.
  99328. * @returns this effect.
  99329. */
  99330. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  99331. /**
  99332. * Sets a Color4 on a uniform variable
  99333. * @param uniformName defines the name of the variable
  99334. * @param color4 defines the value to be set
  99335. * @returns this effect.
  99336. */
  99337. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  99338. /** Release all associated resources */
  99339. dispose(): void;
  99340. /**
  99341. * This function will add a new shader to the shader store
  99342. * @param name the name of the shader
  99343. * @param pixelShader optional pixel shader content
  99344. * @param vertexShader optional vertex shader content
  99345. */
  99346. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  99347. /**
  99348. * Store of each shader (The can be looked up using effect.key)
  99349. */
  99350. static ShadersStore: {
  99351. [key: string]: string;
  99352. };
  99353. /**
  99354. * Store of each included file for a shader (The can be looked up using effect.key)
  99355. */
  99356. static IncludesShadersStore: {
  99357. [key: string]: string;
  99358. };
  99359. /**
  99360. * Resets the cache of effects.
  99361. */
  99362. static ResetCache(): void;
  99363. }
  99364. }
  99365. declare module BABYLON {
  99366. /**
  99367. * Interface used to describe the capabilities of the engine relatively to the current browser
  99368. */
  99369. export interface EngineCapabilities {
  99370. /** Maximum textures units per fragment shader */
  99371. maxTexturesImageUnits: number;
  99372. /** Maximum texture units per vertex shader */
  99373. maxVertexTextureImageUnits: number;
  99374. /** Maximum textures units in the entire pipeline */
  99375. maxCombinedTexturesImageUnits: number;
  99376. /** Maximum texture size */
  99377. maxTextureSize: number;
  99378. /** Maximum texture samples */
  99379. maxSamples?: number;
  99380. /** Maximum cube texture size */
  99381. maxCubemapTextureSize: number;
  99382. /** Maximum render texture size */
  99383. maxRenderTextureSize: number;
  99384. /** Maximum number of vertex attributes */
  99385. maxVertexAttribs: number;
  99386. /** Maximum number of varyings */
  99387. maxVaryingVectors: number;
  99388. /** Maximum number of uniforms per vertex shader */
  99389. maxVertexUniformVectors: number;
  99390. /** Maximum number of uniforms per fragment shader */
  99391. maxFragmentUniformVectors: number;
  99392. /** Defines if standard derivates (dx/dy) are supported */
  99393. standardDerivatives: boolean;
  99394. /** Defines if s3tc texture compression is supported */
  99395. s3tc?: WEBGL_compressed_texture_s3tc;
  99396. /** Defines if pvrtc texture compression is supported */
  99397. pvrtc: any;
  99398. /** Defines if etc1 texture compression is supported */
  99399. etc1: any;
  99400. /** Defines if etc2 texture compression is supported */
  99401. etc2: any;
  99402. /** Defines if astc texture compression is supported */
  99403. astc: any;
  99404. /** Defines if float textures are supported */
  99405. textureFloat: boolean;
  99406. /** Defines if vertex array objects are supported */
  99407. vertexArrayObject: boolean;
  99408. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  99409. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  99410. /** Gets the maximum level of anisotropy supported */
  99411. maxAnisotropy: number;
  99412. /** Defines if instancing is supported */
  99413. instancedArrays: boolean;
  99414. /** Defines if 32 bits indices are supported */
  99415. uintIndices: boolean;
  99416. /** Defines if high precision shaders are supported */
  99417. highPrecisionShaderSupported: boolean;
  99418. /** Defines if depth reading in the fragment shader is supported */
  99419. fragmentDepthSupported: boolean;
  99420. /** Defines if float texture linear filtering is supported*/
  99421. textureFloatLinearFiltering: boolean;
  99422. /** Defines if rendering to float textures is supported */
  99423. textureFloatRender: boolean;
  99424. /** Defines if half float textures are supported*/
  99425. textureHalfFloat: boolean;
  99426. /** Defines if half float texture linear filtering is supported*/
  99427. textureHalfFloatLinearFiltering: boolean;
  99428. /** Defines if rendering to half float textures is supported */
  99429. textureHalfFloatRender: boolean;
  99430. /** Defines if textureLOD shader command is supported */
  99431. textureLOD: boolean;
  99432. /** Defines if draw buffers extension is supported */
  99433. drawBuffersExtension: boolean;
  99434. /** Defines if depth textures are supported */
  99435. depthTextureExtension: boolean;
  99436. /** Defines if float color buffer are supported */
  99437. colorBufferFloat: boolean;
  99438. /** Gets disjoint timer query extension (null if not supported) */
  99439. timerQuery?: EXT_disjoint_timer_query;
  99440. /** Defines if timestamp can be used with timer query */
  99441. canUseTimestampForTimerQuery: boolean;
  99442. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  99443. multiview?: any;
  99444. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  99445. oculusMultiview?: any;
  99446. /** Function used to let the system compiles shaders in background */
  99447. parallelShaderCompile?: {
  99448. COMPLETION_STATUS_KHR: number;
  99449. };
  99450. /** Max number of texture samples for MSAA */
  99451. maxMSAASamples: number;
  99452. /** Defines if the blend min max extension is supported */
  99453. blendMinMax: boolean;
  99454. }
  99455. }
  99456. declare module BABYLON {
  99457. /**
  99458. * @hidden
  99459. **/
  99460. export class DepthCullingState {
  99461. private _isDepthTestDirty;
  99462. private _isDepthMaskDirty;
  99463. private _isDepthFuncDirty;
  99464. private _isCullFaceDirty;
  99465. private _isCullDirty;
  99466. private _isZOffsetDirty;
  99467. private _isFrontFaceDirty;
  99468. private _depthTest;
  99469. private _depthMask;
  99470. private _depthFunc;
  99471. private _cull;
  99472. private _cullFace;
  99473. private _zOffset;
  99474. private _frontFace;
  99475. /**
  99476. * Initializes the state.
  99477. */
  99478. constructor();
  99479. readonly isDirty: boolean;
  99480. zOffset: number;
  99481. cullFace: Nullable<number>;
  99482. cull: Nullable<boolean>;
  99483. depthFunc: Nullable<number>;
  99484. depthMask: boolean;
  99485. depthTest: boolean;
  99486. frontFace: Nullable<number>;
  99487. reset(): void;
  99488. apply(gl: WebGLRenderingContext): void;
  99489. }
  99490. }
  99491. declare module BABYLON {
  99492. /**
  99493. * @hidden
  99494. **/
  99495. export class StencilState {
  99496. /** 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 */
  99497. static readonly ALWAYS: number;
  99498. /** Passed to stencilOperation to specify that stencil value must be kept */
  99499. static readonly KEEP: number;
  99500. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99501. static readonly REPLACE: number;
  99502. private _isStencilTestDirty;
  99503. private _isStencilMaskDirty;
  99504. private _isStencilFuncDirty;
  99505. private _isStencilOpDirty;
  99506. private _stencilTest;
  99507. private _stencilMask;
  99508. private _stencilFunc;
  99509. private _stencilFuncRef;
  99510. private _stencilFuncMask;
  99511. private _stencilOpStencilFail;
  99512. private _stencilOpDepthFail;
  99513. private _stencilOpStencilDepthPass;
  99514. readonly isDirty: boolean;
  99515. stencilFunc: number;
  99516. stencilFuncRef: number;
  99517. stencilFuncMask: number;
  99518. stencilOpStencilFail: number;
  99519. stencilOpDepthFail: number;
  99520. stencilOpStencilDepthPass: number;
  99521. stencilMask: number;
  99522. stencilTest: boolean;
  99523. constructor();
  99524. reset(): void;
  99525. apply(gl: WebGLRenderingContext): void;
  99526. }
  99527. }
  99528. declare module BABYLON {
  99529. /**
  99530. * @hidden
  99531. **/
  99532. export class AlphaState {
  99533. private _isAlphaBlendDirty;
  99534. private _isBlendFunctionParametersDirty;
  99535. private _isBlendEquationParametersDirty;
  99536. private _isBlendConstantsDirty;
  99537. private _alphaBlend;
  99538. private _blendFunctionParameters;
  99539. private _blendEquationParameters;
  99540. private _blendConstants;
  99541. /**
  99542. * Initializes the state.
  99543. */
  99544. constructor();
  99545. readonly isDirty: boolean;
  99546. alphaBlend: boolean;
  99547. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  99548. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  99549. setAlphaEquationParameters(rgb: number, alpha: number): void;
  99550. reset(): void;
  99551. apply(gl: WebGLRenderingContext): void;
  99552. }
  99553. }
  99554. declare module BABYLON {
  99555. /** @hidden */
  99556. export class WebGL2ShaderProcessor implements IShaderProcessor {
  99557. attributeProcessor(attribute: string): string;
  99558. varyingProcessor(varying: string, isFragment: boolean): string;
  99559. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  99560. }
  99561. }
  99562. declare module BABYLON {
  99563. /**
  99564. * Interface for attribute information associated with buffer instanciation
  99565. */
  99566. export interface InstancingAttributeInfo {
  99567. /**
  99568. * Name of the GLSL attribute
  99569. * if attribute index is not specified, this is used to retrieve the index from the effect
  99570. */
  99571. attributeName: string;
  99572. /**
  99573. * Index/offset of the attribute in the vertex shader
  99574. * if not specified, this will be computes from the name.
  99575. */
  99576. index?: number;
  99577. /**
  99578. * size of the attribute, 1, 2, 3 or 4
  99579. */
  99580. attributeSize: number;
  99581. /**
  99582. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  99583. */
  99584. offset: number;
  99585. /**
  99586. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  99587. * default to 1
  99588. */
  99589. divisor?: number;
  99590. /**
  99591. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  99592. * default is FLOAT
  99593. */
  99594. attributeType?: number;
  99595. /**
  99596. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  99597. */
  99598. normalized?: boolean;
  99599. }
  99600. }
  99601. declare module BABYLON {
  99602. interface ThinEngine {
  99603. /**
  99604. * Update a video texture
  99605. * @param texture defines the texture to update
  99606. * @param video defines the video element to use
  99607. * @param invertY defines if data must be stored with Y axis inverted
  99608. */
  99609. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  99610. }
  99611. }
  99612. declare module BABYLON {
  99613. /**
  99614. * Settings for finer control over video usage
  99615. */
  99616. export interface VideoTextureSettings {
  99617. /**
  99618. * Applies `autoplay` to video, if specified
  99619. */
  99620. autoPlay?: boolean;
  99621. /**
  99622. * Applies `loop` to video, if specified
  99623. */
  99624. loop?: boolean;
  99625. /**
  99626. * Automatically updates internal texture from video at every frame in the render loop
  99627. */
  99628. autoUpdateTexture: boolean;
  99629. /**
  99630. * Image src displayed during the video loading or until the user interacts with the video.
  99631. */
  99632. poster?: string;
  99633. }
  99634. /**
  99635. * If you want to display a video in your scene, this is the special texture for that.
  99636. * This special texture works similar to other textures, with the exception of a few parameters.
  99637. * @see https://doc.babylonjs.com/how_to/video_texture
  99638. */
  99639. export class VideoTexture extends Texture {
  99640. /**
  99641. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  99642. */
  99643. readonly autoUpdateTexture: boolean;
  99644. /**
  99645. * The video instance used by the texture internally
  99646. */
  99647. readonly video: HTMLVideoElement;
  99648. private _onUserActionRequestedObservable;
  99649. /**
  99650. * Event triggerd when a dom action is required by the user to play the video.
  99651. * This happens due to recent changes in browser policies preventing video to auto start.
  99652. */
  99653. readonly onUserActionRequestedObservable: Observable<Texture>;
  99654. private _generateMipMaps;
  99655. private _engine;
  99656. private _stillImageCaptured;
  99657. private _displayingPosterTexture;
  99658. private _settings;
  99659. private _createInternalTextureOnEvent;
  99660. private _frameId;
  99661. /**
  99662. * Creates a video texture.
  99663. * If you want to display a video in your scene, this is the special texture for that.
  99664. * This special texture works similar to other textures, with the exception of a few parameters.
  99665. * @see https://doc.babylonjs.com/how_to/video_texture
  99666. * @param name optional name, will detect from video source, if not defined
  99667. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  99668. * @param scene is obviously the current scene.
  99669. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  99670. * @param invertY is false by default but can be used to invert video on Y axis
  99671. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  99672. * @param settings allows finer control over video usage
  99673. */
  99674. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  99675. private _getName;
  99676. private _getVideo;
  99677. private _createInternalTexture;
  99678. private reset;
  99679. /**
  99680. * @hidden Internal method to initiate `update`.
  99681. */
  99682. _rebuild(): void;
  99683. /**
  99684. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  99685. */
  99686. update(): void;
  99687. /**
  99688. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  99689. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  99690. */
  99691. updateTexture(isVisible: boolean): void;
  99692. protected _updateInternalTexture: () => void;
  99693. /**
  99694. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  99695. * @param url New url.
  99696. */
  99697. updateURL(url: string): void;
  99698. /**
  99699. * Dispose the texture and release its associated resources.
  99700. */
  99701. dispose(): void;
  99702. /**
  99703. * Creates a video texture straight from a stream.
  99704. * @param scene Define the scene the texture should be created in
  99705. * @param stream Define the stream the texture should be created from
  99706. * @returns The created video texture as a promise
  99707. */
  99708. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  99709. /**
  99710. * Creates a video texture straight from your WebCam video feed.
  99711. * @param scene Define the scene the texture should be created in
  99712. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99713. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99714. * @returns The created video texture as a promise
  99715. */
  99716. static CreateFromWebCamAsync(scene: Scene, constraints: {
  99717. minWidth: number;
  99718. maxWidth: number;
  99719. minHeight: number;
  99720. maxHeight: number;
  99721. deviceId: string;
  99722. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  99723. /**
  99724. * Creates a video texture straight from your WebCam video feed.
  99725. * @param scene Define the scene the texture should be created in
  99726. * @param onReady Define a callback to triggered once the texture will be ready
  99727. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  99728. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  99729. */
  99730. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  99731. minWidth: number;
  99732. maxWidth: number;
  99733. minHeight: number;
  99734. maxHeight: number;
  99735. deviceId: string;
  99736. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  99737. }
  99738. }
  99739. declare module BABYLON {
  99740. /**
  99741. * Defines the interface used by objects working like Scene
  99742. * @hidden
  99743. */
  99744. interface ISceneLike {
  99745. _addPendingData(data: any): void;
  99746. _removePendingData(data: any): void;
  99747. offlineProvider: IOfflineProvider;
  99748. }
  99749. /** Interface defining initialization parameters for Engine class */
  99750. export interface EngineOptions extends WebGLContextAttributes {
  99751. /**
  99752. * Defines if the engine should no exceed a specified device ratio
  99753. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  99754. */
  99755. limitDeviceRatio?: number;
  99756. /**
  99757. * Defines if webvr should be enabled automatically
  99758. * @see http://doc.babylonjs.com/how_to/webvr_camera
  99759. */
  99760. autoEnableWebVR?: boolean;
  99761. /**
  99762. * Defines if webgl2 should be turned off even if supported
  99763. * @see http://doc.babylonjs.com/features/webgl2
  99764. */
  99765. disableWebGL2Support?: boolean;
  99766. /**
  99767. * Defines if webaudio should be initialized as well
  99768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99769. */
  99770. audioEngine?: boolean;
  99771. /**
  99772. * Defines if animations should run using a deterministic lock step
  99773. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99774. */
  99775. deterministicLockstep?: boolean;
  99776. /** Defines the maximum steps to use with deterministic lock step mode */
  99777. lockstepMaxSteps?: number;
  99778. /** Defines the seconds between each deterministic lock step */
  99779. timeStep?: number;
  99780. /**
  99781. * Defines that engine should ignore context lost events
  99782. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  99783. */
  99784. doNotHandleContextLost?: boolean;
  99785. /**
  99786. * Defines that engine should ignore modifying touch action attribute and style
  99787. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  99788. */
  99789. doNotHandleTouchAction?: boolean;
  99790. /**
  99791. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  99792. */
  99793. useHighPrecisionFloats?: boolean;
  99794. }
  99795. /**
  99796. * The base engine class (root of all engines)
  99797. */
  99798. export class ThinEngine {
  99799. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  99800. static ExceptionList: ({
  99801. key: string;
  99802. capture: string;
  99803. captureConstraint: number;
  99804. targets: string[];
  99805. } | {
  99806. key: string;
  99807. capture: null;
  99808. captureConstraint: null;
  99809. targets: string[];
  99810. })[];
  99811. /** @hidden */
  99812. static _TextureLoaders: IInternalTextureLoader[];
  99813. /**
  99814. * Returns the current npm package of the sdk
  99815. */
  99816. static readonly NpmPackage: string;
  99817. /**
  99818. * Returns the current version of the framework
  99819. */
  99820. static readonly Version: string;
  99821. /**
  99822. * Returns a string describing the current engine
  99823. */
  99824. readonly description: string;
  99825. /**
  99826. * Gets or sets the epsilon value used by collision engine
  99827. */
  99828. static CollisionsEpsilon: number;
  99829. /**
  99830. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  99831. */
  99832. static ShadersRepository: string;
  99833. /**
  99834. * Gets or sets the textures that the engine should not attempt to load as compressed
  99835. */
  99836. protected _excludedCompressedTextures: string[];
  99837. /**
  99838. * Filters the compressed texture formats to only include
  99839. * files that are not included in the skippable list
  99840. *
  99841. * @param url the current extension
  99842. * @param textureFormatInUse the current compressed texture format
  99843. * @returns "format" string
  99844. */
  99845. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  99846. /** @hidden */
  99847. _shaderProcessor: IShaderProcessor;
  99848. /**
  99849. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  99850. */
  99851. forcePOTTextures: boolean;
  99852. /**
  99853. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  99854. */
  99855. isFullscreen: boolean;
  99856. /**
  99857. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  99858. */
  99859. cullBackFaces: boolean;
  99860. /**
  99861. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  99862. */
  99863. renderEvenInBackground: boolean;
  99864. /**
  99865. * Gets or sets a boolean indicating that cache can be kept between frames
  99866. */
  99867. preventCacheWipeBetweenFrames: boolean;
  99868. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  99869. validateShaderPrograms: boolean;
  99870. /**
  99871. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  99872. * This can provide greater z depth for distant objects.
  99873. */
  99874. useReverseDepthBuffer: boolean;
  99875. /**
  99876. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  99877. */
  99878. disableUniformBuffers: boolean;
  99879. /** @hidden */
  99880. _uniformBuffers: UniformBuffer[];
  99881. /**
  99882. * Gets a boolean indicating that the engine supports uniform buffers
  99883. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  99884. */
  99885. readonly supportsUniformBuffers: boolean;
  99886. /** @hidden */
  99887. _gl: WebGLRenderingContext;
  99888. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  99889. protected _windowIsBackground: boolean;
  99890. protected _webGLVersion: number;
  99891. protected _creationOptions: EngineOptions;
  99892. protected _highPrecisionShadersAllowed: boolean;
  99893. /** @hidden */
  99894. readonly _shouldUseHighPrecisionShader: boolean;
  99895. /**
  99896. * Gets a boolean indicating that only power of 2 textures are supported
  99897. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  99898. */
  99899. readonly needPOTTextures: boolean;
  99900. /** @hidden */
  99901. _badOS: boolean;
  99902. /** @hidden */
  99903. _badDesktopOS: boolean;
  99904. private _hardwareScalingLevel;
  99905. /** @hidden */
  99906. _caps: EngineCapabilities;
  99907. private _isStencilEnable;
  99908. private _glVersion;
  99909. private _glRenderer;
  99910. private _glVendor;
  99911. /** @hidden */
  99912. _videoTextureSupported: boolean;
  99913. protected _renderingQueueLaunched: boolean;
  99914. protected _activeRenderLoops: (() => void)[];
  99915. /**
  99916. * Observable signaled when a context lost event is raised
  99917. */
  99918. onContextLostObservable: Observable<ThinEngine>;
  99919. /**
  99920. * Observable signaled when a context restored event is raised
  99921. */
  99922. onContextRestoredObservable: Observable<ThinEngine>;
  99923. private _onContextLost;
  99924. private _onContextRestored;
  99925. protected _contextWasLost: boolean;
  99926. /** @hidden */
  99927. _doNotHandleContextLost: boolean;
  99928. /**
  99929. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  99930. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  99931. */
  99932. doNotHandleContextLost: boolean;
  99933. /**
  99934. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  99935. */
  99936. disableVertexArrayObjects: boolean;
  99937. /** @hidden */
  99938. protected _colorWrite: boolean;
  99939. /** @hidden */
  99940. protected _colorWriteChanged: boolean;
  99941. /** @hidden */
  99942. protected _depthCullingState: DepthCullingState;
  99943. /** @hidden */
  99944. protected _stencilState: StencilState;
  99945. /** @hidden */
  99946. _alphaState: AlphaState;
  99947. /** @hidden */
  99948. _alphaMode: number;
  99949. /** @hidden */
  99950. _alphaEquation: number;
  99951. /** @hidden */
  99952. _internalTexturesCache: InternalTexture[];
  99953. /** @hidden */
  99954. protected _activeChannel: number;
  99955. private _currentTextureChannel;
  99956. /** @hidden */
  99957. protected _boundTexturesCache: {
  99958. [key: string]: Nullable<InternalTexture>;
  99959. };
  99960. /** @hidden */
  99961. protected _currentEffect: Nullable<Effect>;
  99962. /** @hidden */
  99963. protected _currentProgram: Nullable<WebGLProgram>;
  99964. private _compiledEffects;
  99965. private _vertexAttribArraysEnabled;
  99966. /** @hidden */
  99967. protected _cachedViewport: Nullable<IViewportLike>;
  99968. private _cachedVertexArrayObject;
  99969. /** @hidden */
  99970. protected _cachedVertexBuffers: any;
  99971. /** @hidden */
  99972. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  99973. /** @hidden */
  99974. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  99975. /** @hidden */
  99976. _currentRenderTarget: Nullable<InternalTexture>;
  99977. private _uintIndicesCurrentlySet;
  99978. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  99979. /** @hidden */
  99980. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  99981. private _currentBufferPointers;
  99982. private _currentInstanceLocations;
  99983. private _currentInstanceBuffers;
  99984. private _textureUnits;
  99985. /** @hidden */
  99986. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99987. /** @hidden */
  99988. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99989. /** @hidden */
  99990. _boundRenderFunction: any;
  99991. private _vaoRecordInProgress;
  99992. private _mustWipeVertexAttributes;
  99993. private _emptyTexture;
  99994. private _emptyCubeTexture;
  99995. private _emptyTexture3D;
  99996. private _emptyTexture2DArray;
  99997. /** @hidden */
  99998. _frameHandler: number;
  99999. private _nextFreeTextureSlots;
  100000. private _maxSimultaneousTextures;
  100001. private _activeRequests;
  100002. protected _texturesSupported: string[];
  100003. /** @hidden */
  100004. _textureFormatInUse: Nullable<string>;
  100005. protected readonly _supportsHardwareTextureRescaling: boolean;
  100006. /**
  100007. * Gets the list of texture formats supported
  100008. */
  100009. readonly texturesSupported: Array<string>;
  100010. /**
  100011. * Gets the list of texture formats in use
  100012. */
  100013. readonly textureFormatInUse: Nullable<string>;
  100014. /**
  100015. * Gets the current viewport
  100016. */
  100017. readonly currentViewport: Nullable<IViewportLike>;
  100018. /**
  100019. * Gets the default empty texture
  100020. */
  100021. readonly emptyTexture: InternalTexture;
  100022. /**
  100023. * Gets the default empty 3D texture
  100024. */
  100025. readonly emptyTexture3D: InternalTexture;
  100026. /**
  100027. * Gets the default empty 2D array texture
  100028. */
  100029. readonly emptyTexture2DArray: InternalTexture;
  100030. /**
  100031. * Gets the default empty cube texture
  100032. */
  100033. readonly emptyCubeTexture: InternalTexture;
  100034. /**
  100035. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  100036. */
  100037. readonly premultipliedAlpha: boolean;
  100038. /**
  100039. * Observable event triggered before each texture is initialized
  100040. */
  100041. onBeforeTextureInitObservable: Observable<Texture>;
  100042. /**
  100043. * Creates a new engine
  100044. * @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
  100045. * @param antialias defines enable antialiasing (default: false)
  100046. * @param options defines further options to be sent to the getContext() function
  100047. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100048. */
  100049. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100050. private _rebuildInternalTextures;
  100051. private _rebuildEffects;
  100052. /**
  100053. * Gets a boolean indicating if all created effects are ready
  100054. * @returns true if all effects are ready
  100055. */
  100056. areAllEffectsReady(): boolean;
  100057. protected _rebuildBuffers(): void;
  100058. private _initGLContext;
  100059. /**
  100060. * Gets version of the current webGL context
  100061. */
  100062. readonly webGLVersion: number;
  100063. /**
  100064. * Gets a string idenfifying the name of the class
  100065. * @returns "Engine" string
  100066. */
  100067. getClassName(): string;
  100068. /**
  100069. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  100070. */
  100071. readonly isStencilEnable: boolean;
  100072. /** @hidden */
  100073. _prepareWorkingCanvas(): void;
  100074. /**
  100075. * Reset the texture cache to empty state
  100076. */
  100077. resetTextureCache(): void;
  100078. /**
  100079. * Gets an object containing information about the current webGL context
  100080. * @returns an object containing the vender, the renderer and the version of the current webGL context
  100081. */
  100082. getGlInfo(): {
  100083. vendor: string;
  100084. renderer: string;
  100085. version: string;
  100086. };
  100087. /**
  100088. * Defines the hardware scaling level.
  100089. * By default the hardware scaling level is computed from the window device ratio.
  100090. * 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.
  100091. * @param level defines the level to use
  100092. */
  100093. setHardwareScalingLevel(level: number): void;
  100094. /**
  100095. * Gets the current hardware scaling level.
  100096. * By default the hardware scaling level is computed from the window device ratio.
  100097. * 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.
  100098. * @returns a number indicating the current hardware scaling level
  100099. */
  100100. getHardwareScalingLevel(): number;
  100101. /**
  100102. * Gets the list of loaded textures
  100103. * @returns an array containing all loaded textures
  100104. */
  100105. getLoadedTexturesCache(): InternalTexture[];
  100106. /**
  100107. * Gets the object containing all engine capabilities
  100108. * @returns the EngineCapabilities object
  100109. */
  100110. getCaps(): EngineCapabilities;
  100111. /**
  100112. * stop executing a render loop function and remove it from the execution array
  100113. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  100114. */
  100115. stopRenderLoop(renderFunction?: () => void): void;
  100116. /** @hidden */
  100117. _renderLoop(): void;
  100118. /**
  100119. * Gets the HTML canvas attached with the current webGL context
  100120. * @returns a HTML canvas
  100121. */
  100122. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  100123. /**
  100124. * Gets host window
  100125. * @returns the host window object
  100126. */
  100127. getHostWindow(): Nullable<Window>;
  100128. /**
  100129. * Gets the current render width
  100130. * @param useScreen defines if screen size must be used (or the current render target if any)
  100131. * @returns a number defining the current render width
  100132. */
  100133. getRenderWidth(useScreen?: boolean): number;
  100134. /**
  100135. * Gets the current render height
  100136. * @param useScreen defines if screen size must be used (or the current render target if any)
  100137. * @returns a number defining the current render height
  100138. */
  100139. getRenderHeight(useScreen?: boolean): number;
  100140. /**
  100141. * Can be used to override the current requestAnimationFrame requester.
  100142. * @hidden
  100143. */
  100144. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  100145. /**
  100146. * Register and execute a render loop. The engine can have more than one render function
  100147. * @param renderFunction defines the function to continuously execute
  100148. */
  100149. runRenderLoop(renderFunction: () => void): void;
  100150. /**
  100151. * Clear the current render buffer or the current render target (if any is set up)
  100152. * @param color defines the color to use
  100153. * @param backBuffer defines if the back buffer must be cleared
  100154. * @param depth defines if the depth buffer must be cleared
  100155. * @param stencil defines if the stencil buffer must be cleared
  100156. */
  100157. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100158. private _viewportCached;
  100159. /** @hidden */
  100160. _viewport(x: number, y: number, width: number, height: number): void;
  100161. /**
  100162. * Set the WebGL's viewport
  100163. * @param viewport defines the viewport element to be used
  100164. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  100165. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  100166. */
  100167. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  100168. /**
  100169. * Begin a new frame
  100170. */
  100171. beginFrame(): void;
  100172. /**
  100173. * Enf the current frame
  100174. */
  100175. endFrame(): void;
  100176. /**
  100177. * Resize the view according to the canvas' size
  100178. */
  100179. resize(): void;
  100180. /**
  100181. * Force a specific size of the canvas
  100182. * @param width defines the new canvas' width
  100183. * @param height defines the new canvas' height
  100184. */
  100185. setSize(width: number, height: number): void;
  100186. /**
  100187. * Binds the frame buffer to the specified texture.
  100188. * @param texture The texture to render to or null for the default canvas
  100189. * @param faceIndex The face of the texture to render to in case of cube texture
  100190. * @param requiredWidth The width of the target to render to
  100191. * @param requiredHeight The height of the target to render to
  100192. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  100193. * @param depthStencilTexture The depth stencil texture to use to render
  100194. * @param lodLevel defines le lod level to bind to the frame buffer
  100195. */
  100196. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  100197. /** @hidden */
  100198. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  100199. /**
  100200. * Unbind the current render target texture from the webGL context
  100201. * @param texture defines the render target texture to unbind
  100202. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  100203. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  100204. */
  100205. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100206. /**
  100207. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  100208. */
  100209. flushFramebuffer(): void;
  100210. /**
  100211. * Unbind the current render target and bind the default framebuffer
  100212. */
  100213. restoreDefaultFramebuffer(): void;
  100214. /** @hidden */
  100215. protected _resetVertexBufferBinding(): void;
  100216. /**
  100217. * Creates a vertex buffer
  100218. * @param data the data for the vertex buffer
  100219. * @returns the new WebGL static buffer
  100220. */
  100221. createVertexBuffer(data: DataArray): DataBuffer;
  100222. private _createVertexBuffer;
  100223. /**
  100224. * Creates a dynamic vertex buffer
  100225. * @param data the data for the dynamic vertex buffer
  100226. * @returns the new WebGL dynamic buffer
  100227. */
  100228. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  100229. protected _resetIndexBufferBinding(): void;
  100230. /**
  100231. * Creates a new index buffer
  100232. * @param indices defines the content of the index buffer
  100233. * @param updatable defines if the index buffer must be updatable
  100234. * @returns a new webGL buffer
  100235. */
  100236. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  100237. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  100238. /**
  100239. * Bind a webGL buffer to the webGL context
  100240. * @param buffer defines the buffer to bind
  100241. */
  100242. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  100243. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  100244. private bindBuffer;
  100245. /**
  100246. * update the bound buffer with the given data
  100247. * @param data defines the data to update
  100248. */
  100249. updateArrayBuffer(data: Float32Array): void;
  100250. private _vertexAttribPointer;
  100251. private _bindIndexBufferWithCache;
  100252. private _bindVertexBuffersAttributes;
  100253. /**
  100254. * Records a vertex array object
  100255. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100256. * @param vertexBuffers defines the list of vertex buffers to store
  100257. * @param indexBuffer defines the index buffer to store
  100258. * @param effect defines the effect to store
  100259. * @returns the new vertex array object
  100260. */
  100261. recordVertexArrayObject(vertexBuffers: {
  100262. [key: string]: VertexBuffer;
  100263. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  100264. /**
  100265. * Bind a specific vertex array object
  100266. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  100267. * @param vertexArrayObject defines the vertex array object to bind
  100268. * @param indexBuffer defines the index buffer to bind
  100269. */
  100270. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  100271. /**
  100272. * Bind webGl buffers directly to the webGL context
  100273. * @param vertexBuffer defines the vertex buffer to bind
  100274. * @param indexBuffer defines the index buffer to bind
  100275. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  100276. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  100277. * @param effect defines the effect associated with the vertex buffer
  100278. */
  100279. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  100280. private _unbindVertexArrayObject;
  100281. /**
  100282. * Bind a list of vertex buffers to the webGL context
  100283. * @param vertexBuffers defines the list of vertex buffers to bind
  100284. * @param indexBuffer defines the index buffer to bind
  100285. * @param effect defines the effect associated with the vertex buffers
  100286. */
  100287. bindBuffers(vertexBuffers: {
  100288. [key: string]: Nullable<VertexBuffer>;
  100289. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  100290. /**
  100291. * Unbind all instance attributes
  100292. */
  100293. unbindInstanceAttributes(): void;
  100294. /**
  100295. * Release and free the memory of a vertex array object
  100296. * @param vao defines the vertex array object to delete
  100297. */
  100298. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  100299. /** @hidden */
  100300. _releaseBuffer(buffer: DataBuffer): boolean;
  100301. protected _deleteBuffer(buffer: DataBuffer): void;
  100302. /**
  100303. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  100304. * @param instancesBuffer defines the webGL buffer to update and bind
  100305. * @param data defines the data to store in the buffer
  100306. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  100307. */
  100308. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  100309. /**
  100310. * Bind the content of a webGL buffer used with instanciation
  100311. * @param instancesBuffer defines the webGL buffer to bind
  100312. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  100313. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  100314. */
  100315. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  100316. /**
  100317. * Disable the instance attribute corresponding to the name in parameter
  100318. * @param name defines the name of the attribute to disable
  100319. */
  100320. disableInstanceAttributeByName(name: string): void;
  100321. /**
  100322. * Disable the instance attribute corresponding to the location in parameter
  100323. * @param attributeLocation defines the attribute location of the attribute to disable
  100324. */
  100325. disableInstanceAttribute(attributeLocation: number): void;
  100326. /**
  100327. * Disable the attribute corresponding to the location in parameter
  100328. * @param attributeLocation defines the attribute location of the attribute to disable
  100329. */
  100330. disableAttributeByIndex(attributeLocation: number): void;
  100331. /**
  100332. * Send a draw order
  100333. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100334. * @param indexStart defines the starting index
  100335. * @param indexCount defines the number of index to draw
  100336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100337. */
  100338. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100339. /**
  100340. * Draw a list of points
  100341. * @param verticesStart defines the index of first vertex to draw
  100342. * @param verticesCount defines the count of vertices to draw
  100343. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100344. */
  100345. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100346. /**
  100347. * Draw a list of unindexed primitives
  100348. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  100349. * @param verticesStart defines the index of first vertex to draw
  100350. * @param verticesCount defines the count of vertices to draw
  100351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100352. */
  100353. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100354. /**
  100355. * Draw a list of indexed primitives
  100356. * @param fillMode defines the primitive to use
  100357. * @param indexStart defines the starting index
  100358. * @param indexCount defines the number of index to draw
  100359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100360. */
  100361. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100362. /**
  100363. * Draw a list of unindexed primitives
  100364. * @param fillMode defines the primitive to use
  100365. * @param verticesStart defines the index of first vertex to draw
  100366. * @param verticesCount defines the count of vertices to draw
  100367. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  100368. */
  100369. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100370. private _drawMode;
  100371. /** @hidden */
  100372. protected _reportDrawCall(): void;
  100373. /** @hidden */
  100374. _releaseEffect(effect: Effect): void;
  100375. /** @hidden */
  100376. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100377. /**
  100378. * Create a new effect (used to store vertex/fragment shaders)
  100379. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  100380. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  100381. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  100382. * @param samplers defines an array of string used to represent textures
  100383. * @param defines defines the string containing the defines to use to compile the shaders
  100384. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  100385. * @param onCompiled defines a function to call when the effect creation is successful
  100386. * @param onError defines a function to call when the effect creation has failed
  100387. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  100388. * @returns the new Effect
  100389. */
  100390. 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;
  100391. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  100392. private _compileShader;
  100393. private _compileRawShader;
  100394. /**
  100395. * Directly creates a webGL program
  100396. * @param pipelineContext defines the pipeline context to attach to
  100397. * @param vertexCode defines the vertex shader code to use
  100398. * @param fragmentCode defines the fragment shader code to use
  100399. * @param context defines the webGL context to use (if not set, the current one will be used)
  100400. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  100401. * @returns the new webGL program
  100402. */
  100403. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100404. /**
  100405. * Creates a webGL program
  100406. * @param pipelineContext defines the pipeline context to attach to
  100407. * @param vertexCode defines the vertex shader code to use
  100408. * @param fragmentCode defines the fragment shader code to use
  100409. * @param defines defines the string containing the defines to use to compile the shaders
  100410. * @param context defines the webGL context to use (if not set, the current one will be used)
  100411. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  100412. * @returns the new webGL program
  100413. */
  100414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100415. /**
  100416. * Creates a new pipeline context
  100417. * @returns the new pipeline
  100418. */
  100419. createPipelineContext(): IPipelineContext;
  100420. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100421. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  100422. /** @hidden */
  100423. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  100424. /** @hidden */
  100425. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  100426. /** @hidden */
  100427. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  100428. /**
  100429. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  100430. * @param pipelineContext defines the pipeline context to use
  100431. * @param uniformsNames defines the list of uniform names
  100432. * @returns an array of webGL uniform locations
  100433. */
  100434. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  100435. /**
  100436. * Gets the lsit of active attributes for a given webGL program
  100437. * @param pipelineContext defines the pipeline context to use
  100438. * @param attributesNames defines the list of attribute names to get
  100439. * @returns an array of indices indicating the offset of each attribute
  100440. */
  100441. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  100442. /**
  100443. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  100444. * @param effect defines the effect to activate
  100445. */
  100446. enableEffect(effect: Nullable<Effect>): void;
  100447. /**
  100448. * Set the value of an uniform to a number (int)
  100449. * @param uniform defines the webGL uniform location where to store the value
  100450. * @param value defines the int number to store
  100451. */
  100452. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100453. /**
  100454. * Set the value of an uniform to an array of int32
  100455. * @param uniform defines the webGL uniform location where to store the value
  100456. * @param array defines the array of int32 to store
  100457. */
  100458. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100459. /**
  100460. * Set the value of an uniform to an array of int32 (stored as vec2)
  100461. * @param uniform defines the webGL uniform location where to store the value
  100462. * @param array defines the array of int32 to store
  100463. */
  100464. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100465. /**
  100466. * Set the value of an uniform to an array of int32 (stored as vec3)
  100467. * @param uniform defines the webGL uniform location where to store the value
  100468. * @param array defines the array of int32 to store
  100469. */
  100470. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100471. /**
  100472. * Set the value of an uniform to an array of int32 (stored as vec4)
  100473. * @param uniform defines the webGL uniform location where to store the value
  100474. * @param array defines the array of int32 to store
  100475. */
  100476. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  100477. /**
  100478. * Set the value of an uniform to an array of number
  100479. * @param uniform defines the webGL uniform location where to store the value
  100480. * @param array defines the array of number to store
  100481. */
  100482. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100483. /**
  100484. * Set the value of an uniform to an array of number (stored as vec2)
  100485. * @param uniform defines the webGL uniform location where to store the value
  100486. * @param array defines the array of number to store
  100487. */
  100488. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100489. /**
  100490. * Set the value of an uniform to an array of number (stored as vec3)
  100491. * @param uniform defines the webGL uniform location where to store the value
  100492. * @param array defines the array of number to store
  100493. */
  100494. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100495. /**
  100496. * Set the value of an uniform to an array of number (stored as vec4)
  100497. * @param uniform defines the webGL uniform location where to store the value
  100498. * @param array defines the array of number to store
  100499. */
  100500. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  100501. /**
  100502. * Set the value of an uniform to an array of float32 (stored as matrices)
  100503. * @param uniform defines the webGL uniform location where to store the value
  100504. * @param matrices defines the array of float32 to store
  100505. */
  100506. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  100507. /**
  100508. * Set the value of an uniform to a matrix (3x3)
  100509. * @param uniform defines the webGL uniform location where to store the value
  100510. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  100511. */
  100512. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100513. /**
  100514. * Set the value of an uniform to a matrix (2x2)
  100515. * @param uniform defines the webGL uniform location where to store the value
  100516. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  100517. */
  100518. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  100519. /**
  100520. * Set the value of an uniform to a number (float)
  100521. * @param uniform defines the webGL uniform location where to store the value
  100522. * @param value defines the float number to store
  100523. */
  100524. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  100525. /**
  100526. * Set the value of an uniform to a vec2
  100527. * @param uniform defines the webGL uniform location where to store the value
  100528. * @param x defines the 1st component of the value
  100529. * @param y defines the 2nd component of the value
  100530. */
  100531. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  100532. /**
  100533. * Set the value of an uniform to a vec3
  100534. * @param uniform defines the webGL uniform location where to store the value
  100535. * @param x defines the 1st component of the value
  100536. * @param y defines the 2nd component of the value
  100537. * @param z defines the 3rd component of the value
  100538. */
  100539. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  100540. /**
  100541. * Set the value of an uniform to a vec4
  100542. * @param uniform defines the webGL uniform location where to store the value
  100543. * @param x defines the 1st component of the value
  100544. * @param y defines the 2nd component of the value
  100545. * @param z defines the 3rd component of the value
  100546. * @param w defines the 4th component of the value
  100547. */
  100548. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  100549. /**
  100550. * Apply all cached states (depth, culling, stencil and alpha)
  100551. */
  100552. applyStates(): void;
  100553. /**
  100554. * Enable or disable color writing
  100555. * @param enable defines the state to set
  100556. */
  100557. setColorWrite(enable: boolean): void;
  100558. /**
  100559. * Gets a boolean indicating if color writing is enabled
  100560. * @returns the current color writing state
  100561. */
  100562. getColorWrite(): boolean;
  100563. /**
  100564. * Gets the depth culling state manager
  100565. */
  100566. readonly depthCullingState: DepthCullingState;
  100567. /**
  100568. * Gets the alpha state manager
  100569. */
  100570. readonly alphaState: AlphaState;
  100571. /**
  100572. * Gets the stencil state manager
  100573. */
  100574. readonly stencilState: StencilState;
  100575. /**
  100576. * Clears the list of texture accessible through engine.
  100577. * This can help preventing texture load conflict due to name collision.
  100578. */
  100579. clearInternalTexturesCache(): void;
  100580. /**
  100581. * Force the entire cache to be cleared
  100582. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  100583. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  100584. */
  100585. wipeCaches(bruteForce?: boolean): void;
  100586. /** @hidden */
  100587. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  100588. min: number;
  100589. mag: number;
  100590. };
  100591. /** @hidden */
  100592. _createTexture(): WebGLTexture;
  100593. /**
  100594. * Usually called from Texture.ts.
  100595. * Passed information to create a WebGLTexture
  100596. * @param urlArg defines a value which contains one of the following:
  100597. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  100598. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  100599. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  100600. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  100601. * @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)
  100602. * @param scene needed for loading to the correct scene
  100603. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  100604. * @param onLoad optional callback to be called upon successful completion
  100605. * @param onError optional callback to be called upon failure
  100606. * @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
  100607. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  100608. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  100609. * @param forcedExtension defines the extension to use to pick the right loader
  100610. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  100611. * @param mimeType defines an optional mime type
  100612. * @returns a InternalTexture for assignment back into BABYLON.Texture
  100613. */
  100614. 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;
  100615. /**
  100616. * @hidden
  100617. */
  100618. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100619. /**
  100620. * Creates a raw texture
  100621. * @param data defines the data to store in the texture
  100622. * @param width defines the width of the texture
  100623. * @param height defines the height of the texture
  100624. * @param format defines the format of the data
  100625. * @param generateMipMaps defines if the engine should generate the mip levels
  100626. * @param invertY defines if data must be stored with Y axis inverted
  100627. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  100628. * @param compression defines the compression used (null by default)
  100629. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  100630. * @returns the raw texture inside an InternalTexture
  100631. */
  100632. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  100633. /**
  100634. * Creates a new raw cube texture
  100635. * @param data defines the array of data to use to create each face
  100636. * @param size defines the size of the textures
  100637. * @param format defines the format of the data
  100638. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  100639. * @param generateMipMaps defines if the engine should generate the mip levels
  100640. * @param invertY defines if data must be stored with Y axis inverted
  100641. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100642. * @param compression defines the compression used (null by default)
  100643. * @returns the cube texture as an InternalTexture
  100644. */
  100645. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  100646. /**
  100647. * Creates a new raw 3D texture
  100648. * @param data defines the data used to create the texture
  100649. * @param width defines the width of the texture
  100650. * @param height defines the height of the texture
  100651. * @param depth defines the depth of the texture
  100652. * @param format defines the format of the texture
  100653. * @param generateMipMaps defines if the engine must generate mip levels
  100654. * @param invertY defines if data must be stored with Y axis inverted
  100655. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100656. * @param compression defines the compressed used (can be null)
  100657. * @param textureType defines the compressed used (can be null)
  100658. * @returns a new raw 3D texture (stored in an InternalTexture)
  100659. */
  100660. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100661. /**
  100662. * Creates a new raw 2D array texture
  100663. * @param data defines the data used to create the texture
  100664. * @param width defines the width of the texture
  100665. * @param height defines the height of the texture
  100666. * @param depth defines the number of layers of the texture
  100667. * @param format defines the format of the texture
  100668. * @param generateMipMaps defines if the engine must generate mip levels
  100669. * @param invertY defines if data must be stored with Y axis inverted
  100670. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  100671. * @param compression defines the compressed used (can be null)
  100672. * @param textureType defines the compressed used (can be null)
  100673. * @returns a new raw 2D array texture (stored in an InternalTexture)
  100674. */
  100675. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  100676. private _unpackFlipYCached;
  100677. /**
  100678. * In case you are sharing the context with other applications, it might
  100679. * be interested to not cache the unpack flip y state to ensure a consistent
  100680. * value would be set.
  100681. */
  100682. enableUnpackFlipYCached: boolean;
  100683. /** @hidden */
  100684. _unpackFlipY(value: boolean): void;
  100685. /** @hidden */
  100686. _getUnpackAlignement(): number;
  100687. /**
  100688. * Update the sampling mode of a given texture
  100689. * @param samplingMode defines the required sampling mode
  100690. * @param texture defines the texture to update
  100691. */
  100692. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100693. /** @hidden */
  100694. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  100695. width: number;
  100696. height: number;
  100697. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  100698. /** @hidden */
  100699. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100700. /** @hidden */
  100701. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  100702. /** @hidden */
  100703. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100704. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  100705. private _prepareWebGLTexture;
  100706. /** @hidden */
  100707. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  100708. private _getDepthStencilBuffer;
  100709. /** @hidden */
  100710. _releaseFramebufferObjects(texture: InternalTexture): void;
  100711. /** @hidden */
  100712. _releaseTexture(texture: InternalTexture): void;
  100713. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  100714. protected _setProgram(program: WebGLProgram): void;
  100715. protected _boundUniforms: {
  100716. [key: number]: WebGLUniformLocation;
  100717. };
  100718. /**
  100719. * Binds an effect to the webGL context
  100720. * @param effect defines the effect to bind
  100721. */
  100722. bindSamplers(effect: Effect): void;
  100723. private _activateCurrentTexture;
  100724. /** @hidden */
  100725. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  100726. /** @hidden */
  100727. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  100728. /**
  100729. * Unbind all textures from the webGL context
  100730. */
  100731. unbindAllTextures(): void;
  100732. /**
  100733. * Sets a texture to the according uniform.
  100734. * @param channel The texture channel
  100735. * @param uniform The uniform to set
  100736. * @param texture The texture to apply
  100737. */
  100738. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  100739. private _bindSamplerUniformToChannel;
  100740. private _getTextureWrapMode;
  100741. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  100742. /**
  100743. * Sets an array of texture to the webGL context
  100744. * @param channel defines the channel where the texture array must be set
  100745. * @param uniform defines the associated uniform location
  100746. * @param textures defines the array of textures to bind
  100747. */
  100748. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  100749. /** @hidden */
  100750. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  100751. private _setTextureParameterFloat;
  100752. private _setTextureParameterInteger;
  100753. /**
  100754. * Unbind all vertex attributes from the webGL context
  100755. */
  100756. unbindAllAttributes(): void;
  100757. /**
  100758. * 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
  100759. */
  100760. releaseEffects(): void;
  100761. /**
  100762. * Dispose and release all associated resources
  100763. */
  100764. dispose(): void;
  100765. /**
  100766. * Attach a new callback raised when context lost event is fired
  100767. * @param callback defines the callback to call
  100768. */
  100769. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100770. /**
  100771. * Attach a new callback raised when context restored event is fired
  100772. * @param callback defines the callback to call
  100773. */
  100774. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  100775. /**
  100776. * Get the current error code of the webGL context
  100777. * @returns the error code
  100778. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100779. */
  100780. getError(): number;
  100781. private _canRenderToFloatFramebuffer;
  100782. private _canRenderToHalfFloatFramebuffer;
  100783. private _canRenderToFramebuffer;
  100784. /** @hidden */
  100785. _getWebGLTextureType(type: number): number;
  100786. /** @hidden */
  100787. _getInternalFormat(format: number): number;
  100788. /** @hidden */
  100789. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  100790. /** @hidden */
  100791. _getRGBAMultiSampleBufferFormat(type: number): number;
  100792. /** @hidden */
  100793. _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;
  100794. /**
  100795. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  100796. * @returns true if the engine can be created
  100797. * @ignorenaming
  100798. */
  100799. static isSupported(): boolean;
  100800. /**
  100801. * Find the next highest power of two.
  100802. * @param x Number to start search from.
  100803. * @return Next highest power of two.
  100804. */
  100805. static CeilingPOT(x: number): number;
  100806. /**
  100807. * Find the next lowest power of two.
  100808. * @param x Number to start search from.
  100809. * @return Next lowest power of two.
  100810. */
  100811. static FloorPOT(x: number): number;
  100812. /**
  100813. * Find the nearest power of two.
  100814. * @param x Number to start search from.
  100815. * @return Next nearest power of two.
  100816. */
  100817. static NearestPOT(x: number): number;
  100818. /**
  100819. * Get the closest exponent of two
  100820. * @param value defines the value to approximate
  100821. * @param max defines the maximum value to return
  100822. * @param mode defines how to define the closest value
  100823. * @returns closest exponent of two of the given value
  100824. */
  100825. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  100826. /**
  100827. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  100828. * @param func - the function to be called
  100829. * @param requester - the object that will request the next frame. Falls back to window.
  100830. * @returns frame number
  100831. */
  100832. static QueueNewFrame(func: () => void, requester?: any): number;
  100833. /**
  100834. * Gets host document
  100835. * @returns the host document object
  100836. */
  100837. getHostDocument(): Document;
  100838. }
  100839. }
  100840. declare module BABYLON {
  100841. /**
  100842. * Class representing spherical harmonics coefficients to the 3rd degree
  100843. */
  100844. export class SphericalHarmonics {
  100845. /**
  100846. * Defines whether or not the harmonics have been prescaled for rendering.
  100847. */
  100848. preScaled: boolean;
  100849. /**
  100850. * The l0,0 coefficients of the spherical harmonics
  100851. */
  100852. l00: Vector3;
  100853. /**
  100854. * The l1,-1 coefficients of the spherical harmonics
  100855. */
  100856. l1_1: Vector3;
  100857. /**
  100858. * The l1,0 coefficients of the spherical harmonics
  100859. */
  100860. l10: Vector3;
  100861. /**
  100862. * The l1,1 coefficients of the spherical harmonics
  100863. */
  100864. l11: Vector3;
  100865. /**
  100866. * The l2,-2 coefficients of the spherical harmonics
  100867. */
  100868. l2_2: Vector3;
  100869. /**
  100870. * The l2,-1 coefficients of the spherical harmonics
  100871. */
  100872. l2_1: Vector3;
  100873. /**
  100874. * The l2,0 coefficients of the spherical harmonics
  100875. */
  100876. l20: Vector3;
  100877. /**
  100878. * The l2,1 coefficients of the spherical harmonics
  100879. */
  100880. l21: Vector3;
  100881. /**
  100882. * The l2,2 coefficients of the spherical harmonics
  100883. */
  100884. l22: Vector3;
  100885. /**
  100886. * Adds a light to the spherical harmonics
  100887. * @param direction the direction of the light
  100888. * @param color the color of the light
  100889. * @param deltaSolidAngle the delta solid angle of the light
  100890. */
  100891. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  100892. /**
  100893. * Scales the spherical harmonics by the given amount
  100894. * @param scale the amount to scale
  100895. */
  100896. scaleInPlace(scale: number): void;
  100897. /**
  100898. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  100899. *
  100900. * ```
  100901. * E_lm = A_l * L_lm
  100902. * ```
  100903. *
  100904. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  100905. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  100906. * the scaling factors are given in equation 9.
  100907. */
  100908. convertIncidentRadianceToIrradiance(): void;
  100909. /**
  100910. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  100911. *
  100912. * ```
  100913. * L = (1/pi) * E * rho
  100914. * ```
  100915. *
  100916. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  100917. */
  100918. convertIrradianceToLambertianRadiance(): void;
  100919. /**
  100920. * Integrates the reconstruction coefficients directly in to the SH preventing further
  100921. * required operations at run time.
  100922. *
  100923. * This is simply done by scaling back the SH with Ylm constants parameter.
  100924. * The trigonometric part being applied by the shader at run time.
  100925. */
  100926. preScaleForRendering(): void;
  100927. /**
  100928. * Constructs a spherical harmonics from an array.
  100929. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  100930. * @returns the spherical harmonics
  100931. */
  100932. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  100933. /**
  100934. * Gets the spherical harmonics from polynomial
  100935. * @param polynomial the spherical polynomial
  100936. * @returns the spherical harmonics
  100937. */
  100938. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  100939. }
  100940. /**
  100941. * Class representing spherical polynomial coefficients to the 3rd degree
  100942. */
  100943. export class SphericalPolynomial {
  100944. private _harmonics;
  100945. /**
  100946. * The spherical harmonics used to create the polynomials.
  100947. */
  100948. readonly preScaledHarmonics: SphericalHarmonics;
  100949. /**
  100950. * The x coefficients of the spherical polynomial
  100951. */
  100952. x: Vector3;
  100953. /**
  100954. * The y coefficients of the spherical polynomial
  100955. */
  100956. y: Vector3;
  100957. /**
  100958. * The z coefficients of the spherical polynomial
  100959. */
  100960. z: Vector3;
  100961. /**
  100962. * The xx coefficients of the spherical polynomial
  100963. */
  100964. xx: Vector3;
  100965. /**
  100966. * The yy coefficients of the spherical polynomial
  100967. */
  100968. yy: Vector3;
  100969. /**
  100970. * The zz coefficients of the spherical polynomial
  100971. */
  100972. zz: Vector3;
  100973. /**
  100974. * The xy coefficients of the spherical polynomial
  100975. */
  100976. xy: Vector3;
  100977. /**
  100978. * The yz coefficients of the spherical polynomial
  100979. */
  100980. yz: Vector3;
  100981. /**
  100982. * The zx coefficients of the spherical polynomial
  100983. */
  100984. zx: Vector3;
  100985. /**
  100986. * Adds an ambient color to the spherical polynomial
  100987. * @param color the color to add
  100988. */
  100989. addAmbient(color: Color3): void;
  100990. /**
  100991. * Scales the spherical polynomial by the given amount
  100992. * @param scale the amount to scale
  100993. */
  100994. scaleInPlace(scale: number): void;
  100995. /**
  100996. * Gets the spherical polynomial from harmonics
  100997. * @param harmonics the spherical harmonics
  100998. * @returns the spherical polynomial
  100999. */
  101000. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101001. /**
  101002. * Constructs a spherical polynomial from an array.
  101003. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101004. * @returns the spherical polynomial
  101005. */
  101006. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  101007. }
  101008. }
  101009. declare module BABYLON {
  101010. /**
  101011. * Defines the source of the internal texture
  101012. */
  101013. export enum InternalTextureSource {
  101014. /**
  101015. * The source of the texture data is unknown
  101016. */
  101017. Unknown = 0,
  101018. /**
  101019. * Texture data comes from an URL
  101020. */
  101021. Url = 1,
  101022. /**
  101023. * Texture data is only used for temporary storage
  101024. */
  101025. Temp = 2,
  101026. /**
  101027. * Texture data comes from raw data (ArrayBuffer)
  101028. */
  101029. Raw = 3,
  101030. /**
  101031. * Texture content is dynamic (video or dynamic texture)
  101032. */
  101033. Dynamic = 4,
  101034. /**
  101035. * Texture content is generated by rendering to it
  101036. */
  101037. RenderTarget = 5,
  101038. /**
  101039. * Texture content is part of a multi render target process
  101040. */
  101041. MultiRenderTarget = 6,
  101042. /**
  101043. * Texture data comes from a cube data file
  101044. */
  101045. Cube = 7,
  101046. /**
  101047. * Texture data comes from a raw cube data
  101048. */
  101049. CubeRaw = 8,
  101050. /**
  101051. * Texture data come from a prefiltered cube data file
  101052. */
  101053. CubePrefiltered = 9,
  101054. /**
  101055. * Texture content is raw 3D data
  101056. */
  101057. Raw3D = 10,
  101058. /**
  101059. * Texture content is raw 2D array data
  101060. */
  101061. Raw2DArray = 11,
  101062. /**
  101063. * Texture content is a depth texture
  101064. */
  101065. Depth = 12,
  101066. /**
  101067. * Texture data comes from a raw cube data encoded with RGBD
  101068. */
  101069. CubeRawRGBD = 13
  101070. }
  101071. /**
  101072. * Class used to store data associated with WebGL texture data for the engine
  101073. * This class should not be used directly
  101074. */
  101075. export class InternalTexture {
  101076. /** @hidden */
  101077. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  101078. /**
  101079. * Defines if the texture is ready
  101080. */
  101081. isReady: boolean;
  101082. /**
  101083. * Defines if the texture is a cube texture
  101084. */
  101085. isCube: boolean;
  101086. /**
  101087. * Defines if the texture contains 3D data
  101088. */
  101089. is3D: boolean;
  101090. /**
  101091. * Defines if the texture contains 2D array data
  101092. */
  101093. is2DArray: boolean;
  101094. /**
  101095. * Defines if the texture contains multiview data
  101096. */
  101097. isMultiview: boolean;
  101098. /**
  101099. * Gets the URL used to load this texture
  101100. */
  101101. url: string;
  101102. /**
  101103. * Gets the sampling mode of the texture
  101104. */
  101105. samplingMode: number;
  101106. /**
  101107. * Gets a boolean indicating if the texture needs mipmaps generation
  101108. */
  101109. generateMipMaps: boolean;
  101110. /**
  101111. * Gets the number of samples used by the texture (WebGL2+ only)
  101112. */
  101113. samples: number;
  101114. /**
  101115. * Gets the type of the texture (int, float...)
  101116. */
  101117. type: number;
  101118. /**
  101119. * Gets the format of the texture (RGB, RGBA...)
  101120. */
  101121. format: number;
  101122. /**
  101123. * Observable called when the texture is loaded
  101124. */
  101125. onLoadedObservable: Observable<InternalTexture>;
  101126. /**
  101127. * Gets the width of the texture
  101128. */
  101129. width: number;
  101130. /**
  101131. * Gets the height of the texture
  101132. */
  101133. height: number;
  101134. /**
  101135. * Gets the depth of the texture
  101136. */
  101137. depth: number;
  101138. /**
  101139. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  101140. */
  101141. baseWidth: number;
  101142. /**
  101143. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  101144. */
  101145. baseHeight: number;
  101146. /**
  101147. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  101148. */
  101149. baseDepth: number;
  101150. /**
  101151. * Gets a boolean indicating if the texture is inverted on Y axis
  101152. */
  101153. invertY: boolean;
  101154. /** @hidden */
  101155. _invertVScale: boolean;
  101156. /** @hidden */
  101157. _associatedChannel: number;
  101158. /** @hidden */
  101159. _source: InternalTextureSource;
  101160. /** @hidden */
  101161. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101162. /** @hidden */
  101163. _bufferView: Nullable<ArrayBufferView>;
  101164. /** @hidden */
  101165. _bufferViewArray: Nullable<ArrayBufferView[]>;
  101166. /** @hidden */
  101167. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  101168. /** @hidden */
  101169. _size: number;
  101170. /** @hidden */
  101171. _extension: string;
  101172. /** @hidden */
  101173. _files: Nullable<string[]>;
  101174. /** @hidden */
  101175. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101176. /** @hidden */
  101177. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101178. /** @hidden */
  101179. _framebuffer: Nullable<WebGLFramebuffer>;
  101180. /** @hidden */
  101181. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  101182. /** @hidden */
  101183. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  101184. /** @hidden */
  101185. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  101186. /** @hidden */
  101187. _attachments: Nullable<number[]>;
  101188. /** @hidden */
  101189. _cachedCoordinatesMode: Nullable<number>;
  101190. /** @hidden */
  101191. _cachedWrapU: Nullable<number>;
  101192. /** @hidden */
  101193. _cachedWrapV: Nullable<number>;
  101194. /** @hidden */
  101195. _cachedWrapR: Nullable<number>;
  101196. /** @hidden */
  101197. _cachedAnisotropicFilteringLevel: Nullable<number>;
  101198. /** @hidden */
  101199. _isDisabled: boolean;
  101200. /** @hidden */
  101201. _compression: Nullable<string>;
  101202. /** @hidden */
  101203. _generateStencilBuffer: boolean;
  101204. /** @hidden */
  101205. _generateDepthBuffer: boolean;
  101206. /** @hidden */
  101207. _comparisonFunction: number;
  101208. /** @hidden */
  101209. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  101210. /** @hidden */
  101211. _lodGenerationScale: number;
  101212. /** @hidden */
  101213. _lodGenerationOffset: number;
  101214. /** @hidden */
  101215. _colorTextureArray: Nullable<WebGLTexture>;
  101216. /** @hidden */
  101217. _depthStencilTextureArray: Nullable<WebGLTexture>;
  101218. /** @hidden */
  101219. _lodTextureHigh: Nullable<BaseTexture>;
  101220. /** @hidden */
  101221. _lodTextureMid: Nullable<BaseTexture>;
  101222. /** @hidden */
  101223. _lodTextureLow: Nullable<BaseTexture>;
  101224. /** @hidden */
  101225. _isRGBD: boolean;
  101226. /** @hidden */
  101227. _linearSpecularLOD: boolean;
  101228. /** @hidden */
  101229. _irradianceTexture: Nullable<BaseTexture>;
  101230. /** @hidden */
  101231. _webGLTexture: Nullable<WebGLTexture>;
  101232. /** @hidden */
  101233. _references: number;
  101234. private _engine;
  101235. /**
  101236. * Gets the Engine the texture belongs to.
  101237. * @returns The babylon engine
  101238. */
  101239. getEngine(): ThinEngine;
  101240. /**
  101241. * Gets the data source type of the texture
  101242. */
  101243. readonly source: InternalTextureSource;
  101244. /**
  101245. * Creates a new InternalTexture
  101246. * @param engine defines the engine to use
  101247. * @param source defines the type of data that will be used
  101248. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101249. */
  101250. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  101251. /**
  101252. * Increments the number of references (ie. the number of Texture that point to it)
  101253. */
  101254. incrementReferences(): void;
  101255. /**
  101256. * Change the size of the texture (not the size of the content)
  101257. * @param width defines the new width
  101258. * @param height defines the new height
  101259. * @param depth defines the new depth (1 by default)
  101260. */
  101261. updateSize(width: int, height: int, depth?: int): void;
  101262. /** @hidden */
  101263. _rebuild(): void;
  101264. /** @hidden */
  101265. _swapAndDie(target: InternalTexture): void;
  101266. /**
  101267. * Dispose the current allocated resources
  101268. */
  101269. dispose(): void;
  101270. }
  101271. }
  101272. declare module BABYLON {
  101273. /**
  101274. * Class used to work with sound analyzer using fast fourier transform (FFT)
  101275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101276. */
  101277. export class Analyser {
  101278. /**
  101279. * Gets or sets the smoothing
  101280. * @ignorenaming
  101281. */
  101282. SMOOTHING: number;
  101283. /**
  101284. * Gets or sets the FFT table size
  101285. * @ignorenaming
  101286. */
  101287. FFT_SIZE: number;
  101288. /**
  101289. * Gets or sets the bar graph amplitude
  101290. * @ignorenaming
  101291. */
  101292. BARGRAPHAMPLITUDE: number;
  101293. /**
  101294. * Gets or sets the position of the debug canvas
  101295. * @ignorenaming
  101296. */
  101297. DEBUGCANVASPOS: {
  101298. x: number;
  101299. y: number;
  101300. };
  101301. /**
  101302. * Gets or sets the debug canvas size
  101303. * @ignorenaming
  101304. */
  101305. DEBUGCANVASSIZE: {
  101306. width: number;
  101307. height: number;
  101308. };
  101309. private _byteFreqs;
  101310. private _byteTime;
  101311. private _floatFreqs;
  101312. private _webAudioAnalyser;
  101313. private _debugCanvas;
  101314. private _debugCanvasContext;
  101315. private _scene;
  101316. private _registerFunc;
  101317. private _audioEngine;
  101318. /**
  101319. * Creates a new analyser
  101320. * @param scene defines hosting scene
  101321. */
  101322. constructor(scene: Scene);
  101323. /**
  101324. * Get the number of data values you will have to play with for the visualization
  101325. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  101326. * @returns a number
  101327. */
  101328. getFrequencyBinCount(): number;
  101329. /**
  101330. * Gets the current frequency data as a byte array
  101331. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101332. * @returns a Uint8Array
  101333. */
  101334. getByteFrequencyData(): Uint8Array;
  101335. /**
  101336. * Gets the current waveform as a byte array
  101337. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  101338. * @returns a Uint8Array
  101339. */
  101340. getByteTimeDomainData(): Uint8Array;
  101341. /**
  101342. * Gets the current frequency data as a float array
  101343. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  101344. * @returns a Float32Array
  101345. */
  101346. getFloatFrequencyData(): Float32Array;
  101347. /**
  101348. * Renders the debug canvas
  101349. */
  101350. drawDebugCanvas(): void;
  101351. /**
  101352. * Stops rendering the debug canvas and removes it
  101353. */
  101354. stopDebugCanvas(): void;
  101355. /**
  101356. * Connects two audio nodes
  101357. * @param inputAudioNode defines first node to connect
  101358. * @param outputAudioNode defines second node to connect
  101359. */
  101360. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  101361. /**
  101362. * Releases all associated resources
  101363. */
  101364. dispose(): void;
  101365. }
  101366. }
  101367. declare module BABYLON {
  101368. /**
  101369. * This represents an audio engine and it is responsible
  101370. * to play, synchronize and analyse sounds throughout the application.
  101371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101372. */
  101373. export interface IAudioEngine extends IDisposable {
  101374. /**
  101375. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  101376. */
  101377. readonly canUseWebAudio: boolean;
  101378. /**
  101379. * Gets the current AudioContext if available.
  101380. */
  101381. readonly audioContext: Nullable<AudioContext>;
  101382. /**
  101383. * The master gain node defines the global audio volume of your audio engine.
  101384. */
  101385. readonly masterGain: GainNode;
  101386. /**
  101387. * Gets whether or not mp3 are supported by your browser.
  101388. */
  101389. readonly isMP3supported: boolean;
  101390. /**
  101391. * Gets whether or not ogg are supported by your browser.
  101392. */
  101393. readonly isOGGsupported: boolean;
  101394. /**
  101395. * Defines if Babylon should emit a warning if WebAudio is not supported.
  101396. * @ignoreNaming
  101397. */
  101398. WarnedWebAudioUnsupported: boolean;
  101399. /**
  101400. * Defines if the audio engine relies on a custom unlocked button.
  101401. * In this case, the embedded button will not be displayed.
  101402. */
  101403. useCustomUnlockedButton: boolean;
  101404. /**
  101405. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  101406. */
  101407. readonly unlocked: boolean;
  101408. /**
  101409. * Event raised when audio has been unlocked on the browser.
  101410. */
  101411. onAudioUnlockedObservable: Observable<AudioEngine>;
  101412. /**
  101413. * Event raised when audio has been locked on the browser.
  101414. */
  101415. onAudioLockedObservable: Observable<AudioEngine>;
  101416. /**
  101417. * Flags the audio engine in Locked state.
  101418. * This happens due to new browser policies preventing audio to autoplay.
  101419. */
  101420. lock(): void;
  101421. /**
  101422. * Unlocks the audio engine once a user action has been done on the dom.
  101423. * This is helpful to resume play once browser policies have been satisfied.
  101424. */
  101425. unlock(): void;
  101426. }
  101427. /**
  101428. * This represents the default audio engine used in babylon.
  101429. * It is responsible to play, synchronize and analyse sounds throughout the application.
  101430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101431. */
  101432. export class AudioEngine implements IAudioEngine {
  101433. private _audioContext;
  101434. private _audioContextInitialized;
  101435. private _muteButton;
  101436. private _hostElement;
  101437. /**
  101438. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  101439. */
  101440. canUseWebAudio: boolean;
  101441. /**
  101442. * The master gain node defines the global audio volume of your audio engine.
  101443. */
  101444. masterGain: GainNode;
  101445. /**
  101446. * Defines if Babylon should emit a warning if WebAudio is not supported.
  101447. * @ignoreNaming
  101448. */
  101449. WarnedWebAudioUnsupported: boolean;
  101450. /**
  101451. * Gets whether or not mp3 are supported by your browser.
  101452. */
  101453. isMP3supported: boolean;
  101454. /**
  101455. * Gets whether or not ogg are supported by your browser.
  101456. */
  101457. isOGGsupported: boolean;
  101458. /**
  101459. * Gets whether audio has been unlocked on the device.
  101460. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  101461. * a user interaction has happened.
  101462. */
  101463. unlocked: boolean;
  101464. /**
  101465. * Defines if the audio engine relies on a custom unlocked button.
  101466. * In this case, the embedded button will not be displayed.
  101467. */
  101468. useCustomUnlockedButton: boolean;
  101469. /**
  101470. * Event raised when audio has been unlocked on the browser.
  101471. */
  101472. onAudioUnlockedObservable: Observable<AudioEngine>;
  101473. /**
  101474. * Event raised when audio has been locked on the browser.
  101475. */
  101476. onAudioLockedObservable: Observable<AudioEngine>;
  101477. /**
  101478. * Gets the current AudioContext if available.
  101479. */
  101480. readonly audioContext: Nullable<AudioContext>;
  101481. private _connectedAnalyser;
  101482. /**
  101483. * Instantiates a new audio engine.
  101484. *
  101485. * There should be only one per page as some browsers restrict the number
  101486. * of audio contexts you can create.
  101487. * @param hostElement defines the host element where to display the mute icon if necessary
  101488. */
  101489. constructor(hostElement?: Nullable<HTMLElement>);
  101490. /**
  101491. * Flags the audio engine in Locked state.
  101492. * This happens due to new browser policies preventing audio to autoplay.
  101493. */
  101494. lock(): void;
  101495. /**
  101496. * Unlocks the audio engine once a user action has been done on the dom.
  101497. * This is helpful to resume play once browser policies have been satisfied.
  101498. */
  101499. unlock(): void;
  101500. private _resumeAudioContext;
  101501. private _initializeAudioContext;
  101502. private _tryToRun;
  101503. private _triggerRunningState;
  101504. private _triggerSuspendedState;
  101505. private _displayMuteButton;
  101506. private _moveButtonToTopLeft;
  101507. private _onResize;
  101508. private _hideMuteButton;
  101509. /**
  101510. * Destroy and release the resources associated with the audio ccontext.
  101511. */
  101512. dispose(): void;
  101513. /**
  101514. * Gets the global volume sets on the master gain.
  101515. * @returns the global volume if set or -1 otherwise
  101516. */
  101517. getGlobalVolume(): number;
  101518. /**
  101519. * Sets the global volume of your experience (sets on the master gain).
  101520. * @param newVolume Defines the new global volume of the application
  101521. */
  101522. setGlobalVolume(newVolume: number): void;
  101523. /**
  101524. * Connect the audio engine to an audio analyser allowing some amazing
  101525. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101527. * @param analyser The analyser to connect to the engine
  101528. */
  101529. connectToAnalyser(analyser: Analyser): void;
  101530. }
  101531. }
  101532. declare module BABYLON {
  101533. /**
  101534. * Interface used to present a loading screen while loading a scene
  101535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101536. */
  101537. export interface ILoadingScreen {
  101538. /**
  101539. * Function called to display the loading screen
  101540. */
  101541. displayLoadingUI: () => void;
  101542. /**
  101543. * Function called to hide the loading screen
  101544. */
  101545. hideLoadingUI: () => void;
  101546. /**
  101547. * Gets or sets the color to use for the background
  101548. */
  101549. loadingUIBackgroundColor: string;
  101550. /**
  101551. * Gets or sets the text to display while loading
  101552. */
  101553. loadingUIText: string;
  101554. }
  101555. /**
  101556. * Class used for the default loading screen
  101557. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  101558. */
  101559. export class DefaultLoadingScreen implements ILoadingScreen {
  101560. private _renderingCanvas;
  101561. private _loadingText;
  101562. private _loadingDivBackgroundColor;
  101563. private _loadingDiv;
  101564. private _loadingTextDiv;
  101565. /** Gets or sets the logo url to use for the default loading screen */
  101566. static DefaultLogoUrl: string;
  101567. /** Gets or sets the spinner url to use for the default loading screen */
  101568. static DefaultSpinnerUrl: string;
  101569. /**
  101570. * Creates a new default loading screen
  101571. * @param _renderingCanvas defines the canvas used to render the scene
  101572. * @param _loadingText defines the default text to display
  101573. * @param _loadingDivBackgroundColor defines the default background color
  101574. */
  101575. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  101576. /**
  101577. * Function called to display the loading screen
  101578. */
  101579. displayLoadingUI(): void;
  101580. /**
  101581. * Function called to hide the loading screen
  101582. */
  101583. hideLoadingUI(): void;
  101584. /**
  101585. * Gets or sets the text to display while loading
  101586. */
  101587. loadingUIText: string;
  101588. /**
  101589. * Gets or sets the color to use for the background
  101590. */
  101591. loadingUIBackgroundColor: string;
  101592. private _resizeLoadingUI;
  101593. }
  101594. }
  101595. declare module BABYLON {
  101596. /**
  101597. * Interface for any object that can request an animation frame
  101598. */
  101599. export interface ICustomAnimationFrameRequester {
  101600. /**
  101601. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  101602. */
  101603. renderFunction?: Function;
  101604. /**
  101605. * Called to request the next frame to render to
  101606. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  101607. */
  101608. requestAnimationFrame: Function;
  101609. /**
  101610. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  101611. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  101612. */
  101613. requestID?: number;
  101614. }
  101615. }
  101616. declare module BABYLON {
  101617. /**
  101618. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  101619. */
  101620. export class PerformanceMonitor {
  101621. private _enabled;
  101622. private _rollingFrameTime;
  101623. private _lastFrameTimeMs;
  101624. /**
  101625. * constructor
  101626. * @param frameSampleSize The number of samples required to saturate the sliding window
  101627. */
  101628. constructor(frameSampleSize?: number);
  101629. /**
  101630. * Samples current frame
  101631. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  101632. */
  101633. sampleFrame(timeMs?: number): void;
  101634. /**
  101635. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101636. */
  101637. readonly averageFrameTime: number;
  101638. /**
  101639. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  101640. */
  101641. readonly averageFrameTimeVariance: number;
  101642. /**
  101643. * Returns the frame time of the most recent frame
  101644. */
  101645. readonly instantaneousFrameTime: number;
  101646. /**
  101647. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  101648. */
  101649. readonly averageFPS: number;
  101650. /**
  101651. * Returns the average framerate in frames per second using the most recent frame time
  101652. */
  101653. readonly instantaneousFPS: number;
  101654. /**
  101655. * Returns true if enough samples have been taken to completely fill the sliding window
  101656. */
  101657. readonly isSaturated: boolean;
  101658. /**
  101659. * Enables contributions to the sliding window sample set
  101660. */
  101661. enable(): void;
  101662. /**
  101663. * Disables contributions to the sliding window sample set
  101664. * Samples will not be interpolated over the disabled period
  101665. */
  101666. disable(): void;
  101667. /**
  101668. * Returns true if sampling is enabled
  101669. */
  101670. readonly isEnabled: boolean;
  101671. /**
  101672. * Resets performance monitor
  101673. */
  101674. reset(): void;
  101675. }
  101676. /**
  101677. * RollingAverage
  101678. *
  101679. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  101680. */
  101681. export class RollingAverage {
  101682. /**
  101683. * Current average
  101684. */
  101685. average: number;
  101686. /**
  101687. * Current variance
  101688. */
  101689. variance: number;
  101690. protected _samples: Array<number>;
  101691. protected _sampleCount: number;
  101692. protected _pos: number;
  101693. protected _m2: number;
  101694. /**
  101695. * constructor
  101696. * @param length The number of samples required to saturate the sliding window
  101697. */
  101698. constructor(length: number);
  101699. /**
  101700. * Adds a sample to the sample set
  101701. * @param v The sample value
  101702. */
  101703. add(v: number): void;
  101704. /**
  101705. * Returns previously added values or null if outside of history or outside the sliding window domain
  101706. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  101707. * @return Value previously recorded with add() or null if outside of range
  101708. */
  101709. history(i: number): number;
  101710. /**
  101711. * Returns true if enough samples have been taken to completely fill the sliding window
  101712. * @return true if sample-set saturated
  101713. */
  101714. isSaturated(): boolean;
  101715. /**
  101716. * Resets the rolling average (equivalent to 0 samples taken so far)
  101717. */
  101718. reset(): void;
  101719. /**
  101720. * Wraps a value around the sample range boundaries
  101721. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  101722. * @return Wrapped position in sample range
  101723. */
  101724. protected _wrapPosition(i: number): number;
  101725. }
  101726. }
  101727. declare module BABYLON {
  101728. /**
  101729. * This class is used to track a performance counter which is number based.
  101730. * The user has access to many properties which give statistics of different nature.
  101731. *
  101732. * The implementer can track two kinds of Performance Counter: time and count.
  101733. * 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.
  101734. * 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.
  101735. */
  101736. export class PerfCounter {
  101737. /**
  101738. * Gets or sets a global boolean to turn on and off all the counters
  101739. */
  101740. static Enabled: boolean;
  101741. /**
  101742. * Returns the smallest value ever
  101743. */
  101744. readonly min: number;
  101745. /**
  101746. * Returns the biggest value ever
  101747. */
  101748. readonly max: number;
  101749. /**
  101750. * Returns the average value since the performance counter is running
  101751. */
  101752. readonly average: number;
  101753. /**
  101754. * Returns the average value of the last second the counter was monitored
  101755. */
  101756. readonly lastSecAverage: number;
  101757. /**
  101758. * Returns the current value
  101759. */
  101760. readonly current: number;
  101761. /**
  101762. * Gets the accumulated total
  101763. */
  101764. readonly total: number;
  101765. /**
  101766. * Gets the total value count
  101767. */
  101768. readonly count: number;
  101769. /**
  101770. * Creates a new counter
  101771. */
  101772. constructor();
  101773. /**
  101774. * Call this method to start monitoring a new frame.
  101775. * 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.
  101776. */
  101777. fetchNewFrame(): void;
  101778. /**
  101779. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  101780. * @param newCount the count value to add to the monitored count
  101781. * @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.
  101782. */
  101783. addCount(newCount: number, fetchResult: boolean): void;
  101784. /**
  101785. * Start monitoring this performance counter
  101786. */
  101787. beginMonitoring(): void;
  101788. /**
  101789. * Compute the time lapsed since the previous beginMonitoring() call.
  101790. * @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
  101791. */
  101792. endMonitoring(newFrame?: boolean): void;
  101793. private _fetchResult;
  101794. private _startMonitoringTime;
  101795. private _min;
  101796. private _max;
  101797. private _average;
  101798. private _current;
  101799. private _totalValueCount;
  101800. private _totalAccumulated;
  101801. private _lastSecAverage;
  101802. private _lastSecAccumulated;
  101803. private _lastSecTime;
  101804. private _lastSecValueCount;
  101805. }
  101806. }
  101807. declare module BABYLON {
  101808. interface ThinEngine {
  101809. /**
  101810. * Sets alpha constants used by some alpha blending modes
  101811. * @param r defines the red component
  101812. * @param g defines the green component
  101813. * @param b defines the blue component
  101814. * @param a defines the alpha component
  101815. */
  101816. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  101817. /**
  101818. * Sets the current alpha mode
  101819. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  101820. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  101821. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101822. */
  101823. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  101824. /**
  101825. * Gets the current alpha mode
  101826. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  101827. * @returns the current alpha mode
  101828. */
  101829. getAlphaMode(): number;
  101830. /**
  101831. * Sets the current alpha equation
  101832. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  101833. */
  101834. setAlphaEquation(equation: number): void;
  101835. /**
  101836. * Gets the current alpha equation.
  101837. * @returns the current alpha equation
  101838. */
  101839. getAlphaEquation(): number;
  101840. }
  101841. }
  101842. declare module BABYLON {
  101843. /**
  101844. * Defines the interface used by display changed events
  101845. */
  101846. export interface IDisplayChangedEventArgs {
  101847. /** Gets the vrDisplay object (if any) */
  101848. vrDisplay: Nullable<any>;
  101849. /** Gets a boolean indicating if webVR is supported */
  101850. vrSupported: boolean;
  101851. }
  101852. /**
  101853. * Defines the interface used by objects containing a viewport (like a camera)
  101854. */
  101855. interface IViewportOwnerLike {
  101856. /**
  101857. * Gets or sets the viewport
  101858. */
  101859. viewport: IViewportLike;
  101860. }
  101861. /**
  101862. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  101863. */
  101864. export class Engine extends ThinEngine {
  101865. /** Defines that alpha blending is disabled */
  101866. static readonly ALPHA_DISABLE: number;
  101867. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  101868. static readonly ALPHA_ADD: number;
  101869. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  101870. static readonly ALPHA_COMBINE: number;
  101871. /** Defines that alpha blending to DEST - SRC * DEST */
  101872. static readonly ALPHA_SUBTRACT: number;
  101873. /** Defines that alpha blending to SRC * DEST */
  101874. static readonly ALPHA_MULTIPLY: number;
  101875. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  101876. static readonly ALPHA_MAXIMIZED: number;
  101877. /** Defines that alpha blending to SRC + DEST */
  101878. static readonly ALPHA_ONEONE: number;
  101879. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  101880. static readonly ALPHA_PREMULTIPLIED: number;
  101881. /**
  101882. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  101883. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  101884. */
  101885. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  101886. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  101887. static readonly ALPHA_INTERPOLATE: number;
  101888. /**
  101889. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  101890. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  101891. */
  101892. static readonly ALPHA_SCREENMODE: number;
  101893. /** Defines that the ressource is not delayed*/
  101894. static readonly DELAYLOADSTATE_NONE: number;
  101895. /** Defines that the ressource was successfully delay loaded */
  101896. static readonly DELAYLOADSTATE_LOADED: number;
  101897. /** Defines that the ressource is currently delay loading */
  101898. static readonly DELAYLOADSTATE_LOADING: number;
  101899. /** Defines that the ressource is delayed and has not started loading */
  101900. static readonly DELAYLOADSTATE_NOTLOADED: number;
  101901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  101902. static readonly NEVER: number;
  101903. /** 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 */
  101904. static readonly ALWAYS: number;
  101905. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  101906. static readonly LESS: number;
  101907. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  101908. static readonly EQUAL: number;
  101909. /** 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 */
  101910. static readonly LEQUAL: number;
  101911. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  101912. static readonly GREATER: number;
  101913. /** 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 */
  101914. static readonly GEQUAL: number;
  101915. /** 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 */
  101916. static readonly NOTEQUAL: number;
  101917. /** Passed to stencilOperation to specify that stencil value must be kept */
  101918. static readonly KEEP: number;
  101919. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101920. static readonly REPLACE: number;
  101921. /** Passed to stencilOperation to specify that stencil value must be incremented */
  101922. static readonly INCR: number;
  101923. /** Passed to stencilOperation to specify that stencil value must be decremented */
  101924. static readonly DECR: number;
  101925. /** Passed to stencilOperation to specify that stencil value must be inverted */
  101926. static readonly INVERT: number;
  101927. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  101928. static readonly INCR_WRAP: number;
  101929. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  101930. static readonly DECR_WRAP: number;
  101931. /** Texture is not repeating outside of 0..1 UVs */
  101932. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  101933. /** Texture is repeating outside of 0..1 UVs */
  101934. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  101935. /** Texture is repeating and mirrored */
  101936. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  101937. /** ALPHA */
  101938. static readonly TEXTUREFORMAT_ALPHA: number;
  101939. /** LUMINANCE */
  101940. static readonly TEXTUREFORMAT_LUMINANCE: number;
  101941. /** LUMINANCE_ALPHA */
  101942. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  101943. /** RGB */
  101944. static readonly TEXTUREFORMAT_RGB: number;
  101945. /** RGBA */
  101946. static readonly TEXTUREFORMAT_RGBA: number;
  101947. /** RED */
  101948. static readonly TEXTUREFORMAT_RED: number;
  101949. /** RED (2nd reference) */
  101950. static readonly TEXTUREFORMAT_R: number;
  101951. /** RG */
  101952. static readonly TEXTUREFORMAT_RG: number;
  101953. /** RED_INTEGER */
  101954. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  101955. /** RED_INTEGER (2nd reference) */
  101956. static readonly TEXTUREFORMAT_R_INTEGER: number;
  101957. /** RG_INTEGER */
  101958. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  101959. /** RGB_INTEGER */
  101960. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  101961. /** RGBA_INTEGER */
  101962. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  101963. /** UNSIGNED_BYTE */
  101964. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  101965. /** UNSIGNED_BYTE (2nd reference) */
  101966. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  101967. /** FLOAT */
  101968. static readonly TEXTURETYPE_FLOAT: number;
  101969. /** HALF_FLOAT */
  101970. static readonly TEXTURETYPE_HALF_FLOAT: number;
  101971. /** BYTE */
  101972. static readonly TEXTURETYPE_BYTE: number;
  101973. /** SHORT */
  101974. static readonly TEXTURETYPE_SHORT: number;
  101975. /** UNSIGNED_SHORT */
  101976. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  101977. /** INT */
  101978. static readonly TEXTURETYPE_INT: number;
  101979. /** UNSIGNED_INT */
  101980. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  101981. /** UNSIGNED_SHORT_4_4_4_4 */
  101982. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  101983. /** UNSIGNED_SHORT_5_5_5_1 */
  101984. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  101985. /** UNSIGNED_SHORT_5_6_5 */
  101986. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  101987. /** UNSIGNED_INT_2_10_10_10_REV */
  101988. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  101989. /** UNSIGNED_INT_24_8 */
  101990. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  101991. /** UNSIGNED_INT_10F_11F_11F_REV */
  101992. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  101993. /** UNSIGNED_INT_5_9_9_9_REV */
  101994. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  101995. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  101996. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  101997. /** nearest is mag = nearest and min = nearest and mip = linear */
  101998. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  101999. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102000. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  102001. /** Trilinear is mag = linear and min = linear and mip = linear */
  102002. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  102003. /** nearest is mag = nearest and min = nearest and mip = linear */
  102004. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  102005. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102006. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  102007. /** Trilinear is mag = linear and min = linear and mip = linear */
  102008. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  102009. /** mag = nearest and min = nearest and mip = nearest */
  102010. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  102011. /** mag = nearest and min = linear and mip = nearest */
  102012. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  102013. /** mag = nearest and min = linear and mip = linear */
  102014. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  102015. /** mag = nearest and min = linear and mip = none */
  102016. static readonly TEXTURE_NEAREST_LINEAR: number;
  102017. /** mag = nearest and min = nearest and mip = none */
  102018. static readonly TEXTURE_NEAREST_NEAREST: number;
  102019. /** mag = linear and min = nearest and mip = nearest */
  102020. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  102021. /** mag = linear and min = nearest and mip = linear */
  102022. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  102023. /** mag = linear and min = linear and mip = none */
  102024. static readonly TEXTURE_LINEAR_LINEAR: number;
  102025. /** mag = linear and min = nearest and mip = none */
  102026. static readonly TEXTURE_LINEAR_NEAREST: number;
  102027. /** Explicit coordinates mode */
  102028. static readonly TEXTURE_EXPLICIT_MODE: number;
  102029. /** Spherical coordinates mode */
  102030. static readonly TEXTURE_SPHERICAL_MODE: number;
  102031. /** Planar coordinates mode */
  102032. static readonly TEXTURE_PLANAR_MODE: number;
  102033. /** Cubic coordinates mode */
  102034. static readonly TEXTURE_CUBIC_MODE: number;
  102035. /** Projection coordinates mode */
  102036. static readonly TEXTURE_PROJECTION_MODE: number;
  102037. /** Skybox coordinates mode */
  102038. static readonly TEXTURE_SKYBOX_MODE: number;
  102039. /** Inverse Cubic coordinates mode */
  102040. static readonly TEXTURE_INVCUBIC_MODE: number;
  102041. /** Equirectangular coordinates mode */
  102042. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  102043. /** Equirectangular Fixed coordinates mode */
  102044. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  102045. /** Equirectangular Fixed Mirrored coordinates mode */
  102046. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102047. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  102048. static readonly SCALEMODE_FLOOR: number;
  102049. /** Defines that texture rescaling will look for the nearest power of 2 size */
  102050. static readonly SCALEMODE_NEAREST: number;
  102051. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  102052. static readonly SCALEMODE_CEILING: number;
  102053. /**
  102054. * Returns the current npm package of the sdk
  102055. */
  102056. static readonly NpmPackage: string;
  102057. /**
  102058. * Returns the current version of the framework
  102059. */
  102060. static readonly Version: string;
  102061. /** Gets the list of created engines */
  102062. static readonly Instances: Engine[];
  102063. /**
  102064. * Gets the latest created engine
  102065. */
  102066. static readonly LastCreatedEngine: Nullable<Engine>;
  102067. /**
  102068. * Gets the latest created scene
  102069. */
  102070. static readonly LastCreatedScene: Nullable<Scene>;
  102071. /**
  102072. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  102073. * @param flag defines which part of the materials must be marked as dirty
  102074. * @param predicate defines a predicate used to filter which materials should be affected
  102075. */
  102076. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  102077. /**
  102078. * Method called to create the default loading screen.
  102079. * This can be overriden in your own app.
  102080. * @param canvas The rendering canvas element
  102081. * @returns The loading screen
  102082. */
  102083. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  102084. /**
  102085. * Method called to create the default rescale post process on each engine.
  102086. */
  102087. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  102088. /**
  102089. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  102090. **/
  102091. enableOfflineSupport: boolean;
  102092. /**
  102093. * 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)
  102094. **/
  102095. disableManifestCheck: boolean;
  102096. /**
  102097. * Gets the list of created scenes
  102098. */
  102099. scenes: Scene[];
  102100. /**
  102101. * Event raised when a new scene is created
  102102. */
  102103. onNewSceneAddedObservable: Observable<Scene>;
  102104. /**
  102105. * Gets the list of created postprocesses
  102106. */
  102107. postProcesses: PostProcess[];
  102108. /**
  102109. * Gets a boolean indicating if the pointer is currently locked
  102110. */
  102111. isPointerLock: boolean;
  102112. /**
  102113. * Observable event triggered each time the rendering canvas is resized
  102114. */
  102115. onResizeObservable: Observable<Engine>;
  102116. /**
  102117. * Observable event triggered each time the canvas loses focus
  102118. */
  102119. onCanvasBlurObservable: Observable<Engine>;
  102120. /**
  102121. * Observable event triggered each time the canvas gains focus
  102122. */
  102123. onCanvasFocusObservable: Observable<Engine>;
  102124. /**
  102125. * Observable event triggered each time the canvas receives pointerout event
  102126. */
  102127. onCanvasPointerOutObservable: Observable<PointerEvent>;
  102128. /**
  102129. * Observable raised when the engine begins a new frame
  102130. */
  102131. onBeginFrameObservable: Observable<Engine>;
  102132. /**
  102133. * If set, will be used to request the next animation frame for the render loop
  102134. */
  102135. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  102136. /**
  102137. * Observable raised when the engine ends the current frame
  102138. */
  102139. onEndFrameObservable: Observable<Engine>;
  102140. /**
  102141. * Observable raised when the engine is about to compile a shader
  102142. */
  102143. onBeforeShaderCompilationObservable: Observable<Engine>;
  102144. /**
  102145. * Observable raised when the engine has jsut compiled a shader
  102146. */
  102147. onAfterShaderCompilationObservable: Observable<Engine>;
  102148. /**
  102149. * Gets the audio engine
  102150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102151. * @ignorenaming
  102152. */
  102153. static audioEngine: IAudioEngine;
  102154. /**
  102155. * Default AudioEngine factory responsible of creating the Audio Engine.
  102156. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  102157. */
  102158. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  102159. /**
  102160. * Default offline support factory responsible of creating a tool used to store data locally.
  102161. * By default, this will create a Database object if the workload has been embedded.
  102162. */
  102163. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  102164. private _loadingScreen;
  102165. private _pointerLockRequested;
  102166. private _dummyFramebuffer;
  102167. private _rescalePostProcess;
  102168. private _deterministicLockstep;
  102169. private _lockstepMaxSteps;
  102170. private _timeStep;
  102171. protected readonly _supportsHardwareTextureRescaling: boolean;
  102172. private _fps;
  102173. private _deltaTime;
  102174. /** @hidden */
  102175. _drawCalls: PerfCounter;
  102176. /**
  102177. * Turn this value on if you want to pause FPS computation when in background
  102178. */
  102179. disablePerformanceMonitorInBackground: boolean;
  102180. private _performanceMonitor;
  102181. /**
  102182. * Gets the performance monitor attached to this engine
  102183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  102184. */
  102185. readonly performanceMonitor: PerformanceMonitor;
  102186. private _onFocus;
  102187. private _onBlur;
  102188. private _onCanvasPointerOut;
  102189. private _onCanvasBlur;
  102190. private _onCanvasFocus;
  102191. private _onFullscreenChange;
  102192. private _onPointerLockChange;
  102193. /**
  102194. * Gets the HTML element used to attach event listeners
  102195. * @returns a HTML element
  102196. */
  102197. getInputElement(): Nullable<HTMLElement>;
  102198. /**
  102199. * Creates a new engine
  102200. * @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
  102201. * @param antialias defines enable antialiasing (default: false)
  102202. * @param options defines further options to be sent to the getContext() function
  102203. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  102204. */
  102205. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  102206. /**
  102207. * Gets current aspect ratio
  102208. * @param viewportOwner defines the camera to use to get the aspect ratio
  102209. * @param useScreen defines if screen size must be used (or the current render target if any)
  102210. * @returns a number defining the aspect ratio
  102211. */
  102212. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  102213. /**
  102214. * Gets current screen aspect ratio
  102215. * @returns a number defining the aspect ratio
  102216. */
  102217. getScreenAspectRatio(): number;
  102218. /**
  102219. * Gets the client rect of the HTML canvas attached with the current webGL context
  102220. * @returns a client rectanglee
  102221. */
  102222. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  102223. /**
  102224. * Gets the client rect of the HTML element used for events
  102225. * @returns a client rectanglee
  102226. */
  102227. getInputElementClientRect(): Nullable<ClientRect>;
  102228. /**
  102229. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  102230. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102231. * @returns true if engine is in deterministic lock step mode
  102232. */
  102233. isDeterministicLockStep(): boolean;
  102234. /**
  102235. * Gets the max steps when engine is running in deterministic lock step
  102236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102237. * @returns the max steps
  102238. */
  102239. getLockstepMaxSteps(): number;
  102240. /**
  102241. * Returns the time in ms between steps when using deterministic lock step.
  102242. * @returns time step in (ms)
  102243. */
  102244. getTimeStep(): number;
  102245. /**
  102246. * Force the mipmap generation for the given render target texture
  102247. * @param texture defines the render target texture to use
  102248. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  102249. */
  102250. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  102251. /** States */
  102252. /**
  102253. * Set various states to the webGL context
  102254. * @param culling defines backface culling state
  102255. * @param zOffset defines the value to apply to zOffset (0 by default)
  102256. * @param force defines if states must be applied even if cache is up to date
  102257. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  102258. */
  102259. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  102260. /**
  102261. * Set the z offset to apply to current rendering
  102262. * @param value defines the offset to apply
  102263. */
  102264. setZOffset(value: number): void;
  102265. /**
  102266. * Gets the current value of the zOffset
  102267. * @returns the current zOffset state
  102268. */
  102269. getZOffset(): number;
  102270. /**
  102271. * Enable or disable depth buffering
  102272. * @param enable defines the state to set
  102273. */
  102274. setDepthBuffer(enable: boolean): void;
  102275. /**
  102276. * Gets a boolean indicating if depth writing is enabled
  102277. * @returns the current depth writing state
  102278. */
  102279. getDepthWrite(): boolean;
  102280. /**
  102281. * Enable or disable depth writing
  102282. * @param enable defines the state to set
  102283. */
  102284. setDepthWrite(enable: boolean): void;
  102285. /**
  102286. * Gets a boolean indicating if stencil buffer is enabled
  102287. * @returns the current stencil buffer state
  102288. */
  102289. getStencilBuffer(): boolean;
  102290. /**
  102291. * Enable or disable the stencil buffer
  102292. * @param enable defines if the stencil buffer must be enabled or disabled
  102293. */
  102294. setStencilBuffer(enable: boolean): void;
  102295. /**
  102296. * Gets the current stencil mask
  102297. * @returns a number defining the new stencil mask to use
  102298. */
  102299. getStencilMask(): number;
  102300. /**
  102301. * Sets the current stencil mask
  102302. * @param mask defines the new stencil mask to use
  102303. */
  102304. setStencilMask(mask: number): void;
  102305. /**
  102306. * Gets the current stencil function
  102307. * @returns a number defining the stencil function to use
  102308. */
  102309. getStencilFunction(): number;
  102310. /**
  102311. * Gets the current stencil reference value
  102312. * @returns a number defining the stencil reference value to use
  102313. */
  102314. getStencilFunctionReference(): number;
  102315. /**
  102316. * Gets the current stencil mask
  102317. * @returns a number defining the stencil mask to use
  102318. */
  102319. getStencilFunctionMask(): number;
  102320. /**
  102321. * Sets the current stencil function
  102322. * @param stencilFunc defines the new stencil function to use
  102323. */
  102324. setStencilFunction(stencilFunc: number): void;
  102325. /**
  102326. * Sets the current stencil reference
  102327. * @param reference defines the new stencil reference to use
  102328. */
  102329. setStencilFunctionReference(reference: number): void;
  102330. /**
  102331. * Sets the current stencil mask
  102332. * @param mask defines the new stencil mask to use
  102333. */
  102334. setStencilFunctionMask(mask: number): void;
  102335. /**
  102336. * Gets the current stencil operation when stencil fails
  102337. * @returns a number defining stencil operation to use when stencil fails
  102338. */
  102339. getStencilOperationFail(): number;
  102340. /**
  102341. * Gets the current stencil operation when depth fails
  102342. * @returns a number defining stencil operation to use when depth fails
  102343. */
  102344. getStencilOperationDepthFail(): number;
  102345. /**
  102346. * Gets the current stencil operation when stencil passes
  102347. * @returns a number defining stencil operation to use when stencil passes
  102348. */
  102349. getStencilOperationPass(): number;
  102350. /**
  102351. * Sets the stencil operation to use when stencil fails
  102352. * @param operation defines the stencil operation to use when stencil fails
  102353. */
  102354. setStencilOperationFail(operation: number): void;
  102355. /**
  102356. * Sets the stencil operation to use when depth fails
  102357. * @param operation defines the stencil operation to use when depth fails
  102358. */
  102359. setStencilOperationDepthFail(operation: number): void;
  102360. /**
  102361. * Sets the stencil operation to use when stencil passes
  102362. * @param operation defines the stencil operation to use when stencil passes
  102363. */
  102364. setStencilOperationPass(operation: number): void;
  102365. /**
  102366. * Sets a boolean indicating if the dithering state is enabled or disabled
  102367. * @param value defines the dithering state
  102368. */
  102369. setDitheringState(value: boolean): void;
  102370. /**
  102371. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  102372. * @param value defines the rasterizer state
  102373. */
  102374. setRasterizerState(value: boolean): void;
  102375. /**
  102376. * Gets the current depth function
  102377. * @returns a number defining the depth function
  102378. */
  102379. getDepthFunction(): Nullable<number>;
  102380. /**
  102381. * Sets the current depth function
  102382. * @param depthFunc defines the function to use
  102383. */
  102384. setDepthFunction(depthFunc: number): void;
  102385. /**
  102386. * Sets the current depth function to GREATER
  102387. */
  102388. setDepthFunctionToGreater(): void;
  102389. /**
  102390. * Sets the current depth function to GEQUAL
  102391. */
  102392. setDepthFunctionToGreaterOrEqual(): void;
  102393. /**
  102394. * Sets the current depth function to LESS
  102395. */
  102396. setDepthFunctionToLess(): void;
  102397. /**
  102398. * Sets the current depth function to LEQUAL
  102399. */
  102400. setDepthFunctionToLessOrEqual(): void;
  102401. private _cachedStencilBuffer;
  102402. private _cachedStencilFunction;
  102403. private _cachedStencilMask;
  102404. private _cachedStencilOperationPass;
  102405. private _cachedStencilOperationFail;
  102406. private _cachedStencilOperationDepthFail;
  102407. private _cachedStencilReference;
  102408. /**
  102409. * Caches the the state of the stencil buffer
  102410. */
  102411. cacheStencilState(): void;
  102412. /**
  102413. * Restores the state of the stencil buffer
  102414. */
  102415. restoreStencilState(): void;
  102416. /**
  102417. * Directly set the WebGL Viewport
  102418. * @param x defines the x coordinate of the viewport (in screen space)
  102419. * @param y defines the y coordinate of the viewport (in screen space)
  102420. * @param width defines the width of the viewport (in screen space)
  102421. * @param height defines the height of the viewport (in screen space)
  102422. * @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
  102423. */
  102424. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  102425. /**
  102426. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  102427. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  102428. * @param y defines the y-coordinate of the corner of the clear rectangle
  102429. * @param width defines the width of the clear rectangle
  102430. * @param height defines the height of the clear rectangle
  102431. * @param clearColor defines the clear color
  102432. */
  102433. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  102434. /**
  102435. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  102436. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  102437. * @param y defines the y-coordinate of the corner of the clear rectangle
  102438. * @param width defines the width of the clear rectangle
  102439. * @param height defines the height of the clear rectangle
  102440. */
  102441. enableScissor(x: number, y: number, width: number, height: number): void;
  102442. /**
  102443. * Disable previously set scissor test rectangle
  102444. */
  102445. disableScissor(): void;
  102446. protected _reportDrawCall(): void;
  102447. /**
  102448. * Initializes a webVR display and starts listening to display change events
  102449. * The onVRDisplayChangedObservable will be notified upon these changes
  102450. * @returns The onVRDisplayChangedObservable
  102451. */
  102452. initWebVR(): Observable<IDisplayChangedEventArgs>;
  102453. /** @hidden */
  102454. _prepareVRComponent(): void;
  102455. /** @hidden */
  102456. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  102457. /** @hidden */
  102458. _submitVRFrame(): void;
  102459. /**
  102460. * Call this function to leave webVR mode
  102461. * Will do nothing if webVR is not supported or if there is no webVR device
  102462. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102463. */
  102464. disableVR(): void;
  102465. /**
  102466. * Gets a boolean indicating that the system is in VR mode and is presenting
  102467. * @returns true if VR mode is engaged
  102468. */
  102469. isVRPresenting(): boolean;
  102470. /** @hidden */
  102471. _requestVRFrame(): void;
  102472. /** @hidden */
  102473. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  102474. /**
  102475. * Gets the source code of the vertex shader associated with a specific webGL program
  102476. * @param program defines the program to use
  102477. * @returns a string containing the source code of the vertex shader associated with the program
  102478. */
  102479. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  102480. /**
  102481. * Gets the source code of the fragment shader associated with a specific webGL program
  102482. * @param program defines the program to use
  102483. * @returns a string containing the source code of the fragment shader associated with the program
  102484. */
  102485. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  102486. /**
  102487. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102488. * @param x defines the x coordinate of the rectangle where pixels must be read
  102489. * @param y defines the y coordinate of the rectangle where pixels must be read
  102490. * @param width defines the width of the rectangle where pixels must be read
  102491. * @param height defines the height of the rectangle where pixels must be read
  102492. * @returns a Uint8Array containing RGBA colors
  102493. */
  102494. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  102495. /**
  102496. * Sets a depth stencil texture from a render target to the according uniform.
  102497. * @param channel The texture channel
  102498. * @param uniform The uniform to set
  102499. * @param texture The render target texture containing the depth stencil texture to apply
  102500. */
  102501. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  102502. /**
  102503. * Sets a texture to the webGL context from a postprocess
  102504. * @param channel defines the channel to use
  102505. * @param postProcess defines the source postprocess
  102506. */
  102507. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  102508. /**
  102509. * Binds the output of the passed in post process to the texture channel specified
  102510. * @param channel The channel the texture should be bound to
  102511. * @param postProcess The post process which's output should be bound
  102512. */
  102513. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  102514. /** @hidden */
  102515. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  102516. protected _rebuildBuffers(): void;
  102517. /** @hidden */
  102518. _renderFrame(): void;
  102519. _renderLoop(): void;
  102520. /** @hidden */
  102521. _renderViews(): boolean;
  102522. /**
  102523. * Toggle full screen mode
  102524. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102525. */
  102526. switchFullscreen(requestPointerLock: boolean): void;
  102527. /**
  102528. * Enters full screen mode
  102529. * @param requestPointerLock defines if a pointer lock should be requested from the user
  102530. */
  102531. enterFullscreen(requestPointerLock: boolean): void;
  102532. /**
  102533. * Exits full screen mode
  102534. */
  102535. exitFullscreen(): void;
  102536. /**
  102537. * Enters Pointerlock mode
  102538. */
  102539. enterPointerlock(): void;
  102540. /**
  102541. * Exits Pointerlock mode
  102542. */
  102543. exitPointerlock(): void;
  102544. /**
  102545. * Begin a new frame
  102546. */
  102547. beginFrame(): void;
  102548. /**
  102549. * Enf the current frame
  102550. */
  102551. endFrame(): void;
  102552. resize(): void;
  102553. /**
  102554. * Set the compressed texture format to use, based on the formats you have, and the formats
  102555. * supported by the hardware / browser.
  102556. *
  102557. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  102558. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  102559. * to API arguments needed to compressed textures. This puts the burden on the container
  102560. * generator to house the arcane code for determining these for current & future formats.
  102561. *
  102562. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102563. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102564. *
  102565. * Note: The result of this call is not taken into account when a texture is base64.
  102566. *
  102567. * @param formatsAvailable defines the list of those format families you have created
  102568. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  102569. *
  102570. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  102571. * @returns The extension selected.
  102572. */
  102573. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  102574. /**
  102575. * Set the compressed texture extensions or file names to skip.
  102576. *
  102577. * @param skippedFiles defines the list of those texture files you want to skip
  102578. * Example: [".dds", ".env", "myfile.png"]
  102579. */
  102580. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  102581. /**
  102582. * Force a specific size of the canvas
  102583. * @param width defines the new canvas' width
  102584. * @param height defines the new canvas' height
  102585. */
  102586. setSize(width: number, height: number): void;
  102587. /**
  102588. * Updates a dynamic vertex buffer.
  102589. * @param vertexBuffer the vertex buffer to update
  102590. * @param data the data used to update the vertex buffer
  102591. * @param byteOffset the byte offset of the data
  102592. * @param byteLength the byte length of the data
  102593. */
  102594. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  102595. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102596. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102597. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102598. _releaseTexture(texture: InternalTexture): void;
  102599. /**
  102600. * @hidden
  102601. * Rescales a texture
  102602. * @param source input texutre
  102603. * @param destination destination texture
  102604. * @param scene scene to use to render the resize
  102605. * @param internalFormat format to use when resizing
  102606. * @param onComplete callback to be called when resize has completed
  102607. */
  102608. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102609. /**
  102610. * Gets the current framerate
  102611. * @returns a number representing the framerate
  102612. */
  102613. getFps(): number;
  102614. /**
  102615. * Gets the time spent between current and previous frame
  102616. * @returns a number representing the delta time in ms
  102617. */
  102618. getDeltaTime(): number;
  102619. private _measureFps;
  102620. /** @hidden */
  102621. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  102622. /**
  102623. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  102624. * @param renderTarget The render target to set the frame buffer for
  102625. */
  102626. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  102627. /**
  102628. * Update a dynamic index buffer
  102629. * @param indexBuffer defines the target index buffer
  102630. * @param indices defines the data to update
  102631. * @param offset defines the offset in the target index buffer where update should start
  102632. */
  102633. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  102634. /**
  102635. * Updates the sample count of a render target texture
  102636. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  102637. * @param texture defines the texture to update
  102638. * @param samples defines the sample count to set
  102639. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  102640. */
  102641. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  102642. /**
  102643. * Updates a depth texture Comparison Mode and Function.
  102644. * If the comparison Function is equal to 0, the mode will be set to none.
  102645. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  102646. * @param texture The texture to set the comparison function for
  102647. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  102648. */
  102649. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  102650. /**
  102651. * Creates a webGL buffer to use with instanciation
  102652. * @param capacity defines the size of the buffer
  102653. * @returns the webGL buffer
  102654. */
  102655. createInstancesBuffer(capacity: number): DataBuffer;
  102656. /**
  102657. * Delete a webGL buffer used with instanciation
  102658. * @param buffer defines the webGL buffer to delete
  102659. */
  102660. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  102661. /** @hidden */
  102662. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  102663. dispose(): void;
  102664. private _disableTouchAction;
  102665. /**
  102666. * Display the loading screen
  102667. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102668. */
  102669. displayLoadingUI(): void;
  102670. /**
  102671. * Hide the loading screen
  102672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102673. */
  102674. hideLoadingUI(): void;
  102675. /**
  102676. * Gets the current loading screen object
  102677. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102678. */
  102679. /**
  102680. * Sets the current loading screen object
  102681. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102682. */
  102683. loadingScreen: ILoadingScreen;
  102684. /**
  102685. * Sets the current loading screen text
  102686. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102687. */
  102688. loadingUIText: string;
  102689. /**
  102690. * Sets the current loading screen background color
  102691. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  102692. */
  102693. loadingUIBackgroundColor: string;
  102694. /** Pointerlock and fullscreen */
  102695. /**
  102696. * Ask the browser to promote the current element to pointerlock mode
  102697. * @param element defines the DOM element to promote
  102698. */
  102699. static _RequestPointerlock(element: HTMLElement): void;
  102700. /**
  102701. * Asks the browser to exit pointerlock mode
  102702. */
  102703. static _ExitPointerlock(): void;
  102704. /**
  102705. * Ask the browser to promote the current element to fullscreen rendering mode
  102706. * @param element defines the DOM element to promote
  102707. */
  102708. static _RequestFullscreen(element: HTMLElement): void;
  102709. /**
  102710. * Asks the browser to exit fullscreen mode
  102711. */
  102712. static _ExitFullscreen(): void;
  102713. }
  102714. }
  102715. declare module BABYLON {
  102716. /**
  102717. * The engine store class is responsible to hold all the instances of Engine and Scene created
  102718. * during the life time of the application.
  102719. */
  102720. export class EngineStore {
  102721. /** Gets the list of created engines */
  102722. static Instances: Engine[];
  102723. /** @hidden */
  102724. static _LastCreatedScene: Nullable<Scene>;
  102725. /**
  102726. * Gets the latest created engine
  102727. */
  102728. static readonly LastCreatedEngine: Nullable<Engine>;
  102729. /**
  102730. * Gets the latest created scene
  102731. */
  102732. static readonly LastCreatedScene: Nullable<Scene>;
  102733. /**
  102734. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102735. * @ignorenaming
  102736. */
  102737. static UseFallbackTexture: boolean;
  102738. /**
  102739. * Texture content used if a texture cannot loaded
  102740. * @ignorenaming
  102741. */
  102742. static FallbackTexture: string;
  102743. }
  102744. }
  102745. declare module BABYLON {
  102746. /**
  102747. * Helper class that provides a small promise polyfill
  102748. */
  102749. export class PromisePolyfill {
  102750. /**
  102751. * Static function used to check if the polyfill is required
  102752. * If this is the case then the function will inject the polyfill to window.Promise
  102753. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  102754. */
  102755. static Apply(force?: boolean): void;
  102756. }
  102757. }
  102758. declare module BABYLON {
  102759. /**
  102760. * Interface for screenshot methods with describe argument called `size` as object with options
  102761. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  102762. */
  102763. export interface IScreenshotSize {
  102764. /**
  102765. * number in pixels for canvas height
  102766. */
  102767. height?: number;
  102768. /**
  102769. * multiplier allowing render at a higher or lower resolution
  102770. * If value is defined then height and width will be ignored and taken from camera
  102771. */
  102772. precision?: number;
  102773. /**
  102774. * number in pixels for canvas width
  102775. */
  102776. width?: number;
  102777. }
  102778. }
  102779. declare module BABYLON {
  102780. interface IColor4Like {
  102781. r: float;
  102782. g: float;
  102783. b: float;
  102784. a: float;
  102785. }
  102786. /**
  102787. * Class containing a set of static utilities functions
  102788. */
  102789. export class Tools {
  102790. /**
  102791. * Gets or sets the base URL to use to load assets
  102792. */
  102793. static BaseUrl: string;
  102794. /**
  102795. * Enable/Disable Custom HTTP Request Headers globally.
  102796. * default = false
  102797. * @see CustomRequestHeaders
  102798. */
  102799. static UseCustomRequestHeaders: boolean;
  102800. /**
  102801. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  102802. * i.e. when loading files, where the server/service expects an Authorization header
  102803. */
  102804. static CustomRequestHeaders: {
  102805. [key: string]: string;
  102806. };
  102807. /**
  102808. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  102809. */
  102810. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  102811. /**
  102812. * Default behaviour for cors in the application.
  102813. * It can be a string if the expected behavior is identical in the entire app.
  102814. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  102815. */
  102816. static CorsBehavior: string | ((url: string | string[]) => string);
  102817. /**
  102818. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  102819. * @ignorenaming
  102820. */
  102821. static UseFallbackTexture: boolean;
  102822. /**
  102823. * Use this object to register external classes like custom textures or material
  102824. * to allow the laoders to instantiate them
  102825. */
  102826. static RegisteredExternalClasses: {
  102827. [key: string]: Object;
  102828. };
  102829. /**
  102830. * Texture content used if a texture cannot loaded
  102831. * @ignorenaming
  102832. */
  102833. static fallbackTexture: string;
  102834. /**
  102835. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102836. * @param u defines the coordinate on X axis
  102837. * @param v defines the coordinate on Y axis
  102838. * @param width defines the width of the source data
  102839. * @param height defines the height of the source data
  102840. * @param pixels defines the source byte array
  102841. * @param color defines the output color
  102842. */
  102843. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  102844. /**
  102845. * Interpolates between a and b via alpha
  102846. * @param a The lower value (returned when alpha = 0)
  102847. * @param b The upper value (returned when alpha = 1)
  102848. * @param alpha The interpolation-factor
  102849. * @return The mixed value
  102850. */
  102851. static Mix(a: number, b: number, alpha: number): number;
  102852. /**
  102853. * Tries to instantiate a new object from a given class name
  102854. * @param className defines the class name to instantiate
  102855. * @returns the new object or null if the system was not able to do the instantiation
  102856. */
  102857. static Instantiate(className: string): any;
  102858. /**
  102859. * Provides a slice function that will work even on IE
  102860. * @param data defines the array to slice
  102861. * @param start defines the start of the data (optional)
  102862. * @param end defines the end of the data (optional)
  102863. * @returns the new sliced array
  102864. */
  102865. static Slice<T>(data: T, start?: number, end?: number): T;
  102866. /**
  102867. * Polyfill for setImmediate
  102868. * @param action defines the action to execute after the current execution block
  102869. */
  102870. static SetImmediate(action: () => void): void;
  102871. /**
  102872. * Function indicating if a number is an exponent of 2
  102873. * @param value defines the value to test
  102874. * @returns true if the value is an exponent of 2
  102875. */
  102876. static IsExponentOfTwo(value: number): boolean;
  102877. private static _tmpFloatArray;
  102878. /**
  102879. * Returns the nearest 32-bit single precision float representation of a Number
  102880. * @param value A Number. If the parameter is of a different type, it will get converted
  102881. * to a number or to NaN if it cannot be converted
  102882. * @returns number
  102883. */
  102884. static FloatRound(value: number): number;
  102885. /**
  102886. * Extracts the filename from a path
  102887. * @param path defines the path to use
  102888. * @returns the filename
  102889. */
  102890. static GetFilename(path: string): string;
  102891. /**
  102892. * Extracts the "folder" part of a path (everything before the filename).
  102893. * @param uri The URI to extract the info from
  102894. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102895. * @returns The "folder" part of the path
  102896. */
  102897. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  102898. /**
  102899. * Extracts text content from a DOM element hierarchy
  102900. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  102901. */
  102902. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  102903. /**
  102904. * Convert an angle in radians to degrees
  102905. * @param angle defines the angle to convert
  102906. * @returns the angle in degrees
  102907. */
  102908. static ToDegrees(angle: number): number;
  102909. /**
  102910. * Convert an angle in degrees to radians
  102911. * @param angle defines the angle to convert
  102912. * @returns the angle in radians
  102913. */
  102914. static ToRadians(angle: number): number;
  102915. /**
  102916. * Returns an array if obj is not an array
  102917. * @param obj defines the object to evaluate as an array
  102918. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  102919. * @returns either obj directly if obj is an array or a new array containing obj
  102920. */
  102921. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  102922. /**
  102923. * Gets the pointer prefix to use
  102924. * @returns "pointer" if touch is enabled. Else returns "mouse"
  102925. */
  102926. static GetPointerPrefix(): string;
  102927. /**
  102928. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  102929. * @param url define the url we are trying
  102930. * @param element define the dom element where to configure the cors policy
  102931. */
  102932. static SetCorsBehavior(url: string | string[], element: {
  102933. crossOrigin: string | null;
  102934. }): void;
  102935. /**
  102936. * Removes unwanted characters from an url
  102937. * @param url defines the url to clean
  102938. * @returns the cleaned url
  102939. */
  102940. static CleanUrl(url: string): string;
  102941. /**
  102942. * Gets or sets a function used to pre-process url before using them to load assets
  102943. */
  102944. static PreprocessUrl: (url: string) => string;
  102945. /**
  102946. * Loads an image as an HTMLImageElement.
  102947. * @param input url string, ArrayBuffer, or Blob to load
  102948. * @param onLoad callback called when the image successfully loads
  102949. * @param onError callback called when the image fails to load
  102950. * @param offlineProvider offline provider for caching
  102951. * @param mimeType optional mime type
  102952. * @returns the HTMLImageElement of the loaded image
  102953. */
  102954. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102955. /**
  102956. * Loads a file from a url
  102957. * @param url url string, ArrayBuffer, or Blob to load
  102958. * @param onSuccess callback called when the file successfully loads
  102959. * @param onProgress callback called while file is loading (if the server supports this mode)
  102960. * @param offlineProvider defines the offline provider for caching
  102961. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102962. * @param onError callback called when the file fails to load
  102963. * @returns a file request object
  102964. */
  102965. 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;
  102966. /**
  102967. * Loads a file from a url
  102968. * @param url the file url to load
  102969. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  102970. */
  102971. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  102972. /**
  102973. * Load a script (identified by an url). When the url returns, the
  102974. * content of this file is added into a new script element, attached to the DOM (body element)
  102975. * @param scriptUrl defines the url of the script to laod
  102976. * @param onSuccess defines the callback called when the script is loaded
  102977. * @param onError defines the callback to call if an error occurs
  102978. * @param scriptId defines the id of the script element
  102979. */
  102980. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  102981. /**
  102982. * Load an asynchronous script (identified by an url). When the url returns, the
  102983. * content of this file is added into a new script element, attached to the DOM (body element)
  102984. * @param scriptUrl defines the url of the script to laod
  102985. * @param scriptId defines the id of the script element
  102986. * @returns a promise request object
  102987. */
  102988. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  102989. /**
  102990. * Loads a file from a blob
  102991. * @param fileToLoad defines the blob to use
  102992. * @param callback defines the callback to call when data is loaded
  102993. * @param progressCallback defines the callback to call during loading process
  102994. * @returns a file request object
  102995. */
  102996. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  102997. /**
  102998. * Reads a file from a File object
  102999. * @param file defines the file to load
  103000. * @param onSuccess defines the callback to call when data is loaded
  103001. * @param onProgress defines the callback to call during loading process
  103002. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  103003. * @param onError defines the callback to call when an error occurs
  103004. * @returns a file request object
  103005. */
  103006. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103007. /**
  103008. * Creates a data url from a given string content
  103009. * @param content defines the content to convert
  103010. * @returns the new data url link
  103011. */
  103012. static FileAsURL(content: string): string;
  103013. /**
  103014. * Format the given number to a specific decimal format
  103015. * @param value defines the number to format
  103016. * @param decimals defines the number of decimals to use
  103017. * @returns the formatted string
  103018. */
  103019. static Format(value: number, decimals?: number): string;
  103020. /**
  103021. * Tries to copy an object by duplicating every property
  103022. * @param source defines the source object
  103023. * @param destination defines the target object
  103024. * @param doNotCopyList defines a list of properties to avoid
  103025. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  103026. */
  103027. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  103028. /**
  103029. * Gets a boolean indicating if the given object has no own property
  103030. * @param obj defines the object to test
  103031. * @returns true if object has no own property
  103032. */
  103033. static IsEmpty(obj: any): boolean;
  103034. /**
  103035. * Function used to register events at window level
  103036. * @param windowElement defines the Window object to use
  103037. * @param events defines the events to register
  103038. */
  103039. static RegisterTopRootEvents(windowElement: Window, events: {
  103040. name: string;
  103041. handler: Nullable<(e: FocusEvent) => any>;
  103042. }[]): void;
  103043. /**
  103044. * Function used to unregister events from window level
  103045. * @param windowElement defines the Window object to use
  103046. * @param events defines the events to unregister
  103047. */
  103048. static UnregisterTopRootEvents(windowElement: Window, events: {
  103049. name: string;
  103050. handler: Nullable<(e: FocusEvent) => any>;
  103051. }[]): void;
  103052. /**
  103053. * @ignore
  103054. */
  103055. static _ScreenshotCanvas: HTMLCanvasElement;
  103056. /**
  103057. * Dumps the current bound framebuffer
  103058. * @param width defines the rendering width
  103059. * @param height defines the rendering height
  103060. * @param engine defines the hosting engine
  103061. * @param successCallback defines the callback triggered once the data are available
  103062. * @param mimeType defines the mime type of the result
  103063. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  103064. */
  103065. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  103066. /**
  103067. * Converts the canvas data to blob.
  103068. * This acts as a polyfill for browsers not supporting the to blob function.
  103069. * @param canvas Defines the canvas to extract the data from
  103070. * @param successCallback Defines the callback triggered once the data are available
  103071. * @param mimeType Defines the mime type of the result
  103072. */
  103073. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  103074. /**
  103075. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  103076. * @param successCallback defines the callback triggered once the data are available
  103077. * @param mimeType defines the mime type of the result
  103078. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  103079. */
  103080. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  103081. /**
  103082. * Downloads a blob in the browser
  103083. * @param blob defines the blob to download
  103084. * @param fileName defines the name of the downloaded file
  103085. */
  103086. static Download(blob: Blob, fileName: string): void;
  103087. /**
  103088. * Captures a screenshot of the current rendering
  103089. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103090. * @param engine defines the rendering engine
  103091. * @param camera defines the source camera
  103092. * @param size This parameter can be set to a single number or to an object with the
  103093. * following (optional) properties: precision, width, height. If a single number is passed,
  103094. * it will be used for both width and height. If an object is passed, the screenshot size
  103095. * will be derived from the parameters. The precision property is a multiplier allowing
  103096. * rendering at a higher or lower resolution
  103097. * @param successCallback defines the callback receives a single parameter which contains the
  103098. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103099. * src parameter of an <img> to display it
  103100. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103101. * Check your browser for supported MIME types
  103102. */
  103103. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  103104. /**
  103105. * Captures a screenshot of the current rendering
  103106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103107. * @param engine defines the rendering engine
  103108. * @param camera defines the source camera
  103109. * @param size This parameter can be set to a single number or to an object with the
  103110. * following (optional) properties: precision, width, height. If a single number is passed,
  103111. * it will be used for both width and height. If an object is passed, the screenshot size
  103112. * will be derived from the parameters. The precision property is a multiplier allowing
  103113. * rendering at a higher or lower resolution
  103114. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103115. * Check your browser for supported MIME types
  103116. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  103117. * to the src parameter of an <img> to display it
  103118. */
  103119. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  103120. /**
  103121. * Generates an image screenshot from the specified camera.
  103122. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103123. * @param engine The engine to use for rendering
  103124. * @param camera The camera to use for rendering
  103125. * @param size This parameter can be set to a single number or to an object with the
  103126. * following (optional) properties: precision, width, height. If a single number is passed,
  103127. * it will be used for both width and height. If an object is passed, the screenshot size
  103128. * will be derived from the parameters. The precision property is a multiplier allowing
  103129. * rendering at a higher or lower resolution
  103130. * @param successCallback The callback receives a single parameter which contains the
  103131. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103132. * src parameter of an <img> to display it
  103133. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103134. * Check your browser for supported MIME types
  103135. * @param samples Texture samples (default: 1)
  103136. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103137. * @param fileName A name for for the downloaded file.
  103138. */
  103139. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  103140. /**
  103141. * Generates an image screenshot from the specified camera.
  103142. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103143. * @param engine The engine to use for rendering
  103144. * @param camera The camera to use for rendering
  103145. * @param size This parameter can be set to a single number or to an object with the
  103146. * following (optional) properties: precision, width, height. If a single number is passed,
  103147. * it will be used for both width and height. If an object is passed, the screenshot size
  103148. * will be derived from the parameters. The precision property is a multiplier allowing
  103149. * rendering at a higher or lower resolution
  103150. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103151. * Check your browser for supported MIME types
  103152. * @param samples Texture samples (default: 1)
  103153. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103154. * @param fileName A name for for the downloaded file.
  103155. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  103156. * to the src parameter of an <img> to display it
  103157. */
  103158. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  103159. /**
  103160. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103161. * Be aware Math.random() could cause collisions, but:
  103162. * "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"
  103163. * @returns a pseudo random id
  103164. */
  103165. static RandomId(): string;
  103166. /**
  103167. * Test if the given uri is a base64 string
  103168. * @param uri The uri to test
  103169. * @return True if the uri is a base64 string or false otherwise
  103170. */
  103171. static IsBase64(uri: string): boolean;
  103172. /**
  103173. * Decode the given base64 uri.
  103174. * @param uri The uri to decode
  103175. * @return The decoded base64 data.
  103176. */
  103177. static DecodeBase64(uri: string): ArrayBuffer;
  103178. /**
  103179. * Gets the absolute url.
  103180. * @param url the input url
  103181. * @return the absolute url
  103182. */
  103183. static GetAbsoluteUrl(url: string): string;
  103184. /**
  103185. * No log
  103186. */
  103187. static readonly NoneLogLevel: number;
  103188. /**
  103189. * Only message logs
  103190. */
  103191. static readonly MessageLogLevel: number;
  103192. /**
  103193. * Only warning logs
  103194. */
  103195. static readonly WarningLogLevel: number;
  103196. /**
  103197. * Only error logs
  103198. */
  103199. static readonly ErrorLogLevel: number;
  103200. /**
  103201. * All logs
  103202. */
  103203. static readonly AllLogLevel: number;
  103204. /**
  103205. * Gets a value indicating the number of loading errors
  103206. * @ignorenaming
  103207. */
  103208. static readonly errorsCount: number;
  103209. /**
  103210. * Callback called when a new log is added
  103211. */
  103212. static OnNewCacheEntry: (entry: string) => void;
  103213. /**
  103214. * Log a message to the console
  103215. * @param message defines the message to log
  103216. */
  103217. static Log(message: string): void;
  103218. /**
  103219. * Write a warning message to the console
  103220. * @param message defines the message to log
  103221. */
  103222. static Warn(message: string): void;
  103223. /**
  103224. * Write an error message to the console
  103225. * @param message defines the message to log
  103226. */
  103227. static Error(message: string): void;
  103228. /**
  103229. * Gets current log cache (list of logs)
  103230. */
  103231. static readonly LogCache: string;
  103232. /**
  103233. * Clears the log cache
  103234. */
  103235. static ClearLogCache(): void;
  103236. /**
  103237. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  103238. */
  103239. static LogLevels: number;
  103240. /**
  103241. * Checks if the window object exists
  103242. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  103243. */
  103244. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  103245. /**
  103246. * No performance log
  103247. */
  103248. static readonly PerformanceNoneLogLevel: number;
  103249. /**
  103250. * Use user marks to log performance
  103251. */
  103252. static readonly PerformanceUserMarkLogLevel: number;
  103253. /**
  103254. * Log performance to the console
  103255. */
  103256. static readonly PerformanceConsoleLogLevel: number;
  103257. private static _performance;
  103258. /**
  103259. * Sets the current performance log level
  103260. */
  103261. static PerformanceLogLevel: number;
  103262. private static _StartPerformanceCounterDisabled;
  103263. private static _EndPerformanceCounterDisabled;
  103264. private static _StartUserMark;
  103265. private static _EndUserMark;
  103266. private static _StartPerformanceConsole;
  103267. private static _EndPerformanceConsole;
  103268. /**
  103269. * Starts a performance counter
  103270. */
  103271. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103272. /**
  103273. * Ends a specific performance coutner
  103274. */
  103275. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  103276. /**
  103277. * Gets either window.performance.now() if supported or Date.now() else
  103278. */
  103279. static readonly Now: number;
  103280. /**
  103281. * This method will return the name of the class used to create the instance of the given object.
  103282. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  103283. * @param object the object to get the class name from
  103284. * @param isType defines if the object is actually a type
  103285. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  103286. */
  103287. static GetClassName(object: any, isType?: boolean): string;
  103288. /**
  103289. * Gets the first element of an array satisfying a given predicate
  103290. * @param array defines the array to browse
  103291. * @param predicate defines the predicate to use
  103292. * @returns null if not found or the element
  103293. */
  103294. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  103295. /**
  103296. * This method will return the name of the full name of the class, including its owning module (if any).
  103297. * 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).
  103298. * @param object the object to get the class name from
  103299. * @param isType defines if the object is actually a type
  103300. * @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.
  103301. * @ignorenaming
  103302. */
  103303. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  103304. /**
  103305. * Returns a promise that resolves after the given amount of time.
  103306. * @param delay Number of milliseconds to delay
  103307. * @returns Promise that resolves after the given amount of time
  103308. */
  103309. static DelayAsync(delay: number): Promise<void>;
  103310. }
  103311. /**
  103312. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  103313. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  103314. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  103315. * @param name The name of the class, case should be preserved
  103316. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  103317. */
  103318. export function className(name: string, module?: string): (target: Object) => void;
  103319. /**
  103320. * An implementation of a loop for asynchronous functions.
  103321. */
  103322. export class AsyncLoop {
  103323. /**
  103324. * Defines the number of iterations for the loop
  103325. */
  103326. iterations: number;
  103327. /**
  103328. * Defines the current index of the loop.
  103329. */
  103330. index: number;
  103331. private _done;
  103332. private _fn;
  103333. private _successCallback;
  103334. /**
  103335. * Constructor.
  103336. * @param iterations the number of iterations.
  103337. * @param func the function to run each iteration
  103338. * @param successCallback the callback that will be called upon succesful execution
  103339. * @param offset starting offset.
  103340. */
  103341. constructor(
  103342. /**
  103343. * Defines the number of iterations for the loop
  103344. */
  103345. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  103346. /**
  103347. * Execute the next iteration. Must be called after the last iteration was finished.
  103348. */
  103349. executeNext(): void;
  103350. /**
  103351. * Break the loop and run the success callback.
  103352. */
  103353. breakLoop(): void;
  103354. /**
  103355. * Create and run an async loop.
  103356. * @param iterations the number of iterations.
  103357. * @param fn the function to run each iteration
  103358. * @param successCallback the callback that will be called upon succesful execution
  103359. * @param offset starting offset.
  103360. * @returns the created async loop object
  103361. */
  103362. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  103363. /**
  103364. * A for-loop that will run a given number of iterations synchronous and the rest async.
  103365. * @param iterations total number of iterations
  103366. * @param syncedIterations number of synchronous iterations in each async iteration.
  103367. * @param fn the function to call each iteration.
  103368. * @param callback a success call back that will be called when iterating stops.
  103369. * @param breakFunction a break condition (optional)
  103370. * @param timeout timeout settings for the setTimeout function. default - 0.
  103371. * @returns the created async loop object
  103372. */
  103373. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  103374. }
  103375. }
  103376. declare module BABYLON {
  103377. /**
  103378. * This class implement a typical dictionary using a string as key and the generic type T as value.
  103379. * The underlying implementation relies on an associative array to ensure the best performances.
  103380. * The value can be anything including 'null' but except 'undefined'
  103381. */
  103382. export class StringDictionary<T> {
  103383. /**
  103384. * This will clear this dictionary and copy the content from the 'source' one.
  103385. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  103386. * @param source the dictionary to take the content from and copy to this dictionary
  103387. */
  103388. copyFrom(source: StringDictionary<T>): void;
  103389. /**
  103390. * Get a value based from its key
  103391. * @param key the given key to get the matching value from
  103392. * @return the value if found, otherwise undefined is returned
  103393. */
  103394. get(key: string): T | undefined;
  103395. /**
  103396. * Get a value from its key or add it if it doesn't exist.
  103397. * This method will ensure you that a given key/data will be present in the dictionary.
  103398. * @param key the given key to get the matching value from
  103399. * @param factory the factory that will create the value if the key is not present in the dictionary.
  103400. * The factory will only be invoked if there's no data for the given key.
  103401. * @return the value corresponding to the key.
  103402. */
  103403. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  103404. /**
  103405. * Get a value from its key if present in the dictionary otherwise add it
  103406. * @param key the key to get the value from
  103407. * @param val if there's no such key/value pair in the dictionary add it with this value
  103408. * @return the value corresponding to the key
  103409. */
  103410. getOrAdd(key: string, val: T): T;
  103411. /**
  103412. * Check if there's a given key in the dictionary
  103413. * @param key the key to check for
  103414. * @return true if the key is present, false otherwise
  103415. */
  103416. contains(key: string): boolean;
  103417. /**
  103418. * Add a new key and its corresponding value
  103419. * @param key the key to add
  103420. * @param value the value corresponding to the key
  103421. * @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
  103422. */
  103423. add(key: string, value: T): boolean;
  103424. /**
  103425. * Update a specific value associated to a key
  103426. * @param key defines the key to use
  103427. * @param value defines the value to store
  103428. * @returns true if the value was updated (or false if the key was not found)
  103429. */
  103430. set(key: string, value: T): boolean;
  103431. /**
  103432. * Get the element of the given key and remove it from the dictionary
  103433. * @param key defines the key to search
  103434. * @returns the value associated with the key or null if not found
  103435. */
  103436. getAndRemove(key: string): Nullable<T>;
  103437. /**
  103438. * Remove a key/value from the dictionary.
  103439. * @param key the key to remove
  103440. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  103441. */
  103442. remove(key: string): boolean;
  103443. /**
  103444. * Clear the whole content of the dictionary
  103445. */
  103446. clear(): void;
  103447. /**
  103448. * Gets the current count
  103449. */
  103450. readonly count: number;
  103451. /**
  103452. * Execute a callback on each key/val of the dictionary.
  103453. * Note that you can remove any element in this dictionary in the callback implementation
  103454. * @param callback the callback to execute on a given key/value pair
  103455. */
  103456. forEach(callback: (key: string, val: T) => void): void;
  103457. /**
  103458. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  103459. * If the callback returns null or undefined the method will iterate to the next key/value pair
  103460. * Note that you can remove any element in this dictionary in the callback implementation
  103461. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  103462. * @returns the first item
  103463. */
  103464. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  103465. private _count;
  103466. private _data;
  103467. }
  103468. }
  103469. declare module BABYLON {
  103470. /** @hidden */
  103471. export interface ICollisionCoordinator {
  103472. createCollider(): Collider;
  103473. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103474. init(scene: Scene): void;
  103475. }
  103476. /** @hidden */
  103477. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  103478. private _scene;
  103479. private _scaledPosition;
  103480. private _scaledVelocity;
  103481. private _finalPosition;
  103482. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  103483. createCollider(): Collider;
  103484. init(scene: Scene): void;
  103485. private _collideWithWorld;
  103486. }
  103487. }
  103488. declare module BABYLON {
  103489. /**
  103490. * Class used to manage all inputs for the scene.
  103491. */
  103492. export class InputManager {
  103493. /** The distance in pixel that you have to move to prevent some events */
  103494. static DragMovementThreshold: number;
  103495. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  103496. static LongPressDelay: number;
  103497. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  103498. static DoubleClickDelay: number;
  103499. /** If you need to check double click without raising a single click at first click, enable this flag */
  103500. static ExclusiveDoubleClickMode: boolean;
  103501. private _wheelEventName;
  103502. private _onPointerMove;
  103503. private _onPointerDown;
  103504. private _onPointerUp;
  103505. private _initClickEvent;
  103506. private _initActionManager;
  103507. private _delayedSimpleClick;
  103508. private _delayedSimpleClickTimeout;
  103509. private _previousDelayedSimpleClickTimeout;
  103510. private _meshPickProceed;
  103511. private _previousButtonPressed;
  103512. private _currentPickResult;
  103513. private _previousPickResult;
  103514. private _totalPointersPressed;
  103515. private _doubleClickOccured;
  103516. private _pointerOverMesh;
  103517. private _pickedDownMesh;
  103518. private _pickedUpMesh;
  103519. private _pointerX;
  103520. private _pointerY;
  103521. private _unTranslatedPointerX;
  103522. private _unTranslatedPointerY;
  103523. private _startingPointerPosition;
  103524. private _previousStartingPointerPosition;
  103525. private _startingPointerTime;
  103526. private _previousStartingPointerTime;
  103527. private _pointerCaptures;
  103528. private _onKeyDown;
  103529. private _onKeyUp;
  103530. private _onCanvasFocusObserver;
  103531. private _onCanvasBlurObserver;
  103532. private _scene;
  103533. /**
  103534. * Creates a new InputManager
  103535. * @param scene defines the hosting scene
  103536. */
  103537. constructor(scene: Scene);
  103538. /**
  103539. * Gets the mesh that is currently under the pointer
  103540. */
  103541. readonly meshUnderPointer: Nullable<AbstractMesh>;
  103542. /**
  103543. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  103544. */
  103545. readonly unTranslatedPointer: Vector2;
  103546. /**
  103547. * Gets or sets the current on-screen X position of the pointer
  103548. */
  103549. pointerX: number;
  103550. /**
  103551. * Gets or sets the current on-screen Y position of the pointer
  103552. */
  103553. pointerY: number;
  103554. private _updatePointerPosition;
  103555. private _processPointerMove;
  103556. private _setRayOnPointerInfo;
  103557. private _checkPrePointerObservable;
  103558. /**
  103559. * Use this method to simulate a pointer move on a mesh
  103560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103563. */
  103564. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103565. /**
  103566. * Use this method to simulate a pointer down on a mesh
  103567. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103568. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103569. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103570. */
  103571. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  103572. private _processPointerDown;
  103573. /** @hidden */
  103574. _isPointerSwiping(): boolean;
  103575. /**
  103576. * Use this method to simulate a pointer up on a mesh
  103577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  103578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  103579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  103580. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  103581. */
  103582. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  103583. private _processPointerUp;
  103584. /**
  103585. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  103586. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  103587. * @returns true if the pointer was captured
  103588. */
  103589. isPointerCaptured(pointerId?: number): boolean;
  103590. /**
  103591. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  103592. * @param attachUp defines if you want to attach events to pointerup
  103593. * @param attachDown defines if you want to attach events to pointerdown
  103594. * @param attachMove defines if you want to attach events to pointermove
  103595. */
  103596. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  103597. /**
  103598. * Detaches all event handlers
  103599. */
  103600. detachControl(): void;
  103601. /**
  103602. * Force the value of meshUnderPointer
  103603. * @param mesh defines the mesh to use
  103604. */
  103605. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103606. /**
  103607. * Gets the mesh under the pointer
  103608. * @returns a Mesh or null if no mesh is under the pointer
  103609. */
  103610. getPointerOverMesh(): Nullable<AbstractMesh>;
  103611. }
  103612. }
  103613. declare module BABYLON {
  103614. /**
  103615. * Helper class used to generate session unique ID
  103616. */
  103617. export class UniqueIdGenerator {
  103618. private static _UniqueIdCounter;
  103619. /**
  103620. * Gets an unique (relatively to the current scene) Id
  103621. */
  103622. static readonly UniqueId: number;
  103623. }
  103624. }
  103625. declare module BABYLON {
  103626. /**
  103627. * This class defines the direct association between an animation and a target
  103628. */
  103629. export class TargetedAnimation {
  103630. /**
  103631. * Animation to perform
  103632. */
  103633. animation: Animation;
  103634. /**
  103635. * Target to animate
  103636. */
  103637. target: any;
  103638. /**
  103639. * Serialize the object
  103640. * @returns the JSON object representing the current entity
  103641. */
  103642. serialize(): any;
  103643. }
  103644. /**
  103645. * Use this class to create coordinated animations on multiple targets
  103646. */
  103647. export class AnimationGroup implements IDisposable {
  103648. /** The name of the animation group */
  103649. name: string;
  103650. private _scene;
  103651. private _targetedAnimations;
  103652. private _animatables;
  103653. private _from;
  103654. private _to;
  103655. private _isStarted;
  103656. private _isPaused;
  103657. private _speedRatio;
  103658. private _loopAnimation;
  103659. /**
  103660. * Gets or sets the unique id of the node
  103661. */
  103662. uniqueId: number;
  103663. /**
  103664. * This observable will notify when one animation have ended
  103665. */
  103666. onAnimationEndObservable: Observable<TargetedAnimation>;
  103667. /**
  103668. * Observer raised when one animation loops
  103669. */
  103670. onAnimationLoopObservable: Observable<TargetedAnimation>;
  103671. /**
  103672. * Observer raised when all animations have looped
  103673. */
  103674. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  103675. /**
  103676. * This observable will notify when all animations have ended.
  103677. */
  103678. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  103679. /**
  103680. * This observable will notify when all animations have paused.
  103681. */
  103682. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  103683. /**
  103684. * This observable will notify when all animations are playing.
  103685. */
  103686. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  103687. /**
  103688. * Gets the first frame
  103689. */
  103690. readonly from: number;
  103691. /**
  103692. * Gets the last frame
  103693. */
  103694. readonly to: number;
  103695. /**
  103696. * Define if the animations are started
  103697. */
  103698. readonly isStarted: boolean;
  103699. /**
  103700. * Gets a value indicating that the current group is playing
  103701. */
  103702. readonly isPlaying: boolean;
  103703. /**
  103704. * Gets or sets the speed ratio to use for all animations
  103705. */
  103706. /**
  103707. * Gets or sets the speed ratio to use for all animations
  103708. */
  103709. speedRatio: number;
  103710. /**
  103711. * Gets or sets if all animations should loop or not
  103712. */
  103713. loopAnimation: boolean;
  103714. /**
  103715. * Gets the targeted animations for this animation group
  103716. */
  103717. readonly targetedAnimations: Array<TargetedAnimation>;
  103718. /**
  103719. * returning the list of animatables controlled by this animation group.
  103720. */
  103721. readonly animatables: Array<Animatable>;
  103722. /**
  103723. * Instantiates a new Animation Group.
  103724. * This helps managing several animations at once.
  103725. * @see http://doc.babylonjs.com/how_to/group
  103726. * @param name Defines the name of the group
  103727. * @param scene Defines the scene the group belongs to
  103728. */
  103729. constructor(
  103730. /** The name of the animation group */
  103731. name: string, scene?: Nullable<Scene>);
  103732. /**
  103733. * Add an animation (with its target) in the group
  103734. * @param animation defines the animation we want to add
  103735. * @param target defines the target of the animation
  103736. * @returns the TargetedAnimation object
  103737. */
  103738. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  103739. /**
  103740. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  103741. * It can add constant keys at begin or end
  103742. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  103743. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  103744. * @returns the animation group
  103745. */
  103746. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  103747. private _animationLoopCount;
  103748. private _animationLoopFlags;
  103749. private _processLoop;
  103750. /**
  103751. * Start all animations on given targets
  103752. * @param loop defines if animations must loop
  103753. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  103754. * @param from defines the from key (optional)
  103755. * @param to defines the to key (optional)
  103756. * @returns the current animation group
  103757. */
  103758. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  103759. /**
  103760. * Pause all animations
  103761. * @returns the animation group
  103762. */
  103763. pause(): AnimationGroup;
  103764. /**
  103765. * Play all animations to initial state
  103766. * This function will start() the animations if they were not started or will restart() them if they were paused
  103767. * @param loop defines if animations must loop
  103768. * @returns the animation group
  103769. */
  103770. play(loop?: boolean): AnimationGroup;
  103771. /**
  103772. * Reset all animations to initial state
  103773. * @returns the animation group
  103774. */
  103775. reset(): AnimationGroup;
  103776. /**
  103777. * Restart animations from key 0
  103778. * @returns the animation group
  103779. */
  103780. restart(): AnimationGroup;
  103781. /**
  103782. * Stop all animations
  103783. * @returns the animation group
  103784. */
  103785. stop(): AnimationGroup;
  103786. /**
  103787. * Set animation weight for all animatables
  103788. * @param weight defines the weight to use
  103789. * @return the animationGroup
  103790. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103791. */
  103792. setWeightForAllAnimatables(weight: number): AnimationGroup;
  103793. /**
  103794. * Synchronize and normalize all animatables with a source animatable
  103795. * @param root defines the root animatable to synchronize with
  103796. * @return the animationGroup
  103797. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  103798. */
  103799. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  103800. /**
  103801. * Goes to a specific frame in this animation group
  103802. * @param frame the frame number to go to
  103803. * @return the animationGroup
  103804. */
  103805. goToFrame(frame: number): AnimationGroup;
  103806. /**
  103807. * Dispose all associated resources
  103808. */
  103809. dispose(): void;
  103810. private _checkAnimationGroupEnded;
  103811. /**
  103812. * Clone the current animation group and returns a copy
  103813. * @param newName defines the name of the new group
  103814. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  103815. * @returns the new aniamtion group
  103816. */
  103817. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  103818. /**
  103819. * Serializes the animationGroup to an object
  103820. * @returns Serialized object
  103821. */
  103822. serialize(): any;
  103823. /**
  103824. * Returns a new AnimationGroup object parsed from the source provided.
  103825. * @param parsedAnimationGroup defines the source
  103826. * @param scene defines the scene that will receive the animationGroup
  103827. * @returns a new AnimationGroup
  103828. */
  103829. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  103830. /**
  103831. * Returns the string "AnimationGroup"
  103832. * @returns "AnimationGroup"
  103833. */
  103834. getClassName(): string;
  103835. /**
  103836. * Creates a detailled string about the object
  103837. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  103838. * @returns a string representing the object
  103839. */
  103840. toString(fullDetails?: boolean): string;
  103841. }
  103842. }
  103843. declare module BABYLON {
  103844. /**
  103845. * Define an interface for all classes that will hold resources
  103846. */
  103847. export interface IDisposable {
  103848. /**
  103849. * Releases all held resources
  103850. */
  103851. dispose(): void;
  103852. }
  103853. /** Interface defining initialization parameters for Scene class */
  103854. export interface SceneOptions {
  103855. /**
  103856. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  103857. * It will improve performance when the number of geometries becomes important.
  103858. */
  103859. useGeometryUniqueIdsMap?: boolean;
  103860. /**
  103861. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  103862. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103863. */
  103864. useMaterialMeshMap?: boolean;
  103865. /**
  103866. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  103867. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  103868. */
  103869. useClonedMeshhMap?: boolean;
  103870. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  103871. virtual?: boolean;
  103872. }
  103873. /**
  103874. * Represents a scene to be rendered by the engine.
  103875. * @see http://doc.babylonjs.com/features/scene
  103876. */
  103877. export class Scene extends AbstractScene implements IAnimatable {
  103878. /** The fog is deactivated */
  103879. static readonly FOGMODE_NONE: number;
  103880. /** The fog density is following an exponential function */
  103881. static readonly FOGMODE_EXP: number;
  103882. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  103883. static readonly FOGMODE_EXP2: number;
  103884. /** The fog density is following a linear function. */
  103885. static readonly FOGMODE_LINEAR: number;
  103886. /**
  103887. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  103888. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103889. */
  103890. static MinDeltaTime: number;
  103891. /**
  103892. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  103893. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103894. */
  103895. static MaxDeltaTime: number;
  103896. /**
  103897. * Factory used to create the default material.
  103898. * @param name The name of the material to create
  103899. * @param scene The scene to create the material for
  103900. * @returns The default material
  103901. */
  103902. static DefaultMaterialFactory(scene: Scene): Material;
  103903. /**
  103904. * Factory used to create the a collision coordinator.
  103905. * @returns The collision coordinator
  103906. */
  103907. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  103908. /** @hidden */
  103909. _inputManager: InputManager;
  103910. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  103911. cameraToUseForPointers: Nullable<Camera>;
  103912. /** @hidden */
  103913. readonly _isScene: boolean;
  103914. /**
  103915. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  103916. */
  103917. autoClear: boolean;
  103918. /**
  103919. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  103920. */
  103921. autoClearDepthAndStencil: boolean;
  103922. /**
  103923. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  103924. */
  103925. clearColor: Color4;
  103926. /**
  103927. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  103928. */
  103929. ambientColor: Color3;
  103930. /**
  103931. * This is use to store the default BRDF lookup for PBR materials in your scene.
  103932. * It should only be one of the following (if not the default embedded one):
  103933. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103934. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  103935. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103936. * The material properties need to be setup according to the type of texture in use.
  103937. */
  103938. environmentBRDFTexture: BaseTexture;
  103939. /** @hidden */
  103940. protected _environmentTexture: Nullable<BaseTexture>;
  103941. /**
  103942. * Texture used in all pbr material as the reflection texture.
  103943. * As in the majority of the scene they are the same (exception for multi room and so on),
  103944. * this is easier to reference from here than from all the materials.
  103945. */
  103946. /**
  103947. * Texture used in all pbr material as the reflection texture.
  103948. * As in the majority of the scene they are the same (exception for multi room and so on),
  103949. * this is easier to set here than in all the materials.
  103950. */
  103951. environmentTexture: Nullable<BaseTexture>;
  103952. /** @hidden */
  103953. protected _environmentIntensity: number;
  103954. /**
  103955. * Intensity of the environment in all pbr material.
  103956. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103957. * As in the majority of the scene they are the same (exception for multi room and so on),
  103958. * this is easier to reference from here than from all the materials.
  103959. */
  103960. /**
  103961. * Intensity of the environment in all pbr material.
  103962. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  103963. * As in the majority of the scene they are the same (exception for multi room and so on),
  103964. * this is easier to set here than in all the materials.
  103965. */
  103966. environmentIntensity: number;
  103967. /** @hidden */
  103968. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103969. /**
  103970. * Default image processing configuration used either in the rendering
  103971. * Forward main pass or through the imageProcessingPostProcess if present.
  103972. * As in the majority of the scene they are the same (exception for multi camera),
  103973. * this is easier to reference from here than from all the materials and post process.
  103974. *
  103975. * No setter as we it is a shared configuration, you can set the values instead.
  103976. */
  103977. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  103978. private _forceWireframe;
  103979. /**
  103980. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  103981. */
  103982. forceWireframe: boolean;
  103983. private _forcePointsCloud;
  103984. /**
  103985. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  103986. */
  103987. forcePointsCloud: boolean;
  103988. /**
  103989. * Gets or sets the active clipplane 1
  103990. */
  103991. clipPlane: Nullable<Plane>;
  103992. /**
  103993. * Gets or sets the active clipplane 2
  103994. */
  103995. clipPlane2: Nullable<Plane>;
  103996. /**
  103997. * Gets or sets the active clipplane 3
  103998. */
  103999. clipPlane3: Nullable<Plane>;
  104000. /**
  104001. * Gets or sets the active clipplane 4
  104002. */
  104003. clipPlane4: Nullable<Plane>;
  104004. /**
  104005. * Gets or sets a boolean indicating if animations are enabled
  104006. */
  104007. animationsEnabled: boolean;
  104008. private _animationPropertiesOverride;
  104009. /**
  104010. * Gets or sets the animation properties override
  104011. */
  104012. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  104013. /**
  104014. * Gets or sets a boolean indicating if a constant deltatime has to be used
  104015. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  104016. */
  104017. useConstantAnimationDeltaTime: boolean;
  104018. /**
  104019. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  104020. * Please note that it requires to run a ray cast through the scene on every frame
  104021. */
  104022. constantlyUpdateMeshUnderPointer: boolean;
  104023. /**
  104024. * Defines the HTML cursor to use when hovering over interactive elements
  104025. */
  104026. hoverCursor: string;
  104027. /**
  104028. * Defines the HTML default cursor to use (empty by default)
  104029. */
  104030. defaultCursor: string;
  104031. /**
  104032. * Defines wether cursors are handled by the scene.
  104033. */
  104034. doNotHandleCursors: boolean;
  104035. /**
  104036. * This is used to call preventDefault() on pointer down
  104037. * in order to block unwanted artifacts like system double clicks
  104038. */
  104039. preventDefaultOnPointerDown: boolean;
  104040. /**
  104041. * This is used to call preventDefault() on pointer up
  104042. * in order to block unwanted artifacts like system double clicks
  104043. */
  104044. preventDefaultOnPointerUp: boolean;
  104045. /**
  104046. * Gets or sets user defined metadata
  104047. */
  104048. metadata: any;
  104049. /**
  104050. * For internal use only. Please do not use.
  104051. */
  104052. reservedDataStore: any;
  104053. /**
  104054. * Gets the name of the plugin used to load this scene (null by default)
  104055. */
  104056. loadingPluginName: string;
  104057. /**
  104058. * Use this array to add regular expressions used to disable offline support for specific urls
  104059. */
  104060. disableOfflineSupportExceptionRules: RegExp[];
  104061. /**
  104062. * An event triggered when the scene is disposed.
  104063. */
  104064. onDisposeObservable: Observable<Scene>;
  104065. private _onDisposeObserver;
  104066. /** Sets a function to be executed when this scene is disposed. */
  104067. onDispose: () => void;
  104068. /**
  104069. * An event triggered before rendering the scene (right after animations and physics)
  104070. */
  104071. onBeforeRenderObservable: Observable<Scene>;
  104072. private _onBeforeRenderObserver;
  104073. /** Sets a function to be executed before rendering this scene */
  104074. beforeRender: Nullable<() => void>;
  104075. /**
  104076. * An event triggered after rendering the scene
  104077. */
  104078. onAfterRenderObservable: Observable<Scene>;
  104079. /**
  104080. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  104081. */
  104082. onAfterRenderCameraObservable: Observable<Camera>;
  104083. private _onAfterRenderObserver;
  104084. /** Sets a function to be executed after rendering this scene */
  104085. afterRender: Nullable<() => void>;
  104086. /**
  104087. * An event triggered before animating the scene
  104088. */
  104089. onBeforeAnimationsObservable: Observable<Scene>;
  104090. /**
  104091. * An event triggered after animations processing
  104092. */
  104093. onAfterAnimationsObservable: Observable<Scene>;
  104094. /**
  104095. * An event triggered before draw calls are ready to be sent
  104096. */
  104097. onBeforeDrawPhaseObservable: Observable<Scene>;
  104098. /**
  104099. * An event triggered after draw calls have been sent
  104100. */
  104101. onAfterDrawPhaseObservable: Observable<Scene>;
  104102. /**
  104103. * An event triggered when the scene is ready
  104104. */
  104105. onReadyObservable: Observable<Scene>;
  104106. /**
  104107. * An event triggered before rendering a camera
  104108. */
  104109. onBeforeCameraRenderObservable: Observable<Camera>;
  104110. private _onBeforeCameraRenderObserver;
  104111. /** Sets a function to be executed before rendering a camera*/
  104112. beforeCameraRender: () => void;
  104113. /**
  104114. * An event triggered after rendering a camera
  104115. */
  104116. onAfterCameraRenderObservable: Observable<Camera>;
  104117. private _onAfterCameraRenderObserver;
  104118. /** Sets a function to be executed after rendering a camera*/
  104119. afterCameraRender: () => void;
  104120. /**
  104121. * An event triggered when active meshes evaluation is about to start
  104122. */
  104123. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  104124. /**
  104125. * An event triggered when active meshes evaluation is done
  104126. */
  104127. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  104128. /**
  104129. * An event triggered when particles rendering is about to start
  104130. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  104131. */
  104132. onBeforeParticlesRenderingObservable: Observable<Scene>;
  104133. /**
  104134. * An event triggered when particles rendering is done
  104135. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  104136. */
  104137. onAfterParticlesRenderingObservable: Observable<Scene>;
  104138. /**
  104139. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  104140. */
  104141. onDataLoadedObservable: Observable<Scene>;
  104142. /**
  104143. * An event triggered when a camera is created
  104144. */
  104145. onNewCameraAddedObservable: Observable<Camera>;
  104146. /**
  104147. * An event triggered when a camera is removed
  104148. */
  104149. onCameraRemovedObservable: Observable<Camera>;
  104150. /**
  104151. * An event triggered when a light is created
  104152. */
  104153. onNewLightAddedObservable: Observable<Light>;
  104154. /**
  104155. * An event triggered when a light is removed
  104156. */
  104157. onLightRemovedObservable: Observable<Light>;
  104158. /**
  104159. * An event triggered when a geometry is created
  104160. */
  104161. onNewGeometryAddedObservable: Observable<Geometry>;
  104162. /**
  104163. * An event triggered when a geometry is removed
  104164. */
  104165. onGeometryRemovedObservable: Observable<Geometry>;
  104166. /**
  104167. * An event triggered when a transform node is created
  104168. */
  104169. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  104170. /**
  104171. * An event triggered when a transform node is removed
  104172. */
  104173. onTransformNodeRemovedObservable: Observable<TransformNode>;
  104174. /**
  104175. * An event triggered when a mesh is created
  104176. */
  104177. onNewMeshAddedObservable: Observable<AbstractMesh>;
  104178. /**
  104179. * An event triggered when a mesh is removed
  104180. */
  104181. onMeshRemovedObservable: Observable<AbstractMesh>;
  104182. /**
  104183. * An event triggered when a skeleton is created
  104184. */
  104185. onNewSkeletonAddedObservable: Observable<Skeleton>;
  104186. /**
  104187. * An event triggered when a skeleton is removed
  104188. */
  104189. onSkeletonRemovedObservable: Observable<Skeleton>;
  104190. /**
  104191. * An event triggered when a material is created
  104192. */
  104193. onNewMaterialAddedObservable: Observable<Material>;
  104194. /**
  104195. * An event triggered when a material is removed
  104196. */
  104197. onMaterialRemovedObservable: Observable<Material>;
  104198. /**
  104199. * An event triggered when a texture is created
  104200. */
  104201. onNewTextureAddedObservable: Observable<BaseTexture>;
  104202. /**
  104203. * An event triggered when a texture is removed
  104204. */
  104205. onTextureRemovedObservable: Observable<BaseTexture>;
  104206. /**
  104207. * An event triggered when render targets are about to be rendered
  104208. * Can happen multiple times per frame.
  104209. */
  104210. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  104211. /**
  104212. * An event triggered when render targets were rendered.
  104213. * Can happen multiple times per frame.
  104214. */
  104215. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  104216. /**
  104217. * An event triggered before calculating deterministic simulation step
  104218. */
  104219. onBeforeStepObservable: Observable<Scene>;
  104220. /**
  104221. * An event triggered after calculating deterministic simulation step
  104222. */
  104223. onAfterStepObservable: Observable<Scene>;
  104224. /**
  104225. * An event triggered when the activeCamera property is updated
  104226. */
  104227. onActiveCameraChanged: Observable<Scene>;
  104228. /**
  104229. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  104230. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104231. * 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)
  104232. */
  104233. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104234. /**
  104235. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  104236. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  104237. * 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)
  104238. */
  104239. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  104240. /**
  104241. * This Observable will when a mesh has been imported into the scene.
  104242. */
  104243. onMeshImportedObservable: Observable<AbstractMesh>;
  104244. /**
  104245. * This Observable will when an animation file has been imported into the scene.
  104246. */
  104247. onAnimationFileImportedObservable: Observable<Scene>;
  104248. /**
  104249. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  104250. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  104251. */
  104252. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  104253. /** @hidden */
  104254. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  104255. /**
  104256. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  104257. */
  104258. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  104259. /**
  104260. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  104261. */
  104262. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  104263. /**
  104264. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  104265. */
  104266. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  104267. /** Callback called when a pointer move is detected */
  104268. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104269. /** Callback called when a pointer down is detected */
  104270. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  104271. /** Callback called when a pointer up is detected */
  104272. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  104273. /** Callback called when a pointer pick is detected */
  104274. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  104275. /**
  104276. * 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).
  104277. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  104278. */
  104279. onPrePointerObservable: Observable<PointerInfoPre>;
  104280. /**
  104281. * Observable event triggered each time an input event is received from the rendering canvas
  104282. */
  104283. onPointerObservable: Observable<PointerInfo>;
  104284. /**
  104285. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  104286. */
  104287. readonly unTranslatedPointer: Vector2;
  104288. /**
  104289. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  104290. */
  104291. static DragMovementThreshold: number;
  104292. /**
  104293. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  104294. */
  104295. static LongPressDelay: number;
  104296. /**
  104297. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  104298. */
  104299. static DoubleClickDelay: number;
  104300. /** If you need to check double click without raising a single click at first click, enable this flag */
  104301. static ExclusiveDoubleClickMode: boolean;
  104302. /** @hidden */
  104303. _mirroredCameraPosition: Nullable<Vector3>;
  104304. /**
  104305. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  104306. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  104307. */
  104308. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  104309. /**
  104310. * Observable event triggered each time an keyboard event is received from the hosting window
  104311. */
  104312. onKeyboardObservable: Observable<KeyboardInfo>;
  104313. private _useRightHandedSystem;
  104314. /**
  104315. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  104316. */
  104317. useRightHandedSystem: boolean;
  104318. private _timeAccumulator;
  104319. private _currentStepId;
  104320. private _currentInternalStep;
  104321. /**
  104322. * Sets the step Id used by deterministic lock step
  104323. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104324. * @param newStepId defines the step Id
  104325. */
  104326. setStepId(newStepId: number): void;
  104327. /**
  104328. * Gets the step Id used by deterministic lock step
  104329. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104330. * @returns the step Id
  104331. */
  104332. getStepId(): number;
  104333. /**
  104334. * Gets the internal step used by deterministic lock step
  104335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104336. * @returns the internal step
  104337. */
  104338. getInternalStep(): number;
  104339. private _fogEnabled;
  104340. /**
  104341. * Gets or sets a boolean indicating if fog is enabled on this scene
  104342. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104343. * (Default is true)
  104344. */
  104345. fogEnabled: boolean;
  104346. private _fogMode;
  104347. /**
  104348. * Gets or sets the fog mode to use
  104349. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104350. * | mode | value |
  104351. * | --- | --- |
  104352. * | FOGMODE_NONE | 0 |
  104353. * | FOGMODE_EXP | 1 |
  104354. * | FOGMODE_EXP2 | 2 |
  104355. * | FOGMODE_LINEAR | 3 |
  104356. */
  104357. fogMode: number;
  104358. /**
  104359. * Gets or sets the fog color to use
  104360. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104361. * (Default is Color3(0.2, 0.2, 0.3))
  104362. */
  104363. fogColor: Color3;
  104364. /**
  104365. * Gets or sets the fog density to use
  104366. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104367. * (Default is 0.1)
  104368. */
  104369. fogDensity: number;
  104370. /**
  104371. * Gets or sets the fog start distance to use
  104372. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104373. * (Default is 0)
  104374. */
  104375. fogStart: number;
  104376. /**
  104377. * Gets or sets the fog end distance to use
  104378. * @see http://doc.babylonjs.com/babylon101/environment#fog
  104379. * (Default is 1000)
  104380. */
  104381. fogEnd: number;
  104382. private _shadowsEnabled;
  104383. /**
  104384. * Gets or sets a boolean indicating if shadows are enabled on this scene
  104385. */
  104386. shadowsEnabled: boolean;
  104387. private _lightsEnabled;
  104388. /**
  104389. * Gets or sets a boolean indicating if lights are enabled on this scene
  104390. */
  104391. lightsEnabled: boolean;
  104392. /** All of the active cameras added to this scene. */
  104393. activeCameras: Camera[];
  104394. /** @hidden */
  104395. _activeCamera: Nullable<Camera>;
  104396. /** Gets or sets the current active camera */
  104397. activeCamera: Nullable<Camera>;
  104398. private _defaultMaterial;
  104399. /** The default material used on meshes when no material is affected */
  104400. /** The default material used on meshes when no material is affected */
  104401. defaultMaterial: Material;
  104402. private _texturesEnabled;
  104403. /**
  104404. * Gets or sets a boolean indicating if textures are enabled on this scene
  104405. */
  104406. texturesEnabled: boolean;
  104407. /**
  104408. * Gets or sets a boolean indicating if particles are enabled on this scene
  104409. */
  104410. particlesEnabled: boolean;
  104411. /**
  104412. * Gets or sets a boolean indicating if sprites are enabled on this scene
  104413. */
  104414. spritesEnabled: boolean;
  104415. private _skeletonsEnabled;
  104416. /**
  104417. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  104418. */
  104419. skeletonsEnabled: boolean;
  104420. /**
  104421. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  104422. */
  104423. lensFlaresEnabled: boolean;
  104424. /**
  104425. * Gets or sets a boolean indicating if collisions are enabled on this scene
  104426. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104427. */
  104428. collisionsEnabled: boolean;
  104429. private _collisionCoordinator;
  104430. /** @hidden */
  104431. readonly collisionCoordinator: ICollisionCoordinator;
  104432. /**
  104433. * Defines the gravity applied to this scene (used only for collisions)
  104434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  104435. */
  104436. gravity: Vector3;
  104437. /**
  104438. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  104439. */
  104440. postProcessesEnabled: boolean;
  104441. /**
  104442. * The list of postprocesses added to the scene
  104443. */
  104444. postProcesses: PostProcess[];
  104445. /**
  104446. * Gets the current postprocess manager
  104447. */
  104448. postProcessManager: PostProcessManager;
  104449. /**
  104450. * Gets or sets a boolean indicating if render targets are enabled on this scene
  104451. */
  104452. renderTargetsEnabled: boolean;
  104453. /**
  104454. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  104455. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  104456. */
  104457. dumpNextRenderTargets: boolean;
  104458. /**
  104459. * The list of user defined render targets added to the scene
  104460. */
  104461. customRenderTargets: RenderTargetTexture[];
  104462. /**
  104463. * Defines if texture loading must be delayed
  104464. * If true, textures will only be loaded when they need to be rendered
  104465. */
  104466. useDelayedTextureLoading: boolean;
  104467. /**
  104468. * Gets the list of meshes imported to the scene through SceneLoader
  104469. */
  104470. importedMeshesFiles: String[];
  104471. /**
  104472. * Gets or sets a boolean indicating if probes are enabled on this scene
  104473. */
  104474. probesEnabled: boolean;
  104475. /**
  104476. * Gets or sets the current offline provider to use to store scene data
  104477. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104478. */
  104479. offlineProvider: IOfflineProvider;
  104480. /**
  104481. * Gets or sets the action manager associated with the scene
  104482. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104483. */
  104484. actionManager: AbstractActionManager;
  104485. private _meshesForIntersections;
  104486. /**
  104487. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  104488. */
  104489. proceduralTexturesEnabled: boolean;
  104490. private _engine;
  104491. private _totalVertices;
  104492. /** @hidden */
  104493. _activeIndices: PerfCounter;
  104494. /** @hidden */
  104495. _activeParticles: PerfCounter;
  104496. /** @hidden */
  104497. _activeBones: PerfCounter;
  104498. private _animationRatio;
  104499. /** @hidden */
  104500. _animationTimeLast: number;
  104501. /** @hidden */
  104502. _animationTime: number;
  104503. /**
  104504. * Gets or sets a general scale for animation speed
  104505. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  104506. */
  104507. animationTimeScale: number;
  104508. /** @hidden */
  104509. _cachedMaterial: Nullable<Material>;
  104510. /** @hidden */
  104511. _cachedEffect: Nullable<Effect>;
  104512. /** @hidden */
  104513. _cachedVisibility: Nullable<number>;
  104514. private _renderId;
  104515. private _frameId;
  104516. private _executeWhenReadyTimeoutId;
  104517. private _intermediateRendering;
  104518. private _viewUpdateFlag;
  104519. private _projectionUpdateFlag;
  104520. /** @hidden */
  104521. _toBeDisposed: Nullable<IDisposable>[];
  104522. private _activeRequests;
  104523. /** @hidden */
  104524. _pendingData: any[];
  104525. private _isDisposed;
  104526. /**
  104527. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  104528. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  104529. */
  104530. dispatchAllSubMeshesOfActiveMeshes: boolean;
  104531. private _activeMeshes;
  104532. private _processedMaterials;
  104533. private _renderTargets;
  104534. /** @hidden */
  104535. _activeParticleSystems: SmartArray<IParticleSystem>;
  104536. private _activeSkeletons;
  104537. private _softwareSkinnedMeshes;
  104538. private _renderingManager;
  104539. /** @hidden */
  104540. _activeAnimatables: Animatable[];
  104541. private _transformMatrix;
  104542. private _sceneUbo;
  104543. /** @hidden */
  104544. _viewMatrix: Matrix;
  104545. private _projectionMatrix;
  104546. /** @hidden */
  104547. _forcedViewPosition: Nullable<Vector3>;
  104548. /** @hidden */
  104549. _frustumPlanes: Plane[];
  104550. /**
  104551. * Gets the list of frustum planes (built from the active camera)
  104552. */
  104553. readonly frustumPlanes: Plane[];
  104554. /**
  104555. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  104556. * This is useful if there are more lights that the maximum simulteanous authorized
  104557. */
  104558. requireLightSorting: boolean;
  104559. /** @hidden */
  104560. readonly useMaterialMeshMap: boolean;
  104561. /** @hidden */
  104562. readonly useClonedMeshhMap: boolean;
  104563. private _externalData;
  104564. private _uid;
  104565. /**
  104566. * @hidden
  104567. * Backing store of defined scene components.
  104568. */
  104569. _components: ISceneComponent[];
  104570. /**
  104571. * @hidden
  104572. * Backing store of defined scene components.
  104573. */
  104574. _serializableComponents: ISceneSerializableComponent[];
  104575. /**
  104576. * List of components to register on the next registration step.
  104577. */
  104578. private _transientComponents;
  104579. /**
  104580. * Registers the transient components if needed.
  104581. */
  104582. private _registerTransientComponents;
  104583. /**
  104584. * @hidden
  104585. * Add a component to the scene.
  104586. * Note that the ccomponent could be registered on th next frame if this is called after
  104587. * the register component stage.
  104588. * @param component Defines the component to add to the scene
  104589. */
  104590. _addComponent(component: ISceneComponent): void;
  104591. /**
  104592. * @hidden
  104593. * Gets a component from the scene.
  104594. * @param name defines the name of the component to retrieve
  104595. * @returns the component or null if not present
  104596. */
  104597. _getComponent(name: string): Nullable<ISceneComponent>;
  104598. /**
  104599. * @hidden
  104600. * Defines the actions happening before camera updates.
  104601. */
  104602. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  104603. /**
  104604. * @hidden
  104605. * Defines the actions happening before clear the canvas.
  104606. */
  104607. _beforeClearStage: Stage<SimpleStageAction>;
  104608. /**
  104609. * @hidden
  104610. * Defines the actions when collecting render targets for the frame.
  104611. */
  104612. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104613. /**
  104614. * @hidden
  104615. * Defines the actions happening for one camera in the frame.
  104616. */
  104617. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  104618. /**
  104619. * @hidden
  104620. * Defines the actions happening during the per mesh ready checks.
  104621. */
  104622. _isReadyForMeshStage: Stage<MeshStageAction>;
  104623. /**
  104624. * @hidden
  104625. * Defines the actions happening before evaluate active mesh checks.
  104626. */
  104627. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  104628. /**
  104629. * @hidden
  104630. * Defines the actions happening during the evaluate sub mesh checks.
  104631. */
  104632. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  104633. /**
  104634. * @hidden
  104635. * Defines the actions happening during the active mesh stage.
  104636. */
  104637. _activeMeshStage: Stage<ActiveMeshStageAction>;
  104638. /**
  104639. * @hidden
  104640. * Defines the actions happening during the per camera render target step.
  104641. */
  104642. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  104643. /**
  104644. * @hidden
  104645. * Defines the actions happening just before the active camera is drawing.
  104646. */
  104647. _beforeCameraDrawStage: Stage<CameraStageAction>;
  104648. /**
  104649. * @hidden
  104650. * Defines the actions happening just before a render target is drawing.
  104651. */
  104652. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104653. /**
  104654. * @hidden
  104655. * Defines the actions happening just before a rendering group is drawing.
  104656. */
  104657. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104658. /**
  104659. * @hidden
  104660. * Defines the actions happening just before a mesh is drawing.
  104661. */
  104662. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104663. /**
  104664. * @hidden
  104665. * Defines the actions happening just after a mesh has been drawn.
  104666. */
  104667. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  104668. /**
  104669. * @hidden
  104670. * Defines the actions happening just after a rendering group has been drawn.
  104671. */
  104672. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  104673. /**
  104674. * @hidden
  104675. * Defines the actions happening just after the active camera has been drawn.
  104676. */
  104677. _afterCameraDrawStage: Stage<CameraStageAction>;
  104678. /**
  104679. * @hidden
  104680. * Defines the actions happening just after a render target has been drawn.
  104681. */
  104682. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  104683. /**
  104684. * @hidden
  104685. * Defines the actions happening just after rendering all cameras and computing intersections.
  104686. */
  104687. _afterRenderStage: Stage<SimpleStageAction>;
  104688. /**
  104689. * @hidden
  104690. * Defines the actions happening when a pointer move event happens.
  104691. */
  104692. _pointerMoveStage: Stage<PointerMoveStageAction>;
  104693. /**
  104694. * @hidden
  104695. * Defines the actions happening when a pointer down event happens.
  104696. */
  104697. _pointerDownStage: Stage<PointerUpDownStageAction>;
  104698. /**
  104699. * @hidden
  104700. * Defines the actions happening when a pointer up event happens.
  104701. */
  104702. _pointerUpStage: Stage<PointerUpDownStageAction>;
  104703. /**
  104704. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  104705. */
  104706. private geometriesByUniqueId;
  104707. /**
  104708. * Creates a new Scene
  104709. * @param engine defines the engine to use to render this scene
  104710. * @param options defines the scene options
  104711. */
  104712. constructor(engine: Engine, options?: SceneOptions);
  104713. /**
  104714. * Gets a string idenfifying the name of the class
  104715. * @returns "Scene" string
  104716. */
  104717. getClassName(): string;
  104718. private _defaultMeshCandidates;
  104719. /**
  104720. * @hidden
  104721. */
  104722. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  104723. private _defaultSubMeshCandidates;
  104724. /**
  104725. * @hidden
  104726. */
  104727. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  104728. /**
  104729. * Sets the default candidate providers for the scene.
  104730. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  104731. * and getCollidingSubMeshCandidates to their default function
  104732. */
  104733. setDefaultCandidateProviders(): void;
  104734. /**
  104735. * Gets the mesh that is currently under the pointer
  104736. */
  104737. readonly meshUnderPointer: Nullable<AbstractMesh>;
  104738. /**
  104739. * Gets or sets the current on-screen X position of the pointer
  104740. */
  104741. pointerX: number;
  104742. /**
  104743. * Gets or sets the current on-screen Y position of the pointer
  104744. */
  104745. pointerY: number;
  104746. /**
  104747. * Gets the cached material (ie. the latest rendered one)
  104748. * @returns the cached material
  104749. */
  104750. getCachedMaterial(): Nullable<Material>;
  104751. /**
  104752. * Gets the cached effect (ie. the latest rendered one)
  104753. * @returns the cached effect
  104754. */
  104755. getCachedEffect(): Nullable<Effect>;
  104756. /**
  104757. * Gets the cached visibility state (ie. the latest rendered one)
  104758. * @returns the cached visibility state
  104759. */
  104760. getCachedVisibility(): Nullable<number>;
  104761. /**
  104762. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  104763. * @param material defines the current material
  104764. * @param effect defines the current effect
  104765. * @param visibility defines the current visibility state
  104766. * @returns true if one parameter is not cached
  104767. */
  104768. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  104769. /**
  104770. * Gets the engine associated with the scene
  104771. * @returns an Engine
  104772. */
  104773. getEngine(): Engine;
  104774. /**
  104775. * Gets the total number of vertices rendered per frame
  104776. * @returns the total number of vertices rendered per frame
  104777. */
  104778. getTotalVertices(): number;
  104779. /**
  104780. * Gets the performance counter for total vertices
  104781. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104782. */
  104783. readonly totalVerticesPerfCounter: PerfCounter;
  104784. /**
  104785. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  104786. * @returns the total number of active indices rendered per frame
  104787. */
  104788. getActiveIndices(): number;
  104789. /**
  104790. * Gets the performance counter for active indices
  104791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104792. */
  104793. readonly totalActiveIndicesPerfCounter: PerfCounter;
  104794. /**
  104795. * Gets the total number of active particles rendered per frame
  104796. * @returns the total number of active particles rendered per frame
  104797. */
  104798. getActiveParticles(): number;
  104799. /**
  104800. * Gets the performance counter for active particles
  104801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104802. */
  104803. readonly activeParticlesPerfCounter: PerfCounter;
  104804. /**
  104805. * Gets the total number of active bones rendered per frame
  104806. * @returns the total number of active bones rendered per frame
  104807. */
  104808. getActiveBones(): number;
  104809. /**
  104810. * Gets the performance counter for active bones
  104811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  104812. */
  104813. readonly activeBonesPerfCounter: PerfCounter;
  104814. /**
  104815. * Gets the array of active meshes
  104816. * @returns an array of AbstractMesh
  104817. */
  104818. getActiveMeshes(): SmartArray<AbstractMesh>;
  104819. /**
  104820. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  104821. * @returns a number
  104822. */
  104823. getAnimationRatio(): number;
  104824. /**
  104825. * Gets an unique Id for the current render phase
  104826. * @returns a number
  104827. */
  104828. getRenderId(): number;
  104829. /**
  104830. * Gets an unique Id for the current frame
  104831. * @returns a number
  104832. */
  104833. getFrameId(): number;
  104834. /** Call this function if you want to manually increment the render Id*/
  104835. incrementRenderId(): void;
  104836. private _createUbo;
  104837. /**
  104838. * Use this method to simulate a pointer move on a mesh
  104839. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104840. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104841. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104842. * @returns the current scene
  104843. */
  104844. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104845. /**
  104846. * Use this method to simulate a pointer down on a mesh
  104847. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104848. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104849. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104850. * @returns the current scene
  104851. */
  104852. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  104853. /**
  104854. * Use this method to simulate a pointer up on a mesh
  104855. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  104856. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  104857. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  104858. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  104859. * @returns the current scene
  104860. */
  104861. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  104862. /**
  104863. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  104864. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  104865. * @returns true if the pointer was captured
  104866. */
  104867. isPointerCaptured(pointerId?: number): boolean;
  104868. /**
  104869. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  104870. * @param attachUp defines if you want to attach events to pointerup
  104871. * @param attachDown defines if you want to attach events to pointerdown
  104872. * @param attachMove defines if you want to attach events to pointermove
  104873. */
  104874. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  104875. /** Detaches all event handlers*/
  104876. detachControl(): void;
  104877. /**
  104878. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  104879. * Delay loaded resources are not taking in account
  104880. * @return true if all required resources are ready
  104881. */
  104882. isReady(): boolean;
  104883. /** Resets all cached information relative to material (including effect and visibility) */
  104884. resetCachedMaterial(): void;
  104885. /**
  104886. * Registers a function to be called before every frame render
  104887. * @param func defines the function to register
  104888. */
  104889. registerBeforeRender(func: () => void): void;
  104890. /**
  104891. * Unregisters a function called before every frame render
  104892. * @param func defines the function to unregister
  104893. */
  104894. unregisterBeforeRender(func: () => void): void;
  104895. /**
  104896. * Registers a function to be called after every frame render
  104897. * @param func defines the function to register
  104898. */
  104899. registerAfterRender(func: () => void): void;
  104900. /**
  104901. * Unregisters a function called after every frame render
  104902. * @param func defines the function to unregister
  104903. */
  104904. unregisterAfterRender(func: () => void): void;
  104905. private _executeOnceBeforeRender;
  104906. /**
  104907. * The provided function will run before render once and will be disposed afterwards.
  104908. * A timeout delay can be provided so that the function will be executed in N ms.
  104909. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  104910. * @param func The function to be executed.
  104911. * @param timeout optional delay in ms
  104912. */
  104913. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  104914. /** @hidden */
  104915. _addPendingData(data: any): void;
  104916. /** @hidden */
  104917. _removePendingData(data: any): void;
  104918. /**
  104919. * Returns the number of items waiting to be loaded
  104920. * @returns the number of items waiting to be loaded
  104921. */
  104922. getWaitingItemsCount(): number;
  104923. /**
  104924. * Returns a boolean indicating if the scene is still loading data
  104925. */
  104926. readonly isLoading: boolean;
  104927. /**
  104928. * Registers a function to be executed when the scene is ready
  104929. * @param {Function} func - the function to be executed
  104930. */
  104931. executeWhenReady(func: () => void): void;
  104932. /**
  104933. * Returns a promise that resolves when the scene is ready
  104934. * @returns A promise that resolves when the scene is ready
  104935. */
  104936. whenReadyAsync(): Promise<void>;
  104937. /** @hidden */
  104938. _checkIsReady(): void;
  104939. /**
  104940. * Gets all animatable attached to the scene
  104941. */
  104942. readonly animatables: Animatable[];
  104943. /**
  104944. * Resets the last animation time frame.
  104945. * Useful to override when animations start running when loading a scene for the first time.
  104946. */
  104947. resetLastAnimationTimeFrame(): void;
  104948. /**
  104949. * Gets the current view matrix
  104950. * @returns a Matrix
  104951. */
  104952. getViewMatrix(): Matrix;
  104953. /**
  104954. * Gets the current projection matrix
  104955. * @returns a Matrix
  104956. */
  104957. getProjectionMatrix(): Matrix;
  104958. /**
  104959. * Gets the current transform matrix
  104960. * @returns a Matrix made of View * Projection
  104961. */
  104962. getTransformMatrix(): Matrix;
  104963. /**
  104964. * Sets the current transform matrix
  104965. * @param viewL defines the View matrix to use
  104966. * @param projectionL defines the Projection matrix to use
  104967. * @param viewR defines the right View matrix to use (if provided)
  104968. * @param projectionR defines the right Projection matrix to use (if provided)
  104969. */
  104970. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  104971. /**
  104972. * Gets the uniform buffer used to store scene data
  104973. * @returns a UniformBuffer
  104974. */
  104975. getSceneUniformBuffer(): UniformBuffer;
  104976. /**
  104977. * Gets an unique (relatively to the current scene) Id
  104978. * @returns an unique number for the scene
  104979. */
  104980. getUniqueId(): number;
  104981. /**
  104982. * Add a mesh to the list of scene's meshes
  104983. * @param newMesh defines the mesh to add
  104984. * @param recursive if all child meshes should also be added to the scene
  104985. */
  104986. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  104987. /**
  104988. * Remove a mesh for the list of scene's meshes
  104989. * @param toRemove defines the mesh to remove
  104990. * @param recursive if all child meshes should also be removed from the scene
  104991. * @returns the index where the mesh was in the mesh list
  104992. */
  104993. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  104994. /**
  104995. * Add a transform node to the list of scene's transform nodes
  104996. * @param newTransformNode defines the transform node to add
  104997. */
  104998. addTransformNode(newTransformNode: TransformNode): void;
  104999. /**
  105000. * Remove a transform node for the list of scene's transform nodes
  105001. * @param toRemove defines the transform node to remove
  105002. * @returns the index where the transform node was in the transform node list
  105003. */
  105004. removeTransformNode(toRemove: TransformNode): number;
  105005. /**
  105006. * Remove a skeleton for the list of scene's skeletons
  105007. * @param toRemove defines the skeleton to remove
  105008. * @returns the index where the skeleton was in the skeleton list
  105009. */
  105010. removeSkeleton(toRemove: Skeleton): number;
  105011. /**
  105012. * Remove a morph target for the list of scene's morph targets
  105013. * @param toRemove defines the morph target to remove
  105014. * @returns the index where the morph target was in the morph target list
  105015. */
  105016. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  105017. /**
  105018. * Remove a light for the list of scene's lights
  105019. * @param toRemove defines the light to remove
  105020. * @returns the index where the light was in the light list
  105021. */
  105022. removeLight(toRemove: Light): number;
  105023. /**
  105024. * Remove a camera for the list of scene's cameras
  105025. * @param toRemove defines the camera to remove
  105026. * @returns the index where the camera was in the camera list
  105027. */
  105028. removeCamera(toRemove: Camera): number;
  105029. /**
  105030. * Remove a particle system for the list of scene's particle systems
  105031. * @param toRemove defines the particle system to remove
  105032. * @returns the index where the particle system was in the particle system list
  105033. */
  105034. removeParticleSystem(toRemove: IParticleSystem): number;
  105035. /**
  105036. * Remove a animation for the list of scene's animations
  105037. * @param toRemove defines the animation to remove
  105038. * @returns the index where the animation was in the animation list
  105039. */
  105040. removeAnimation(toRemove: Animation): number;
  105041. /**
  105042. * Will stop the animation of the given target
  105043. * @param target - the target
  105044. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  105045. * @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)
  105046. */
  105047. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  105048. /**
  105049. * Removes the given animation group from this scene.
  105050. * @param toRemove The animation group to remove
  105051. * @returns The index of the removed animation group
  105052. */
  105053. removeAnimationGroup(toRemove: AnimationGroup): number;
  105054. /**
  105055. * Removes the given multi-material from this scene.
  105056. * @param toRemove The multi-material to remove
  105057. * @returns The index of the removed multi-material
  105058. */
  105059. removeMultiMaterial(toRemove: MultiMaterial): number;
  105060. /**
  105061. * Removes the given material from this scene.
  105062. * @param toRemove The material to remove
  105063. * @returns The index of the removed material
  105064. */
  105065. removeMaterial(toRemove: Material): number;
  105066. /**
  105067. * Removes the given action manager from this scene.
  105068. * @param toRemove The action manager to remove
  105069. * @returns The index of the removed action manager
  105070. */
  105071. removeActionManager(toRemove: AbstractActionManager): number;
  105072. /**
  105073. * Removes the given texture from this scene.
  105074. * @param toRemove The texture to remove
  105075. * @returns The index of the removed texture
  105076. */
  105077. removeTexture(toRemove: BaseTexture): number;
  105078. /**
  105079. * Adds the given light to this scene
  105080. * @param newLight The light to add
  105081. */
  105082. addLight(newLight: Light): void;
  105083. /**
  105084. * Sorts the list list based on light priorities
  105085. */
  105086. sortLightsByPriority(): void;
  105087. /**
  105088. * Adds the given camera to this scene
  105089. * @param newCamera The camera to add
  105090. */
  105091. addCamera(newCamera: Camera): void;
  105092. /**
  105093. * Adds the given skeleton to this scene
  105094. * @param newSkeleton The skeleton to add
  105095. */
  105096. addSkeleton(newSkeleton: Skeleton): void;
  105097. /**
  105098. * Adds the given particle system to this scene
  105099. * @param newParticleSystem The particle system to add
  105100. */
  105101. addParticleSystem(newParticleSystem: IParticleSystem): void;
  105102. /**
  105103. * Adds the given animation to this scene
  105104. * @param newAnimation The animation to add
  105105. */
  105106. addAnimation(newAnimation: Animation): void;
  105107. /**
  105108. * Adds the given animation group to this scene.
  105109. * @param newAnimationGroup The animation group to add
  105110. */
  105111. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  105112. /**
  105113. * Adds the given multi-material to this scene
  105114. * @param newMultiMaterial The multi-material to add
  105115. */
  105116. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  105117. /**
  105118. * Adds the given material to this scene
  105119. * @param newMaterial The material to add
  105120. */
  105121. addMaterial(newMaterial: Material): void;
  105122. /**
  105123. * Adds the given morph target to this scene
  105124. * @param newMorphTargetManager The morph target to add
  105125. */
  105126. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  105127. /**
  105128. * Adds the given geometry to this scene
  105129. * @param newGeometry The geometry to add
  105130. */
  105131. addGeometry(newGeometry: Geometry): void;
  105132. /**
  105133. * Adds the given action manager to this scene
  105134. * @param newActionManager The action manager to add
  105135. */
  105136. addActionManager(newActionManager: AbstractActionManager): void;
  105137. /**
  105138. * Adds the given texture to this scene.
  105139. * @param newTexture The texture to add
  105140. */
  105141. addTexture(newTexture: BaseTexture): void;
  105142. /**
  105143. * Switch active camera
  105144. * @param newCamera defines the new active camera
  105145. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  105146. */
  105147. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  105148. /**
  105149. * sets the active camera of the scene using its ID
  105150. * @param id defines the camera's ID
  105151. * @return the new active camera or null if none found.
  105152. */
  105153. setActiveCameraByID(id: string): Nullable<Camera>;
  105154. /**
  105155. * sets the active camera of the scene using its name
  105156. * @param name defines the camera's name
  105157. * @returns the new active camera or null if none found.
  105158. */
  105159. setActiveCameraByName(name: string): Nullable<Camera>;
  105160. /**
  105161. * get an animation group using its name
  105162. * @param name defines the material's name
  105163. * @return the animation group or null if none found.
  105164. */
  105165. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  105166. /**
  105167. * Get a material using its unique id
  105168. * @param uniqueId defines the material's unique id
  105169. * @return the material or null if none found.
  105170. */
  105171. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  105172. /**
  105173. * get a material using its id
  105174. * @param id defines the material's ID
  105175. * @return the material or null if none found.
  105176. */
  105177. getMaterialByID(id: string): Nullable<Material>;
  105178. /**
  105179. * Gets a the last added material using a given id
  105180. * @param id defines the material's ID
  105181. * @return the last material with the given id or null if none found.
  105182. */
  105183. getLastMaterialByID(id: string): Nullable<Material>;
  105184. /**
  105185. * Gets a material using its name
  105186. * @param name defines the material's name
  105187. * @return the material or null if none found.
  105188. */
  105189. getMaterialByName(name: string): Nullable<Material>;
  105190. /**
  105191. * Get a texture using its unique id
  105192. * @param uniqueId defines the texture's unique id
  105193. * @return the texture or null if none found.
  105194. */
  105195. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  105196. /**
  105197. * Gets a camera using its id
  105198. * @param id defines the id to look for
  105199. * @returns the camera or null if not found
  105200. */
  105201. getCameraByID(id: string): Nullable<Camera>;
  105202. /**
  105203. * Gets a camera using its unique id
  105204. * @param uniqueId defines the unique id to look for
  105205. * @returns the camera or null if not found
  105206. */
  105207. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  105208. /**
  105209. * Gets a camera using its name
  105210. * @param name defines the camera's name
  105211. * @return the camera or null if none found.
  105212. */
  105213. getCameraByName(name: string): Nullable<Camera>;
  105214. /**
  105215. * Gets a bone using its id
  105216. * @param id defines the bone's id
  105217. * @return the bone or null if not found
  105218. */
  105219. getBoneByID(id: string): Nullable<Bone>;
  105220. /**
  105221. * Gets a bone using its id
  105222. * @param name defines the bone's name
  105223. * @return the bone or null if not found
  105224. */
  105225. getBoneByName(name: string): Nullable<Bone>;
  105226. /**
  105227. * Gets a light node using its name
  105228. * @param name defines the the light's name
  105229. * @return the light or null if none found.
  105230. */
  105231. getLightByName(name: string): Nullable<Light>;
  105232. /**
  105233. * Gets a light node using its id
  105234. * @param id defines the light's id
  105235. * @return the light or null if none found.
  105236. */
  105237. getLightByID(id: string): Nullable<Light>;
  105238. /**
  105239. * Gets a light node using its scene-generated unique ID
  105240. * @param uniqueId defines the light's unique id
  105241. * @return the light or null if none found.
  105242. */
  105243. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  105244. /**
  105245. * Gets a particle system by id
  105246. * @param id defines the particle system id
  105247. * @return the corresponding system or null if none found
  105248. */
  105249. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  105250. /**
  105251. * Gets a geometry using its ID
  105252. * @param id defines the geometry's id
  105253. * @return the geometry or null if none found.
  105254. */
  105255. getGeometryByID(id: string): Nullable<Geometry>;
  105256. private _getGeometryByUniqueID;
  105257. /**
  105258. * Add a new geometry to this scene
  105259. * @param geometry defines the geometry to be added to the scene.
  105260. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  105261. * @return a boolean defining if the geometry was added or not
  105262. */
  105263. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  105264. /**
  105265. * Removes an existing geometry
  105266. * @param geometry defines the geometry to be removed from the scene
  105267. * @return a boolean defining if the geometry was removed or not
  105268. */
  105269. removeGeometry(geometry: Geometry): boolean;
  105270. /**
  105271. * Gets the list of geometries attached to the scene
  105272. * @returns an array of Geometry
  105273. */
  105274. getGeometries(): Geometry[];
  105275. /**
  105276. * Gets the first added mesh found of a given ID
  105277. * @param id defines the id to search for
  105278. * @return the mesh found or null if not found at all
  105279. */
  105280. getMeshByID(id: string): Nullable<AbstractMesh>;
  105281. /**
  105282. * Gets a list of meshes using their id
  105283. * @param id defines the id to search for
  105284. * @returns a list of meshes
  105285. */
  105286. getMeshesByID(id: string): Array<AbstractMesh>;
  105287. /**
  105288. * Gets the first added transform node found of a given ID
  105289. * @param id defines the id to search for
  105290. * @return the found transform node or null if not found at all.
  105291. */
  105292. getTransformNodeByID(id: string): Nullable<TransformNode>;
  105293. /**
  105294. * Gets a transform node with its auto-generated unique id
  105295. * @param uniqueId efines the unique id to search for
  105296. * @return the found transform node or null if not found at all.
  105297. */
  105298. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  105299. /**
  105300. * Gets a list of transform nodes using their id
  105301. * @param id defines the id to search for
  105302. * @returns a list of transform nodes
  105303. */
  105304. getTransformNodesByID(id: string): Array<TransformNode>;
  105305. /**
  105306. * Gets a mesh with its auto-generated unique id
  105307. * @param uniqueId defines the unique id to search for
  105308. * @return the found mesh or null if not found at all.
  105309. */
  105310. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  105311. /**
  105312. * Gets a the last added mesh using a given id
  105313. * @param id defines the id to search for
  105314. * @return the found mesh or null if not found at all.
  105315. */
  105316. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  105317. /**
  105318. * Gets a the last added node (Mesh, Camera, Light) using a given id
  105319. * @param id defines the id to search for
  105320. * @return the found node or null if not found at all
  105321. */
  105322. getLastEntryByID(id: string): Nullable<Node>;
  105323. /**
  105324. * Gets a node (Mesh, Camera, Light) using a given id
  105325. * @param id defines the id to search for
  105326. * @return the found node or null if not found at all
  105327. */
  105328. getNodeByID(id: string): Nullable<Node>;
  105329. /**
  105330. * Gets a node (Mesh, Camera, Light) using a given name
  105331. * @param name defines the name to search for
  105332. * @return the found node or null if not found at all.
  105333. */
  105334. getNodeByName(name: string): Nullable<Node>;
  105335. /**
  105336. * Gets a mesh using a given name
  105337. * @param name defines the name to search for
  105338. * @return the found mesh or null if not found at all.
  105339. */
  105340. getMeshByName(name: string): Nullable<AbstractMesh>;
  105341. /**
  105342. * Gets a transform node using a given name
  105343. * @param name defines the name to search for
  105344. * @return the found transform node or null if not found at all.
  105345. */
  105346. getTransformNodeByName(name: string): Nullable<TransformNode>;
  105347. /**
  105348. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  105349. * @param id defines the id to search for
  105350. * @return the found skeleton or null if not found at all.
  105351. */
  105352. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  105353. /**
  105354. * Gets a skeleton using a given auto generated unique id
  105355. * @param uniqueId defines the unique id to search for
  105356. * @return the found skeleton or null if not found at all.
  105357. */
  105358. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  105359. /**
  105360. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  105361. * @param id defines the id to search for
  105362. * @return the found skeleton or null if not found at all.
  105363. */
  105364. getSkeletonById(id: string): Nullable<Skeleton>;
  105365. /**
  105366. * Gets a skeleton using a given name
  105367. * @param name defines the name to search for
  105368. * @return the found skeleton or null if not found at all.
  105369. */
  105370. getSkeletonByName(name: string): Nullable<Skeleton>;
  105371. /**
  105372. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  105373. * @param id defines the id to search for
  105374. * @return the found morph target manager or null if not found at all.
  105375. */
  105376. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  105377. /**
  105378. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  105379. * @param id defines the id to search for
  105380. * @return the found morph target or null if not found at all.
  105381. */
  105382. getMorphTargetById(id: string): Nullable<MorphTarget>;
  105383. /**
  105384. * Gets a boolean indicating if the given mesh is active
  105385. * @param mesh defines the mesh to look for
  105386. * @returns true if the mesh is in the active list
  105387. */
  105388. isActiveMesh(mesh: AbstractMesh): boolean;
  105389. /**
  105390. * Return a unique id as a string which can serve as an identifier for the scene
  105391. */
  105392. readonly uid: string;
  105393. /**
  105394. * Add an externaly attached data from its key.
  105395. * This method call will fail and return false, if such key already exists.
  105396. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  105397. * @param key the unique key that identifies the data
  105398. * @param data the data object to associate to the key for this Engine instance
  105399. * @return true if no such key were already present and the data was added successfully, false otherwise
  105400. */
  105401. addExternalData<T>(key: string, data: T): boolean;
  105402. /**
  105403. * Get an externaly attached data from its key
  105404. * @param key the unique key that identifies the data
  105405. * @return the associated data, if present (can be null), or undefined if not present
  105406. */
  105407. getExternalData<T>(key: string): Nullable<T>;
  105408. /**
  105409. * Get an externaly attached data from its key, create it using a factory if it's not already present
  105410. * @param key the unique key that identifies the data
  105411. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  105412. * @return the associated data, can be null if the factory returned null.
  105413. */
  105414. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  105415. /**
  105416. * Remove an externaly attached data from the Engine instance
  105417. * @param key the unique key that identifies the data
  105418. * @return true if the data was successfully removed, false if it doesn't exist
  105419. */
  105420. removeExternalData(key: string): boolean;
  105421. private _evaluateSubMesh;
  105422. /**
  105423. * Clear the processed materials smart array preventing retention point in material dispose.
  105424. */
  105425. freeProcessedMaterials(): void;
  105426. private _preventFreeActiveMeshesAndRenderingGroups;
  105427. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  105428. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  105429. * when disposing several meshes in a row or a hierarchy of meshes.
  105430. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  105431. */
  105432. blockfreeActiveMeshesAndRenderingGroups: boolean;
  105433. /**
  105434. * Clear the active meshes smart array preventing retention point in mesh dispose.
  105435. */
  105436. freeActiveMeshes(): void;
  105437. /**
  105438. * Clear the info related to rendering groups preventing retention points during dispose.
  105439. */
  105440. freeRenderingGroups(): void;
  105441. /** @hidden */
  105442. _isInIntermediateRendering(): boolean;
  105443. /**
  105444. * Lambda returning the list of potentially active meshes.
  105445. */
  105446. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  105447. /**
  105448. * Lambda returning the list of potentially active sub meshes.
  105449. */
  105450. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  105451. /**
  105452. * Lambda returning the list of potentially intersecting sub meshes.
  105453. */
  105454. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  105455. /**
  105456. * Lambda returning the list of potentially colliding sub meshes.
  105457. */
  105458. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  105459. private _activeMeshesFrozen;
  105460. private _skipEvaluateActiveMeshesCompletely;
  105461. /**
  105462. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  105463. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  105464. * @returns the current scene
  105465. */
  105466. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  105467. /**
  105468. * Use this function to restart evaluating active meshes on every frame
  105469. * @returns the current scene
  105470. */
  105471. unfreezeActiveMeshes(): Scene;
  105472. private _evaluateActiveMeshes;
  105473. private _activeMesh;
  105474. /**
  105475. * Update the transform matrix to update from the current active camera
  105476. * @param force defines a boolean used to force the update even if cache is up to date
  105477. */
  105478. updateTransformMatrix(force?: boolean): void;
  105479. private _bindFrameBuffer;
  105480. /** @hidden */
  105481. _allowPostProcessClearColor: boolean;
  105482. /** @hidden */
  105483. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  105484. private _processSubCameras;
  105485. private _checkIntersections;
  105486. /** @hidden */
  105487. _advancePhysicsEngineStep(step: number): void;
  105488. /**
  105489. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  105490. */
  105491. getDeterministicFrameTime: () => number;
  105492. /** @hidden */
  105493. _animate(): void;
  105494. /** Execute all animations (for a frame) */
  105495. animate(): void;
  105496. /**
  105497. * Render the scene
  105498. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  105499. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  105500. */
  105501. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  105502. /**
  105503. * Freeze all materials
  105504. * A frozen material will not be updatable but should be faster to render
  105505. */
  105506. freezeMaterials(): void;
  105507. /**
  105508. * Unfreeze all materials
  105509. * A frozen material will not be updatable but should be faster to render
  105510. */
  105511. unfreezeMaterials(): void;
  105512. /**
  105513. * Releases all held ressources
  105514. */
  105515. dispose(): void;
  105516. /**
  105517. * Gets if the scene is already disposed
  105518. */
  105519. readonly isDisposed: boolean;
  105520. /**
  105521. * Call this function to reduce memory footprint of the scene.
  105522. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  105523. */
  105524. clearCachedVertexData(): void;
  105525. /**
  105526. * This function will remove the local cached buffer data from texture.
  105527. * It will save memory but will prevent the texture from being rebuilt
  105528. */
  105529. cleanCachedTextureBuffer(): void;
  105530. /**
  105531. * Get the world extend vectors with an optional filter
  105532. *
  105533. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  105534. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  105535. */
  105536. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  105537. min: Vector3;
  105538. max: Vector3;
  105539. };
  105540. /**
  105541. * Creates a ray that can be used to pick in the scene
  105542. * @param x defines the x coordinate of the origin (on-screen)
  105543. * @param y defines the y coordinate of the origin (on-screen)
  105544. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105545. * @param camera defines the camera to use for the picking
  105546. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105547. * @returns a Ray
  105548. */
  105549. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  105550. /**
  105551. * Creates a ray that can be used to pick in the scene
  105552. * @param x defines the x coordinate of the origin (on-screen)
  105553. * @param y defines the y coordinate of the origin (on-screen)
  105554. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  105555. * @param result defines the ray where to store the picking ray
  105556. * @param camera defines the camera to use for the picking
  105557. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  105558. * @returns the current scene
  105559. */
  105560. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  105561. /**
  105562. * Creates a ray that can be used to pick in the scene
  105563. * @param x defines the x coordinate of the origin (on-screen)
  105564. * @param y defines the y coordinate of the origin (on-screen)
  105565. * @param camera defines the camera to use for the picking
  105566. * @returns a Ray
  105567. */
  105568. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  105569. /**
  105570. * Creates a ray that can be used to pick in the scene
  105571. * @param x defines the x coordinate of the origin (on-screen)
  105572. * @param y defines the y coordinate of the origin (on-screen)
  105573. * @param result defines the ray where to store the picking ray
  105574. * @param camera defines the camera to use for the picking
  105575. * @returns the current scene
  105576. */
  105577. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  105578. /** Launch a ray to try to pick a mesh in the scene
  105579. * @param x position on screen
  105580. * @param y position on screen
  105581. * @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
  105582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  105583. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105585. * @returns a PickingInfo
  105586. */
  105587. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105588. /** Use the given ray to pick a mesh in the scene
  105589. * @param ray The ray to use to pick meshes
  105590. * @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
  105591. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  105592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105593. * @returns a PickingInfo
  105594. */
  105595. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  105596. /**
  105597. * Launch a ray to try to pick a mesh in the scene
  105598. * @param x X position on screen
  105599. * @param y Y position on screen
  105600. * @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
  105601. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  105602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105603. * @returns an array of PickingInfo
  105604. */
  105605. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105606. /**
  105607. * Launch a ray to try to pick a mesh in the scene
  105608. * @param ray Ray to use
  105609. * @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
  105610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105611. * @returns an array of PickingInfo
  105612. */
  105613. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  105614. /**
  105615. * Force the value of meshUnderPointer
  105616. * @param mesh defines the mesh to use
  105617. */
  105618. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105619. /**
  105620. * Gets the mesh under the pointer
  105621. * @returns a Mesh or null if no mesh is under the pointer
  105622. */
  105623. getPointerOverMesh(): Nullable<AbstractMesh>;
  105624. /** @hidden */
  105625. _rebuildGeometries(): void;
  105626. /** @hidden */
  105627. _rebuildTextures(): void;
  105628. private _getByTags;
  105629. /**
  105630. * Get a list of meshes by tags
  105631. * @param tagsQuery defines the tags query to use
  105632. * @param forEach defines a predicate used to filter results
  105633. * @returns an array of Mesh
  105634. */
  105635. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  105636. /**
  105637. * Get a list of cameras by tags
  105638. * @param tagsQuery defines the tags query to use
  105639. * @param forEach defines a predicate used to filter results
  105640. * @returns an array of Camera
  105641. */
  105642. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  105643. /**
  105644. * Get a list of lights by tags
  105645. * @param tagsQuery defines the tags query to use
  105646. * @param forEach defines a predicate used to filter results
  105647. * @returns an array of Light
  105648. */
  105649. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  105650. /**
  105651. * Get a list of materials by tags
  105652. * @param tagsQuery defines the tags query to use
  105653. * @param forEach defines a predicate used to filter results
  105654. * @returns an array of Material
  105655. */
  105656. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  105657. /**
  105658. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  105659. * This allowed control for front to back rendering or reversly depending of the special needs.
  105660. *
  105661. * @param renderingGroupId The rendering group id corresponding to its index
  105662. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105663. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105664. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105665. */
  105666. 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;
  105667. /**
  105668. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105669. *
  105670. * @param renderingGroupId The rendering group id corresponding to its index
  105671. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105672. * @param depth Automatically clears depth between groups if true and autoClear is true.
  105673. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  105674. */
  105675. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  105676. /**
  105677. * Gets the current auto clear configuration for one rendering group of the rendering
  105678. * manager.
  105679. * @param index the rendering group index to get the information for
  105680. * @returns The auto clear setup for the requested rendering group
  105681. */
  105682. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  105683. private _blockMaterialDirtyMechanism;
  105684. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  105685. blockMaterialDirtyMechanism: boolean;
  105686. /**
  105687. * Will flag all materials as dirty to trigger new shader compilation
  105688. * @param flag defines the flag used to specify which material part must be marked as dirty
  105689. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  105690. */
  105691. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  105692. /** @hidden */
  105693. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  105694. /** @hidden */
  105695. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105696. /** @hidden */
  105697. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  105698. /** @hidden */
  105699. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  105700. /** @hidden */
  105701. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105702. /** @hidden */
  105703. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  105704. }
  105705. }
  105706. declare module BABYLON {
  105707. /**
  105708. * Set of assets to keep when moving a scene into an asset container.
  105709. */
  105710. export class KeepAssets extends AbstractScene {
  105711. }
  105712. /**
  105713. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  105714. */
  105715. export class InstantiatedEntries {
  105716. /**
  105717. * List of new root nodes (eg. nodes with no parent)
  105718. */
  105719. rootNodes: TransformNode[];
  105720. /**
  105721. * List of new skeletons
  105722. */
  105723. skeletons: Skeleton[];
  105724. /**
  105725. * List of new animation groups
  105726. */
  105727. animationGroups: AnimationGroup[];
  105728. }
  105729. /**
  105730. * Container with a set of assets that can be added or removed from a scene.
  105731. */
  105732. export class AssetContainer extends AbstractScene {
  105733. /**
  105734. * The scene the AssetContainer belongs to.
  105735. */
  105736. scene: Scene;
  105737. /**
  105738. * Instantiates an AssetContainer.
  105739. * @param scene The scene the AssetContainer belongs to.
  105740. */
  105741. constructor(scene: Scene);
  105742. /**
  105743. * Instantiate or clone all meshes and add the new ones to the scene.
  105744. * Skeletons and animation groups will all be cloned
  105745. * @param nameFunction defines an optional function used to get new names for clones
  105746. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  105747. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  105748. */
  105749. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  105750. /**
  105751. * Adds all the assets from the container to the scene.
  105752. */
  105753. addAllToScene(): void;
  105754. /**
  105755. * Removes all the assets in the container from the scene
  105756. */
  105757. removeAllFromScene(): void;
  105758. /**
  105759. * Disposes all the assets in the container
  105760. */
  105761. dispose(): void;
  105762. private _moveAssets;
  105763. /**
  105764. * Removes all the assets contained in the scene and adds them to the container.
  105765. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  105766. */
  105767. moveAllFromScene(keepAssets?: KeepAssets): void;
  105768. /**
  105769. * 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.
  105770. * @returns the root mesh
  105771. */
  105772. createRootMesh(): Mesh;
  105773. /**
  105774. * Merge animations from this asset container into a scene
  105775. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105776. * @param animatables set of animatables to retarget to a node from the scene
  105777. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  105778. */
  105779. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  105780. }
  105781. }
  105782. declare module BABYLON {
  105783. /**
  105784. * Defines how the parser contract is defined.
  105785. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  105786. */
  105787. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  105788. /**
  105789. * Defines how the individual parser contract is defined.
  105790. * These parser can parse an individual asset
  105791. */
  105792. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  105793. /**
  105794. * Base class of the scene acting as a container for the different elements composing a scene.
  105795. * This class is dynamically extended by the different components of the scene increasing
  105796. * flexibility and reducing coupling
  105797. */
  105798. export abstract class AbstractScene {
  105799. /**
  105800. * Stores the list of available parsers in the application.
  105801. */
  105802. private static _BabylonFileParsers;
  105803. /**
  105804. * Stores the list of available individual parsers in the application.
  105805. */
  105806. private static _IndividualBabylonFileParsers;
  105807. /**
  105808. * Adds a parser in the list of available ones
  105809. * @param name Defines the name of the parser
  105810. * @param parser Defines the parser to add
  105811. */
  105812. static AddParser(name: string, parser: BabylonFileParser): void;
  105813. /**
  105814. * Gets a general parser from the list of avaialble ones
  105815. * @param name Defines the name of the parser
  105816. * @returns the requested parser or null
  105817. */
  105818. static GetParser(name: string): Nullable<BabylonFileParser>;
  105819. /**
  105820. * Adds n individual parser in the list of available ones
  105821. * @param name Defines the name of the parser
  105822. * @param parser Defines the parser to add
  105823. */
  105824. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  105825. /**
  105826. * Gets an individual parser from the list of avaialble ones
  105827. * @param name Defines the name of the parser
  105828. * @returns the requested parser or null
  105829. */
  105830. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  105831. /**
  105832. * Parser json data and populate both a scene and its associated container object
  105833. * @param jsonData Defines the data to parse
  105834. * @param scene Defines the scene to parse the data for
  105835. * @param container Defines the container attached to the parsing sequence
  105836. * @param rootUrl Defines the root url of the data
  105837. */
  105838. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  105839. /**
  105840. * Gets the list of root nodes (ie. nodes with no parent)
  105841. */
  105842. rootNodes: Node[];
  105843. /** All of the cameras added to this scene
  105844. * @see http://doc.babylonjs.com/babylon101/cameras
  105845. */
  105846. cameras: Camera[];
  105847. /**
  105848. * All of the lights added to this scene
  105849. * @see http://doc.babylonjs.com/babylon101/lights
  105850. */
  105851. lights: Light[];
  105852. /**
  105853. * All of the (abstract) meshes added to this scene
  105854. */
  105855. meshes: AbstractMesh[];
  105856. /**
  105857. * The list of skeletons added to the scene
  105858. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  105859. */
  105860. skeletons: Skeleton[];
  105861. /**
  105862. * All of the particle systems added to this scene
  105863. * @see http://doc.babylonjs.com/babylon101/particles
  105864. */
  105865. particleSystems: IParticleSystem[];
  105866. /**
  105867. * Gets a list of Animations associated with the scene
  105868. */
  105869. animations: Animation[];
  105870. /**
  105871. * All of the animation groups added to this scene
  105872. * @see http://doc.babylonjs.com/how_to/group
  105873. */
  105874. animationGroups: AnimationGroup[];
  105875. /**
  105876. * All of the multi-materials added to this scene
  105877. * @see http://doc.babylonjs.com/how_to/multi_materials
  105878. */
  105879. multiMaterials: MultiMaterial[];
  105880. /**
  105881. * All of the materials added to this scene
  105882. * In the context of a Scene, it is not supposed to be modified manually.
  105883. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  105884. * Note also that the order of the Material within the array is not significant and might change.
  105885. * @see http://doc.babylonjs.com/babylon101/materials
  105886. */
  105887. materials: Material[];
  105888. /**
  105889. * The list of morph target managers added to the scene
  105890. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  105891. */
  105892. morphTargetManagers: MorphTargetManager[];
  105893. /**
  105894. * The list of geometries used in the scene.
  105895. */
  105896. geometries: Geometry[];
  105897. /**
  105898. * All of the tranform nodes added to this scene
  105899. * In the context of a Scene, it is not supposed to be modified manually.
  105900. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  105901. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  105902. * @see http://doc.babylonjs.com/how_to/transformnode
  105903. */
  105904. transformNodes: TransformNode[];
  105905. /**
  105906. * ActionManagers available on the scene.
  105907. */
  105908. actionManagers: AbstractActionManager[];
  105909. /**
  105910. * Textures to keep.
  105911. */
  105912. textures: BaseTexture[];
  105913. /**
  105914. * Environment texture for the scene
  105915. */
  105916. environmentTexture: Nullable<BaseTexture>;
  105917. /**
  105918. * @returns all meshes, lights, cameras, transformNodes and bones
  105919. */
  105920. getNodes(): Array<Node>;
  105921. }
  105922. }
  105923. declare module BABYLON {
  105924. /**
  105925. * Interface used to define options for Sound class
  105926. */
  105927. export interface ISoundOptions {
  105928. /**
  105929. * Does the sound autoplay once loaded.
  105930. */
  105931. autoplay?: boolean;
  105932. /**
  105933. * Does the sound loop after it finishes playing once.
  105934. */
  105935. loop?: boolean;
  105936. /**
  105937. * Sound's volume
  105938. */
  105939. volume?: number;
  105940. /**
  105941. * Is it a spatial sound?
  105942. */
  105943. spatialSound?: boolean;
  105944. /**
  105945. * Maximum distance to hear that sound
  105946. */
  105947. maxDistance?: number;
  105948. /**
  105949. * Uses user defined attenuation function
  105950. */
  105951. useCustomAttenuation?: boolean;
  105952. /**
  105953. * Define the roll off factor of spatial sounds.
  105954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105955. */
  105956. rolloffFactor?: number;
  105957. /**
  105958. * Define the reference distance the sound should be heard perfectly.
  105959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105960. */
  105961. refDistance?: number;
  105962. /**
  105963. * Define the distance attenuation model the sound will follow.
  105964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  105965. */
  105966. distanceModel?: string;
  105967. /**
  105968. * Defines the playback speed (1 by default)
  105969. */
  105970. playbackRate?: number;
  105971. /**
  105972. * Defines if the sound is from a streaming source
  105973. */
  105974. streaming?: boolean;
  105975. /**
  105976. * Defines an optional length (in seconds) inside the sound file
  105977. */
  105978. length?: number;
  105979. /**
  105980. * Defines an optional offset (in seconds) inside the sound file
  105981. */
  105982. offset?: number;
  105983. /**
  105984. * If true, URLs will not be required to state the audio file codec to use.
  105985. */
  105986. skipCodecCheck?: boolean;
  105987. }
  105988. /**
  105989. * Defines a sound that can be played in the application.
  105990. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  105991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105992. */
  105993. export class Sound {
  105994. /**
  105995. * The name of the sound in the scene.
  105996. */
  105997. name: string;
  105998. /**
  105999. * Does the sound autoplay once loaded.
  106000. */
  106001. autoplay: boolean;
  106002. /**
  106003. * Does the sound loop after it finishes playing once.
  106004. */
  106005. loop: boolean;
  106006. /**
  106007. * Does the sound use a custom attenuation curve to simulate the falloff
  106008. * happening when the source gets further away from the camera.
  106009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  106010. */
  106011. useCustomAttenuation: boolean;
  106012. /**
  106013. * The sound track id this sound belongs to.
  106014. */
  106015. soundTrackId: number;
  106016. /**
  106017. * Is this sound currently played.
  106018. */
  106019. isPlaying: boolean;
  106020. /**
  106021. * Is this sound currently paused.
  106022. */
  106023. isPaused: boolean;
  106024. /**
  106025. * Does this sound enables spatial sound.
  106026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106027. */
  106028. spatialSound: boolean;
  106029. /**
  106030. * Define the reference distance the sound should be heard perfectly.
  106031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106032. */
  106033. refDistance: number;
  106034. /**
  106035. * Define the roll off factor of spatial sounds.
  106036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106037. */
  106038. rolloffFactor: number;
  106039. /**
  106040. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  106041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106042. */
  106043. maxDistance: number;
  106044. /**
  106045. * Define the distance attenuation model the sound will follow.
  106046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106047. */
  106048. distanceModel: string;
  106049. /**
  106050. * @hidden
  106051. * Back Compat
  106052. **/
  106053. onended: () => any;
  106054. /**
  106055. * Observable event when the current playing sound finishes.
  106056. */
  106057. onEndedObservable: Observable<Sound>;
  106058. private _panningModel;
  106059. private _playbackRate;
  106060. private _streaming;
  106061. private _startTime;
  106062. private _startOffset;
  106063. private _position;
  106064. /** @hidden */
  106065. _positionInEmitterSpace: boolean;
  106066. private _localDirection;
  106067. private _volume;
  106068. private _isReadyToPlay;
  106069. private _isDirectional;
  106070. private _readyToPlayCallback;
  106071. private _audioBuffer;
  106072. private _soundSource;
  106073. private _streamingSource;
  106074. private _soundPanner;
  106075. private _soundGain;
  106076. private _inputAudioNode;
  106077. private _outputAudioNode;
  106078. private _coneInnerAngle;
  106079. private _coneOuterAngle;
  106080. private _coneOuterGain;
  106081. private _scene;
  106082. private _connectedTransformNode;
  106083. private _customAttenuationFunction;
  106084. private _registerFunc;
  106085. private _isOutputConnected;
  106086. private _htmlAudioElement;
  106087. private _urlType;
  106088. private _length?;
  106089. private _offset?;
  106090. /** @hidden */
  106091. static _SceneComponentInitialization: (scene: Scene) => void;
  106092. /**
  106093. * Create a sound and attach it to a scene
  106094. * @param name Name of your sound
  106095. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  106096. * @param scene defines the scene the sound belongs to
  106097. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  106098. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  106099. */
  106100. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  106101. /**
  106102. * Release the sound and its associated resources
  106103. */
  106104. dispose(): void;
  106105. /**
  106106. * Gets if the sounds is ready to be played or not.
  106107. * @returns true if ready, otherwise false
  106108. */
  106109. isReady(): boolean;
  106110. private _soundLoaded;
  106111. /**
  106112. * Sets the data of the sound from an audiobuffer
  106113. * @param audioBuffer The audioBuffer containing the data
  106114. */
  106115. setAudioBuffer(audioBuffer: AudioBuffer): void;
  106116. /**
  106117. * Updates the current sounds options such as maxdistance, loop...
  106118. * @param options A JSON object containing values named as the object properties
  106119. */
  106120. updateOptions(options: ISoundOptions): void;
  106121. private _createSpatialParameters;
  106122. private _updateSpatialParameters;
  106123. /**
  106124. * Switch the panning model to HRTF:
  106125. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  106126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106127. */
  106128. switchPanningModelToHRTF(): void;
  106129. /**
  106130. * Switch the panning model to Equal Power:
  106131. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  106132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106133. */
  106134. switchPanningModelToEqualPower(): void;
  106135. private _switchPanningModel;
  106136. /**
  106137. * Connect this sound to a sound track audio node like gain...
  106138. * @param soundTrackAudioNode the sound track audio node to connect to
  106139. */
  106140. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  106141. /**
  106142. * Transform this sound into a directional source
  106143. * @param coneInnerAngle Size of the inner cone in degree
  106144. * @param coneOuterAngle Size of the outer cone in degree
  106145. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  106146. */
  106147. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  106148. /**
  106149. * Gets or sets the inner angle for the directional cone.
  106150. */
  106151. /**
  106152. * Gets or sets the inner angle for the directional cone.
  106153. */
  106154. directionalConeInnerAngle: number;
  106155. /**
  106156. * Gets or sets the outer angle for the directional cone.
  106157. */
  106158. /**
  106159. * Gets or sets the outer angle for the directional cone.
  106160. */
  106161. directionalConeOuterAngle: number;
  106162. /**
  106163. * Sets the position of the emitter if spatial sound is enabled
  106164. * @param newPosition Defines the new posisiton
  106165. */
  106166. setPosition(newPosition: Vector3): void;
  106167. /**
  106168. * Sets the local direction of the emitter if spatial sound is enabled
  106169. * @param newLocalDirection Defines the new local direction
  106170. */
  106171. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  106172. private _updateDirection;
  106173. /** @hidden */
  106174. updateDistanceFromListener(): void;
  106175. /**
  106176. * Sets a new custom attenuation function for the sound.
  106177. * @param callback Defines the function used for the attenuation
  106178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  106179. */
  106180. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  106181. /**
  106182. * Play the sound
  106183. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  106184. * @param offset (optional) Start the sound at a specific time in seconds
  106185. * @param length (optional) Sound duration (in seconds)
  106186. */
  106187. play(time?: number, offset?: number, length?: number): void;
  106188. private _onended;
  106189. /**
  106190. * Stop the sound
  106191. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  106192. */
  106193. stop(time?: number): void;
  106194. /**
  106195. * Put the sound in pause
  106196. */
  106197. pause(): void;
  106198. /**
  106199. * Sets a dedicated volume for this sounds
  106200. * @param newVolume Define the new volume of the sound
  106201. * @param time Define time for gradual change to new volume
  106202. */
  106203. setVolume(newVolume: number, time?: number): void;
  106204. /**
  106205. * Set the sound play back rate
  106206. * @param newPlaybackRate Define the playback rate the sound should be played at
  106207. */
  106208. setPlaybackRate(newPlaybackRate: number): void;
  106209. /**
  106210. * Gets the volume of the sound.
  106211. * @returns the volume of the sound
  106212. */
  106213. getVolume(): number;
  106214. /**
  106215. * Attach the sound to a dedicated mesh
  106216. * @param transformNode The transform node to connect the sound with
  106217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106218. */
  106219. attachToMesh(transformNode: TransformNode): void;
  106220. /**
  106221. * Detach the sound from the previously attached mesh
  106222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  106223. */
  106224. detachFromMesh(): void;
  106225. private _onRegisterAfterWorldMatrixUpdate;
  106226. /**
  106227. * Clone the current sound in the scene.
  106228. * @returns the new sound clone
  106229. */
  106230. clone(): Nullable<Sound>;
  106231. /**
  106232. * Gets the current underlying audio buffer containing the data
  106233. * @returns the audio buffer
  106234. */
  106235. getAudioBuffer(): Nullable<AudioBuffer>;
  106236. /**
  106237. * Serializes the Sound in a JSON representation
  106238. * @returns the JSON representation of the sound
  106239. */
  106240. serialize(): any;
  106241. /**
  106242. * Parse a JSON representation of a sound to innstantiate in a given scene
  106243. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  106244. * @param scene Define the scene the new parsed sound should be created in
  106245. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  106246. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  106247. * @returns the newly parsed sound
  106248. */
  106249. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  106250. }
  106251. }
  106252. declare module BABYLON {
  106253. /**
  106254. * This defines an action helpful to play a defined sound on a triggered action.
  106255. */
  106256. export class PlaySoundAction extends Action {
  106257. private _sound;
  106258. /**
  106259. * Instantiate the action
  106260. * @param triggerOptions defines the trigger options
  106261. * @param sound defines the sound to play
  106262. * @param condition defines the trigger related conditions
  106263. */
  106264. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106265. /** @hidden */
  106266. _prepare(): void;
  106267. /**
  106268. * Execute the action and play the sound.
  106269. */
  106270. execute(): void;
  106271. /**
  106272. * Serializes the actions and its related information.
  106273. * @param parent defines the object to serialize in
  106274. * @returns the serialized object
  106275. */
  106276. serialize(parent: any): any;
  106277. }
  106278. /**
  106279. * This defines an action helpful to stop a defined sound on a triggered action.
  106280. */
  106281. export class StopSoundAction extends Action {
  106282. private _sound;
  106283. /**
  106284. * Instantiate the action
  106285. * @param triggerOptions defines the trigger options
  106286. * @param sound defines the sound to stop
  106287. * @param condition defines the trigger related conditions
  106288. */
  106289. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  106290. /** @hidden */
  106291. _prepare(): void;
  106292. /**
  106293. * Execute the action and stop the sound.
  106294. */
  106295. execute(): void;
  106296. /**
  106297. * Serializes the actions and its related information.
  106298. * @param parent defines the object to serialize in
  106299. * @returns the serialized object
  106300. */
  106301. serialize(parent: any): any;
  106302. }
  106303. }
  106304. declare module BABYLON {
  106305. /**
  106306. * This defines an action responsible to change the value of a property
  106307. * by interpolating between its current value and the newly set one once triggered.
  106308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106309. */
  106310. export class InterpolateValueAction extends Action {
  106311. /**
  106312. * Defines the path of the property where the value should be interpolated
  106313. */
  106314. propertyPath: string;
  106315. /**
  106316. * Defines the target value at the end of the interpolation.
  106317. */
  106318. value: any;
  106319. /**
  106320. * Defines the time it will take for the property to interpolate to the value.
  106321. */
  106322. duration: number;
  106323. /**
  106324. * Defines if the other scene animations should be stopped when the action has been triggered
  106325. */
  106326. stopOtherAnimations?: boolean;
  106327. /**
  106328. * Defines a callback raised once the interpolation animation has been done.
  106329. */
  106330. onInterpolationDone?: () => void;
  106331. /**
  106332. * Observable triggered once the interpolation animation has been done.
  106333. */
  106334. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  106335. private _target;
  106336. private _effectiveTarget;
  106337. private _property;
  106338. /**
  106339. * Instantiate the action
  106340. * @param triggerOptions defines the trigger options
  106341. * @param target defines the object containing the value to interpolate
  106342. * @param propertyPath defines the path to the property in the target object
  106343. * @param value defines the target value at the end of the interpolation
  106344. * @param duration deines the time it will take for the property to interpolate to the value.
  106345. * @param condition defines the trigger related conditions
  106346. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  106347. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  106348. */
  106349. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  106350. /** @hidden */
  106351. _prepare(): void;
  106352. /**
  106353. * Execute the action starts the value interpolation.
  106354. */
  106355. execute(): void;
  106356. /**
  106357. * Serializes the actions and its related information.
  106358. * @param parent defines the object to serialize in
  106359. * @returns the serialized object
  106360. */
  106361. serialize(parent: any): any;
  106362. }
  106363. }
  106364. declare module BABYLON {
  106365. /**
  106366. * Options allowed during the creation of a sound track.
  106367. */
  106368. export interface ISoundTrackOptions {
  106369. /**
  106370. * The volume the sound track should take during creation
  106371. */
  106372. volume?: number;
  106373. /**
  106374. * Define if the sound track is the main sound track of the scene
  106375. */
  106376. mainTrack?: boolean;
  106377. }
  106378. /**
  106379. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  106380. * It will be also used in a future release to apply effects on a specific track.
  106381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  106382. */
  106383. export class SoundTrack {
  106384. /**
  106385. * The unique identifier of the sound track in the scene.
  106386. */
  106387. id: number;
  106388. /**
  106389. * The list of sounds included in the sound track.
  106390. */
  106391. soundCollection: Array<Sound>;
  106392. private _outputAudioNode;
  106393. private _scene;
  106394. private _connectedAnalyser;
  106395. private _options;
  106396. private _isInitialized;
  106397. /**
  106398. * Creates a new sound track.
  106399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  106400. * @param scene Define the scene the sound track belongs to
  106401. * @param options
  106402. */
  106403. constructor(scene: Scene, options?: ISoundTrackOptions);
  106404. private _initializeSoundTrackAudioGraph;
  106405. /**
  106406. * Release the sound track and its associated resources
  106407. */
  106408. dispose(): void;
  106409. /**
  106410. * Adds a sound to this sound track
  106411. * @param sound define the cound to add
  106412. * @ignoreNaming
  106413. */
  106414. AddSound(sound: Sound): void;
  106415. /**
  106416. * Removes a sound to this sound track
  106417. * @param sound define the cound to remove
  106418. * @ignoreNaming
  106419. */
  106420. RemoveSound(sound: Sound): void;
  106421. /**
  106422. * Set a global volume for the full sound track.
  106423. * @param newVolume Define the new volume of the sound track
  106424. */
  106425. setVolume(newVolume: number): void;
  106426. /**
  106427. * Switch the panning model to HRTF:
  106428. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  106429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106430. */
  106431. switchPanningModelToHRTF(): void;
  106432. /**
  106433. * Switch the panning model to Equal Power:
  106434. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  106435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  106436. */
  106437. switchPanningModelToEqualPower(): void;
  106438. /**
  106439. * Connect the sound track to an audio analyser allowing some amazing
  106440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106442. * @param analyser The analyser to connect to the engine
  106443. */
  106444. connectToAnalyser(analyser: Analyser): void;
  106445. }
  106446. }
  106447. declare module BABYLON {
  106448. interface AbstractScene {
  106449. /**
  106450. * The list of sounds used in the scene.
  106451. */
  106452. sounds: Nullable<Array<Sound>>;
  106453. }
  106454. interface Scene {
  106455. /**
  106456. * @hidden
  106457. * Backing field
  106458. */
  106459. _mainSoundTrack: SoundTrack;
  106460. /**
  106461. * The main sound track played by the scene.
  106462. * It cotains your primary collection of sounds.
  106463. */
  106464. mainSoundTrack: SoundTrack;
  106465. /**
  106466. * The list of sound tracks added to the scene
  106467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106468. */
  106469. soundTracks: Nullable<Array<SoundTrack>>;
  106470. /**
  106471. * Gets a sound using a given name
  106472. * @param name defines the name to search for
  106473. * @return the found sound or null if not found at all.
  106474. */
  106475. getSoundByName(name: string): Nullable<Sound>;
  106476. /**
  106477. * Gets or sets if audio support is enabled
  106478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106479. */
  106480. audioEnabled: boolean;
  106481. /**
  106482. * Gets or sets if audio will be output to headphones
  106483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106484. */
  106485. headphone: boolean;
  106486. /**
  106487. * Gets or sets custom audio listener position provider
  106488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106489. */
  106490. audioListenerPositionProvider: Nullable<() => Vector3>;
  106491. /**
  106492. * Gets or sets a refresh rate when using 3D audio positioning
  106493. */
  106494. audioPositioningRefreshRate: number;
  106495. }
  106496. /**
  106497. * Defines the sound scene component responsible to manage any sounds
  106498. * in a given scene.
  106499. */
  106500. export class AudioSceneComponent implements ISceneSerializableComponent {
  106501. /**
  106502. * The component name helpfull to identify the component in the list of scene components.
  106503. */
  106504. readonly name: string;
  106505. /**
  106506. * The scene the component belongs to.
  106507. */
  106508. scene: Scene;
  106509. private _audioEnabled;
  106510. /**
  106511. * Gets whether audio is enabled or not.
  106512. * Please use related enable/disable method to switch state.
  106513. */
  106514. readonly audioEnabled: boolean;
  106515. private _headphone;
  106516. /**
  106517. * Gets whether audio is outputing to headphone or not.
  106518. * Please use the according Switch methods to change output.
  106519. */
  106520. readonly headphone: boolean;
  106521. /**
  106522. * Gets or sets a refresh rate when using 3D audio positioning
  106523. */
  106524. audioPositioningRefreshRate: number;
  106525. private _audioListenerPositionProvider;
  106526. /**
  106527. * Gets the current audio listener position provider
  106528. */
  106529. /**
  106530. * Sets a custom listener position for all sounds in the scene
  106531. * By default, this is the position of the first active camera
  106532. */
  106533. audioListenerPositionProvider: Nullable<() => Vector3>;
  106534. /**
  106535. * Creates a new instance of the component for the given scene
  106536. * @param scene Defines the scene to register the component in
  106537. */
  106538. constructor(scene: Scene);
  106539. /**
  106540. * Registers the component in a given scene
  106541. */
  106542. register(): void;
  106543. /**
  106544. * Rebuilds the elements related to this component in case of
  106545. * context lost for instance.
  106546. */
  106547. rebuild(): void;
  106548. /**
  106549. * Serializes the component data to the specified json object
  106550. * @param serializationObject The object to serialize to
  106551. */
  106552. serialize(serializationObject: any): void;
  106553. /**
  106554. * Adds all the elements from the container to the scene
  106555. * @param container the container holding the elements
  106556. */
  106557. addFromContainer(container: AbstractScene): void;
  106558. /**
  106559. * Removes all the elements in the container from the scene
  106560. * @param container contains the elements to remove
  106561. * @param dispose if the removed element should be disposed (default: false)
  106562. */
  106563. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106564. /**
  106565. * Disposes the component and the associated ressources.
  106566. */
  106567. dispose(): void;
  106568. /**
  106569. * Disables audio in the associated scene.
  106570. */
  106571. disableAudio(): void;
  106572. /**
  106573. * Enables audio in the associated scene.
  106574. */
  106575. enableAudio(): void;
  106576. /**
  106577. * Switch audio to headphone output.
  106578. */
  106579. switchAudioModeForHeadphones(): void;
  106580. /**
  106581. * Switch audio to normal speakers.
  106582. */
  106583. switchAudioModeForNormalSpeakers(): void;
  106584. private _cachedCameraDirection;
  106585. private _cachedCameraPosition;
  106586. private _lastCheck;
  106587. private _afterRender;
  106588. }
  106589. }
  106590. declare module BABYLON {
  106591. /**
  106592. * Wraps one or more Sound objects and selects one with random weight for playback.
  106593. */
  106594. export class WeightedSound {
  106595. /** When true a Sound will be selected and played when the current playing Sound completes. */
  106596. loop: boolean;
  106597. private _coneInnerAngle;
  106598. private _coneOuterAngle;
  106599. private _volume;
  106600. /** A Sound is currently playing. */
  106601. isPlaying: boolean;
  106602. /** A Sound is currently paused. */
  106603. isPaused: boolean;
  106604. private _sounds;
  106605. private _weights;
  106606. private _currentIndex?;
  106607. /**
  106608. * Creates a new WeightedSound from the list of sounds given.
  106609. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  106610. * @param sounds Array of Sounds that will be selected from.
  106611. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  106612. */
  106613. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  106614. /**
  106615. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  106616. */
  106617. /**
  106618. * The size of cone in degress for a directional sound in which there will be no attenuation.
  106619. */
  106620. directionalConeInnerAngle: number;
  106621. /**
  106622. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106623. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106624. */
  106625. /**
  106626. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  106627. * Listener angles between innerAngle and outerAngle will falloff linearly.
  106628. */
  106629. directionalConeOuterAngle: number;
  106630. /**
  106631. * Playback volume.
  106632. */
  106633. /**
  106634. * Playback volume.
  106635. */
  106636. volume: number;
  106637. private _onended;
  106638. /**
  106639. * Suspend playback
  106640. */
  106641. pause(): void;
  106642. /**
  106643. * Stop playback
  106644. */
  106645. stop(): void;
  106646. /**
  106647. * Start playback.
  106648. * @param startOffset Position the clip head at a specific time in seconds.
  106649. */
  106650. play(startOffset?: number): void;
  106651. }
  106652. }
  106653. declare module BABYLON {
  106654. /**
  106655. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  106656. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  106657. */
  106658. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  106659. /**
  106660. * Gets the name of the behavior.
  106661. */
  106662. readonly name: string;
  106663. /**
  106664. * The easing function used by animations
  106665. */
  106666. static EasingFunction: BackEase;
  106667. /**
  106668. * The easing mode used by animations
  106669. */
  106670. static EasingMode: number;
  106671. /**
  106672. * The duration of the animation, in milliseconds
  106673. */
  106674. transitionDuration: number;
  106675. /**
  106676. * Length of the distance animated by the transition when lower radius is reached
  106677. */
  106678. lowerRadiusTransitionRange: number;
  106679. /**
  106680. * Length of the distance animated by the transition when upper radius is reached
  106681. */
  106682. upperRadiusTransitionRange: number;
  106683. private _autoTransitionRange;
  106684. /**
  106685. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106686. */
  106687. /**
  106688. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  106689. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  106690. */
  106691. autoTransitionRange: boolean;
  106692. private _attachedCamera;
  106693. private _onAfterCheckInputsObserver;
  106694. private _onMeshTargetChangedObserver;
  106695. /**
  106696. * Initializes the behavior.
  106697. */
  106698. init(): void;
  106699. /**
  106700. * Attaches the behavior to its arc rotate camera.
  106701. * @param camera Defines the camera to attach the behavior to
  106702. */
  106703. attach(camera: ArcRotateCamera): void;
  106704. /**
  106705. * Detaches the behavior from its current arc rotate camera.
  106706. */
  106707. detach(): void;
  106708. private _radiusIsAnimating;
  106709. private _radiusBounceTransition;
  106710. private _animatables;
  106711. private _cachedWheelPrecision;
  106712. /**
  106713. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  106714. * @param radiusLimit The limit to check against.
  106715. * @return Bool to indicate if at limit.
  106716. */
  106717. private _isRadiusAtLimit;
  106718. /**
  106719. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  106720. * @param radiusDelta The delta by which to animate to. Can be negative.
  106721. */
  106722. private _applyBoundRadiusAnimation;
  106723. /**
  106724. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  106725. */
  106726. protected _clearAnimationLocks(): void;
  106727. /**
  106728. * Stops and removes all animations that have been applied to the camera
  106729. */
  106730. stopAllAnimations(): void;
  106731. }
  106732. }
  106733. declare module BABYLON {
  106734. /**
  106735. * 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.
  106736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  106737. */
  106738. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  106739. /**
  106740. * Gets the name of the behavior.
  106741. */
  106742. readonly name: string;
  106743. private _mode;
  106744. private _radiusScale;
  106745. private _positionScale;
  106746. private _defaultElevation;
  106747. private _elevationReturnTime;
  106748. private _elevationReturnWaitTime;
  106749. private _zoomStopsAnimation;
  106750. private _framingTime;
  106751. /**
  106752. * The easing function used by animations
  106753. */
  106754. static EasingFunction: ExponentialEase;
  106755. /**
  106756. * The easing mode used by animations
  106757. */
  106758. static EasingMode: number;
  106759. /**
  106760. * Sets the current mode used by the behavior
  106761. */
  106762. /**
  106763. * Gets current mode used by the behavior.
  106764. */
  106765. mode: number;
  106766. /**
  106767. * Sets the scale applied to the radius (1 by default)
  106768. */
  106769. /**
  106770. * Gets the scale applied to the radius
  106771. */
  106772. radiusScale: number;
  106773. /**
  106774. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106775. */
  106776. /**
  106777. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  106778. */
  106779. positionScale: number;
  106780. /**
  106781. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106782. * behaviour is triggered, in radians.
  106783. */
  106784. /**
  106785. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  106786. * behaviour is triggered, in radians.
  106787. */
  106788. defaultElevation: number;
  106789. /**
  106790. * Sets the time (in milliseconds) taken to return to the default beta position.
  106791. * Negative value indicates camera should not return to default.
  106792. */
  106793. /**
  106794. * Gets the time (in milliseconds) taken to return to the default beta position.
  106795. * Negative value indicates camera should not return to default.
  106796. */
  106797. elevationReturnTime: number;
  106798. /**
  106799. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106800. */
  106801. /**
  106802. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  106803. */
  106804. elevationReturnWaitTime: number;
  106805. /**
  106806. * Sets the flag that indicates if user zooming should stop animation.
  106807. */
  106808. /**
  106809. * Gets the flag that indicates if user zooming should stop animation.
  106810. */
  106811. zoomStopsAnimation: boolean;
  106812. /**
  106813. * Sets the transition time when framing the mesh, in milliseconds
  106814. */
  106815. /**
  106816. * Gets the transition time when framing the mesh, in milliseconds
  106817. */
  106818. framingTime: number;
  106819. /**
  106820. * Define if the behavior should automatically change the configured
  106821. * camera limits and sensibilities.
  106822. */
  106823. autoCorrectCameraLimitsAndSensibility: boolean;
  106824. private _onPrePointerObservableObserver;
  106825. private _onAfterCheckInputsObserver;
  106826. private _onMeshTargetChangedObserver;
  106827. private _attachedCamera;
  106828. private _isPointerDown;
  106829. private _lastInteractionTime;
  106830. /**
  106831. * Initializes the behavior.
  106832. */
  106833. init(): void;
  106834. /**
  106835. * Attaches the behavior to its arc rotate camera.
  106836. * @param camera Defines the camera to attach the behavior to
  106837. */
  106838. attach(camera: ArcRotateCamera): void;
  106839. /**
  106840. * Detaches the behavior from its current arc rotate camera.
  106841. */
  106842. detach(): void;
  106843. private _animatables;
  106844. private _betaIsAnimating;
  106845. private _betaTransition;
  106846. private _radiusTransition;
  106847. private _vectorTransition;
  106848. /**
  106849. * Targets the given mesh and updates zoom level accordingly.
  106850. * @param mesh The mesh to target.
  106851. * @param radius Optional. If a cached radius position already exists, overrides default.
  106852. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106853. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106854. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106855. */
  106856. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106857. /**
  106858. * Targets the given mesh with its children and updates zoom level accordingly.
  106859. * @param mesh The mesh to target.
  106860. * @param radius Optional. If a cached radius position already exists, overrides default.
  106861. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106862. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106863. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106864. */
  106865. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106866. /**
  106867. * Targets the given meshes with their children and updates zoom level accordingly.
  106868. * @param meshes The mesh to target.
  106869. * @param radius Optional. If a cached radius position already exists, overrides default.
  106870. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  106871. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106872. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106873. */
  106874. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106875. /**
  106876. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  106877. * @param minimumWorld Determines the smaller position of the bounding box extend
  106878. * @param maximumWorld Determines the bigger position of the bounding box extend
  106879. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  106880. * @param onAnimationEnd Callback triggered at the end of the framing animation
  106881. */
  106882. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  106883. /**
  106884. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  106885. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  106886. * frustum width.
  106887. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  106888. * to fully enclose the mesh in the viewing frustum.
  106889. */
  106890. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  106891. /**
  106892. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  106893. * is automatically returned to its default position (expected to be above ground plane).
  106894. */
  106895. private _maintainCameraAboveGround;
  106896. /**
  106897. * Returns the frustum slope based on the canvas ratio and camera FOV
  106898. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  106899. */
  106900. private _getFrustumSlope;
  106901. /**
  106902. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  106903. */
  106904. private _clearAnimationLocks;
  106905. /**
  106906. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  106907. */
  106908. private _applyUserInteraction;
  106909. /**
  106910. * Stops and removes all animations that have been applied to the camera
  106911. */
  106912. stopAllAnimations(): void;
  106913. /**
  106914. * Gets a value indicating if the user is moving the camera
  106915. */
  106916. readonly isUserIsMoving: boolean;
  106917. /**
  106918. * The camera can move all the way towards the mesh.
  106919. */
  106920. static IgnoreBoundsSizeMode: number;
  106921. /**
  106922. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  106923. */
  106924. static FitFrustumSidesMode: number;
  106925. }
  106926. }
  106927. declare module BABYLON {
  106928. /**
  106929. * Base class for Camera Pointer Inputs.
  106930. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  106931. * for example usage.
  106932. */
  106933. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  106934. /**
  106935. * Defines the camera the input is attached to.
  106936. */
  106937. abstract camera: Camera;
  106938. /**
  106939. * Whether keyboard modifier keys are pressed at time of last mouse event.
  106940. */
  106941. protected _altKey: boolean;
  106942. protected _ctrlKey: boolean;
  106943. protected _metaKey: boolean;
  106944. protected _shiftKey: boolean;
  106945. /**
  106946. * Which mouse buttons were pressed at time of last mouse event.
  106947. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  106948. */
  106949. protected _buttonsPressed: number;
  106950. /**
  106951. * Defines the buttons associated with the input to handle camera move.
  106952. */
  106953. buttons: number[];
  106954. /**
  106955. * Attach the input controls to a specific dom element to get the input from.
  106956. * @param element Defines the element the controls should be listened from
  106957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106958. */
  106959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106960. /**
  106961. * Detach the current controls from the specified dom element.
  106962. * @param element Defines the element to stop listening the inputs from
  106963. */
  106964. detachControl(element: Nullable<HTMLElement>): void;
  106965. /**
  106966. * Gets the class name of the current input.
  106967. * @returns the class name
  106968. */
  106969. getClassName(): string;
  106970. /**
  106971. * Get the friendly name associated with the input class.
  106972. * @returns the input friendly name
  106973. */
  106974. getSimpleName(): string;
  106975. /**
  106976. * Called on pointer POINTERDOUBLETAP event.
  106977. * Override this method to provide functionality on POINTERDOUBLETAP event.
  106978. */
  106979. protected onDoubleTap(type: string): void;
  106980. /**
  106981. * Called on pointer POINTERMOVE event if only a single touch is active.
  106982. * Override this method to provide functionality.
  106983. */
  106984. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106985. /**
  106986. * Called on pointer POINTERMOVE event if multiple touches are active.
  106987. * Override this method to provide functionality.
  106988. */
  106989. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106990. /**
  106991. * Called on JS contextmenu event.
  106992. * Override this method to provide functionality.
  106993. */
  106994. protected onContextMenu(evt: PointerEvent): void;
  106995. /**
  106996. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  106997. * press.
  106998. * Override this method to provide functionality.
  106999. */
  107000. protected onButtonDown(evt: PointerEvent): void;
  107001. /**
  107002. * Called each time a new POINTERUP event occurs. Ie, for each button
  107003. * release.
  107004. * Override this method to provide functionality.
  107005. */
  107006. protected onButtonUp(evt: PointerEvent): void;
  107007. /**
  107008. * Called when window becomes inactive.
  107009. * Override this method to provide functionality.
  107010. */
  107011. protected onLostFocus(): void;
  107012. private _pointerInput;
  107013. private _observer;
  107014. private _onLostFocus;
  107015. private pointA;
  107016. private pointB;
  107017. }
  107018. }
  107019. declare module BABYLON {
  107020. /**
  107021. * Manage the pointers inputs to control an arc rotate camera.
  107022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107023. */
  107024. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  107025. /**
  107026. * Defines the camera the input is attached to.
  107027. */
  107028. camera: ArcRotateCamera;
  107029. /**
  107030. * Gets the class name of the current input.
  107031. * @returns the class name
  107032. */
  107033. getClassName(): string;
  107034. /**
  107035. * Defines the buttons associated with the input to handle camera move.
  107036. */
  107037. buttons: number[];
  107038. /**
  107039. * Defines the pointer angular sensibility along the X axis or how fast is
  107040. * the camera rotating.
  107041. */
  107042. angularSensibilityX: number;
  107043. /**
  107044. * Defines the pointer angular sensibility along the Y axis or how fast is
  107045. * the camera rotating.
  107046. */
  107047. angularSensibilityY: number;
  107048. /**
  107049. * Defines the pointer pinch precision or how fast is the camera zooming.
  107050. */
  107051. pinchPrecision: number;
  107052. /**
  107053. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  107054. * from 0.
  107055. * It defines the percentage of current camera.radius to use as delta when
  107056. * pinch zoom is used.
  107057. */
  107058. pinchDeltaPercentage: number;
  107059. /**
  107060. * Defines the pointer panning sensibility or how fast is the camera moving.
  107061. */
  107062. panningSensibility: number;
  107063. /**
  107064. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  107065. */
  107066. multiTouchPanning: boolean;
  107067. /**
  107068. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  107069. * zoom (pinch) through multitouch.
  107070. */
  107071. multiTouchPanAndZoom: boolean;
  107072. /**
  107073. * Revers pinch action direction.
  107074. */
  107075. pinchInwards: boolean;
  107076. private _isPanClick;
  107077. private _twoFingerActivityCount;
  107078. private _isPinching;
  107079. /**
  107080. * Called on pointer POINTERMOVE event if only a single touch is active.
  107081. */
  107082. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  107083. /**
  107084. * Called on pointer POINTERDOUBLETAP event.
  107085. */
  107086. protected onDoubleTap(type: string): void;
  107087. /**
  107088. * Called on pointer POINTERMOVE event if multiple touches are active.
  107089. */
  107090. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  107091. /**
  107092. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  107093. * press.
  107094. */
  107095. protected onButtonDown(evt: PointerEvent): void;
  107096. /**
  107097. * Called each time a new POINTERUP event occurs. Ie, for each button
  107098. * release.
  107099. */
  107100. protected onButtonUp(evt: PointerEvent): void;
  107101. /**
  107102. * Called when window becomes inactive.
  107103. */
  107104. protected onLostFocus(): void;
  107105. }
  107106. }
  107107. declare module BABYLON {
  107108. /**
  107109. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  107110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107111. */
  107112. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  107113. /**
  107114. * Defines the camera the input is attached to.
  107115. */
  107116. camera: ArcRotateCamera;
  107117. /**
  107118. * Defines the list of key codes associated with the up action (increase alpha)
  107119. */
  107120. keysUp: number[];
  107121. /**
  107122. * Defines the list of key codes associated with the down action (decrease alpha)
  107123. */
  107124. keysDown: number[];
  107125. /**
  107126. * Defines the list of key codes associated with the left action (increase beta)
  107127. */
  107128. keysLeft: number[];
  107129. /**
  107130. * Defines the list of key codes associated with the right action (decrease beta)
  107131. */
  107132. keysRight: number[];
  107133. /**
  107134. * Defines the list of key codes associated with the reset action.
  107135. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  107136. */
  107137. keysReset: number[];
  107138. /**
  107139. * Defines the panning sensibility of the inputs.
  107140. * (How fast is the camera paning)
  107141. */
  107142. panningSensibility: number;
  107143. /**
  107144. * Defines the zooming sensibility of the inputs.
  107145. * (How fast is the camera zooming)
  107146. */
  107147. zoomingSensibility: number;
  107148. /**
  107149. * Defines wether maintaining the alt key down switch the movement mode from
  107150. * orientation to zoom.
  107151. */
  107152. useAltToZoom: boolean;
  107153. /**
  107154. * Rotation speed of the camera
  107155. */
  107156. angularSpeed: number;
  107157. private _keys;
  107158. private _ctrlPressed;
  107159. private _altPressed;
  107160. private _onCanvasBlurObserver;
  107161. private _onKeyboardObserver;
  107162. private _engine;
  107163. private _scene;
  107164. /**
  107165. * Attach the input controls to a specific dom element to get the input from.
  107166. * @param element Defines the element the controls should be listened from
  107167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107168. */
  107169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107170. /**
  107171. * Detach the current controls from the specified dom element.
  107172. * @param element Defines the element to stop listening the inputs from
  107173. */
  107174. detachControl(element: Nullable<HTMLElement>): void;
  107175. /**
  107176. * Update the current camera state depending on the inputs that have been used this frame.
  107177. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107178. */
  107179. checkInputs(): void;
  107180. /**
  107181. * Gets the class name of the current intput.
  107182. * @returns the class name
  107183. */
  107184. getClassName(): string;
  107185. /**
  107186. * Get the friendly name associated with the input class.
  107187. * @returns the input friendly name
  107188. */
  107189. getSimpleName(): string;
  107190. }
  107191. }
  107192. declare module BABYLON {
  107193. /**
  107194. * Manage the mouse wheel inputs to control an arc rotate camera.
  107195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107196. */
  107197. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  107198. /**
  107199. * Defines the camera the input is attached to.
  107200. */
  107201. camera: ArcRotateCamera;
  107202. /**
  107203. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107204. */
  107205. wheelPrecision: number;
  107206. /**
  107207. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  107208. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  107209. */
  107210. wheelDeltaPercentage: number;
  107211. private _wheel;
  107212. private _observer;
  107213. private computeDeltaFromMouseWheelLegacyEvent;
  107214. /**
  107215. * Attach the input controls to a specific dom element to get the input from.
  107216. * @param element Defines the element the controls should be listened from
  107217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107218. */
  107219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107220. /**
  107221. * Detach the current controls from the specified dom element.
  107222. * @param element Defines the element to stop listening the inputs from
  107223. */
  107224. detachControl(element: Nullable<HTMLElement>): void;
  107225. /**
  107226. * Gets the class name of the current intput.
  107227. * @returns the class name
  107228. */
  107229. getClassName(): string;
  107230. /**
  107231. * Get the friendly name associated with the input class.
  107232. * @returns the input friendly name
  107233. */
  107234. getSimpleName(): string;
  107235. }
  107236. }
  107237. declare module BABYLON {
  107238. /**
  107239. * Default Inputs manager for the ArcRotateCamera.
  107240. * It groups all the default supported inputs for ease of use.
  107241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107242. */
  107243. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  107244. /**
  107245. * Instantiates a new ArcRotateCameraInputsManager.
  107246. * @param camera Defines the camera the inputs belong to
  107247. */
  107248. constructor(camera: ArcRotateCamera);
  107249. /**
  107250. * Add mouse wheel input support to the input manager.
  107251. * @returns the current input manager
  107252. */
  107253. addMouseWheel(): ArcRotateCameraInputsManager;
  107254. /**
  107255. * Add pointers input support to the input manager.
  107256. * @returns the current input manager
  107257. */
  107258. addPointers(): ArcRotateCameraInputsManager;
  107259. /**
  107260. * Add keyboard input support to the input manager.
  107261. * @returns the current input manager
  107262. */
  107263. addKeyboard(): ArcRotateCameraInputsManager;
  107264. }
  107265. }
  107266. declare module BABYLON {
  107267. /**
  107268. * This represents an orbital type of camera.
  107269. *
  107270. * 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.
  107271. * 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.
  107272. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  107273. */
  107274. export class ArcRotateCamera extends TargetCamera {
  107275. /**
  107276. * Defines the rotation angle of the camera along the longitudinal axis.
  107277. */
  107278. alpha: number;
  107279. /**
  107280. * Defines the rotation angle of the camera along the latitudinal axis.
  107281. */
  107282. beta: number;
  107283. /**
  107284. * Defines the radius of the camera from it s target point.
  107285. */
  107286. radius: number;
  107287. protected _target: Vector3;
  107288. protected _targetHost: Nullable<AbstractMesh>;
  107289. /**
  107290. * Defines the target point of the camera.
  107291. * The camera looks towards it form the radius distance.
  107292. */
  107293. target: Vector3;
  107294. /**
  107295. * Define the current local position of the camera in the scene
  107296. */
  107297. position: Vector3;
  107298. protected _upVector: Vector3;
  107299. protected _upToYMatrix: Matrix;
  107300. protected _YToUpMatrix: Matrix;
  107301. /**
  107302. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  107303. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  107304. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  107305. */
  107306. upVector: Vector3;
  107307. /**
  107308. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  107309. */
  107310. setMatUp(): void;
  107311. /**
  107312. * Current inertia value on the longitudinal axis.
  107313. * The bigger this number the longer it will take for the camera to stop.
  107314. */
  107315. inertialAlphaOffset: number;
  107316. /**
  107317. * Current inertia value on the latitudinal axis.
  107318. * The bigger this number the longer it will take for the camera to stop.
  107319. */
  107320. inertialBetaOffset: number;
  107321. /**
  107322. * Current inertia value on the radius axis.
  107323. * The bigger this number the longer it will take for the camera to stop.
  107324. */
  107325. inertialRadiusOffset: number;
  107326. /**
  107327. * Minimum allowed angle on the longitudinal axis.
  107328. * This can help limiting how the Camera is able to move in the scene.
  107329. */
  107330. lowerAlphaLimit: Nullable<number>;
  107331. /**
  107332. * Maximum allowed angle on the longitudinal axis.
  107333. * This can help limiting how the Camera is able to move in the scene.
  107334. */
  107335. upperAlphaLimit: Nullable<number>;
  107336. /**
  107337. * Minimum allowed angle on the latitudinal axis.
  107338. * This can help limiting how the Camera is able to move in the scene.
  107339. */
  107340. lowerBetaLimit: number;
  107341. /**
  107342. * Maximum allowed angle on the latitudinal axis.
  107343. * This can help limiting how the Camera is able to move in the scene.
  107344. */
  107345. upperBetaLimit: number;
  107346. /**
  107347. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  107348. * This can help limiting how the Camera is able to move in the scene.
  107349. */
  107350. lowerRadiusLimit: Nullable<number>;
  107351. /**
  107352. * Maximum allowed distance of the camera to the target (The camera can not get further).
  107353. * This can help limiting how the Camera is able to move in the scene.
  107354. */
  107355. upperRadiusLimit: Nullable<number>;
  107356. /**
  107357. * Defines the current inertia value used during panning of the camera along the X axis.
  107358. */
  107359. inertialPanningX: number;
  107360. /**
  107361. * Defines the current inertia value used during panning of the camera along the Y axis.
  107362. */
  107363. inertialPanningY: number;
  107364. /**
  107365. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  107366. * Basically if your fingers moves away from more than this distance you will be considered
  107367. * in pinch mode.
  107368. */
  107369. pinchToPanMaxDistance: number;
  107370. /**
  107371. * Defines the maximum distance the camera can pan.
  107372. * This could help keeping the cammera always in your scene.
  107373. */
  107374. panningDistanceLimit: Nullable<number>;
  107375. /**
  107376. * Defines the target of the camera before paning.
  107377. */
  107378. panningOriginTarget: Vector3;
  107379. /**
  107380. * Defines the value of the inertia used during panning.
  107381. * 0 would mean stop inertia and one would mean no decelleration at all.
  107382. */
  107383. panningInertia: number;
  107384. /**
  107385. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  107386. */
  107387. angularSensibilityX: number;
  107388. /**
  107389. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  107390. */
  107391. angularSensibilityY: number;
  107392. /**
  107393. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  107394. */
  107395. pinchPrecision: number;
  107396. /**
  107397. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  107398. * It will be used instead of pinchDeltaPrecision if different from 0.
  107399. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  107400. */
  107401. pinchDeltaPercentage: number;
  107402. /**
  107403. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  107404. */
  107405. panningSensibility: number;
  107406. /**
  107407. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  107408. */
  107409. keysUp: number[];
  107410. /**
  107411. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  107412. */
  107413. keysDown: number[];
  107414. /**
  107415. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  107416. */
  107417. keysLeft: number[];
  107418. /**
  107419. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  107420. */
  107421. keysRight: number[];
  107422. /**
  107423. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  107424. */
  107425. wheelPrecision: number;
  107426. /**
  107427. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  107428. * It will be used instead of pinchDeltaPrecision if different from 0.
  107429. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  107430. */
  107431. wheelDeltaPercentage: number;
  107432. /**
  107433. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  107434. */
  107435. zoomOnFactor: number;
  107436. /**
  107437. * Defines a screen offset for the camera position.
  107438. */
  107439. targetScreenOffset: Vector2;
  107440. /**
  107441. * Allows the camera to be completely reversed.
  107442. * If false the camera can not arrive upside down.
  107443. */
  107444. allowUpsideDown: boolean;
  107445. /**
  107446. * Define if double tap/click is used to restore the previously saved state of the camera.
  107447. */
  107448. useInputToRestoreState: boolean;
  107449. /** @hidden */
  107450. _viewMatrix: Matrix;
  107451. /** @hidden */
  107452. _useCtrlForPanning: boolean;
  107453. /** @hidden */
  107454. _panningMouseButton: number;
  107455. /**
  107456. * Defines the input associated to the camera.
  107457. */
  107458. inputs: ArcRotateCameraInputsManager;
  107459. /** @hidden */
  107460. _reset: () => void;
  107461. /**
  107462. * Defines the allowed panning axis.
  107463. */
  107464. panningAxis: Vector3;
  107465. protected _localDirection: Vector3;
  107466. protected _transformedDirection: Vector3;
  107467. private _bouncingBehavior;
  107468. /**
  107469. * Gets the bouncing behavior of the camera if it has been enabled.
  107470. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107471. */
  107472. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  107473. /**
  107474. * Defines if the bouncing behavior of the camera is enabled on the camera.
  107475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  107476. */
  107477. useBouncingBehavior: boolean;
  107478. private _framingBehavior;
  107479. /**
  107480. * Gets the framing behavior of the camera if it has been enabled.
  107481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107482. */
  107483. readonly framingBehavior: Nullable<FramingBehavior>;
  107484. /**
  107485. * Defines if the framing behavior of the camera is enabled on the camera.
  107486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  107487. */
  107488. useFramingBehavior: boolean;
  107489. private _autoRotationBehavior;
  107490. /**
  107491. * Gets the auto rotation behavior of the camera if it has been enabled.
  107492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107493. */
  107494. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  107495. /**
  107496. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  107497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107498. */
  107499. useAutoRotationBehavior: boolean;
  107500. /**
  107501. * Observable triggered when the mesh target has been changed on the camera.
  107502. */
  107503. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  107504. /**
  107505. * Event raised when the camera is colliding with a mesh.
  107506. */
  107507. onCollide: (collidedMesh: AbstractMesh) => void;
  107508. /**
  107509. * Defines whether the camera should check collision with the objects oh the scene.
  107510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  107511. */
  107512. checkCollisions: boolean;
  107513. /**
  107514. * Defines the collision radius of the camera.
  107515. * This simulates a sphere around the camera.
  107516. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  107517. */
  107518. collisionRadius: Vector3;
  107519. protected _collider: Collider;
  107520. protected _previousPosition: Vector3;
  107521. protected _collisionVelocity: Vector3;
  107522. protected _newPosition: Vector3;
  107523. protected _previousAlpha: number;
  107524. protected _previousBeta: number;
  107525. protected _previousRadius: number;
  107526. protected _collisionTriggered: boolean;
  107527. protected _targetBoundingCenter: Nullable<Vector3>;
  107528. private _computationVector;
  107529. /**
  107530. * Instantiates a new ArcRotateCamera in a given scene
  107531. * @param name Defines the name of the camera
  107532. * @param alpha Defines the camera rotation along the logitudinal axis
  107533. * @param beta Defines the camera rotation along the latitudinal axis
  107534. * @param radius Defines the camera distance from its target
  107535. * @param target Defines the camera target
  107536. * @param scene Defines the scene the camera belongs to
  107537. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  107538. */
  107539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107540. /** @hidden */
  107541. _initCache(): void;
  107542. /** @hidden */
  107543. _updateCache(ignoreParentClass?: boolean): void;
  107544. protected _getTargetPosition(): Vector3;
  107545. private _storedAlpha;
  107546. private _storedBeta;
  107547. private _storedRadius;
  107548. private _storedTarget;
  107549. private _storedTargetScreenOffset;
  107550. /**
  107551. * Stores the current state of the camera (alpha, beta, radius and target)
  107552. * @returns the camera itself
  107553. */
  107554. storeState(): Camera;
  107555. /**
  107556. * @hidden
  107557. * Restored camera state. You must call storeState() first
  107558. */
  107559. _restoreStateValues(): boolean;
  107560. /** @hidden */
  107561. _isSynchronizedViewMatrix(): boolean;
  107562. /**
  107563. * Attached controls to the current camera.
  107564. * @param element Defines the element the controls should be listened from
  107565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107566. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  107567. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  107568. */
  107569. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  107570. /**
  107571. * Detach the current controls from the camera.
  107572. * The camera will stop reacting to inputs.
  107573. * @param element Defines the element to stop listening the inputs from
  107574. */
  107575. detachControl(element: HTMLElement): void;
  107576. /** @hidden */
  107577. _checkInputs(): void;
  107578. protected _checkLimits(): void;
  107579. /**
  107580. * Rebuilds angles (alpha, beta) and radius from the give position and target
  107581. */
  107582. rebuildAnglesAndRadius(): void;
  107583. /**
  107584. * Use a position to define the current camera related information like alpha, beta and radius
  107585. * @param position Defines the position to set the camera at
  107586. */
  107587. setPosition(position: Vector3): void;
  107588. /**
  107589. * Defines the target the camera should look at.
  107590. * This will automatically adapt alpha beta and radius to fit within the new target.
  107591. * @param target Defines the new target as a Vector or a mesh
  107592. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  107593. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  107594. */
  107595. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  107596. /** @hidden */
  107597. _getViewMatrix(): Matrix;
  107598. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  107599. /**
  107600. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  107601. * @param meshes Defines the mesh to zoom on
  107602. * @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)
  107603. */
  107604. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  107605. /**
  107606. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  107607. * The target will be changed but the radius
  107608. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  107609. * @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)
  107610. */
  107611. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  107612. min: Vector3;
  107613. max: Vector3;
  107614. distance: number;
  107615. }, doNotUpdateMaxZ?: boolean): void;
  107616. /**
  107617. * @override
  107618. * Override Camera.createRigCamera
  107619. */
  107620. createRigCamera(name: string, cameraIndex: number): Camera;
  107621. /**
  107622. * @hidden
  107623. * @override
  107624. * Override Camera._updateRigCameras
  107625. */
  107626. _updateRigCameras(): void;
  107627. /**
  107628. * Destroy the camera and release the current resources hold by it.
  107629. */
  107630. dispose(): void;
  107631. /**
  107632. * Gets the current object class name.
  107633. * @return the class name
  107634. */
  107635. getClassName(): string;
  107636. }
  107637. }
  107638. declare module BABYLON {
  107639. /**
  107640. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  107641. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  107642. */
  107643. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  107644. /**
  107645. * Gets the name of the behavior.
  107646. */
  107647. readonly name: string;
  107648. private _zoomStopsAnimation;
  107649. private _idleRotationSpeed;
  107650. private _idleRotationWaitTime;
  107651. private _idleRotationSpinupTime;
  107652. /**
  107653. * Sets the flag that indicates if user zooming should stop animation.
  107654. */
  107655. /**
  107656. * Gets the flag that indicates if user zooming should stop animation.
  107657. */
  107658. zoomStopsAnimation: boolean;
  107659. /**
  107660. * Sets the default speed at which the camera rotates around the model.
  107661. */
  107662. /**
  107663. * Gets the default speed at which the camera rotates around the model.
  107664. */
  107665. idleRotationSpeed: number;
  107666. /**
  107667. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  107668. */
  107669. /**
  107670. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  107671. */
  107672. idleRotationWaitTime: number;
  107673. /**
  107674. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107675. */
  107676. /**
  107677. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  107678. */
  107679. idleRotationSpinupTime: number;
  107680. /**
  107681. * Gets a value indicating if the camera is currently rotating because of this behavior
  107682. */
  107683. readonly rotationInProgress: boolean;
  107684. private _onPrePointerObservableObserver;
  107685. private _onAfterCheckInputsObserver;
  107686. private _attachedCamera;
  107687. private _isPointerDown;
  107688. private _lastFrameTime;
  107689. private _lastInteractionTime;
  107690. private _cameraRotationSpeed;
  107691. /**
  107692. * Initializes the behavior.
  107693. */
  107694. init(): void;
  107695. /**
  107696. * Attaches the behavior to its arc rotate camera.
  107697. * @param camera Defines the camera to attach the behavior to
  107698. */
  107699. attach(camera: ArcRotateCamera): void;
  107700. /**
  107701. * Detaches the behavior from its current arc rotate camera.
  107702. */
  107703. detach(): void;
  107704. /**
  107705. * Returns true if user is scrolling.
  107706. * @return true if user is scrolling.
  107707. */
  107708. private _userIsZooming;
  107709. private _lastFrameRadius;
  107710. private _shouldAnimationStopForInteraction;
  107711. /**
  107712. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  107713. */
  107714. private _applyUserInteraction;
  107715. private _userIsMoving;
  107716. }
  107717. }
  107718. declare module BABYLON {
  107719. /**
  107720. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  107721. */
  107722. export class AttachToBoxBehavior implements Behavior<Mesh> {
  107723. private ui;
  107724. /**
  107725. * The name of the behavior
  107726. */
  107727. name: string;
  107728. /**
  107729. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  107730. */
  107731. distanceAwayFromFace: number;
  107732. /**
  107733. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  107734. */
  107735. distanceAwayFromBottomOfFace: number;
  107736. private _faceVectors;
  107737. private _target;
  107738. private _scene;
  107739. private _onRenderObserver;
  107740. private _tmpMatrix;
  107741. private _tmpVector;
  107742. /**
  107743. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  107744. * @param ui The transform node that should be attched to the mesh
  107745. */
  107746. constructor(ui: TransformNode);
  107747. /**
  107748. * Initializes the behavior
  107749. */
  107750. init(): void;
  107751. private _closestFace;
  107752. private _zeroVector;
  107753. private _lookAtTmpMatrix;
  107754. private _lookAtToRef;
  107755. /**
  107756. * Attaches the AttachToBoxBehavior to the passed in mesh
  107757. * @param target The mesh that the specified node will be attached to
  107758. */
  107759. attach(target: Mesh): void;
  107760. /**
  107761. * Detaches the behavior from the mesh
  107762. */
  107763. detach(): void;
  107764. }
  107765. }
  107766. declare module BABYLON {
  107767. /**
  107768. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  107769. */
  107770. export class FadeInOutBehavior implements Behavior<Mesh> {
  107771. /**
  107772. * Time in milliseconds to delay before fading in (Default: 0)
  107773. */
  107774. delay: number;
  107775. /**
  107776. * Time in milliseconds for the mesh to fade in (Default: 300)
  107777. */
  107778. fadeInTime: number;
  107779. private _millisecondsPerFrame;
  107780. private _hovered;
  107781. private _hoverValue;
  107782. private _ownerNode;
  107783. /**
  107784. * Instatiates the FadeInOutBehavior
  107785. */
  107786. constructor();
  107787. /**
  107788. * The name of the behavior
  107789. */
  107790. readonly name: string;
  107791. /**
  107792. * Initializes the behavior
  107793. */
  107794. init(): void;
  107795. /**
  107796. * Attaches the fade behavior on the passed in mesh
  107797. * @param ownerNode The mesh that will be faded in/out once attached
  107798. */
  107799. attach(ownerNode: Mesh): void;
  107800. /**
  107801. * Detaches the behavior from the mesh
  107802. */
  107803. detach(): void;
  107804. /**
  107805. * Triggers the mesh to begin fading in or out
  107806. * @param value if the object should fade in or out (true to fade in)
  107807. */
  107808. fadeIn(value: boolean): void;
  107809. private _update;
  107810. private _setAllVisibility;
  107811. }
  107812. }
  107813. declare module BABYLON {
  107814. /**
  107815. * Class containing a set of static utilities functions for managing Pivots
  107816. * @hidden
  107817. */
  107818. export class PivotTools {
  107819. private static _PivotCached;
  107820. private static _OldPivotPoint;
  107821. private static _PivotTranslation;
  107822. private static _PivotTmpVector;
  107823. /** @hidden */
  107824. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  107825. /** @hidden */
  107826. static _RestorePivotPoint(mesh: AbstractMesh): void;
  107827. }
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * Class containing static functions to help procedurally build meshes
  107832. */
  107833. export class PlaneBuilder {
  107834. /**
  107835. * Creates a plane mesh
  107836. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107837. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107838. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107842. * @param name defines the name of the mesh
  107843. * @param options defines the options used to create the mesh
  107844. * @param scene defines the hosting scene
  107845. * @returns the plane mesh
  107846. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107847. */
  107848. static CreatePlane(name: string, options: {
  107849. size?: number;
  107850. width?: number;
  107851. height?: number;
  107852. sideOrientation?: number;
  107853. frontUVs?: Vector4;
  107854. backUVs?: Vector4;
  107855. updatable?: boolean;
  107856. sourcePlane?: Plane;
  107857. }, scene?: Nullable<Scene>): Mesh;
  107858. }
  107859. }
  107860. declare module BABYLON {
  107861. /**
  107862. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  107863. */
  107864. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  107865. private static _AnyMouseID;
  107866. /**
  107867. * Abstract mesh the behavior is set on
  107868. */
  107869. attachedNode: AbstractMesh;
  107870. private _dragPlane;
  107871. private _scene;
  107872. private _pointerObserver;
  107873. private _beforeRenderObserver;
  107874. private static _planeScene;
  107875. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  107876. /**
  107877. * 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)
  107878. */
  107879. maxDragAngle: number;
  107880. /**
  107881. * @hidden
  107882. */
  107883. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  107884. /**
  107885. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  107886. */
  107887. currentDraggingPointerID: number;
  107888. /**
  107889. * The last position where the pointer hit the drag plane in world space
  107890. */
  107891. lastDragPosition: Vector3;
  107892. /**
  107893. * If the behavior is currently in a dragging state
  107894. */
  107895. dragging: boolean;
  107896. /**
  107897. * 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)
  107898. */
  107899. dragDeltaRatio: number;
  107900. /**
  107901. * If the drag plane orientation should be updated during the dragging (Default: true)
  107902. */
  107903. updateDragPlane: boolean;
  107904. private _debugMode;
  107905. private _moving;
  107906. /**
  107907. * Fires each time the attached mesh is dragged with the pointer
  107908. * * delta between last drag position and current drag position in world space
  107909. * * dragDistance along the drag axis
  107910. * * dragPlaneNormal normal of the current drag plane used during the drag
  107911. * * dragPlanePoint in world space where the drag intersects the drag plane
  107912. */
  107913. onDragObservable: Observable<{
  107914. delta: Vector3;
  107915. dragPlanePoint: Vector3;
  107916. dragPlaneNormal: Vector3;
  107917. dragDistance: number;
  107918. pointerId: number;
  107919. }>;
  107920. /**
  107921. * Fires each time a drag begins (eg. mouse down on mesh)
  107922. */
  107923. onDragStartObservable: Observable<{
  107924. dragPlanePoint: Vector3;
  107925. pointerId: number;
  107926. }>;
  107927. /**
  107928. * Fires each time a drag ends (eg. mouse release after drag)
  107929. */
  107930. onDragEndObservable: Observable<{
  107931. dragPlanePoint: Vector3;
  107932. pointerId: number;
  107933. }>;
  107934. /**
  107935. * If the attached mesh should be moved when dragged
  107936. */
  107937. moveAttached: boolean;
  107938. /**
  107939. * If the drag behavior will react to drag events (Default: true)
  107940. */
  107941. enabled: boolean;
  107942. /**
  107943. * If pointer events should start and release the drag (Default: true)
  107944. */
  107945. startAndReleaseDragOnPointerEvents: boolean;
  107946. /**
  107947. * If camera controls should be detached during the drag
  107948. */
  107949. detachCameraControls: boolean;
  107950. /**
  107951. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  107952. */
  107953. useObjectOrienationForDragging: boolean;
  107954. private _options;
  107955. /**
  107956. * Gets the options used by the behavior
  107957. */
  107958. /**
  107959. * Sets the options used by the behavior
  107960. */
  107961. options: {
  107962. dragAxis?: Vector3;
  107963. dragPlaneNormal?: Vector3;
  107964. };
  107965. /**
  107966. * Creates a pointer drag behavior that can be attached to a mesh
  107967. * @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)
  107968. */
  107969. constructor(options?: {
  107970. dragAxis?: Vector3;
  107971. dragPlaneNormal?: Vector3;
  107972. });
  107973. /**
  107974. * Predicate to determine if it is valid to move the object to a new position when it is moved
  107975. */
  107976. validateDrag: (targetPosition: Vector3) => boolean;
  107977. /**
  107978. * The name of the behavior
  107979. */
  107980. readonly name: string;
  107981. /**
  107982. * Initializes the behavior
  107983. */
  107984. init(): void;
  107985. private _tmpVector;
  107986. private _alternatePickedPoint;
  107987. private _worldDragAxis;
  107988. private _targetPosition;
  107989. private _attachedElement;
  107990. /**
  107991. * Attaches the drag behavior the passed in mesh
  107992. * @param ownerNode The mesh that will be dragged around once attached
  107993. * @param predicate Predicate to use for pick filtering
  107994. */
  107995. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  107996. /**
  107997. * Force relase the drag action by code.
  107998. */
  107999. releaseDrag(): void;
  108000. private _startDragRay;
  108001. private _lastPointerRay;
  108002. /**
  108003. * Simulates the start of a pointer drag event on the behavior
  108004. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  108005. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  108006. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  108007. */
  108008. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  108009. private _startDrag;
  108010. private _dragDelta;
  108011. private _moveDrag;
  108012. private _pickWithRayOnDragPlane;
  108013. private _pointA;
  108014. private _pointB;
  108015. private _pointC;
  108016. private _lineA;
  108017. private _lineB;
  108018. private _localAxis;
  108019. private _lookAt;
  108020. private _updateDragPlanePosition;
  108021. /**
  108022. * Detaches the behavior from the mesh
  108023. */
  108024. detach(): void;
  108025. }
  108026. }
  108027. declare module BABYLON {
  108028. /**
  108029. * A behavior that when attached to a mesh will allow the mesh to be scaled
  108030. */
  108031. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  108032. private _dragBehaviorA;
  108033. private _dragBehaviorB;
  108034. private _startDistance;
  108035. private _initialScale;
  108036. private _targetScale;
  108037. private _ownerNode;
  108038. private _sceneRenderObserver;
  108039. /**
  108040. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  108041. */
  108042. constructor();
  108043. /**
  108044. * The name of the behavior
  108045. */
  108046. readonly name: string;
  108047. /**
  108048. * Initializes the behavior
  108049. */
  108050. init(): void;
  108051. private _getCurrentDistance;
  108052. /**
  108053. * Attaches the scale behavior the passed in mesh
  108054. * @param ownerNode The mesh that will be scaled around once attached
  108055. */
  108056. attach(ownerNode: Mesh): void;
  108057. /**
  108058. * Detaches the behavior from the mesh
  108059. */
  108060. detach(): void;
  108061. }
  108062. }
  108063. declare module BABYLON {
  108064. /**
  108065. * 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
  108066. */
  108067. export class SixDofDragBehavior implements Behavior<Mesh> {
  108068. private static _virtualScene;
  108069. private _ownerNode;
  108070. private _sceneRenderObserver;
  108071. private _scene;
  108072. private _targetPosition;
  108073. private _virtualOriginMesh;
  108074. private _virtualDragMesh;
  108075. private _pointerObserver;
  108076. private _moving;
  108077. private _startingOrientation;
  108078. /**
  108079. * 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)
  108080. */
  108081. private zDragFactor;
  108082. /**
  108083. * If the object should rotate to face the drag origin
  108084. */
  108085. rotateDraggedObject: boolean;
  108086. /**
  108087. * If the behavior is currently in a dragging state
  108088. */
  108089. dragging: boolean;
  108090. /**
  108091. * 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)
  108092. */
  108093. dragDeltaRatio: number;
  108094. /**
  108095. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  108096. */
  108097. currentDraggingPointerID: number;
  108098. /**
  108099. * If camera controls should be detached during the drag
  108100. */
  108101. detachCameraControls: boolean;
  108102. /**
  108103. * Fires each time a drag starts
  108104. */
  108105. onDragStartObservable: Observable<{}>;
  108106. /**
  108107. * Fires each time a drag ends (eg. mouse release after drag)
  108108. */
  108109. onDragEndObservable: Observable<{}>;
  108110. /**
  108111. * 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
  108112. */
  108113. constructor();
  108114. /**
  108115. * The name of the behavior
  108116. */
  108117. readonly name: string;
  108118. /**
  108119. * Initializes the behavior
  108120. */
  108121. init(): void;
  108122. /**
  108123. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  108124. */
  108125. private readonly _pointerCamera;
  108126. /**
  108127. * Attaches the scale behavior the passed in mesh
  108128. * @param ownerNode The mesh that will be scaled around once attached
  108129. */
  108130. attach(ownerNode: Mesh): void;
  108131. /**
  108132. * Detaches the behavior from the mesh
  108133. */
  108134. detach(): void;
  108135. }
  108136. }
  108137. declare module BABYLON {
  108138. /**
  108139. * Class used to apply inverse kinematics to bones
  108140. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  108141. */
  108142. export class BoneIKController {
  108143. private static _tmpVecs;
  108144. private static _tmpQuat;
  108145. private static _tmpMats;
  108146. /**
  108147. * Gets or sets the target mesh
  108148. */
  108149. targetMesh: AbstractMesh;
  108150. /** Gets or sets the mesh used as pole */
  108151. poleTargetMesh: AbstractMesh;
  108152. /**
  108153. * Gets or sets the bone used as pole
  108154. */
  108155. poleTargetBone: Nullable<Bone>;
  108156. /**
  108157. * Gets or sets the target position
  108158. */
  108159. targetPosition: Vector3;
  108160. /**
  108161. * Gets or sets the pole target position
  108162. */
  108163. poleTargetPosition: Vector3;
  108164. /**
  108165. * Gets or sets the pole target local offset
  108166. */
  108167. poleTargetLocalOffset: Vector3;
  108168. /**
  108169. * Gets or sets the pole angle
  108170. */
  108171. poleAngle: number;
  108172. /**
  108173. * Gets or sets the mesh associated with the controller
  108174. */
  108175. mesh: AbstractMesh;
  108176. /**
  108177. * 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)
  108178. */
  108179. slerpAmount: number;
  108180. private _bone1Quat;
  108181. private _bone1Mat;
  108182. private _bone2Ang;
  108183. private _bone1;
  108184. private _bone2;
  108185. private _bone1Length;
  108186. private _bone2Length;
  108187. private _maxAngle;
  108188. private _maxReach;
  108189. private _rightHandedSystem;
  108190. private _bendAxis;
  108191. private _slerping;
  108192. private _adjustRoll;
  108193. /**
  108194. * Gets or sets maximum allowed angle
  108195. */
  108196. maxAngle: number;
  108197. /**
  108198. * Creates a new BoneIKController
  108199. * @param mesh defines the mesh to control
  108200. * @param bone defines the bone to control
  108201. * @param options defines options to set up the controller
  108202. */
  108203. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  108204. targetMesh?: AbstractMesh;
  108205. poleTargetMesh?: AbstractMesh;
  108206. poleTargetBone?: Bone;
  108207. poleTargetLocalOffset?: Vector3;
  108208. poleAngle?: number;
  108209. bendAxis?: Vector3;
  108210. maxAngle?: number;
  108211. slerpAmount?: number;
  108212. });
  108213. private _setMaxAngle;
  108214. /**
  108215. * Force the controller to update the bones
  108216. */
  108217. update(): void;
  108218. }
  108219. }
  108220. declare module BABYLON {
  108221. /**
  108222. * Class used to make a bone look toward a point in space
  108223. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  108224. */
  108225. export class BoneLookController {
  108226. private static _tmpVecs;
  108227. private static _tmpQuat;
  108228. private static _tmpMats;
  108229. /**
  108230. * The target Vector3 that the bone will look at
  108231. */
  108232. target: Vector3;
  108233. /**
  108234. * The mesh that the bone is attached to
  108235. */
  108236. mesh: AbstractMesh;
  108237. /**
  108238. * The bone that will be looking to the target
  108239. */
  108240. bone: Bone;
  108241. /**
  108242. * The up axis of the coordinate system that is used when the bone is rotated
  108243. */
  108244. upAxis: Vector3;
  108245. /**
  108246. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  108247. */
  108248. upAxisSpace: Space;
  108249. /**
  108250. * Used to make an adjustment to the yaw of the bone
  108251. */
  108252. adjustYaw: number;
  108253. /**
  108254. * Used to make an adjustment to the pitch of the bone
  108255. */
  108256. adjustPitch: number;
  108257. /**
  108258. * Used to make an adjustment to the roll of the bone
  108259. */
  108260. adjustRoll: number;
  108261. /**
  108262. * 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)
  108263. */
  108264. slerpAmount: number;
  108265. private _minYaw;
  108266. private _maxYaw;
  108267. private _minPitch;
  108268. private _maxPitch;
  108269. private _minYawSin;
  108270. private _minYawCos;
  108271. private _maxYawSin;
  108272. private _maxYawCos;
  108273. private _midYawConstraint;
  108274. private _minPitchTan;
  108275. private _maxPitchTan;
  108276. private _boneQuat;
  108277. private _slerping;
  108278. private _transformYawPitch;
  108279. private _transformYawPitchInv;
  108280. private _firstFrameSkipped;
  108281. private _yawRange;
  108282. private _fowardAxis;
  108283. /**
  108284. * Gets or sets the minimum yaw angle that the bone can look to
  108285. */
  108286. minYaw: number;
  108287. /**
  108288. * Gets or sets the maximum yaw angle that the bone can look to
  108289. */
  108290. maxYaw: number;
  108291. /**
  108292. * Gets or sets the minimum pitch angle that the bone can look to
  108293. */
  108294. minPitch: number;
  108295. /**
  108296. * Gets or sets the maximum pitch angle that the bone can look to
  108297. */
  108298. maxPitch: number;
  108299. /**
  108300. * Create a BoneLookController
  108301. * @param mesh the mesh that the bone belongs to
  108302. * @param bone the bone that will be looking to the target
  108303. * @param target the target Vector3 to look at
  108304. * @param options optional settings:
  108305. * * maxYaw: the maximum angle the bone will yaw to
  108306. * * minYaw: the minimum angle the bone will yaw to
  108307. * * maxPitch: the maximum angle the bone will pitch to
  108308. * * minPitch: the minimum angle the bone will yaw to
  108309. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  108310. * * upAxis: the up axis of the coordinate system
  108311. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  108312. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  108313. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  108314. * * adjustYaw: used to make an adjustment to the yaw of the bone
  108315. * * adjustPitch: used to make an adjustment to the pitch of the bone
  108316. * * adjustRoll: used to make an adjustment to the roll of the bone
  108317. **/
  108318. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  108319. maxYaw?: number;
  108320. minYaw?: number;
  108321. maxPitch?: number;
  108322. minPitch?: number;
  108323. slerpAmount?: number;
  108324. upAxis?: Vector3;
  108325. upAxisSpace?: Space;
  108326. yawAxis?: Vector3;
  108327. pitchAxis?: Vector3;
  108328. adjustYaw?: number;
  108329. adjustPitch?: number;
  108330. adjustRoll?: number;
  108331. });
  108332. /**
  108333. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  108334. */
  108335. update(): void;
  108336. private _getAngleDiff;
  108337. private _getAngleBetween;
  108338. private _isAngleBetween;
  108339. }
  108340. }
  108341. declare module BABYLON {
  108342. /**
  108343. * Manage the gamepad inputs to control an arc rotate camera.
  108344. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108345. */
  108346. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  108347. /**
  108348. * Defines the camera the input is attached to.
  108349. */
  108350. camera: ArcRotateCamera;
  108351. /**
  108352. * Defines the gamepad the input is gathering event from.
  108353. */
  108354. gamepad: Nullable<Gamepad>;
  108355. /**
  108356. * Defines the gamepad rotation sensiblity.
  108357. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108358. */
  108359. gamepadRotationSensibility: number;
  108360. /**
  108361. * Defines the gamepad move sensiblity.
  108362. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108363. */
  108364. gamepadMoveSensibility: number;
  108365. private _yAxisScale;
  108366. /**
  108367. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  108368. */
  108369. invertYAxis: boolean;
  108370. private _onGamepadConnectedObserver;
  108371. private _onGamepadDisconnectedObserver;
  108372. /**
  108373. * Attach the input controls to a specific dom element to get the input from.
  108374. * @param element Defines the element the controls should be listened from
  108375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108376. */
  108377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108378. /**
  108379. * Detach the current controls from the specified dom element.
  108380. * @param element Defines the element to stop listening the inputs from
  108381. */
  108382. detachControl(element: Nullable<HTMLElement>): void;
  108383. /**
  108384. * Update the current camera state depending on the inputs that have been used this frame.
  108385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108386. */
  108387. checkInputs(): void;
  108388. /**
  108389. * Gets the class name of the current intput.
  108390. * @returns the class name
  108391. */
  108392. getClassName(): string;
  108393. /**
  108394. * Get the friendly name associated with the input class.
  108395. * @returns the input friendly name
  108396. */
  108397. getSimpleName(): string;
  108398. }
  108399. }
  108400. declare module BABYLON {
  108401. interface ArcRotateCameraInputsManager {
  108402. /**
  108403. * Add orientation input support to the input manager.
  108404. * @returns the current input manager
  108405. */
  108406. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  108407. }
  108408. /**
  108409. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  108410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108411. */
  108412. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  108413. /**
  108414. * Defines the camera the input is attached to.
  108415. */
  108416. camera: ArcRotateCamera;
  108417. /**
  108418. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  108419. */
  108420. alphaCorrection: number;
  108421. /**
  108422. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  108423. */
  108424. gammaCorrection: number;
  108425. private _alpha;
  108426. private _gamma;
  108427. private _dirty;
  108428. private _deviceOrientationHandler;
  108429. /**
  108430. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  108431. */
  108432. constructor();
  108433. /**
  108434. * Attach the input controls to a specific dom element to get the input from.
  108435. * @param element Defines the element the controls should be listened from
  108436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108437. */
  108438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108439. /** @hidden */
  108440. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  108441. /**
  108442. * Update the current camera state depending on the inputs that have been used this frame.
  108443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108444. */
  108445. checkInputs(): void;
  108446. /**
  108447. * Detach the current controls from the specified dom element.
  108448. * @param element Defines the element to stop listening the inputs from
  108449. */
  108450. detachControl(element: Nullable<HTMLElement>): void;
  108451. /**
  108452. * Gets the class name of the current intput.
  108453. * @returns the class name
  108454. */
  108455. getClassName(): string;
  108456. /**
  108457. * Get the friendly name associated with the input class.
  108458. * @returns the input friendly name
  108459. */
  108460. getSimpleName(): string;
  108461. }
  108462. }
  108463. declare module BABYLON {
  108464. /**
  108465. * Listen to mouse events to control the camera.
  108466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108467. */
  108468. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  108469. /**
  108470. * Defines the camera the input is attached to.
  108471. */
  108472. camera: FlyCamera;
  108473. /**
  108474. * Defines if touch is enabled. (Default is true.)
  108475. */
  108476. touchEnabled: boolean;
  108477. /**
  108478. * Defines the buttons associated with the input to handle camera rotation.
  108479. */
  108480. buttons: number[];
  108481. /**
  108482. * Assign buttons for Yaw control.
  108483. */
  108484. buttonsYaw: number[];
  108485. /**
  108486. * Assign buttons for Pitch control.
  108487. */
  108488. buttonsPitch: number[];
  108489. /**
  108490. * Assign buttons for Roll control.
  108491. */
  108492. buttonsRoll: number[];
  108493. /**
  108494. * Detect if any button is being pressed while mouse is moved.
  108495. * -1 = Mouse locked.
  108496. * 0 = Left button.
  108497. * 1 = Middle Button.
  108498. * 2 = Right Button.
  108499. */
  108500. activeButton: number;
  108501. /**
  108502. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  108503. * Higher values reduce its sensitivity.
  108504. */
  108505. angularSensibility: number;
  108506. private _mousemoveCallback;
  108507. private _observer;
  108508. private _rollObserver;
  108509. private previousPosition;
  108510. private noPreventDefault;
  108511. private element;
  108512. /**
  108513. * Listen to mouse events to control the camera.
  108514. * @param touchEnabled Define if touch is enabled. (Default is true.)
  108515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108516. */
  108517. constructor(touchEnabled?: boolean);
  108518. /**
  108519. * Attach the mouse control to the HTML DOM element.
  108520. * @param element Defines the element that listens to the input events.
  108521. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  108522. */
  108523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108524. /**
  108525. * Detach the current controls from the specified dom element.
  108526. * @param element Defines the element to stop listening the inputs from
  108527. */
  108528. detachControl(element: Nullable<HTMLElement>): void;
  108529. /**
  108530. * Gets the class name of the current input.
  108531. * @returns the class name.
  108532. */
  108533. getClassName(): string;
  108534. /**
  108535. * Get the friendly name associated with the input class.
  108536. * @returns the input's friendly name.
  108537. */
  108538. getSimpleName(): string;
  108539. private _pointerInput;
  108540. private _onMouseMove;
  108541. /**
  108542. * Rotate camera by mouse offset.
  108543. */
  108544. private rotateCamera;
  108545. }
  108546. }
  108547. declare module BABYLON {
  108548. /**
  108549. * Default Inputs manager for the FlyCamera.
  108550. * It groups all the default supported inputs for ease of use.
  108551. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108552. */
  108553. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  108554. /**
  108555. * Instantiates a new FlyCameraInputsManager.
  108556. * @param camera Defines the camera the inputs belong to.
  108557. */
  108558. constructor(camera: FlyCamera);
  108559. /**
  108560. * Add keyboard input support to the input manager.
  108561. * @returns the new FlyCameraKeyboardMoveInput().
  108562. */
  108563. addKeyboard(): FlyCameraInputsManager;
  108564. /**
  108565. * Add mouse input support to the input manager.
  108566. * @param touchEnabled Enable touch screen support.
  108567. * @returns the new FlyCameraMouseInput().
  108568. */
  108569. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  108570. }
  108571. }
  108572. declare module BABYLON {
  108573. /**
  108574. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108575. * such as in a 3D Space Shooter or a Flight Simulator.
  108576. */
  108577. export class FlyCamera extends TargetCamera {
  108578. /**
  108579. * Define the collision ellipsoid of the camera.
  108580. * This is helpful for simulating a camera body, like a player's body.
  108581. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  108582. */
  108583. ellipsoid: Vector3;
  108584. /**
  108585. * Define an offset for the position of the ellipsoid around the camera.
  108586. * This can be helpful if the camera is attached away from the player's body center,
  108587. * such as at its head.
  108588. */
  108589. ellipsoidOffset: Vector3;
  108590. /**
  108591. * Enable or disable collisions of the camera with the rest of the scene objects.
  108592. */
  108593. checkCollisions: boolean;
  108594. /**
  108595. * Enable or disable gravity on the camera.
  108596. */
  108597. applyGravity: boolean;
  108598. /**
  108599. * Define the current direction the camera is moving to.
  108600. */
  108601. cameraDirection: Vector3;
  108602. /**
  108603. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  108604. * This overrides and empties cameraRotation.
  108605. */
  108606. rotationQuaternion: Quaternion;
  108607. /**
  108608. * Track Roll to maintain the wanted Rolling when looking around.
  108609. */
  108610. _trackRoll: number;
  108611. /**
  108612. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  108613. */
  108614. rollCorrect: number;
  108615. /**
  108616. * Mimic a banked turn, Rolling the camera when Yawing.
  108617. * It's recommended to use rollCorrect = 10 for faster banking correction.
  108618. */
  108619. bankedTurn: boolean;
  108620. /**
  108621. * Limit in radians for how much Roll banking will add. (Default: 90°)
  108622. */
  108623. bankedTurnLimit: number;
  108624. /**
  108625. * Value of 0 disables the banked Roll.
  108626. * Value of 1 is equal to the Yaw angle in radians.
  108627. */
  108628. bankedTurnMultiplier: number;
  108629. /**
  108630. * The inputs manager loads all the input sources, such as keyboard and mouse.
  108631. */
  108632. inputs: FlyCameraInputsManager;
  108633. /**
  108634. * Gets the input sensibility for mouse input.
  108635. * Higher values reduce sensitivity.
  108636. */
  108637. /**
  108638. * Sets the input sensibility for a mouse input.
  108639. * Higher values reduce sensitivity.
  108640. */
  108641. angularSensibility: number;
  108642. /**
  108643. * Get the keys for camera movement forward.
  108644. */
  108645. /**
  108646. * Set the keys for camera movement forward.
  108647. */
  108648. keysForward: number[];
  108649. /**
  108650. * Get the keys for camera movement backward.
  108651. */
  108652. keysBackward: number[];
  108653. /**
  108654. * Get the keys for camera movement up.
  108655. */
  108656. /**
  108657. * Set the keys for camera movement up.
  108658. */
  108659. keysUp: number[];
  108660. /**
  108661. * Get the keys for camera movement down.
  108662. */
  108663. /**
  108664. * Set the keys for camera movement down.
  108665. */
  108666. keysDown: number[];
  108667. /**
  108668. * Get the keys for camera movement left.
  108669. */
  108670. /**
  108671. * Set the keys for camera movement left.
  108672. */
  108673. keysLeft: number[];
  108674. /**
  108675. * Set the keys for camera movement right.
  108676. */
  108677. /**
  108678. * Set the keys for camera movement right.
  108679. */
  108680. keysRight: number[];
  108681. /**
  108682. * Event raised when the camera collides with a mesh in the scene.
  108683. */
  108684. onCollide: (collidedMesh: AbstractMesh) => void;
  108685. private _collider;
  108686. private _needMoveForGravity;
  108687. private _oldPosition;
  108688. private _diffPosition;
  108689. private _newPosition;
  108690. /** @hidden */
  108691. _localDirection: Vector3;
  108692. /** @hidden */
  108693. _transformedDirection: Vector3;
  108694. /**
  108695. * Instantiates a FlyCamera.
  108696. * This is a flying camera, designed for 3D movement and rotation in all directions,
  108697. * such as in a 3D Space Shooter or a Flight Simulator.
  108698. * @param name Define the name of the camera in the scene.
  108699. * @param position Define the starting position of the camera in the scene.
  108700. * @param scene Define the scene the camera belongs to.
  108701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  108702. */
  108703. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  108704. /**
  108705. * Attach a control to the HTML DOM element.
  108706. * @param element Defines the element that listens to the input events.
  108707. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  108708. */
  108709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108710. /**
  108711. * Detach a control from the HTML DOM element.
  108712. * The camera will stop reacting to that input.
  108713. * @param element Defines the element that listens to the input events.
  108714. */
  108715. detachControl(element: HTMLElement): void;
  108716. private _collisionMask;
  108717. /**
  108718. * Get the mask that the camera ignores in collision events.
  108719. */
  108720. /**
  108721. * Set the mask that the camera ignores in collision events.
  108722. */
  108723. collisionMask: number;
  108724. /** @hidden */
  108725. _collideWithWorld(displacement: Vector3): void;
  108726. /** @hidden */
  108727. private _onCollisionPositionChange;
  108728. /** @hidden */
  108729. _checkInputs(): void;
  108730. /** @hidden */
  108731. _decideIfNeedsToMove(): boolean;
  108732. /** @hidden */
  108733. _updatePosition(): void;
  108734. /**
  108735. * Restore the Roll to its target value at the rate specified.
  108736. * @param rate - Higher means slower restoring.
  108737. * @hidden
  108738. */
  108739. restoreRoll(rate: number): void;
  108740. /**
  108741. * Destroy the camera and release the current resources held by it.
  108742. */
  108743. dispose(): void;
  108744. /**
  108745. * Get the current object class name.
  108746. * @returns the class name.
  108747. */
  108748. getClassName(): string;
  108749. }
  108750. }
  108751. declare module BABYLON {
  108752. /**
  108753. * Listen to keyboard events to control the camera.
  108754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108755. */
  108756. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  108757. /**
  108758. * Defines the camera the input is attached to.
  108759. */
  108760. camera: FlyCamera;
  108761. /**
  108762. * The list of keyboard keys used to control the forward move of the camera.
  108763. */
  108764. keysForward: number[];
  108765. /**
  108766. * The list of keyboard keys used to control the backward move of the camera.
  108767. */
  108768. keysBackward: number[];
  108769. /**
  108770. * The list of keyboard keys used to control the forward move of the camera.
  108771. */
  108772. keysUp: number[];
  108773. /**
  108774. * The list of keyboard keys used to control the backward move of the camera.
  108775. */
  108776. keysDown: number[];
  108777. /**
  108778. * The list of keyboard keys used to control the right strafe move of the camera.
  108779. */
  108780. keysRight: number[];
  108781. /**
  108782. * The list of keyboard keys used to control the left strafe move of the camera.
  108783. */
  108784. keysLeft: number[];
  108785. private _keys;
  108786. private _onCanvasBlurObserver;
  108787. private _onKeyboardObserver;
  108788. private _engine;
  108789. private _scene;
  108790. /**
  108791. * Attach the input controls to a specific dom element to get the input from.
  108792. * @param element Defines the element the controls should be listened from
  108793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108794. */
  108795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108796. /**
  108797. * Detach the current controls from the specified dom element.
  108798. * @param element Defines the element to stop listening the inputs from
  108799. */
  108800. detachControl(element: Nullable<HTMLElement>): void;
  108801. /**
  108802. * Gets the class name of the current intput.
  108803. * @returns the class name
  108804. */
  108805. getClassName(): string;
  108806. /** @hidden */
  108807. _onLostFocus(e: FocusEvent): void;
  108808. /**
  108809. * Get the friendly name associated with the input class.
  108810. * @returns the input friendly name
  108811. */
  108812. getSimpleName(): string;
  108813. /**
  108814. * Update the current camera state depending on the inputs that have been used this frame.
  108815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108816. */
  108817. checkInputs(): void;
  108818. }
  108819. }
  108820. declare module BABYLON {
  108821. /**
  108822. * Manage the mouse wheel inputs to control a follow camera.
  108823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108824. */
  108825. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  108826. /**
  108827. * Defines the camera the input is attached to.
  108828. */
  108829. camera: FollowCamera;
  108830. /**
  108831. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  108832. */
  108833. axisControlRadius: boolean;
  108834. /**
  108835. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  108836. */
  108837. axisControlHeight: boolean;
  108838. /**
  108839. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  108840. */
  108841. axisControlRotation: boolean;
  108842. /**
  108843. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  108844. * relation to mouseWheel events.
  108845. */
  108846. wheelPrecision: number;
  108847. /**
  108848. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108849. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108850. */
  108851. wheelDeltaPercentage: number;
  108852. private _wheel;
  108853. private _observer;
  108854. /**
  108855. * Attach the input controls to a specific dom element to get the input from.
  108856. * @param element Defines the element the controls should be listened from
  108857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108858. */
  108859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108860. /**
  108861. * Detach the current controls from the specified dom element.
  108862. * @param element Defines the element to stop listening the inputs from
  108863. */
  108864. detachControl(element: Nullable<HTMLElement>): void;
  108865. /**
  108866. * Gets the class name of the current intput.
  108867. * @returns the class name
  108868. */
  108869. getClassName(): string;
  108870. /**
  108871. * Get the friendly name associated with the input class.
  108872. * @returns the input friendly name
  108873. */
  108874. getSimpleName(): string;
  108875. }
  108876. }
  108877. declare module BABYLON {
  108878. /**
  108879. * Manage the pointers inputs to control an follow camera.
  108880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108881. */
  108882. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  108883. /**
  108884. * Defines the camera the input is attached to.
  108885. */
  108886. camera: FollowCamera;
  108887. /**
  108888. * Gets the class name of the current input.
  108889. * @returns the class name
  108890. */
  108891. getClassName(): string;
  108892. /**
  108893. * Defines the pointer angular sensibility along the X axis or how fast is
  108894. * the camera rotating.
  108895. * A negative number will reverse the axis direction.
  108896. */
  108897. angularSensibilityX: number;
  108898. /**
  108899. * Defines the pointer angular sensibility along the Y axis or how fast is
  108900. * the camera rotating.
  108901. * A negative number will reverse the axis direction.
  108902. */
  108903. angularSensibilityY: number;
  108904. /**
  108905. * Defines the pointer pinch precision or how fast is the camera zooming.
  108906. * A negative number will reverse the axis direction.
  108907. */
  108908. pinchPrecision: number;
  108909. /**
  108910. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108911. * from 0.
  108912. * It defines the percentage of current camera.radius to use as delta when
  108913. * pinch zoom is used.
  108914. */
  108915. pinchDeltaPercentage: number;
  108916. /**
  108917. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  108918. */
  108919. axisXControlRadius: boolean;
  108920. /**
  108921. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  108922. */
  108923. axisXControlHeight: boolean;
  108924. /**
  108925. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  108926. */
  108927. axisXControlRotation: boolean;
  108928. /**
  108929. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  108930. */
  108931. axisYControlRadius: boolean;
  108932. /**
  108933. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  108934. */
  108935. axisYControlHeight: boolean;
  108936. /**
  108937. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  108938. */
  108939. axisYControlRotation: boolean;
  108940. /**
  108941. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  108942. */
  108943. axisPinchControlRadius: boolean;
  108944. /**
  108945. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  108946. */
  108947. axisPinchControlHeight: boolean;
  108948. /**
  108949. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  108950. */
  108951. axisPinchControlRotation: boolean;
  108952. /**
  108953. * Log error messages if basic misconfiguration has occurred.
  108954. */
  108955. warningEnable: boolean;
  108956. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108957. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108958. private _warningCounter;
  108959. private _warning;
  108960. }
  108961. }
  108962. declare module BABYLON {
  108963. /**
  108964. * Default Inputs manager for the FollowCamera.
  108965. * It groups all the default supported inputs for ease of use.
  108966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108967. */
  108968. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  108969. /**
  108970. * Instantiates a new FollowCameraInputsManager.
  108971. * @param camera Defines the camera the inputs belong to
  108972. */
  108973. constructor(camera: FollowCamera);
  108974. /**
  108975. * Add keyboard input support to the input manager.
  108976. * @returns the current input manager
  108977. */
  108978. addKeyboard(): FollowCameraInputsManager;
  108979. /**
  108980. * Add mouse wheel input support to the input manager.
  108981. * @returns the current input manager
  108982. */
  108983. addMouseWheel(): FollowCameraInputsManager;
  108984. /**
  108985. * Add pointers input support to the input manager.
  108986. * @returns the current input manager
  108987. */
  108988. addPointers(): FollowCameraInputsManager;
  108989. /**
  108990. * Add orientation input support to the input manager.
  108991. * @returns the current input manager
  108992. */
  108993. addVRDeviceOrientation(): FollowCameraInputsManager;
  108994. }
  108995. }
  108996. declare module BABYLON {
  108997. /**
  108998. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  108999. * an arc rotate version arcFollowCamera are available.
  109000. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109001. */
  109002. export class FollowCamera extends TargetCamera {
  109003. /**
  109004. * Distance the follow camera should follow an object at
  109005. */
  109006. radius: number;
  109007. /**
  109008. * Minimum allowed distance of the camera to the axis of rotation
  109009. * (The camera can not get closer).
  109010. * This can help limiting how the Camera is able to move in the scene.
  109011. */
  109012. lowerRadiusLimit: Nullable<number>;
  109013. /**
  109014. * Maximum allowed distance of the camera to the axis of rotation
  109015. * (The camera can not get further).
  109016. * This can help limiting how the Camera is able to move in the scene.
  109017. */
  109018. upperRadiusLimit: Nullable<number>;
  109019. /**
  109020. * Define a rotation offset between the camera and the object it follows
  109021. */
  109022. rotationOffset: number;
  109023. /**
  109024. * Minimum allowed angle to camera position relative to target object.
  109025. * This can help limiting how the Camera is able to move in the scene.
  109026. */
  109027. lowerRotationOffsetLimit: Nullable<number>;
  109028. /**
  109029. * Maximum allowed angle to camera position relative to target object.
  109030. * This can help limiting how the Camera is able to move in the scene.
  109031. */
  109032. upperRotationOffsetLimit: Nullable<number>;
  109033. /**
  109034. * Define a height offset between the camera and the object it follows.
  109035. * It can help following an object from the top (like a car chaing a plane)
  109036. */
  109037. heightOffset: number;
  109038. /**
  109039. * Minimum allowed height of camera position relative to target object.
  109040. * This can help limiting how the Camera is able to move in the scene.
  109041. */
  109042. lowerHeightOffsetLimit: Nullable<number>;
  109043. /**
  109044. * Maximum allowed height of camera position relative to target object.
  109045. * This can help limiting how the Camera is able to move in the scene.
  109046. */
  109047. upperHeightOffsetLimit: Nullable<number>;
  109048. /**
  109049. * Define how fast the camera can accelerate to follow it s target.
  109050. */
  109051. cameraAcceleration: number;
  109052. /**
  109053. * Define the speed limit of the camera following an object.
  109054. */
  109055. maxCameraSpeed: number;
  109056. /**
  109057. * Define the target of the camera.
  109058. */
  109059. lockedTarget: Nullable<AbstractMesh>;
  109060. /**
  109061. * Defines the input associated with the camera.
  109062. */
  109063. inputs: FollowCameraInputsManager;
  109064. /**
  109065. * Instantiates the follow camera.
  109066. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109067. * @param name Define the name of the camera in the scene
  109068. * @param position Define the position of the camera
  109069. * @param scene Define the scene the camera belong to
  109070. * @param lockedTarget Define the target of the camera
  109071. */
  109072. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  109073. private _follow;
  109074. /**
  109075. * Attached controls to the current camera.
  109076. * @param element Defines the element the controls should be listened from
  109077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109078. */
  109079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109080. /**
  109081. * Detach the current controls from the camera.
  109082. * The camera will stop reacting to inputs.
  109083. * @param element Defines the element to stop listening the inputs from
  109084. */
  109085. detachControl(element: HTMLElement): void;
  109086. /** @hidden */
  109087. _checkInputs(): void;
  109088. private _checkLimits;
  109089. /**
  109090. * Gets the camera class name.
  109091. * @returns the class name
  109092. */
  109093. getClassName(): string;
  109094. }
  109095. /**
  109096. * Arc Rotate version of the follow camera.
  109097. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  109098. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109099. */
  109100. export class ArcFollowCamera extends TargetCamera {
  109101. /** The longitudinal angle of the camera */
  109102. alpha: number;
  109103. /** The latitudinal angle of the camera */
  109104. beta: number;
  109105. /** The radius of the camera from its target */
  109106. radius: number;
  109107. /** Define the camera target (the messh it should follow) */
  109108. target: Nullable<AbstractMesh>;
  109109. private _cartesianCoordinates;
  109110. /**
  109111. * Instantiates a new ArcFollowCamera
  109112. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  109113. * @param name Define the name of the camera
  109114. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  109115. * @param beta Define the rotation angle of the camera around the elevation axis
  109116. * @param radius Define the radius of the camera from its target point
  109117. * @param target Define the target of the camera
  109118. * @param scene Define the scene the camera belongs to
  109119. */
  109120. constructor(name: string,
  109121. /** The longitudinal angle of the camera */
  109122. alpha: number,
  109123. /** The latitudinal angle of the camera */
  109124. beta: number,
  109125. /** The radius of the camera from its target */
  109126. radius: number,
  109127. /** Define the camera target (the messh it should follow) */
  109128. target: Nullable<AbstractMesh>, scene: Scene);
  109129. private _follow;
  109130. /** @hidden */
  109131. _checkInputs(): void;
  109132. /**
  109133. * Returns the class name of the object.
  109134. * It is mostly used internally for serialization purposes.
  109135. */
  109136. getClassName(): string;
  109137. }
  109138. }
  109139. declare module BABYLON {
  109140. /**
  109141. * Manage the keyboard inputs to control the movement of a follow camera.
  109142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109143. */
  109144. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  109145. /**
  109146. * Defines the camera the input is attached to.
  109147. */
  109148. camera: FollowCamera;
  109149. /**
  109150. * Defines the list of key codes associated with the up action (increase heightOffset)
  109151. */
  109152. keysHeightOffsetIncr: number[];
  109153. /**
  109154. * Defines the list of key codes associated with the down action (decrease heightOffset)
  109155. */
  109156. keysHeightOffsetDecr: number[];
  109157. /**
  109158. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  109159. */
  109160. keysHeightOffsetModifierAlt: boolean;
  109161. /**
  109162. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  109163. */
  109164. keysHeightOffsetModifierCtrl: boolean;
  109165. /**
  109166. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  109167. */
  109168. keysHeightOffsetModifierShift: boolean;
  109169. /**
  109170. * Defines the list of key codes associated with the left action (increase rotationOffset)
  109171. */
  109172. keysRotationOffsetIncr: number[];
  109173. /**
  109174. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  109175. */
  109176. keysRotationOffsetDecr: number[];
  109177. /**
  109178. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  109179. */
  109180. keysRotationOffsetModifierAlt: boolean;
  109181. /**
  109182. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  109183. */
  109184. keysRotationOffsetModifierCtrl: boolean;
  109185. /**
  109186. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  109187. */
  109188. keysRotationOffsetModifierShift: boolean;
  109189. /**
  109190. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  109191. */
  109192. keysRadiusIncr: number[];
  109193. /**
  109194. * Defines the list of key codes associated with the zoom-out action (increase radius)
  109195. */
  109196. keysRadiusDecr: number[];
  109197. /**
  109198. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  109199. */
  109200. keysRadiusModifierAlt: boolean;
  109201. /**
  109202. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  109203. */
  109204. keysRadiusModifierCtrl: boolean;
  109205. /**
  109206. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  109207. */
  109208. keysRadiusModifierShift: boolean;
  109209. /**
  109210. * Defines the rate of change of heightOffset.
  109211. */
  109212. heightSensibility: number;
  109213. /**
  109214. * Defines the rate of change of rotationOffset.
  109215. */
  109216. rotationSensibility: number;
  109217. /**
  109218. * Defines the rate of change of radius.
  109219. */
  109220. radiusSensibility: number;
  109221. private _keys;
  109222. private _ctrlPressed;
  109223. private _altPressed;
  109224. private _shiftPressed;
  109225. private _onCanvasBlurObserver;
  109226. private _onKeyboardObserver;
  109227. private _engine;
  109228. private _scene;
  109229. /**
  109230. * Attach the input controls to a specific dom element to get the input from.
  109231. * @param element Defines the element the controls should be listened from
  109232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109233. */
  109234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109235. /**
  109236. * Detach the current controls from the specified dom element.
  109237. * @param element Defines the element to stop listening the inputs from
  109238. */
  109239. detachControl(element: Nullable<HTMLElement>): void;
  109240. /**
  109241. * Update the current camera state depending on the inputs that have been used this frame.
  109242. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109243. */
  109244. checkInputs(): void;
  109245. /**
  109246. * Gets the class name of the current input.
  109247. * @returns the class name
  109248. */
  109249. getClassName(): string;
  109250. /**
  109251. * Get the friendly name associated with the input class.
  109252. * @returns the input friendly name
  109253. */
  109254. getSimpleName(): string;
  109255. /**
  109256. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109257. * allow modification of the heightOffset value.
  109258. */
  109259. private _modifierHeightOffset;
  109260. /**
  109261. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109262. * allow modification of the rotationOffset value.
  109263. */
  109264. private _modifierRotationOffset;
  109265. /**
  109266. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  109267. * allow modification of the radius value.
  109268. */
  109269. private _modifierRadius;
  109270. }
  109271. }
  109272. declare module BABYLON {
  109273. interface FreeCameraInputsManager {
  109274. /**
  109275. * @hidden
  109276. */
  109277. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  109278. /**
  109279. * Add orientation input support to the input manager.
  109280. * @returns the current input manager
  109281. */
  109282. addDeviceOrientation(): FreeCameraInputsManager;
  109283. }
  109284. /**
  109285. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  109286. * Screen rotation is taken into account.
  109287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109288. */
  109289. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  109290. private _camera;
  109291. private _screenOrientationAngle;
  109292. private _constantTranform;
  109293. private _screenQuaternion;
  109294. private _alpha;
  109295. private _beta;
  109296. private _gamma;
  109297. /**
  109298. * Can be used to detect if a device orientation sensor is available on a device
  109299. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  109300. * @returns a promise that will resolve on orientation change
  109301. */
  109302. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  109303. /**
  109304. * @hidden
  109305. */
  109306. _onDeviceOrientationChangedObservable: Observable<void>;
  109307. /**
  109308. * Instantiates a new input
  109309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109310. */
  109311. constructor();
  109312. /**
  109313. * Define the camera controlled by the input.
  109314. */
  109315. camera: FreeCamera;
  109316. /**
  109317. * Attach the input controls to a specific dom element to get the input from.
  109318. * @param element Defines the element the controls should be listened from
  109319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109320. */
  109321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109322. private _orientationChanged;
  109323. private _deviceOrientation;
  109324. /**
  109325. * Detach the current controls from the specified dom element.
  109326. * @param element Defines the element to stop listening the inputs from
  109327. */
  109328. detachControl(element: Nullable<HTMLElement>): void;
  109329. /**
  109330. * Update the current camera state depending on the inputs that have been used this frame.
  109331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109332. */
  109333. checkInputs(): void;
  109334. /**
  109335. * Gets the class name of the current intput.
  109336. * @returns the class name
  109337. */
  109338. getClassName(): string;
  109339. /**
  109340. * Get the friendly name associated with the input class.
  109341. * @returns the input friendly name
  109342. */
  109343. getSimpleName(): string;
  109344. }
  109345. }
  109346. declare module BABYLON {
  109347. /**
  109348. * Manage the gamepad inputs to control a free camera.
  109349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109350. */
  109351. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  109352. /**
  109353. * Define the camera the input is attached to.
  109354. */
  109355. camera: FreeCamera;
  109356. /**
  109357. * Define the Gamepad controlling the input
  109358. */
  109359. gamepad: Nullable<Gamepad>;
  109360. /**
  109361. * Defines the gamepad rotation sensiblity.
  109362. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  109363. */
  109364. gamepadAngularSensibility: number;
  109365. /**
  109366. * Defines the gamepad move sensiblity.
  109367. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  109368. */
  109369. gamepadMoveSensibility: number;
  109370. private _yAxisScale;
  109371. /**
  109372. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  109373. */
  109374. invertYAxis: boolean;
  109375. private _onGamepadConnectedObserver;
  109376. private _onGamepadDisconnectedObserver;
  109377. private _cameraTransform;
  109378. private _deltaTransform;
  109379. private _vector3;
  109380. private _vector2;
  109381. /**
  109382. * Attach the input controls to a specific dom element to get the input from.
  109383. * @param element Defines the element the controls should be listened from
  109384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109385. */
  109386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109387. /**
  109388. * Detach the current controls from the specified dom element.
  109389. * @param element Defines the element to stop listening the inputs from
  109390. */
  109391. detachControl(element: Nullable<HTMLElement>): void;
  109392. /**
  109393. * Update the current camera state depending on the inputs that have been used this frame.
  109394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109395. */
  109396. checkInputs(): void;
  109397. /**
  109398. * Gets the class name of the current intput.
  109399. * @returns the class name
  109400. */
  109401. getClassName(): string;
  109402. /**
  109403. * Get the friendly name associated with the input class.
  109404. * @returns the input friendly name
  109405. */
  109406. getSimpleName(): string;
  109407. }
  109408. }
  109409. declare module BABYLON {
  109410. /**
  109411. * Defines the potential axis of a Joystick
  109412. */
  109413. export enum JoystickAxis {
  109414. /** X axis */
  109415. X = 0,
  109416. /** Y axis */
  109417. Y = 1,
  109418. /** Z axis */
  109419. Z = 2
  109420. }
  109421. /**
  109422. * Class used to define virtual joystick (used in touch mode)
  109423. */
  109424. export class VirtualJoystick {
  109425. /**
  109426. * Gets or sets a boolean indicating that left and right values must be inverted
  109427. */
  109428. reverseLeftRight: boolean;
  109429. /**
  109430. * Gets or sets a boolean indicating that up and down values must be inverted
  109431. */
  109432. reverseUpDown: boolean;
  109433. /**
  109434. * Gets the offset value for the position (ie. the change of the position value)
  109435. */
  109436. deltaPosition: Vector3;
  109437. /**
  109438. * Gets a boolean indicating if the virtual joystick was pressed
  109439. */
  109440. pressed: boolean;
  109441. /**
  109442. * Canvas the virtual joystick will render onto, default z-index of this is 5
  109443. */
  109444. static Canvas: Nullable<HTMLCanvasElement>;
  109445. private static _globalJoystickIndex;
  109446. private static vjCanvasContext;
  109447. private static vjCanvasWidth;
  109448. private static vjCanvasHeight;
  109449. private static halfWidth;
  109450. private _action;
  109451. private _axisTargetedByLeftAndRight;
  109452. private _axisTargetedByUpAndDown;
  109453. private _joystickSensibility;
  109454. private _inversedSensibility;
  109455. private _joystickPointerID;
  109456. private _joystickColor;
  109457. private _joystickPointerPos;
  109458. private _joystickPreviousPointerPos;
  109459. private _joystickPointerStartPos;
  109460. private _deltaJoystickVector;
  109461. private _leftJoystick;
  109462. private _touches;
  109463. private _onPointerDownHandlerRef;
  109464. private _onPointerMoveHandlerRef;
  109465. private _onPointerUpHandlerRef;
  109466. private _onResize;
  109467. /**
  109468. * Creates a new virtual joystick
  109469. * @param leftJoystick defines that the joystick is for left hand (false by default)
  109470. */
  109471. constructor(leftJoystick?: boolean);
  109472. /**
  109473. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  109474. * @param newJoystickSensibility defines the new sensibility
  109475. */
  109476. setJoystickSensibility(newJoystickSensibility: number): void;
  109477. private _onPointerDown;
  109478. private _onPointerMove;
  109479. private _onPointerUp;
  109480. /**
  109481. * Change the color of the virtual joystick
  109482. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  109483. */
  109484. setJoystickColor(newColor: string): void;
  109485. /**
  109486. * Defines a callback to call when the joystick is touched
  109487. * @param action defines the callback
  109488. */
  109489. setActionOnTouch(action: () => any): void;
  109490. /**
  109491. * Defines which axis you'd like to control for left & right
  109492. * @param axis defines the axis to use
  109493. */
  109494. setAxisForLeftRight(axis: JoystickAxis): void;
  109495. /**
  109496. * Defines which axis you'd like to control for up & down
  109497. * @param axis defines the axis to use
  109498. */
  109499. setAxisForUpDown(axis: JoystickAxis): void;
  109500. private _drawVirtualJoystick;
  109501. /**
  109502. * Release internal HTML canvas
  109503. */
  109504. releaseCanvas(): void;
  109505. }
  109506. }
  109507. declare module BABYLON {
  109508. interface FreeCameraInputsManager {
  109509. /**
  109510. * Add virtual joystick input support to the input manager.
  109511. * @returns the current input manager
  109512. */
  109513. addVirtualJoystick(): FreeCameraInputsManager;
  109514. }
  109515. /**
  109516. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  109517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109518. */
  109519. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  109520. /**
  109521. * Defines the camera the input is attached to.
  109522. */
  109523. camera: FreeCamera;
  109524. private _leftjoystick;
  109525. private _rightjoystick;
  109526. /**
  109527. * Gets the left stick of the virtual joystick.
  109528. * @returns The virtual Joystick
  109529. */
  109530. getLeftJoystick(): VirtualJoystick;
  109531. /**
  109532. * Gets the right stick of the virtual joystick.
  109533. * @returns The virtual Joystick
  109534. */
  109535. getRightJoystick(): VirtualJoystick;
  109536. /**
  109537. * Update the current camera state depending on the inputs that have been used this frame.
  109538. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109539. */
  109540. checkInputs(): void;
  109541. /**
  109542. * Attach the input controls to a specific dom element to get the input from.
  109543. * @param element Defines the element the controls should be listened from
  109544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109545. */
  109546. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109547. /**
  109548. * Detach the current controls from the specified dom element.
  109549. * @param element Defines the element to stop listening the inputs from
  109550. */
  109551. detachControl(element: Nullable<HTMLElement>): void;
  109552. /**
  109553. * Gets the class name of the current intput.
  109554. * @returns the class name
  109555. */
  109556. getClassName(): string;
  109557. /**
  109558. * Get the friendly name associated with the input class.
  109559. * @returns the input friendly name
  109560. */
  109561. getSimpleName(): string;
  109562. }
  109563. }
  109564. declare module BABYLON {
  109565. /**
  109566. * This represents a FPS type of camera controlled by touch.
  109567. * This is like a universal camera minus the Gamepad controls.
  109568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109569. */
  109570. export class TouchCamera extends FreeCamera {
  109571. /**
  109572. * Defines the touch sensibility for rotation.
  109573. * The higher the faster.
  109574. */
  109575. touchAngularSensibility: number;
  109576. /**
  109577. * Defines the touch sensibility for move.
  109578. * The higher the faster.
  109579. */
  109580. touchMoveSensibility: number;
  109581. /**
  109582. * Instantiates a new touch camera.
  109583. * This represents a FPS type of camera controlled by touch.
  109584. * This is like a universal camera minus the Gamepad controls.
  109585. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  109586. * @param name Define the name of the camera in the scene
  109587. * @param position Define the start position of the camera in the scene
  109588. * @param scene Define the scene the camera belongs to
  109589. */
  109590. constructor(name: string, position: Vector3, scene: Scene);
  109591. /**
  109592. * Gets the current object class name.
  109593. * @return the class name
  109594. */
  109595. getClassName(): string;
  109596. /** @hidden */
  109597. _setupInputs(): void;
  109598. }
  109599. }
  109600. declare module BABYLON {
  109601. /**
  109602. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  109603. * being tilted forward or back and left or right.
  109604. */
  109605. export class DeviceOrientationCamera extends FreeCamera {
  109606. private _initialQuaternion;
  109607. private _quaternionCache;
  109608. private _tmpDragQuaternion;
  109609. private _disablePointerInputWhenUsingDeviceOrientation;
  109610. /**
  109611. * Creates a new device orientation camera
  109612. * @param name The name of the camera
  109613. * @param position The start position camera
  109614. * @param scene The scene the camera belongs to
  109615. */
  109616. constructor(name: string, position: Vector3, scene: Scene);
  109617. /**
  109618. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  109619. */
  109620. disablePointerInputWhenUsingDeviceOrientation: boolean;
  109621. private _dragFactor;
  109622. /**
  109623. * Enabled turning on the y axis when the orientation sensor is active
  109624. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  109625. */
  109626. enableHorizontalDragging(dragFactor?: number): void;
  109627. /**
  109628. * Gets the current instance class name ("DeviceOrientationCamera").
  109629. * This helps avoiding instanceof at run time.
  109630. * @returns the class name
  109631. */
  109632. getClassName(): string;
  109633. /**
  109634. * @hidden
  109635. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  109636. */
  109637. _checkInputs(): void;
  109638. /**
  109639. * Reset the camera to its default orientation on the specified axis only.
  109640. * @param axis The axis to reset
  109641. */
  109642. resetToCurrentRotation(axis?: Axis): void;
  109643. }
  109644. }
  109645. declare module BABYLON {
  109646. /**
  109647. * Defines supported buttons for XBox360 compatible gamepads
  109648. */
  109649. export enum Xbox360Button {
  109650. /** A */
  109651. A = 0,
  109652. /** B */
  109653. B = 1,
  109654. /** X */
  109655. X = 2,
  109656. /** Y */
  109657. Y = 3,
  109658. /** Start */
  109659. Start = 4,
  109660. /** Back */
  109661. Back = 5,
  109662. /** Left button */
  109663. LB = 6,
  109664. /** Right button */
  109665. RB = 7,
  109666. /** Left stick */
  109667. LeftStick = 8,
  109668. /** Right stick */
  109669. RightStick = 9
  109670. }
  109671. /** Defines values for XBox360 DPad */
  109672. export enum Xbox360Dpad {
  109673. /** Up */
  109674. Up = 0,
  109675. /** Down */
  109676. Down = 1,
  109677. /** Left */
  109678. Left = 2,
  109679. /** Right */
  109680. Right = 3
  109681. }
  109682. /**
  109683. * Defines a XBox360 gamepad
  109684. */
  109685. export class Xbox360Pad extends Gamepad {
  109686. private _leftTrigger;
  109687. private _rightTrigger;
  109688. private _onlefttriggerchanged;
  109689. private _onrighttriggerchanged;
  109690. private _onbuttondown;
  109691. private _onbuttonup;
  109692. private _ondpaddown;
  109693. private _ondpadup;
  109694. /** Observable raised when a button is pressed */
  109695. onButtonDownObservable: Observable<Xbox360Button>;
  109696. /** Observable raised when a button is released */
  109697. onButtonUpObservable: Observable<Xbox360Button>;
  109698. /** Observable raised when a pad is pressed */
  109699. onPadDownObservable: Observable<Xbox360Dpad>;
  109700. /** Observable raised when a pad is released */
  109701. onPadUpObservable: Observable<Xbox360Dpad>;
  109702. private _buttonA;
  109703. private _buttonB;
  109704. private _buttonX;
  109705. private _buttonY;
  109706. private _buttonBack;
  109707. private _buttonStart;
  109708. private _buttonLB;
  109709. private _buttonRB;
  109710. private _buttonLeftStick;
  109711. private _buttonRightStick;
  109712. private _dPadUp;
  109713. private _dPadDown;
  109714. private _dPadLeft;
  109715. private _dPadRight;
  109716. private _isXboxOnePad;
  109717. /**
  109718. * Creates a new XBox360 gamepad object
  109719. * @param id defines the id of this gamepad
  109720. * @param index defines its index
  109721. * @param gamepad defines the internal HTML gamepad object
  109722. * @param xboxOne defines if it is a XBox One gamepad
  109723. */
  109724. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  109725. /**
  109726. * Defines the callback to call when left trigger is pressed
  109727. * @param callback defines the callback to use
  109728. */
  109729. onlefttriggerchanged(callback: (value: number) => void): void;
  109730. /**
  109731. * Defines the callback to call when right trigger is pressed
  109732. * @param callback defines the callback to use
  109733. */
  109734. onrighttriggerchanged(callback: (value: number) => void): void;
  109735. /**
  109736. * Gets the left trigger value
  109737. */
  109738. /**
  109739. * Sets the left trigger value
  109740. */
  109741. leftTrigger: number;
  109742. /**
  109743. * Gets the right trigger value
  109744. */
  109745. /**
  109746. * Sets the right trigger value
  109747. */
  109748. rightTrigger: number;
  109749. /**
  109750. * Defines the callback to call when a button is pressed
  109751. * @param callback defines the callback to use
  109752. */
  109753. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  109754. /**
  109755. * Defines the callback to call when a button is released
  109756. * @param callback defines the callback to use
  109757. */
  109758. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  109759. /**
  109760. * Defines the callback to call when a pad is pressed
  109761. * @param callback defines the callback to use
  109762. */
  109763. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  109764. /**
  109765. * Defines the callback to call when a pad is released
  109766. * @param callback defines the callback to use
  109767. */
  109768. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  109769. private _setButtonValue;
  109770. private _setDPadValue;
  109771. /**
  109772. * Gets the value of the `A` button
  109773. */
  109774. /**
  109775. * Sets the value of the `A` button
  109776. */
  109777. buttonA: number;
  109778. /**
  109779. * Gets the value of the `B` button
  109780. */
  109781. /**
  109782. * Sets the value of the `B` button
  109783. */
  109784. buttonB: number;
  109785. /**
  109786. * Gets the value of the `X` button
  109787. */
  109788. /**
  109789. * Sets the value of the `X` button
  109790. */
  109791. buttonX: number;
  109792. /**
  109793. * Gets the value of the `Y` button
  109794. */
  109795. /**
  109796. * Sets the value of the `Y` button
  109797. */
  109798. buttonY: number;
  109799. /**
  109800. * Gets the value of the `Start` button
  109801. */
  109802. /**
  109803. * Sets the value of the `Start` button
  109804. */
  109805. buttonStart: number;
  109806. /**
  109807. * Gets the value of the `Back` button
  109808. */
  109809. /**
  109810. * Sets the value of the `Back` button
  109811. */
  109812. buttonBack: number;
  109813. /**
  109814. * Gets the value of the `Left` button
  109815. */
  109816. /**
  109817. * Sets the value of the `Left` button
  109818. */
  109819. buttonLB: number;
  109820. /**
  109821. * Gets the value of the `Right` button
  109822. */
  109823. /**
  109824. * Sets the value of the `Right` button
  109825. */
  109826. buttonRB: number;
  109827. /**
  109828. * Gets the value of the Left joystick
  109829. */
  109830. /**
  109831. * Sets the value of the Left joystick
  109832. */
  109833. buttonLeftStick: number;
  109834. /**
  109835. * Gets the value of the Right joystick
  109836. */
  109837. /**
  109838. * Sets the value of the Right joystick
  109839. */
  109840. buttonRightStick: number;
  109841. /**
  109842. * Gets the value of D-pad up
  109843. */
  109844. /**
  109845. * Sets the value of D-pad up
  109846. */
  109847. dPadUp: number;
  109848. /**
  109849. * Gets the value of D-pad down
  109850. */
  109851. /**
  109852. * Sets the value of D-pad down
  109853. */
  109854. dPadDown: number;
  109855. /**
  109856. * Gets the value of D-pad left
  109857. */
  109858. /**
  109859. * Sets the value of D-pad left
  109860. */
  109861. dPadLeft: number;
  109862. /**
  109863. * Gets the value of D-pad right
  109864. */
  109865. /**
  109866. * Sets the value of D-pad right
  109867. */
  109868. dPadRight: number;
  109869. /**
  109870. * Force the gamepad to synchronize with device values
  109871. */
  109872. update(): void;
  109873. /**
  109874. * Disposes the gamepad
  109875. */
  109876. dispose(): void;
  109877. }
  109878. }
  109879. declare module BABYLON {
  109880. /**
  109881. * Defines supported buttons for DualShock compatible gamepads
  109882. */
  109883. export enum DualShockButton {
  109884. /** Cross */
  109885. Cross = 0,
  109886. /** Circle */
  109887. Circle = 1,
  109888. /** Square */
  109889. Square = 2,
  109890. /** Triangle */
  109891. Triangle = 3,
  109892. /** Options */
  109893. Options = 4,
  109894. /** Share */
  109895. Share = 5,
  109896. /** L1 */
  109897. L1 = 6,
  109898. /** R1 */
  109899. R1 = 7,
  109900. /** Left stick */
  109901. LeftStick = 8,
  109902. /** Right stick */
  109903. RightStick = 9
  109904. }
  109905. /** Defines values for DualShock DPad */
  109906. export enum DualShockDpad {
  109907. /** Up */
  109908. Up = 0,
  109909. /** Down */
  109910. Down = 1,
  109911. /** Left */
  109912. Left = 2,
  109913. /** Right */
  109914. Right = 3
  109915. }
  109916. /**
  109917. * Defines a DualShock gamepad
  109918. */
  109919. export class DualShockPad extends Gamepad {
  109920. private _leftTrigger;
  109921. private _rightTrigger;
  109922. private _onlefttriggerchanged;
  109923. private _onrighttriggerchanged;
  109924. private _onbuttondown;
  109925. private _onbuttonup;
  109926. private _ondpaddown;
  109927. private _ondpadup;
  109928. /** Observable raised when a button is pressed */
  109929. onButtonDownObservable: Observable<DualShockButton>;
  109930. /** Observable raised when a button is released */
  109931. onButtonUpObservable: Observable<DualShockButton>;
  109932. /** Observable raised when a pad is pressed */
  109933. onPadDownObservable: Observable<DualShockDpad>;
  109934. /** Observable raised when a pad is released */
  109935. onPadUpObservable: Observable<DualShockDpad>;
  109936. private _buttonCross;
  109937. private _buttonCircle;
  109938. private _buttonSquare;
  109939. private _buttonTriangle;
  109940. private _buttonShare;
  109941. private _buttonOptions;
  109942. private _buttonL1;
  109943. private _buttonR1;
  109944. private _buttonLeftStick;
  109945. private _buttonRightStick;
  109946. private _dPadUp;
  109947. private _dPadDown;
  109948. private _dPadLeft;
  109949. private _dPadRight;
  109950. /**
  109951. * Creates a new DualShock gamepad object
  109952. * @param id defines the id of this gamepad
  109953. * @param index defines its index
  109954. * @param gamepad defines the internal HTML gamepad object
  109955. */
  109956. constructor(id: string, index: number, gamepad: any);
  109957. /**
  109958. * Defines the callback to call when left trigger is pressed
  109959. * @param callback defines the callback to use
  109960. */
  109961. onlefttriggerchanged(callback: (value: number) => void): void;
  109962. /**
  109963. * Defines the callback to call when right trigger is pressed
  109964. * @param callback defines the callback to use
  109965. */
  109966. onrighttriggerchanged(callback: (value: number) => void): void;
  109967. /**
  109968. * Gets the left trigger value
  109969. */
  109970. /**
  109971. * Sets the left trigger value
  109972. */
  109973. leftTrigger: number;
  109974. /**
  109975. * Gets the right trigger value
  109976. */
  109977. /**
  109978. * Sets the right trigger value
  109979. */
  109980. rightTrigger: number;
  109981. /**
  109982. * Defines the callback to call when a button is pressed
  109983. * @param callback defines the callback to use
  109984. */
  109985. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  109986. /**
  109987. * Defines the callback to call when a button is released
  109988. * @param callback defines the callback to use
  109989. */
  109990. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  109991. /**
  109992. * Defines the callback to call when a pad is pressed
  109993. * @param callback defines the callback to use
  109994. */
  109995. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  109996. /**
  109997. * Defines the callback to call when a pad is released
  109998. * @param callback defines the callback to use
  109999. */
  110000. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  110001. private _setButtonValue;
  110002. private _setDPadValue;
  110003. /**
  110004. * Gets the value of the `Cross` button
  110005. */
  110006. /**
  110007. * Sets the value of the `Cross` button
  110008. */
  110009. buttonCross: number;
  110010. /**
  110011. * Gets the value of the `Circle` button
  110012. */
  110013. /**
  110014. * Sets the value of the `Circle` button
  110015. */
  110016. buttonCircle: number;
  110017. /**
  110018. * Gets the value of the `Square` button
  110019. */
  110020. /**
  110021. * Sets the value of the `Square` button
  110022. */
  110023. buttonSquare: number;
  110024. /**
  110025. * Gets the value of the `Triangle` button
  110026. */
  110027. /**
  110028. * Sets the value of the `Triangle` button
  110029. */
  110030. buttonTriangle: number;
  110031. /**
  110032. * Gets the value of the `Options` button
  110033. */
  110034. /**
  110035. * Sets the value of the `Options` button
  110036. */
  110037. buttonOptions: number;
  110038. /**
  110039. * Gets the value of the `Share` button
  110040. */
  110041. /**
  110042. * Sets the value of the `Share` button
  110043. */
  110044. buttonShare: number;
  110045. /**
  110046. * Gets the value of the `L1` button
  110047. */
  110048. /**
  110049. * Sets the value of the `L1` button
  110050. */
  110051. buttonL1: number;
  110052. /**
  110053. * Gets the value of the `R1` button
  110054. */
  110055. /**
  110056. * Sets the value of the `R1` button
  110057. */
  110058. buttonR1: number;
  110059. /**
  110060. * Gets the value of the Left joystick
  110061. */
  110062. /**
  110063. * Sets the value of the Left joystick
  110064. */
  110065. buttonLeftStick: number;
  110066. /**
  110067. * Gets the value of the Right joystick
  110068. */
  110069. /**
  110070. * Sets the value of the Right joystick
  110071. */
  110072. buttonRightStick: number;
  110073. /**
  110074. * Gets the value of D-pad up
  110075. */
  110076. /**
  110077. * Sets the value of D-pad up
  110078. */
  110079. dPadUp: number;
  110080. /**
  110081. * Gets the value of D-pad down
  110082. */
  110083. /**
  110084. * Sets the value of D-pad down
  110085. */
  110086. dPadDown: number;
  110087. /**
  110088. * Gets the value of D-pad left
  110089. */
  110090. /**
  110091. * Sets the value of D-pad left
  110092. */
  110093. dPadLeft: number;
  110094. /**
  110095. * Gets the value of D-pad right
  110096. */
  110097. /**
  110098. * Sets the value of D-pad right
  110099. */
  110100. dPadRight: number;
  110101. /**
  110102. * Force the gamepad to synchronize with device values
  110103. */
  110104. update(): void;
  110105. /**
  110106. * Disposes the gamepad
  110107. */
  110108. dispose(): void;
  110109. }
  110110. }
  110111. declare module BABYLON {
  110112. /**
  110113. * Manager for handling gamepads
  110114. */
  110115. export class GamepadManager {
  110116. private _scene?;
  110117. private _babylonGamepads;
  110118. private _oneGamepadConnected;
  110119. /** @hidden */
  110120. _isMonitoring: boolean;
  110121. private _gamepadEventSupported;
  110122. private _gamepadSupport;
  110123. /**
  110124. * observable to be triggered when the gamepad controller has been connected
  110125. */
  110126. onGamepadConnectedObservable: Observable<Gamepad>;
  110127. /**
  110128. * observable to be triggered when the gamepad controller has been disconnected
  110129. */
  110130. onGamepadDisconnectedObservable: Observable<Gamepad>;
  110131. private _onGamepadConnectedEvent;
  110132. private _onGamepadDisconnectedEvent;
  110133. /**
  110134. * Initializes the gamepad manager
  110135. * @param _scene BabylonJS scene
  110136. */
  110137. constructor(_scene?: Scene | undefined);
  110138. /**
  110139. * The gamepads in the game pad manager
  110140. */
  110141. readonly gamepads: Gamepad[];
  110142. /**
  110143. * Get the gamepad controllers based on type
  110144. * @param type The type of gamepad controller
  110145. * @returns Nullable gamepad
  110146. */
  110147. getGamepadByType(type?: number): Nullable<Gamepad>;
  110148. /**
  110149. * Disposes the gamepad manager
  110150. */
  110151. dispose(): void;
  110152. private _addNewGamepad;
  110153. private _startMonitoringGamepads;
  110154. private _stopMonitoringGamepads;
  110155. /** @hidden */
  110156. _checkGamepadsStatus(): void;
  110157. private _updateGamepadObjects;
  110158. }
  110159. }
  110160. declare module BABYLON {
  110161. interface Scene {
  110162. /** @hidden */
  110163. _gamepadManager: Nullable<GamepadManager>;
  110164. /**
  110165. * Gets the gamepad manager associated with the scene
  110166. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  110167. */
  110168. gamepadManager: GamepadManager;
  110169. }
  110170. /**
  110171. * Interface representing a free camera inputs manager
  110172. */
  110173. interface FreeCameraInputsManager {
  110174. /**
  110175. * Adds gamepad input support to the FreeCameraInputsManager.
  110176. * @returns the FreeCameraInputsManager
  110177. */
  110178. addGamepad(): FreeCameraInputsManager;
  110179. }
  110180. /**
  110181. * Interface representing an arc rotate camera inputs manager
  110182. */
  110183. interface ArcRotateCameraInputsManager {
  110184. /**
  110185. * Adds gamepad input support to the ArcRotateCamera InputManager.
  110186. * @returns the camera inputs manager
  110187. */
  110188. addGamepad(): ArcRotateCameraInputsManager;
  110189. }
  110190. /**
  110191. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  110192. */
  110193. export class GamepadSystemSceneComponent implements ISceneComponent {
  110194. /**
  110195. * The component name helpfull to identify the component in the list of scene components.
  110196. */
  110197. readonly name: string;
  110198. /**
  110199. * The scene the component belongs to.
  110200. */
  110201. scene: Scene;
  110202. /**
  110203. * Creates a new instance of the component for the given scene
  110204. * @param scene Defines the scene to register the component in
  110205. */
  110206. constructor(scene: Scene);
  110207. /**
  110208. * Registers the component in a given scene
  110209. */
  110210. register(): void;
  110211. /**
  110212. * Rebuilds the elements related to this component in case of
  110213. * context lost for instance.
  110214. */
  110215. rebuild(): void;
  110216. /**
  110217. * Disposes the component and the associated ressources
  110218. */
  110219. dispose(): void;
  110220. private _beforeCameraUpdate;
  110221. }
  110222. }
  110223. declare module BABYLON {
  110224. /**
  110225. * 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,
  110226. * which still works and will still be found in many Playgrounds.
  110227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110228. */
  110229. export class UniversalCamera extends TouchCamera {
  110230. /**
  110231. * Defines the gamepad rotation sensiblity.
  110232. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110233. */
  110234. gamepadAngularSensibility: number;
  110235. /**
  110236. * Defines the gamepad move sensiblity.
  110237. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110238. */
  110239. gamepadMoveSensibility: number;
  110240. /**
  110241. * 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,
  110242. * which still works and will still be found in many Playgrounds.
  110243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110244. * @param name Define the name of the camera in the scene
  110245. * @param position Define the start position of the camera in the scene
  110246. * @param scene Define the scene the camera belongs to
  110247. */
  110248. constructor(name: string, position: Vector3, scene: Scene);
  110249. /**
  110250. * Gets the current object class name.
  110251. * @return the class name
  110252. */
  110253. getClassName(): string;
  110254. }
  110255. }
  110256. declare module BABYLON {
  110257. /**
  110258. * This represents a FPS type of camera. This is only here for back compat purpose.
  110259. * Please use the UniversalCamera instead as both are identical.
  110260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110261. */
  110262. export class GamepadCamera extends UniversalCamera {
  110263. /**
  110264. * Instantiates a new Gamepad Camera
  110265. * This represents a FPS type of camera. This is only here for back compat purpose.
  110266. * Please use the UniversalCamera instead as both are identical.
  110267. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  110268. * @param name Define the name of the camera in the scene
  110269. * @param position Define the start position of the camera in the scene
  110270. * @param scene Define the scene the camera belongs to
  110271. */
  110272. constructor(name: string, position: Vector3, scene: Scene);
  110273. /**
  110274. * Gets the current object class name.
  110275. * @return the class name
  110276. */
  110277. getClassName(): string;
  110278. }
  110279. }
  110280. declare module BABYLON {
  110281. /** @hidden */
  110282. export var passPixelShader: {
  110283. name: string;
  110284. shader: string;
  110285. };
  110286. }
  110287. declare module BABYLON {
  110288. /** @hidden */
  110289. export var passCubePixelShader: {
  110290. name: string;
  110291. shader: string;
  110292. };
  110293. }
  110294. declare module BABYLON {
  110295. /**
  110296. * PassPostProcess which produces an output the same as it's input
  110297. */
  110298. export class PassPostProcess extends PostProcess {
  110299. /**
  110300. * Creates the PassPostProcess
  110301. * @param name The name of the effect.
  110302. * @param options The required width/height ratio to downsize to before computing the render pass.
  110303. * @param camera The camera to apply the render pass to.
  110304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110305. * @param engine The engine which the post process will be applied. (default: current engine)
  110306. * @param reusable If the post process can be reused on the same frame. (default: false)
  110307. * @param textureType The type of texture to be used when performing the post processing.
  110308. * @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)
  110309. */
  110310. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110311. }
  110312. /**
  110313. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  110314. */
  110315. export class PassCubePostProcess extends PostProcess {
  110316. private _face;
  110317. /**
  110318. * Gets or sets the cube face to display.
  110319. * * 0 is +X
  110320. * * 1 is -X
  110321. * * 2 is +Y
  110322. * * 3 is -Y
  110323. * * 4 is +Z
  110324. * * 5 is -Z
  110325. */
  110326. face: number;
  110327. /**
  110328. * Creates the PassCubePostProcess
  110329. * @param name The name of the effect.
  110330. * @param options The required width/height ratio to downsize to before computing the render pass.
  110331. * @param camera The camera to apply the render pass to.
  110332. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110333. * @param engine The engine which the post process will be applied. (default: current engine)
  110334. * @param reusable If the post process can be reused on the same frame. (default: false)
  110335. * @param textureType The type of texture to be used when performing the post processing.
  110336. * @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)
  110337. */
  110338. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110339. }
  110340. }
  110341. declare module BABYLON {
  110342. /** @hidden */
  110343. export var anaglyphPixelShader: {
  110344. name: string;
  110345. shader: string;
  110346. };
  110347. }
  110348. declare module BABYLON {
  110349. /**
  110350. * Postprocess used to generate anaglyphic rendering
  110351. */
  110352. export class AnaglyphPostProcess extends PostProcess {
  110353. private _passedProcess;
  110354. /**
  110355. * Creates a new AnaglyphPostProcess
  110356. * @param name defines postprocess name
  110357. * @param options defines creation options or target ratio scale
  110358. * @param rigCameras defines cameras using this postprocess
  110359. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  110360. * @param engine defines hosting engine
  110361. * @param reusable defines if the postprocess will be reused multiple times per frame
  110362. */
  110363. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  110364. }
  110365. }
  110366. declare module BABYLON {
  110367. /**
  110368. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  110369. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110370. */
  110371. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  110372. /**
  110373. * Creates a new AnaglyphArcRotateCamera
  110374. * @param name defines camera name
  110375. * @param alpha defines alpha angle (in radians)
  110376. * @param beta defines beta angle (in radians)
  110377. * @param radius defines radius
  110378. * @param target defines camera target
  110379. * @param interaxialDistance defines distance between each color axis
  110380. * @param scene defines the hosting scene
  110381. */
  110382. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  110383. /**
  110384. * Gets camera class name
  110385. * @returns AnaglyphArcRotateCamera
  110386. */
  110387. getClassName(): string;
  110388. }
  110389. }
  110390. declare module BABYLON {
  110391. /**
  110392. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  110393. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110394. */
  110395. export class AnaglyphFreeCamera extends FreeCamera {
  110396. /**
  110397. * Creates a new AnaglyphFreeCamera
  110398. * @param name defines camera name
  110399. * @param position defines initial position
  110400. * @param interaxialDistance defines distance between each color axis
  110401. * @param scene defines the hosting scene
  110402. */
  110403. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110404. /**
  110405. * Gets camera class name
  110406. * @returns AnaglyphFreeCamera
  110407. */
  110408. getClassName(): string;
  110409. }
  110410. }
  110411. declare module BABYLON {
  110412. /**
  110413. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  110414. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110415. */
  110416. export class AnaglyphGamepadCamera extends GamepadCamera {
  110417. /**
  110418. * Creates a new AnaglyphGamepadCamera
  110419. * @param name defines camera name
  110420. * @param position defines initial position
  110421. * @param interaxialDistance defines distance between each color axis
  110422. * @param scene defines the hosting scene
  110423. */
  110424. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110425. /**
  110426. * Gets camera class name
  110427. * @returns AnaglyphGamepadCamera
  110428. */
  110429. getClassName(): string;
  110430. }
  110431. }
  110432. declare module BABYLON {
  110433. /**
  110434. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  110435. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  110436. */
  110437. export class AnaglyphUniversalCamera extends UniversalCamera {
  110438. /**
  110439. * Creates a new AnaglyphUniversalCamera
  110440. * @param name defines camera name
  110441. * @param position defines initial position
  110442. * @param interaxialDistance defines distance between each color axis
  110443. * @param scene defines the hosting scene
  110444. */
  110445. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  110446. /**
  110447. * Gets camera class name
  110448. * @returns AnaglyphUniversalCamera
  110449. */
  110450. getClassName(): string;
  110451. }
  110452. }
  110453. declare module BABYLON {
  110454. /** @hidden */
  110455. export var stereoscopicInterlacePixelShader: {
  110456. name: string;
  110457. shader: string;
  110458. };
  110459. }
  110460. declare module BABYLON {
  110461. /**
  110462. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  110463. */
  110464. export class StereoscopicInterlacePostProcess extends PostProcess {
  110465. private _stepSize;
  110466. private _passedProcess;
  110467. /**
  110468. * Initializes a StereoscopicInterlacePostProcess
  110469. * @param name The name of the effect.
  110470. * @param rigCameras The rig cameras to be appled to the post process
  110471. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  110472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110473. * @param engine The engine which the post process will be applied. (default: current engine)
  110474. * @param reusable If the post process can be reused on the same frame. (default: false)
  110475. */
  110476. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110477. }
  110478. }
  110479. declare module BABYLON {
  110480. /**
  110481. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  110482. * @see http://doc.babylonjs.com/features/cameras
  110483. */
  110484. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  110485. /**
  110486. * Creates a new StereoscopicArcRotateCamera
  110487. * @param name defines camera name
  110488. * @param alpha defines alpha angle (in radians)
  110489. * @param beta defines beta angle (in radians)
  110490. * @param radius defines radius
  110491. * @param target defines camera target
  110492. * @param interaxialDistance defines distance between each color axis
  110493. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110494. * @param scene defines the hosting scene
  110495. */
  110496. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110497. /**
  110498. * Gets camera class name
  110499. * @returns StereoscopicArcRotateCamera
  110500. */
  110501. getClassName(): string;
  110502. }
  110503. }
  110504. declare module BABYLON {
  110505. /**
  110506. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  110507. * @see http://doc.babylonjs.com/features/cameras
  110508. */
  110509. export class StereoscopicFreeCamera extends FreeCamera {
  110510. /**
  110511. * Creates a new StereoscopicFreeCamera
  110512. * @param name defines camera name
  110513. * @param position defines initial position
  110514. * @param interaxialDistance defines distance between each color axis
  110515. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110516. * @param scene defines the hosting scene
  110517. */
  110518. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110519. /**
  110520. * Gets camera class name
  110521. * @returns StereoscopicFreeCamera
  110522. */
  110523. getClassName(): string;
  110524. }
  110525. }
  110526. declare module BABYLON {
  110527. /**
  110528. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  110529. * @see http://doc.babylonjs.com/features/cameras
  110530. */
  110531. export class StereoscopicGamepadCamera extends GamepadCamera {
  110532. /**
  110533. * Creates a new StereoscopicGamepadCamera
  110534. * @param name defines camera name
  110535. * @param position defines initial position
  110536. * @param interaxialDistance defines distance between each color axis
  110537. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110538. * @param scene defines the hosting scene
  110539. */
  110540. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110541. /**
  110542. * Gets camera class name
  110543. * @returns StereoscopicGamepadCamera
  110544. */
  110545. getClassName(): string;
  110546. }
  110547. }
  110548. declare module BABYLON {
  110549. /**
  110550. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  110551. * @see http://doc.babylonjs.com/features/cameras
  110552. */
  110553. export class StereoscopicUniversalCamera extends UniversalCamera {
  110554. /**
  110555. * Creates a new StereoscopicUniversalCamera
  110556. * @param name defines camera name
  110557. * @param position defines initial position
  110558. * @param interaxialDistance defines distance between each color axis
  110559. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  110560. * @param scene defines the hosting scene
  110561. */
  110562. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  110563. /**
  110564. * Gets camera class name
  110565. * @returns StereoscopicUniversalCamera
  110566. */
  110567. getClassName(): string;
  110568. }
  110569. }
  110570. declare module BABYLON {
  110571. /**
  110572. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  110573. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110574. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110575. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110576. */
  110577. export class VirtualJoysticksCamera extends FreeCamera {
  110578. /**
  110579. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  110580. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  110581. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  110582. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  110583. * @param name Define the name of the camera in the scene
  110584. * @param position Define the start position of the camera in the scene
  110585. * @param scene Define the scene the camera belongs to
  110586. */
  110587. constructor(name: string, position: Vector3, scene: Scene);
  110588. /**
  110589. * Gets the current object class name.
  110590. * @return the class name
  110591. */
  110592. getClassName(): string;
  110593. }
  110594. }
  110595. declare module BABYLON {
  110596. /**
  110597. * This represents all the required metrics to create a VR camera.
  110598. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  110599. */
  110600. export class VRCameraMetrics {
  110601. /**
  110602. * Define the horizontal resolution off the screen.
  110603. */
  110604. hResolution: number;
  110605. /**
  110606. * Define the vertical resolution off the screen.
  110607. */
  110608. vResolution: number;
  110609. /**
  110610. * Define the horizontal screen size.
  110611. */
  110612. hScreenSize: number;
  110613. /**
  110614. * Define the vertical screen size.
  110615. */
  110616. vScreenSize: number;
  110617. /**
  110618. * Define the vertical screen center position.
  110619. */
  110620. vScreenCenter: number;
  110621. /**
  110622. * Define the distance of the eyes to the screen.
  110623. */
  110624. eyeToScreenDistance: number;
  110625. /**
  110626. * Define the distance between both lenses
  110627. */
  110628. lensSeparationDistance: number;
  110629. /**
  110630. * Define the distance between both viewer's eyes.
  110631. */
  110632. interpupillaryDistance: number;
  110633. /**
  110634. * Define the distortion factor of the VR postprocess.
  110635. * Please, touch with care.
  110636. */
  110637. distortionK: number[];
  110638. /**
  110639. * Define the chromatic aberration correction factors for the VR post process.
  110640. */
  110641. chromaAbCorrection: number[];
  110642. /**
  110643. * Define the scale factor of the post process.
  110644. * The smaller the better but the slower.
  110645. */
  110646. postProcessScaleFactor: number;
  110647. /**
  110648. * Define an offset for the lens center.
  110649. */
  110650. lensCenterOffset: number;
  110651. /**
  110652. * Define if the current vr camera should compensate the distortion of the lense or not.
  110653. */
  110654. compensateDistortion: boolean;
  110655. /**
  110656. * Defines if multiview should be enabled when rendering (Default: false)
  110657. */
  110658. multiviewEnabled: boolean;
  110659. /**
  110660. * Gets the rendering aspect ratio based on the provided resolutions.
  110661. */
  110662. readonly aspectRatio: number;
  110663. /**
  110664. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  110665. */
  110666. readonly aspectRatioFov: number;
  110667. /**
  110668. * @hidden
  110669. */
  110670. readonly leftHMatrix: Matrix;
  110671. /**
  110672. * @hidden
  110673. */
  110674. readonly rightHMatrix: Matrix;
  110675. /**
  110676. * @hidden
  110677. */
  110678. readonly leftPreViewMatrix: Matrix;
  110679. /**
  110680. * @hidden
  110681. */
  110682. readonly rightPreViewMatrix: Matrix;
  110683. /**
  110684. * Get the default VRMetrics based on the most generic setup.
  110685. * @returns the default vr metrics
  110686. */
  110687. static GetDefault(): VRCameraMetrics;
  110688. }
  110689. }
  110690. declare module BABYLON {
  110691. /** @hidden */
  110692. export var vrDistortionCorrectionPixelShader: {
  110693. name: string;
  110694. shader: string;
  110695. };
  110696. }
  110697. declare module BABYLON {
  110698. /**
  110699. * VRDistortionCorrectionPostProcess used for mobile VR
  110700. */
  110701. export class VRDistortionCorrectionPostProcess extends PostProcess {
  110702. private _isRightEye;
  110703. private _distortionFactors;
  110704. private _postProcessScaleFactor;
  110705. private _lensCenterOffset;
  110706. private _scaleIn;
  110707. private _scaleFactor;
  110708. private _lensCenter;
  110709. /**
  110710. * Initializes the VRDistortionCorrectionPostProcess
  110711. * @param name The name of the effect.
  110712. * @param camera The camera to apply the render pass to.
  110713. * @param isRightEye If this is for the right eye distortion
  110714. * @param vrMetrics All the required metrics for the VR camera
  110715. */
  110716. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  110717. }
  110718. }
  110719. declare module BABYLON {
  110720. /**
  110721. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  110722. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110723. */
  110724. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  110725. /**
  110726. * Creates a new VRDeviceOrientationArcRotateCamera
  110727. * @param name defines camera name
  110728. * @param alpha defines the camera rotation along the logitudinal axis
  110729. * @param beta defines the camera rotation along the latitudinal axis
  110730. * @param radius defines the camera distance from its target
  110731. * @param target defines the camera target
  110732. * @param scene defines the scene the camera belongs to
  110733. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110735. */
  110736. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110737. /**
  110738. * Gets camera class name
  110739. * @returns VRDeviceOrientationArcRotateCamera
  110740. */
  110741. getClassName(): string;
  110742. }
  110743. }
  110744. declare module BABYLON {
  110745. /**
  110746. * Camera used to simulate VR rendering (based on FreeCamera)
  110747. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110748. */
  110749. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  110750. /**
  110751. * Creates a new VRDeviceOrientationFreeCamera
  110752. * @param name defines camera name
  110753. * @param position defines the start position of the camera
  110754. * @param scene defines the scene the camera belongs to
  110755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110757. */
  110758. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110759. /**
  110760. * Gets camera class name
  110761. * @returns VRDeviceOrientationFreeCamera
  110762. */
  110763. getClassName(): string;
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  110769. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  110770. */
  110771. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  110772. /**
  110773. * Creates a new VRDeviceOrientationGamepadCamera
  110774. * @param name defines camera name
  110775. * @param position defines the start position of the camera
  110776. * @param scene defines the scene the camera belongs to
  110777. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  110778. * @param vrCameraMetrics defines the vr metrics associated to the camera
  110779. */
  110780. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  110781. /**
  110782. * Gets camera class name
  110783. * @returns VRDeviceOrientationGamepadCamera
  110784. */
  110785. getClassName(): string;
  110786. }
  110787. }
  110788. declare module BABYLON {
  110789. /** @hidden */
  110790. export var imageProcessingPixelShader: {
  110791. name: string;
  110792. shader: string;
  110793. };
  110794. }
  110795. declare module BABYLON {
  110796. /**
  110797. * ImageProcessingPostProcess
  110798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  110799. */
  110800. export class ImageProcessingPostProcess extends PostProcess {
  110801. /**
  110802. * Default configuration related to image processing available in the PBR Material.
  110803. */
  110804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110805. /**
  110806. * Gets the image processing configuration used either in this material.
  110807. */
  110808. /**
  110809. * Sets the Default image processing configuration used either in the this material.
  110810. *
  110811. * If sets to null, the scene one is in use.
  110812. */
  110813. imageProcessingConfiguration: ImageProcessingConfiguration;
  110814. /**
  110815. * Keep track of the image processing observer to allow dispose and replace.
  110816. */
  110817. private _imageProcessingObserver;
  110818. /**
  110819. * Attaches a new image processing configuration to the PBR Material.
  110820. * @param configuration
  110821. */
  110822. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  110823. /**
  110824. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110825. */
  110826. /**
  110827. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  110828. */
  110829. colorCurves: Nullable<ColorCurves>;
  110830. /**
  110831. * Gets wether the color curves effect is enabled.
  110832. */
  110833. /**
  110834. * Sets wether the color curves effect is enabled.
  110835. */
  110836. colorCurvesEnabled: boolean;
  110837. /**
  110838. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110839. */
  110840. /**
  110841. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  110842. */
  110843. colorGradingTexture: Nullable<BaseTexture>;
  110844. /**
  110845. * Gets wether the color grading effect is enabled.
  110846. */
  110847. /**
  110848. * Gets wether the color grading effect is enabled.
  110849. */
  110850. colorGradingEnabled: boolean;
  110851. /**
  110852. * Gets exposure used in the effect.
  110853. */
  110854. /**
  110855. * Sets exposure used in the effect.
  110856. */
  110857. exposure: number;
  110858. /**
  110859. * Gets wether tonemapping is enabled or not.
  110860. */
  110861. /**
  110862. * Sets wether tonemapping is enabled or not
  110863. */
  110864. toneMappingEnabled: boolean;
  110865. /**
  110866. * Gets the type of tone mapping effect.
  110867. */
  110868. /**
  110869. * Sets the type of tone mapping effect.
  110870. */
  110871. toneMappingType: number;
  110872. /**
  110873. * Gets contrast used in the effect.
  110874. */
  110875. /**
  110876. * Sets contrast used in the effect.
  110877. */
  110878. contrast: number;
  110879. /**
  110880. * Gets Vignette stretch size.
  110881. */
  110882. /**
  110883. * Sets Vignette stretch size.
  110884. */
  110885. vignetteStretch: number;
  110886. /**
  110887. * Gets Vignette centre X Offset.
  110888. */
  110889. /**
  110890. * Sets Vignette centre X Offset.
  110891. */
  110892. vignetteCentreX: number;
  110893. /**
  110894. * Gets Vignette centre Y Offset.
  110895. */
  110896. /**
  110897. * Sets Vignette centre Y Offset.
  110898. */
  110899. vignetteCentreY: number;
  110900. /**
  110901. * Gets Vignette weight or intensity of the vignette effect.
  110902. */
  110903. /**
  110904. * Sets Vignette weight or intensity of the vignette effect.
  110905. */
  110906. vignetteWeight: number;
  110907. /**
  110908. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110909. * if vignetteEnabled is set to true.
  110910. */
  110911. /**
  110912. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  110913. * if vignetteEnabled is set to true.
  110914. */
  110915. vignetteColor: Color4;
  110916. /**
  110917. * Gets Camera field of view used by the Vignette effect.
  110918. */
  110919. /**
  110920. * Sets Camera field of view used by the Vignette effect.
  110921. */
  110922. vignetteCameraFov: number;
  110923. /**
  110924. * Gets the vignette blend mode allowing different kind of effect.
  110925. */
  110926. /**
  110927. * Sets the vignette blend mode allowing different kind of effect.
  110928. */
  110929. vignetteBlendMode: number;
  110930. /**
  110931. * Gets wether the vignette effect is enabled.
  110932. */
  110933. /**
  110934. * Sets wether the vignette effect is enabled.
  110935. */
  110936. vignetteEnabled: boolean;
  110937. private _fromLinearSpace;
  110938. /**
  110939. * Gets wether the input of the processing is in Gamma or Linear Space.
  110940. */
  110941. /**
  110942. * Sets wether the input of the processing is in Gamma or Linear Space.
  110943. */
  110944. fromLinearSpace: boolean;
  110945. /**
  110946. * Defines cache preventing GC.
  110947. */
  110948. private _defines;
  110949. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  110950. /**
  110951. * "ImageProcessingPostProcess"
  110952. * @returns "ImageProcessingPostProcess"
  110953. */
  110954. getClassName(): string;
  110955. protected _updateParameters(): void;
  110956. dispose(camera?: Camera): void;
  110957. }
  110958. }
  110959. declare module BABYLON {
  110960. /**
  110961. * Class containing static functions to help procedurally build meshes
  110962. */
  110963. export class GroundBuilder {
  110964. /**
  110965. * Creates a ground mesh
  110966. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110967. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110969. * @param name defines the name of the mesh
  110970. * @param options defines the options used to create the mesh
  110971. * @param scene defines the hosting scene
  110972. * @returns the ground mesh
  110973. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110974. */
  110975. static CreateGround(name: string, options: {
  110976. width?: number;
  110977. height?: number;
  110978. subdivisions?: number;
  110979. subdivisionsX?: number;
  110980. subdivisionsY?: number;
  110981. updatable?: boolean;
  110982. }, scene: any): Mesh;
  110983. /**
  110984. * Creates a tiled ground mesh
  110985. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110986. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110987. * * 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
  110988. * * 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
  110989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110990. * @param name defines the name of the mesh
  110991. * @param options defines the options used to create the mesh
  110992. * @param scene defines the hosting scene
  110993. * @returns the tiled ground mesh
  110994. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110995. */
  110996. static CreateTiledGround(name: string, options: {
  110997. xmin: number;
  110998. zmin: number;
  110999. xmax: number;
  111000. zmax: number;
  111001. subdivisions?: {
  111002. w: number;
  111003. h: number;
  111004. };
  111005. precision?: {
  111006. w: number;
  111007. h: number;
  111008. };
  111009. updatable?: boolean;
  111010. }, scene?: Nullable<Scene>): Mesh;
  111011. /**
  111012. * Creates a ground mesh from a height map
  111013. * * The parameter `url` sets the URL of the height map image resource.
  111014. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  111015. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  111016. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  111017. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  111018. * * 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.
  111019. * * 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).
  111020. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  111021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111022. * @param name defines the name of the mesh
  111023. * @param url defines the url to the height map
  111024. * @param options defines the options used to create the mesh
  111025. * @param scene defines the hosting scene
  111026. * @returns the ground mesh
  111027. * @see https://doc.babylonjs.com/babylon101/height_map
  111028. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  111029. */
  111030. static CreateGroundFromHeightMap(name: string, url: string, options: {
  111031. width?: number;
  111032. height?: number;
  111033. subdivisions?: number;
  111034. minHeight?: number;
  111035. maxHeight?: number;
  111036. colorFilter?: Color3;
  111037. alphaFilter?: number;
  111038. updatable?: boolean;
  111039. onReady?: (mesh: GroundMesh) => void;
  111040. }, scene?: Nullable<Scene>): GroundMesh;
  111041. }
  111042. }
  111043. declare module BABYLON {
  111044. /**
  111045. * Class containing static functions to help procedurally build meshes
  111046. */
  111047. export class TorusBuilder {
  111048. /**
  111049. * Creates a torus mesh
  111050. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  111051. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  111052. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  111053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111056. * @param name defines the name of the mesh
  111057. * @param options defines the options used to create the mesh
  111058. * @param scene defines the hosting scene
  111059. * @returns the torus mesh
  111060. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  111061. */
  111062. static CreateTorus(name: string, options: {
  111063. diameter?: number;
  111064. thickness?: number;
  111065. tessellation?: number;
  111066. updatable?: boolean;
  111067. sideOrientation?: number;
  111068. frontUVs?: Vector4;
  111069. backUVs?: Vector4;
  111070. }, scene: any): Mesh;
  111071. }
  111072. }
  111073. declare module BABYLON {
  111074. /**
  111075. * Class containing static functions to help procedurally build meshes
  111076. */
  111077. export class CylinderBuilder {
  111078. /**
  111079. * Creates a cylinder or a cone mesh
  111080. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  111081. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  111082. * * 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.
  111083. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  111084. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  111085. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  111086. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  111087. * * 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).
  111088. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  111089. * * 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).
  111090. * * 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
  111091. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  111092. * * 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
  111093. * * 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.
  111094. * * If `enclose` is false, a ring surface is one element.
  111095. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  111096. * * 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
  111097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111100. * @param name defines the name of the mesh
  111101. * @param options defines the options used to create the mesh
  111102. * @param scene defines the hosting scene
  111103. * @returns the cylinder mesh
  111104. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  111105. */
  111106. static CreateCylinder(name: string, options: {
  111107. height?: number;
  111108. diameterTop?: number;
  111109. diameterBottom?: number;
  111110. diameter?: number;
  111111. tessellation?: number;
  111112. subdivisions?: number;
  111113. arc?: number;
  111114. faceColors?: Color4[];
  111115. faceUV?: Vector4[];
  111116. updatable?: boolean;
  111117. hasRings?: boolean;
  111118. enclose?: boolean;
  111119. cap?: number;
  111120. sideOrientation?: number;
  111121. frontUVs?: Vector4;
  111122. backUVs?: Vector4;
  111123. }, scene: any): Mesh;
  111124. }
  111125. }
  111126. declare module BABYLON {
  111127. /**
  111128. * States of the webXR experience
  111129. */
  111130. export enum WebXRState {
  111131. /**
  111132. * Transitioning to being in XR mode
  111133. */
  111134. ENTERING_XR = 0,
  111135. /**
  111136. * Transitioning to non XR mode
  111137. */
  111138. EXITING_XR = 1,
  111139. /**
  111140. * In XR mode and presenting
  111141. */
  111142. IN_XR = 2,
  111143. /**
  111144. * Not entered XR mode
  111145. */
  111146. NOT_IN_XR = 3
  111147. }
  111148. /**
  111149. * Abstraction of the XR render target
  111150. */
  111151. export interface WebXRRenderTarget extends IDisposable {
  111152. /**
  111153. * xrpresent context of the canvas which can be used to display/mirror xr content
  111154. */
  111155. canvasContext: WebGLRenderingContext;
  111156. /**
  111157. * xr layer for the canvas
  111158. */
  111159. xrLayer: Nullable<XRWebGLLayer>;
  111160. /**
  111161. * Initializes the xr layer for the session
  111162. * @param xrSession xr session
  111163. * @returns a promise that will resolve once the XR Layer has been created
  111164. */
  111165. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  111166. }
  111167. }
  111168. declare module BABYLON {
  111169. /**
  111170. * COnfiguration object for WebXR output canvas
  111171. */
  111172. export class WebXRManagedOutputCanvasOptions {
  111173. /**
  111174. * Options for this XR Layer output
  111175. */
  111176. canvasOptions: XRWebGLLayerOptions;
  111177. /**
  111178. * CSS styling for a newly created canvas (if not provided)
  111179. */
  111180. newCanvasCssStyle?: string;
  111181. /**
  111182. * Get the default values of the configuration object
  111183. * @returns default values of this configuration object
  111184. */
  111185. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  111186. }
  111187. /**
  111188. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  111189. */
  111190. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  111191. private configuration;
  111192. private _engine;
  111193. private _canvas;
  111194. /**
  111195. * xrpresent context of the canvas which can be used to display/mirror xr content
  111196. */
  111197. canvasContext: WebGLRenderingContext;
  111198. /**
  111199. * xr layer for the canvas
  111200. */
  111201. xrLayer: Nullable<XRWebGLLayer>;
  111202. /**
  111203. * Initializes the xr layer for the session
  111204. * @param xrSession xr session
  111205. * @returns a promise that will resolve once the XR Layer has been created
  111206. */
  111207. initializeXRLayerAsync(xrSession: any): any;
  111208. /**
  111209. * Initializes the canvas to be added/removed upon entering/exiting xr
  111210. * @param engine the Babylon engine
  111211. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  111212. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  111213. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  111214. */
  111215. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  111216. /**
  111217. * Disposes of the object
  111218. */
  111219. dispose(): void;
  111220. private _setManagedOutputCanvas;
  111221. private _addCanvas;
  111222. private _removeCanvas;
  111223. }
  111224. }
  111225. declare module BABYLON {
  111226. /**
  111227. * Manages an XRSession to work with Babylon's engine
  111228. * @see https://doc.babylonjs.com/how_to/webxr
  111229. */
  111230. export class WebXRSessionManager implements IDisposable {
  111231. /** The scene which the session should be created for */
  111232. scene: Scene;
  111233. /**
  111234. * Fires every time a new xrFrame arrives which can be used to update the camera
  111235. */
  111236. onXRFrameObservable: Observable<XRFrame>;
  111237. /**
  111238. * Fires when the xr session is ended either by the device or manually done
  111239. */
  111240. onXRSessionEnded: Observable<any>;
  111241. /**
  111242. * Fires when the xr session is ended either by the device or manually done
  111243. */
  111244. onXRSessionInit: Observable<XRSession>;
  111245. /**
  111246. * Underlying xr session
  111247. */
  111248. session: XRSession;
  111249. /**
  111250. * Type of reference space used when creating the session
  111251. */
  111252. referenceSpace: XRReferenceSpace;
  111253. /**
  111254. * Current XR frame
  111255. */
  111256. currentFrame: Nullable<XRFrame>;
  111257. private _xrNavigator;
  111258. private baseLayer;
  111259. private _rttProvider;
  111260. private _sessionEnded;
  111261. /**
  111262. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  111263. * @param scene The scene which the session should be created for
  111264. */
  111265. constructor(
  111266. /** The scene which the session should be created for */
  111267. scene: Scene);
  111268. /**
  111269. * Initializes the manager
  111270. * After initialization enterXR can be called to start an XR session
  111271. * @returns Promise which resolves after it is initialized
  111272. */
  111273. initializeAsync(): Promise<void>;
  111274. /**
  111275. * Initializes an xr session
  111276. * @param xrSessionMode mode to initialize
  111277. * @param optionalFeatures defines optional values to pass to the session builder
  111278. * @returns a promise which will resolve once the session has been initialized
  111279. */
  111280. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  111281. /**
  111282. * Sets the reference space on the xr session
  111283. * @param referenceSpace space to set
  111284. * @returns a promise that will resolve once the reference space has been set
  111285. */
  111286. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  111287. /**
  111288. * Updates the render state of the session
  111289. * @param state state to set
  111290. * @returns a promise that resolves once the render state has been updated
  111291. */
  111292. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  111293. /**
  111294. * Starts rendering to the xr layer
  111295. * @returns a promise that will resolve once rendering has started
  111296. */
  111297. startRenderingToXRAsync(): Promise<void>;
  111298. /**
  111299. * Gets the correct render target texture to be rendered this frame for this eye
  111300. * @param eye the eye for which to get the render target
  111301. * @returns the render target for the specified eye
  111302. */
  111303. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  111304. /**
  111305. * Stops the xrSession and restores the renderloop
  111306. * @returns Promise which resolves after it exits XR
  111307. */
  111308. exitXRAsync(): Promise<void>;
  111309. /**
  111310. * Checks if a session would be supported for the creation options specified
  111311. * @param sessionMode session mode to check if supported eg. immersive-vr
  111312. * @returns true if supported
  111313. */
  111314. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111315. /**
  111316. * Creates a WebXRRenderTarget object for the XR session
  111317. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  111318. * @param options optional options to provide when creating a new render target
  111319. * @returns a WebXR render target to which the session can render
  111320. */
  111321. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  111322. /**
  111323. * @hidden
  111324. * Converts the render layer of xrSession to a render target
  111325. * @param session session to create render target for
  111326. * @param scene scene the new render target should be created for
  111327. * @param baseLayer the webgl layer to create the render target for
  111328. */
  111329. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  111330. /**
  111331. * Disposes of the session manager
  111332. */
  111333. dispose(): void;
  111334. /**
  111335. * Gets a promise returning true when fullfiled if the given session mode is supported
  111336. * @param sessionMode defines the session to test
  111337. * @returns a promise
  111338. */
  111339. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  111340. }
  111341. }
  111342. declare module BABYLON {
  111343. /**
  111344. * WebXR Camera which holds the views for the xrSession
  111345. * @see https://doc.babylonjs.com/how_to/webxr
  111346. */
  111347. export class WebXRCamera extends FreeCamera {
  111348. /**
  111349. * Is the camera in debug mode. Used when using an emulator
  111350. */
  111351. debugMode: boolean;
  111352. /**
  111353. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  111354. * @param name the name of the camera
  111355. * @param scene the scene to add the camera to
  111356. */
  111357. constructor(name: string, scene: Scene);
  111358. private _updateNumberOfRigCameras;
  111359. /** @hidden */
  111360. _updateForDualEyeDebugging(): void;
  111361. /**
  111362. * Updates the cameras position from the current pose information of the XR session
  111363. * @param xrSessionManager the session containing pose information
  111364. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  111365. */
  111366. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  111367. }
  111368. }
  111369. declare module BABYLON {
  111370. /**
  111371. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  111372. * @see https://doc.babylonjs.com/how_to/webxr
  111373. */
  111374. export class WebXRExperienceHelper implements IDisposable {
  111375. private scene;
  111376. /**
  111377. * 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
  111378. */
  111379. container: AbstractMesh;
  111380. /**
  111381. * Camera used to render xr content
  111382. */
  111383. camera: WebXRCamera;
  111384. /**
  111385. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  111386. */
  111387. state: WebXRState;
  111388. private _setState;
  111389. private static _TmpVector;
  111390. /**
  111391. * Fires when the state of the experience helper has changed
  111392. */
  111393. onStateChangedObservable: Observable<WebXRState>;
  111394. /** Session manager used to keep track of xr session */
  111395. sessionManager: WebXRSessionManager;
  111396. private _nonVRCamera;
  111397. private _originalSceneAutoClear;
  111398. private _supported;
  111399. /**
  111400. * Creates the experience helper
  111401. * @param scene the scene to attach the experience helper to
  111402. * @returns a promise for the experience helper
  111403. */
  111404. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  111405. /**
  111406. * Creates a WebXRExperienceHelper
  111407. * @param scene The scene the helper should be created in
  111408. */
  111409. private constructor();
  111410. /**
  111411. * Exits XR mode and returns the scene to its original state
  111412. * @returns promise that resolves after xr mode has exited
  111413. */
  111414. exitXRAsync(): Promise<void>;
  111415. /**
  111416. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  111417. * @param sessionMode options for the XR session
  111418. * @param referenceSpaceType frame of reference of the XR session
  111419. * @param renderTarget the output canvas that will be used to enter XR mode
  111420. * @returns promise that resolves after xr mode has entered
  111421. */
  111422. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  111423. /**
  111424. * Updates the global position of the camera by moving the camera's container
  111425. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  111426. * @param position The desired global position of the camera
  111427. */
  111428. setPositionOfCameraUsingContainer(position: Vector3): void;
  111429. /**
  111430. * Rotates the xr camera by rotating the camera's container around the camera's position
  111431. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  111432. * @param rotation the desired quaternion rotation to apply to the camera
  111433. */
  111434. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  111435. /**
  111436. * Disposes of the experience helper
  111437. */
  111438. dispose(): void;
  111439. }
  111440. }
  111441. declare module BABYLON {
  111442. /**
  111443. * Represents an XR input
  111444. */
  111445. export class WebXRController {
  111446. private scene;
  111447. /** The underlying input source for the controller */
  111448. inputSource: XRInputSource;
  111449. private parentContainer;
  111450. /**
  111451. * 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
  111452. */
  111453. grip?: AbstractMesh;
  111454. /**
  111455. * Pointer which can be used to select objects or attach a visible laser to
  111456. */
  111457. pointer: AbstractMesh;
  111458. private _gamepadMode;
  111459. /**
  111460. * If available, this is the gamepad object related to this controller.
  111461. * Using this object it is possible to get click events and trackpad changes of the
  111462. * webxr controller that is currently being used.
  111463. */
  111464. gamepadController?: WebVRController;
  111465. /**
  111466. * Event that fires when the controller is removed/disposed
  111467. */
  111468. onDisposeObservable: Observable<{}>;
  111469. private _tmpQuaternion;
  111470. private _tmpVector;
  111471. /**
  111472. * Creates the controller
  111473. * @see https://doc.babylonjs.com/how_to/webxr
  111474. * @param scene the scene which the controller should be associated to
  111475. * @param inputSource the underlying input source for the controller
  111476. * @param parentContainer parent that the controller meshes should be children of
  111477. */
  111478. constructor(scene: Scene,
  111479. /** The underlying input source for the controller */
  111480. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  111481. /**
  111482. * Updates the controller pose based on the given XRFrame
  111483. * @param xrFrame xr frame to update the pose with
  111484. * @param referenceSpace reference space to use
  111485. */
  111486. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  111487. /**
  111488. * Gets a world space ray coming from the controller
  111489. * @param result the resulting ray
  111490. */
  111491. getWorldPointerRayToRef(result: Ray): void;
  111492. /**
  111493. * Get the scene associated with this controller
  111494. * @returns the scene object
  111495. */
  111496. getScene(): Scene;
  111497. /**
  111498. * Disposes of the object
  111499. */
  111500. dispose(): void;
  111501. }
  111502. }
  111503. declare module BABYLON {
  111504. /**
  111505. * XR input used to track XR inputs such as controllers/rays
  111506. */
  111507. export class WebXRInput implements IDisposable {
  111508. /**
  111509. * Base experience the input listens to
  111510. */
  111511. baseExperience: WebXRExperienceHelper;
  111512. /**
  111513. * XR controllers being tracked
  111514. */
  111515. controllers: Array<WebXRController>;
  111516. private _frameObserver;
  111517. private _stateObserver;
  111518. /**
  111519. * Event when a controller has been connected/added
  111520. */
  111521. onControllerAddedObservable: Observable<WebXRController>;
  111522. /**
  111523. * Event when a controller has been removed/disconnected
  111524. */
  111525. onControllerRemovedObservable: Observable<WebXRController>;
  111526. /**
  111527. * Initializes the WebXRInput
  111528. * @param baseExperience experience helper which the input should be created for
  111529. */
  111530. constructor(
  111531. /**
  111532. * Base experience the input listens to
  111533. */
  111534. baseExperience: WebXRExperienceHelper);
  111535. private _onInputSourcesChange;
  111536. private _addAndRemoveControllers;
  111537. /**
  111538. * Disposes of the object
  111539. */
  111540. dispose(): void;
  111541. }
  111542. }
  111543. declare module BABYLON {
  111544. /**
  111545. * Class used to represent data loading progression
  111546. */
  111547. export class SceneLoaderProgressEvent {
  111548. /** defines if data length to load can be evaluated */
  111549. readonly lengthComputable: boolean;
  111550. /** defines the loaded data length */
  111551. readonly loaded: number;
  111552. /** defines the data length to load */
  111553. readonly total: number;
  111554. /**
  111555. * Create a new progress event
  111556. * @param lengthComputable defines if data length to load can be evaluated
  111557. * @param loaded defines the loaded data length
  111558. * @param total defines the data length to load
  111559. */
  111560. constructor(
  111561. /** defines if data length to load can be evaluated */
  111562. lengthComputable: boolean,
  111563. /** defines the loaded data length */
  111564. loaded: number,
  111565. /** defines the data length to load */
  111566. total: number);
  111567. /**
  111568. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  111569. * @param event defines the source event
  111570. * @returns a new SceneLoaderProgressEvent
  111571. */
  111572. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  111573. }
  111574. /**
  111575. * Interface used by SceneLoader plugins to define supported file extensions
  111576. */
  111577. export interface ISceneLoaderPluginExtensions {
  111578. /**
  111579. * Defines the list of supported extensions
  111580. */
  111581. [extension: string]: {
  111582. isBinary: boolean;
  111583. };
  111584. }
  111585. /**
  111586. * Interface used by SceneLoader plugin factory
  111587. */
  111588. export interface ISceneLoaderPluginFactory {
  111589. /**
  111590. * Defines the name of the factory
  111591. */
  111592. name: string;
  111593. /**
  111594. * Function called to create a new plugin
  111595. * @return the new plugin
  111596. */
  111597. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  111598. /**
  111599. * The callback that returns true if the data can be directly loaded.
  111600. * @param data string containing the file data
  111601. * @returns if the data can be loaded directly
  111602. */
  111603. canDirectLoad?(data: string): boolean;
  111604. }
  111605. /**
  111606. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  111607. */
  111608. export interface ISceneLoaderPluginBase {
  111609. /**
  111610. * The friendly name of this plugin.
  111611. */
  111612. name: string;
  111613. /**
  111614. * The file extensions supported by this plugin.
  111615. */
  111616. extensions: string | ISceneLoaderPluginExtensions;
  111617. /**
  111618. * The callback called when loading from a url.
  111619. * @param scene scene loading this url
  111620. * @param url url to load
  111621. * @param onSuccess callback called when the file successfully loads
  111622. * @param onProgress callback called while file is loading (if the server supports this mode)
  111623. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  111624. * @param onError callback called when the file fails to load
  111625. * @returns a file request object
  111626. */
  111627. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111628. /**
  111629. * The callback called when loading from a file object.
  111630. * @param scene scene loading this file
  111631. * @param file defines the file to load
  111632. * @param onSuccess defines the callback to call when data is loaded
  111633. * @param onProgress defines the callback to call during loading process
  111634. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  111635. * @param onError defines the callback to call when an error occurs
  111636. * @returns a file request object
  111637. */
  111638. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  111639. /**
  111640. * The callback that returns true if the data can be directly loaded.
  111641. * @param data string containing the file data
  111642. * @returns if the data can be loaded directly
  111643. */
  111644. canDirectLoad?(data: string): boolean;
  111645. /**
  111646. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  111647. * @param scene scene loading this data
  111648. * @param data string containing the data
  111649. * @returns data to pass to the plugin
  111650. */
  111651. directLoad?(scene: Scene, data: string): any;
  111652. /**
  111653. * The callback that allows custom handling of the root url based on the response url.
  111654. * @param rootUrl the original root url
  111655. * @param responseURL the response url if available
  111656. * @returns the new root url
  111657. */
  111658. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  111659. }
  111660. /**
  111661. * Interface used to define a SceneLoader plugin
  111662. */
  111663. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  111664. /**
  111665. * Import meshes into a scene.
  111666. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111667. * @param scene The scene to import into
  111668. * @param data The data to import
  111669. * @param rootUrl The root url for scene and resources
  111670. * @param meshes The meshes array to import into
  111671. * @param particleSystems The particle systems array to import into
  111672. * @param skeletons The skeletons array to import into
  111673. * @param onError The callback when import fails
  111674. * @returns True if successful or false otherwise
  111675. */
  111676. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  111677. /**
  111678. * Load into a scene.
  111679. * @param scene The scene to load into
  111680. * @param data The data to import
  111681. * @param rootUrl The root url for scene and resources
  111682. * @param onError The callback when import fails
  111683. * @returns True if successful or false otherwise
  111684. */
  111685. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  111686. /**
  111687. * Load into an asset container.
  111688. * @param scene The scene to load into
  111689. * @param data The data to import
  111690. * @param rootUrl The root url for scene and resources
  111691. * @param onError The callback when import fails
  111692. * @returns The loaded asset container
  111693. */
  111694. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  111695. }
  111696. /**
  111697. * Interface used to define an async SceneLoader plugin
  111698. */
  111699. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  111700. /**
  111701. * Import meshes into a scene.
  111702. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111703. * @param scene The scene to import into
  111704. * @param data The data to import
  111705. * @param rootUrl The root url for scene and resources
  111706. * @param onProgress The callback when the load progresses
  111707. * @param fileName Defines the name of the file to load
  111708. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  111709. */
  111710. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  111711. meshes: AbstractMesh[];
  111712. particleSystems: IParticleSystem[];
  111713. skeletons: Skeleton[];
  111714. animationGroups: AnimationGroup[];
  111715. }>;
  111716. /**
  111717. * Load into a scene.
  111718. * @param scene The scene to load into
  111719. * @param data The data to import
  111720. * @param rootUrl The root url for scene and resources
  111721. * @param onProgress The callback when the load progresses
  111722. * @param fileName Defines the name of the file to load
  111723. * @returns Nothing
  111724. */
  111725. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  111726. /**
  111727. * Load into an asset container.
  111728. * @param scene The scene to load into
  111729. * @param data The data to import
  111730. * @param rootUrl The root url for scene and resources
  111731. * @param onProgress The callback when the load progresses
  111732. * @param fileName Defines the name of the file to load
  111733. * @returns The loaded asset container
  111734. */
  111735. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  111736. }
  111737. /**
  111738. * Mode that determines how to handle old animation groups before loading new ones.
  111739. */
  111740. export enum SceneLoaderAnimationGroupLoadingMode {
  111741. /**
  111742. * Reset all old animations to initial state then dispose them.
  111743. */
  111744. Clean = 0,
  111745. /**
  111746. * Stop all old animations.
  111747. */
  111748. Stop = 1,
  111749. /**
  111750. * Restart old animations from first frame.
  111751. */
  111752. Sync = 2,
  111753. /**
  111754. * Old animations remains untouched.
  111755. */
  111756. NoSync = 3
  111757. }
  111758. /**
  111759. * Class used to load scene from various file formats using registered plugins
  111760. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  111761. */
  111762. export class SceneLoader {
  111763. /**
  111764. * No logging while loading
  111765. */
  111766. static readonly NO_LOGGING: number;
  111767. /**
  111768. * Minimal logging while loading
  111769. */
  111770. static readonly MINIMAL_LOGGING: number;
  111771. /**
  111772. * Summary logging while loading
  111773. */
  111774. static readonly SUMMARY_LOGGING: number;
  111775. /**
  111776. * Detailled logging while loading
  111777. */
  111778. static readonly DETAILED_LOGGING: number;
  111779. /**
  111780. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111781. */
  111782. static ForceFullSceneLoadingForIncremental: boolean;
  111783. /**
  111784. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111785. */
  111786. static ShowLoadingScreen: boolean;
  111787. /**
  111788. * Defines the current logging level (while loading the scene)
  111789. * @ignorenaming
  111790. */
  111791. static loggingLevel: number;
  111792. /**
  111793. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111794. */
  111795. static CleanBoneMatrixWeights: boolean;
  111796. /**
  111797. * Event raised when a plugin is used to load a scene
  111798. */
  111799. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111800. private static _registeredPlugins;
  111801. private static _getDefaultPlugin;
  111802. private static _getPluginForExtension;
  111803. private static _getPluginForDirectLoad;
  111804. private static _getPluginForFilename;
  111805. private static _getDirectLoad;
  111806. private static _loadData;
  111807. private static _getFileInfo;
  111808. /**
  111809. * Gets a plugin that can load the given extension
  111810. * @param extension defines the extension to load
  111811. * @returns a plugin or null if none works
  111812. */
  111813. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111814. /**
  111815. * Gets a boolean indicating that the given extension can be loaded
  111816. * @param extension defines the extension to load
  111817. * @returns true if the extension is supported
  111818. */
  111819. static IsPluginForExtensionAvailable(extension: string): boolean;
  111820. /**
  111821. * Adds a new plugin to the list of registered plugins
  111822. * @param plugin defines the plugin to add
  111823. */
  111824. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111825. /**
  111826. * Import meshes into a scene
  111827. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111828. * @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)
  111829. * @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)
  111830. * @param scene the instance of BABYLON.Scene to append to
  111831. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111832. * @param onProgress a callback with a progress event for each file being loaded
  111833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111834. * @param pluginExtension the extension used to determine the plugin
  111835. * @returns The loaded plugin
  111836. */
  111837. 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>;
  111838. /**
  111839. * Import meshes into a scene
  111840. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111841. * @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)
  111842. * @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)
  111843. * @param scene the instance of BABYLON.Scene to append to
  111844. * @param onProgress a callback with a progress event for each file being loaded
  111845. * @param pluginExtension the extension used to determine the plugin
  111846. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111847. */
  111848. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111849. meshes: AbstractMesh[];
  111850. particleSystems: IParticleSystem[];
  111851. skeletons: Skeleton[];
  111852. animationGroups: AnimationGroup[];
  111853. }>;
  111854. /**
  111855. * Load a scene
  111856. * @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)
  111857. * @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)
  111858. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111859. * @param onSuccess a callback with the scene when import succeeds
  111860. * @param onProgress a callback with a progress event for each file being loaded
  111861. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111862. * @param pluginExtension the extension used to determine the plugin
  111863. * @returns The loaded plugin
  111864. */
  111865. 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>;
  111866. /**
  111867. * Load a scene
  111868. * @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)
  111869. * @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)
  111870. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111871. * @param onProgress a callback with a progress event for each file being loaded
  111872. * @param pluginExtension the extension used to determine the plugin
  111873. * @returns The loaded scene
  111874. */
  111875. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111876. /**
  111877. * Append a scene
  111878. * @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)
  111879. * @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)
  111880. * @param scene is the instance of BABYLON.Scene to append to
  111881. * @param onSuccess a callback with the scene when import succeeds
  111882. * @param onProgress a callback with a progress event for each file being loaded
  111883. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111884. * @param pluginExtension the extension used to determine the plugin
  111885. * @returns The loaded plugin
  111886. */
  111887. 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>;
  111888. /**
  111889. * Append a scene
  111890. * @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)
  111891. * @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)
  111892. * @param scene is the instance of BABYLON.Scene to append to
  111893. * @param onProgress a callback with a progress event for each file being loaded
  111894. * @param pluginExtension the extension used to determine the plugin
  111895. * @returns The given scene
  111896. */
  111897. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111898. /**
  111899. * Load a scene into an asset container
  111900. * @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)
  111901. * @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)
  111902. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111903. * @param onSuccess a callback with the scene when import succeeds
  111904. * @param onProgress a callback with a progress event for each file being loaded
  111905. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111906. * @param pluginExtension the extension used to determine the plugin
  111907. * @returns The loaded plugin
  111908. */
  111909. 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>;
  111910. /**
  111911. * Load a scene into an asset container
  111912. * @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)
  111913. * @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)
  111914. * @param scene is the instance of Scene to append to
  111915. * @param onProgress a callback with a progress event for each file being loaded
  111916. * @param pluginExtension the extension used to determine the plugin
  111917. * @returns The loaded asset container
  111918. */
  111919. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111920. /**
  111921. * Import animations from a file into a scene
  111922. * @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)
  111923. * @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)
  111924. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111925. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  111926. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  111927. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  111928. * @param onSuccess a callback with the scene when import succeeds
  111929. * @param onProgress a callback with a progress event for each file being loaded
  111930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111931. */
  111932. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  111933. /**
  111934. * Import animations from a file into a scene
  111935. * @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)
  111936. * @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)
  111937. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111938. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  111939. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  111940. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  111941. * @param onSuccess a callback with the scene when import succeeds
  111942. * @param onProgress a callback with a progress event for each file being loaded
  111943. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111944. * @returns the updated scene with imported animations
  111945. */
  111946. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  111947. }
  111948. }
  111949. declare module BABYLON {
  111950. /**
  111951. * Generic Controller
  111952. */
  111953. export class GenericController extends WebVRController {
  111954. /**
  111955. * Base Url for the controller model.
  111956. */
  111957. static readonly MODEL_BASE_URL: string;
  111958. /**
  111959. * File name for the controller model.
  111960. */
  111961. static readonly MODEL_FILENAME: string;
  111962. /**
  111963. * Creates a new GenericController from a gamepad
  111964. * @param vrGamepad the gamepad that the controller should be created from
  111965. */
  111966. constructor(vrGamepad: any);
  111967. /**
  111968. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111969. * @param scene scene in which to add meshes
  111970. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111971. */
  111972. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111973. /**
  111974. * Called once for each button that changed state since the last frame
  111975. * @param buttonIdx Which button index changed
  111976. * @param state New state of the button
  111977. * @param changes Which properties on the state changed since last frame
  111978. */
  111979. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111980. }
  111981. }
  111982. declare module BABYLON {
  111983. /**
  111984. * Defines the WindowsMotionController object that the state of the windows motion controller
  111985. */
  111986. export class WindowsMotionController extends WebVRController {
  111987. /**
  111988. * The base url used to load the left and right controller models
  111989. */
  111990. static MODEL_BASE_URL: string;
  111991. /**
  111992. * The name of the left controller model file
  111993. */
  111994. static MODEL_LEFT_FILENAME: string;
  111995. /**
  111996. * The name of the right controller model file
  111997. */
  111998. static MODEL_RIGHT_FILENAME: string;
  111999. /**
  112000. * The controller name prefix for this controller type
  112001. */
  112002. static readonly GAMEPAD_ID_PREFIX: string;
  112003. /**
  112004. * The controller id pattern for this controller type
  112005. */
  112006. private static readonly GAMEPAD_ID_PATTERN;
  112007. private _loadedMeshInfo;
  112008. protected readonly _mapping: {
  112009. buttons: string[];
  112010. buttonMeshNames: {
  112011. 'trigger': string;
  112012. 'menu': string;
  112013. 'grip': string;
  112014. 'thumbstick': string;
  112015. 'trackpad': string;
  112016. };
  112017. buttonObservableNames: {
  112018. 'trigger': string;
  112019. 'menu': string;
  112020. 'grip': string;
  112021. 'thumbstick': string;
  112022. 'trackpad': string;
  112023. };
  112024. axisMeshNames: string[];
  112025. pointingPoseMeshName: string;
  112026. };
  112027. /**
  112028. * Fired when the trackpad on this controller is clicked
  112029. */
  112030. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  112031. /**
  112032. * Fired when the trackpad on this controller is modified
  112033. */
  112034. onTrackpadValuesChangedObservable: Observable<StickValues>;
  112035. /**
  112036. * The current x and y values of this controller's trackpad
  112037. */
  112038. trackpad: StickValues;
  112039. /**
  112040. * Creates a new WindowsMotionController from a gamepad
  112041. * @param vrGamepad the gamepad that the controller should be created from
  112042. */
  112043. constructor(vrGamepad: any);
  112044. /**
  112045. * Fired when the trigger on this controller is modified
  112046. */
  112047. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112048. /**
  112049. * Fired when the menu button on this controller is modified
  112050. */
  112051. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112052. /**
  112053. * Fired when the grip button on this controller is modified
  112054. */
  112055. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112056. /**
  112057. * Fired when the thumbstick button on this controller is modified
  112058. */
  112059. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112060. /**
  112061. * Fired when the touchpad button on this controller is modified
  112062. */
  112063. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112064. /**
  112065. * Fired when the touchpad values on this controller are modified
  112066. */
  112067. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  112068. protected _updateTrackpad(): void;
  112069. /**
  112070. * Called once per frame by the engine.
  112071. */
  112072. update(): void;
  112073. /**
  112074. * Called once for each button that changed state since the last frame
  112075. * @param buttonIdx Which button index changed
  112076. * @param state New state of the button
  112077. * @param changes Which properties on the state changed since last frame
  112078. */
  112079. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112080. /**
  112081. * Moves the buttons on the controller mesh based on their current state
  112082. * @param buttonName the name of the button to move
  112083. * @param buttonValue the value of the button which determines the buttons new position
  112084. */
  112085. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  112086. /**
  112087. * Moves the axis on the controller mesh based on its current state
  112088. * @param axis the index of the axis
  112089. * @param axisValue the value of the axis which determines the meshes new position
  112090. * @hidden
  112091. */
  112092. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  112093. /**
  112094. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112095. * @param scene scene in which to add meshes
  112096. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112097. */
  112098. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  112099. /**
  112100. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  112101. * can be transformed by button presses and axes values, based on this._mapping.
  112102. *
  112103. * @param scene scene in which the meshes exist
  112104. * @param meshes list of meshes that make up the controller model to process
  112105. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  112106. */
  112107. private processModel;
  112108. private createMeshInfo;
  112109. /**
  112110. * Gets the ray of the controller in the direction the controller is pointing
  112111. * @param length the length the resulting ray should be
  112112. * @returns a ray in the direction the controller is pointing
  112113. */
  112114. getForwardRay(length?: number): Ray;
  112115. /**
  112116. * Disposes of the controller
  112117. */
  112118. dispose(): void;
  112119. }
  112120. /**
  112121. * This class represents a new windows motion controller in XR.
  112122. */
  112123. export class XRWindowsMotionController extends WindowsMotionController {
  112124. /**
  112125. * Changing the original WIndowsMotionController mapping to fir the new mapping
  112126. */
  112127. protected readonly _mapping: {
  112128. buttons: string[];
  112129. buttonMeshNames: {
  112130. 'trigger': string;
  112131. 'menu': string;
  112132. 'grip': string;
  112133. 'thumbstick': string;
  112134. 'trackpad': string;
  112135. };
  112136. buttonObservableNames: {
  112137. 'trigger': string;
  112138. 'menu': string;
  112139. 'grip': string;
  112140. 'thumbstick': string;
  112141. 'trackpad': string;
  112142. };
  112143. axisMeshNames: string[];
  112144. pointingPoseMeshName: string;
  112145. };
  112146. /**
  112147. * Construct a new XR-Based windows motion controller
  112148. *
  112149. * @param gamepadInfo the gamepad object from the browser
  112150. */
  112151. constructor(gamepadInfo: any);
  112152. /**
  112153. * holds the thumbstick values (X,Y)
  112154. */
  112155. thumbstickValues: StickValues;
  112156. /**
  112157. * Fired when the thumbstick on this controller is clicked
  112158. */
  112159. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  112160. /**
  112161. * Fired when the thumbstick on this controller is modified
  112162. */
  112163. onThumbstickValuesChangedObservable: Observable<StickValues>;
  112164. /**
  112165. * Fired when the touchpad button on this controller is modified
  112166. */
  112167. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  112168. /**
  112169. * Fired when the touchpad values on this controller are modified
  112170. */
  112171. onTrackpadValuesChangedObservable: Observable<StickValues>;
  112172. /**
  112173. * Fired when the thumbstick button on this controller is modified
  112174. * here to prevent breaking changes
  112175. */
  112176. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112177. /**
  112178. * updating the thumbstick(!) and not the trackpad.
  112179. * This is named this way due to the difference between WebVR and XR and to avoid
  112180. * changing the parent class.
  112181. */
  112182. protected _updateTrackpad(): void;
  112183. /**
  112184. * Disposes the class with joy
  112185. */
  112186. dispose(): void;
  112187. }
  112188. }
  112189. declare module BABYLON {
  112190. /**
  112191. * Oculus Touch Controller
  112192. */
  112193. export class OculusTouchController extends WebVRController {
  112194. /**
  112195. * Base Url for the controller model.
  112196. */
  112197. static MODEL_BASE_URL: string;
  112198. /**
  112199. * File name for the left controller model.
  112200. */
  112201. static MODEL_LEFT_FILENAME: string;
  112202. /**
  112203. * File name for the right controller model.
  112204. */
  112205. static MODEL_RIGHT_FILENAME: string;
  112206. /**
  112207. * Base Url for the Quest controller model.
  112208. */
  112209. static QUEST_MODEL_BASE_URL: string;
  112210. /**
  112211. * @hidden
  112212. * If the controllers are running on a device that needs the updated Quest controller models
  112213. */
  112214. static _IsQuest: boolean;
  112215. /**
  112216. * Fired when the secondary trigger on this controller is modified
  112217. */
  112218. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  112219. /**
  112220. * Fired when the thumb rest on this controller is modified
  112221. */
  112222. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  112223. /**
  112224. * Creates a new OculusTouchController from a gamepad
  112225. * @param vrGamepad the gamepad that the controller should be created from
  112226. */
  112227. constructor(vrGamepad: any);
  112228. /**
  112229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112230. * @param scene scene in which to add meshes
  112231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112232. */
  112233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112234. /**
  112235. * Fired when the A button on this controller is modified
  112236. */
  112237. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112238. /**
  112239. * Fired when the B button on this controller is modified
  112240. */
  112241. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112242. /**
  112243. * Fired when the X button on this controller is modified
  112244. */
  112245. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112246. /**
  112247. * Fired when the Y button on this controller is modified
  112248. */
  112249. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112250. /**
  112251. * Called once for each button that changed state since the last frame
  112252. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  112253. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  112254. * 2) secondary trigger (same)
  112255. * 3) A (right) X (left), touch, pressed = value
  112256. * 4) B / Y
  112257. * 5) thumb rest
  112258. * @param buttonIdx Which button index changed
  112259. * @param state New state of the button
  112260. * @param changes Which properties on the state changed since last frame
  112261. */
  112262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112263. }
  112264. }
  112265. declare module BABYLON {
  112266. /**
  112267. * Vive Controller
  112268. */
  112269. export class ViveController extends WebVRController {
  112270. /**
  112271. * Base Url for the controller model.
  112272. */
  112273. static MODEL_BASE_URL: string;
  112274. /**
  112275. * File name for the controller model.
  112276. */
  112277. static MODEL_FILENAME: string;
  112278. /**
  112279. * Creates a new ViveController from a gamepad
  112280. * @param vrGamepad the gamepad that the controller should be created from
  112281. */
  112282. constructor(vrGamepad: any);
  112283. /**
  112284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  112285. * @param scene scene in which to add meshes
  112286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  112287. */
  112288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  112289. /**
  112290. * Fired when the left button on this controller is modified
  112291. */
  112292. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112293. /**
  112294. * Fired when the right button on this controller is modified
  112295. */
  112296. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112297. /**
  112298. * Fired when the menu button on this controller is modified
  112299. */
  112300. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  112301. /**
  112302. * Called once for each button that changed state since the last frame
  112303. * Vive mapping:
  112304. * 0: touchpad
  112305. * 1: trigger
  112306. * 2: left AND right buttons
  112307. * 3: menu button
  112308. * @param buttonIdx Which button index changed
  112309. * @param state New state of the button
  112310. * @param changes Which properties on the state changed since last frame
  112311. */
  112312. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  112313. }
  112314. }
  112315. declare module BABYLON {
  112316. /**
  112317. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  112318. */
  112319. export class WebXRControllerModelLoader {
  112320. /**
  112321. * an observable that triggers when a new model (the mesh itself) was initialized.
  112322. * To know when the mesh was loaded use the controller's own modelLoaded() method
  112323. */
  112324. onControllerModelLoaded: Observable<WebXRController>;
  112325. /**
  112326. * Creates the WebXRControllerModelLoader
  112327. * @param input xr input that creates the controllers
  112328. */
  112329. constructor(input: WebXRInput);
  112330. }
  112331. }
  112332. declare module BABYLON {
  112333. /**
  112334. * Handles pointer input automatically for the pointer of XR controllers
  112335. */
  112336. export class WebXRControllerPointerSelection {
  112337. private static _idCounter;
  112338. private _tmpRay;
  112339. /**
  112340. * Creates a WebXRControllerPointerSelection
  112341. * @param input input manager to setup pointer selection
  112342. */
  112343. constructor(input: WebXRInput);
  112344. private _convertNormalToDirectionOfRay;
  112345. private _updatePointerDistance;
  112346. }
  112347. }
  112348. declare module BABYLON {
  112349. /**
  112350. * Enables teleportation
  112351. */
  112352. export class WebXRControllerTeleportation {
  112353. private _teleportationFillColor;
  112354. private _teleportationBorderColor;
  112355. private _tmpRay;
  112356. private _tmpVector;
  112357. /**
  112358. * when set to true (default) teleportation will wait for thumbstick changes.
  112359. * When set to false teleportation will be disabled.
  112360. *
  112361. * If set to false while teleporting results can be unexpected.
  112362. */
  112363. enabled: boolean;
  112364. /**
  112365. * Creates a WebXRControllerTeleportation
  112366. * @param input input manager to add teleportation to
  112367. * @param floorMeshes floormeshes which can be teleported to
  112368. */
  112369. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  112370. }
  112371. }
  112372. declare module BABYLON {
  112373. /**
  112374. * Button which can be used to enter a different mode of XR
  112375. */
  112376. export class WebXREnterExitUIButton {
  112377. /** button element */
  112378. element: HTMLElement;
  112379. /** XR initialization options for the button */
  112380. sessionMode: XRSessionMode;
  112381. /** Reference space type */
  112382. referenceSpaceType: XRReferenceSpaceType;
  112383. /**
  112384. * Creates a WebXREnterExitUIButton
  112385. * @param element button element
  112386. * @param sessionMode XR initialization session mode
  112387. * @param referenceSpaceType the type of reference space to be used
  112388. */
  112389. constructor(
  112390. /** button element */
  112391. element: HTMLElement,
  112392. /** XR initialization options for the button */
  112393. sessionMode: XRSessionMode,
  112394. /** Reference space type */
  112395. referenceSpaceType: XRReferenceSpaceType);
  112396. /**
  112397. * Overwritable function which can be used to update the button's visuals when the state changes
  112398. * @param activeButton the current active button in the UI
  112399. */
  112400. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  112401. }
  112402. /**
  112403. * Options to create the webXR UI
  112404. */
  112405. export class WebXREnterExitUIOptions {
  112406. /**
  112407. * Context to enter xr with
  112408. */
  112409. renderTarget?: Nullable<WebXRRenderTarget>;
  112410. /**
  112411. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  112412. */
  112413. customButtons?: Array<WebXREnterExitUIButton>;
  112414. /**
  112415. * A session mode to use when creating the default button.
  112416. * Default is immersive-vr
  112417. */
  112418. sessionMode?: XRSessionMode;
  112419. /**
  112420. * A reference space type to use when creating the default button.
  112421. * Default is local-floor
  112422. */
  112423. referenceSpaceType?: XRReferenceSpaceType;
  112424. }
  112425. /**
  112426. * UI to allow the user to enter/exit XR mode
  112427. */
  112428. export class WebXREnterExitUI implements IDisposable {
  112429. private scene;
  112430. /** version of the options passed to this UI */
  112431. options: WebXREnterExitUIOptions;
  112432. private _overlay;
  112433. private _buttons;
  112434. private _activeButton;
  112435. /**
  112436. * Fired every time the active button is changed.
  112437. *
  112438. * When xr is entered via a button that launches xr that button will be the callback parameter
  112439. *
  112440. * When exiting xr the callback parameter will be null)
  112441. */
  112442. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  112443. /**
  112444. * Creates UI to allow the user to enter/exit XR mode
  112445. * @param scene the scene to add the ui to
  112446. * @param helper the xr experience helper to enter/exit xr with
  112447. * @param options options to configure the UI
  112448. * @returns the created ui
  112449. */
  112450. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  112451. /**
  112452. *
  112453. * @param scene babylon scene object to use
  112454. * @param options (read-only) version of the options passed to this UI
  112455. */
  112456. private constructor();
  112457. private _updateButtons;
  112458. /**
  112459. * Disposes of the object
  112460. */
  112461. dispose(): void;
  112462. }
  112463. }
  112464. declare module BABYLON {
  112465. /**
  112466. * Options for the default xr helper
  112467. */
  112468. export class WebXRDefaultExperienceOptions {
  112469. /**
  112470. * Floor meshes that should be used for teleporting
  112471. */
  112472. floorMeshes: Array<AbstractMesh>;
  112473. /**
  112474. * Enable or disable default UI to enter XR
  112475. */
  112476. disableDefaultUI?: boolean;
  112477. /**
  112478. * optional configuration for the output canvas
  112479. */
  112480. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  112481. /**
  112482. * optional UI options. This can be used among other to change session mode and reference space type
  112483. */
  112484. uiOptions?: WebXREnterExitUIOptions;
  112485. }
  112486. /**
  112487. * Default experience which provides a similar setup to the previous webVRExperience
  112488. */
  112489. export class WebXRDefaultExperience {
  112490. /**
  112491. * Base experience
  112492. */
  112493. baseExperience: WebXRExperienceHelper;
  112494. /**
  112495. * Input experience extension
  112496. */
  112497. input: WebXRInput;
  112498. /**
  112499. * Loads the controller models
  112500. */
  112501. controllerModelLoader: WebXRControllerModelLoader;
  112502. /**
  112503. * Enables laser pointer and selection
  112504. */
  112505. pointerSelection: WebXRControllerPointerSelection;
  112506. /**
  112507. * Enables teleportation
  112508. */
  112509. teleportation: WebXRControllerTeleportation;
  112510. /**
  112511. * Enables ui for entering/exiting xr
  112512. */
  112513. enterExitUI: WebXREnterExitUI;
  112514. /**
  112515. * Default target xr should render to
  112516. */
  112517. renderTarget: WebXRRenderTarget;
  112518. /**
  112519. * Creates the default xr experience
  112520. * @param scene scene
  112521. * @param options options for basic configuration
  112522. * @returns resulting WebXRDefaultExperience
  112523. */
  112524. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112525. private constructor();
  112526. /**
  112527. * DIsposes of the experience helper
  112528. */
  112529. dispose(): void;
  112530. }
  112531. }
  112532. declare module BABYLON {
  112533. /**
  112534. * Options to modify the vr teleportation behavior.
  112535. */
  112536. export interface VRTeleportationOptions {
  112537. /**
  112538. * The name of the mesh which should be used as the teleportation floor. (default: null)
  112539. */
  112540. floorMeshName?: string;
  112541. /**
  112542. * A list of meshes to be used as the teleportation floor. (default: empty)
  112543. */
  112544. floorMeshes?: Mesh[];
  112545. /**
  112546. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  112547. */
  112548. teleportationMode?: number;
  112549. /**
  112550. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  112551. */
  112552. teleportationTime?: number;
  112553. /**
  112554. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  112555. */
  112556. teleportationSpeed?: number;
  112557. /**
  112558. * The easing function used in the animation or null for Linear. (default CircleEase)
  112559. */
  112560. easingFunction?: EasingFunction;
  112561. }
  112562. /**
  112563. * Options to modify the vr experience helper's behavior.
  112564. */
  112565. export interface VRExperienceHelperOptions extends WebVROptions {
  112566. /**
  112567. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  112568. */
  112569. createDeviceOrientationCamera?: boolean;
  112570. /**
  112571. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  112572. */
  112573. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  112574. /**
  112575. * Uses the main button on the controller to toggle the laser casted. (default: true)
  112576. */
  112577. laserToggle?: boolean;
  112578. /**
  112579. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  112580. */
  112581. floorMeshes?: Mesh[];
  112582. /**
  112583. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  112584. */
  112585. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  112586. /**
  112587. * Defines if WebXR should be used instead of WebVR (if available)
  112588. */
  112589. useXR?: boolean;
  112590. }
  112591. /**
  112592. * Event containing information after VR has been entered
  112593. */
  112594. export class OnAfterEnteringVRObservableEvent {
  112595. /**
  112596. * If entering vr was successful
  112597. */
  112598. success: boolean;
  112599. }
  112600. /**
  112601. * Helps to quickly add VR support to an existing scene.
  112602. * See http://doc.babylonjs.com/how_to/webvr_helper
  112603. */
  112604. export class VRExperienceHelper {
  112605. /** Options to modify the vr experience helper's behavior. */
  112606. webVROptions: VRExperienceHelperOptions;
  112607. private _scene;
  112608. private _position;
  112609. private _btnVR;
  112610. private _btnVRDisplayed;
  112611. private _webVRsupported;
  112612. private _webVRready;
  112613. private _webVRrequesting;
  112614. private _webVRpresenting;
  112615. private _hasEnteredVR;
  112616. private _fullscreenVRpresenting;
  112617. private _inputElement;
  112618. private _webVRCamera;
  112619. private _vrDeviceOrientationCamera;
  112620. private _deviceOrientationCamera;
  112621. private _existingCamera;
  112622. private _onKeyDown;
  112623. private _onVrDisplayPresentChange;
  112624. private _onVRDisplayChanged;
  112625. private _onVRRequestPresentStart;
  112626. private _onVRRequestPresentComplete;
  112627. /**
  112628. * 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)
  112629. */
  112630. enableGazeEvenWhenNoPointerLock: boolean;
  112631. /**
  112632. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  112633. */
  112634. exitVROnDoubleTap: boolean;
  112635. /**
  112636. * Observable raised right before entering VR.
  112637. */
  112638. onEnteringVRObservable: Observable<VRExperienceHelper>;
  112639. /**
  112640. * Observable raised when entering VR has completed.
  112641. */
  112642. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  112643. /**
  112644. * Observable raised when exiting VR.
  112645. */
  112646. onExitingVRObservable: Observable<VRExperienceHelper>;
  112647. /**
  112648. * Observable raised when controller mesh is loaded.
  112649. */
  112650. onControllerMeshLoadedObservable: Observable<WebVRController>;
  112651. /** Return this.onEnteringVRObservable
  112652. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  112653. */
  112654. readonly onEnteringVR: Observable<VRExperienceHelper>;
  112655. /** Return this.onExitingVRObservable
  112656. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  112657. */
  112658. readonly onExitingVR: Observable<VRExperienceHelper>;
  112659. /** Return this.onControllerMeshLoadedObservable
  112660. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  112661. */
  112662. readonly onControllerMeshLoaded: Observable<WebVRController>;
  112663. private _rayLength;
  112664. private _useCustomVRButton;
  112665. private _teleportationRequested;
  112666. private _teleportActive;
  112667. private _floorMeshName;
  112668. private _floorMeshesCollection;
  112669. private _teleportationMode;
  112670. private _teleportationTime;
  112671. private _teleportationSpeed;
  112672. private _teleportationEasing;
  112673. private _rotationAllowed;
  112674. private _teleportBackwardsVector;
  112675. private _teleportationTarget;
  112676. private _isDefaultTeleportationTarget;
  112677. private _postProcessMove;
  112678. private _teleportationFillColor;
  112679. private _teleportationBorderColor;
  112680. private _rotationAngle;
  112681. private _haloCenter;
  112682. private _cameraGazer;
  112683. private _padSensibilityUp;
  112684. private _padSensibilityDown;
  112685. private _leftController;
  112686. private _rightController;
  112687. /**
  112688. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  112689. */
  112690. onNewMeshSelected: Observable<AbstractMesh>;
  112691. /**
  112692. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  112693. * This observable will provide the mesh and the controller used to select the mesh
  112694. */
  112695. onMeshSelectedWithController: Observable<{
  112696. mesh: AbstractMesh;
  112697. controller: WebVRController;
  112698. }>;
  112699. /**
  112700. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  112701. */
  112702. onNewMeshPicked: Observable<PickingInfo>;
  112703. private _circleEase;
  112704. /**
  112705. * Observable raised before camera teleportation
  112706. */
  112707. onBeforeCameraTeleport: Observable<Vector3>;
  112708. /**
  112709. * Observable raised after camera teleportation
  112710. */
  112711. onAfterCameraTeleport: Observable<Vector3>;
  112712. /**
  112713. * Observable raised when current selected mesh gets unselected
  112714. */
  112715. onSelectedMeshUnselected: Observable<AbstractMesh>;
  112716. private _raySelectionPredicate;
  112717. /**
  112718. * To be optionaly changed by user to define custom ray selection
  112719. */
  112720. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  112721. /**
  112722. * To be optionaly changed by user to define custom selection logic (after ray selection)
  112723. */
  112724. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112725. /**
  112726. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  112727. */
  112728. teleportationEnabled: boolean;
  112729. private _defaultHeight;
  112730. private _teleportationInitialized;
  112731. private _interactionsEnabled;
  112732. private _interactionsRequested;
  112733. private _displayGaze;
  112734. private _displayLaserPointer;
  112735. /**
  112736. * The mesh used to display where the user is going to teleport.
  112737. */
  112738. /**
  112739. * Sets the mesh to be used to display where the user is going to teleport.
  112740. */
  112741. teleportationTarget: Mesh;
  112742. /**
  112743. * 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
  112744. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  112745. * See http://doc.babylonjs.com/resources/baking_transformations
  112746. */
  112747. gazeTrackerMesh: Mesh;
  112748. /**
  112749. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  112750. */
  112751. updateGazeTrackerScale: boolean;
  112752. /**
  112753. * If the gaze trackers color should be updated when selecting meshes
  112754. */
  112755. updateGazeTrackerColor: boolean;
  112756. /**
  112757. * If the controller laser color should be updated when selecting meshes
  112758. */
  112759. updateControllerLaserColor: boolean;
  112760. /**
  112761. * The gaze tracking mesh corresponding to the left controller
  112762. */
  112763. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  112764. /**
  112765. * The gaze tracking mesh corresponding to the right controller
  112766. */
  112767. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  112768. /**
  112769. * If the ray of the gaze should be displayed.
  112770. */
  112771. /**
  112772. * Sets if the ray of the gaze should be displayed.
  112773. */
  112774. displayGaze: boolean;
  112775. /**
  112776. * If the ray of the LaserPointer should be displayed.
  112777. */
  112778. /**
  112779. * Sets if the ray of the LaserPointer should be displayed.
  112780. */
  112781. displayLaserPointer: boolean;
  112782. /**
  112783. * The deviceOrientationCamera used as the camera when not in VR.
  112784. */
  112785. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  112786. /**
  112787. * Based on the current WebVR support, returns the current VR camera used.
  112788. */
  112789. readonly currentVRCamera: Nullable<Camera>;
  112790. /**
  112791. * The webVRCamera which is used when in VR.
  112792. */
  112793. readonly webVRCamera: WebVRFreeCamera;
  112794. /**
  112795. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  112796. */
  112797. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  112798. /**
  112799. * The html button that is used to trigger entering into VR.
  112800. */
  112801. readonly vrButton: Nullable<HTMLButtonElement>;
  112802. private readonly _teleportationRequestInitiated;
  112803. /**
  112804. * Defines wether or not Pointer lock should be requested when switching to
  112805. * full screen.
  112806. */
  112807. requestPointerLockOnFullScreen: boolean;
  112808. /**
  112809. * If asking to force XR, this will be populated with the default xr experience
  112810. */
  112811. xr: WebXRDefaultExperience;
  112812. /**
  112813. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  112814. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  112815. */
  112816. xrTestDone: boolean;
  112817. /**
  112818. * Instantiates a VRExperienceHelper.
  112819. * Helps to quickly add VR support to an existing scene.
  112820. * @param scene The scene the VRExperienceHelper belongs to.
  112821. * @param webVROptions Options to modify the vr experience helper's behavior.
  112822. */
  112823. constructor(scene: Scene,
  112824. /** Options to modify the vr experience helper's behavior. */
  112825. webVROptions?: VRExperienceHelperOptions);
  112826. private completeVRInit;
  112827. private _onDefaultMeshLoaded;
  112828. private _onResize;
  112829. private _onFullscreenChange;
  112830. /**
  112831. * Gets a value indicating if we are currently in VR mode.
  112832. */
  112833. readonly isInVRMode: boolean;
  112834. private onVrDisplayPresentChange;
  112835. private onVRDisplayChanged;
  112836. private moveButtonToBottomRight;
  112837. private displayVRButton;
  112838. private updateButtonVisibility;
  112839. private _cachedAngularSensibility;
  112840. /**
  112841. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  112842. * Otherwise, will use the fullscreen API.
  112843. */
  112844. enterVR(): void;
  112845. /**
  112846. * Attempt to exit VR, or fullscreen.
  112847. */
  112848. exitVR(): void;
  112849. /**
  112850. * The position of the vr experience helper.
  112851. */
  112852. /**
  112853. * Sets the position of the vr experience helper.
  112854. */
  112855. position: Vector3;
  112856. /**
  112857. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  112858. */
  112859. enableInteractions(): void;
  112860. private readonly _noControllerIsActive;
  112861. private beforeRender;
  112862. private _isTeleportationFloor;
  112863. /**
  112864. * Adds a floor mesh to be used for teleportation.
  112865. * @param floorMesh the mesh to be used for teleportation.
  112866. */
  112867. addFloorMesh(floorMesh: Mesh): void;
  112868. /**
  112869. * Removes a floor mesh from being used for teleportation.
  112870. * @param floorMesh the mesh to be removed.
  112871. */
  112872. removeFloorMesh(floorMesh: Mesh): void;
  112873. /**
  112874. * Enables interactions and teleportation using the VR controllers and gaze.
  112875. * @param vrTeleportationOptions options to modify teleportation behavior.
  112876. */
  112877. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  112878. private _onNewGamepadConnected;
  112879. private _tryEnableInteractionOnController;
  112880. private _onNewGamepadDisconnected;
  112881. private _enableInteractionOnController;
  112882. private _checkTeleportWithRay;
  112883. private _checkRotate;
  112884. private _checkTeleportBackwards;
  112885. private _enableTeleportationOnController;
  112886. private _createTeleportationCircles;
  112887. private _displayTeleportationTarget;
  112888. private _hideTeleportationTarget;
  112889. private _rotateCamera;
  112890. private _moveTeleportationSelectorTo;
  112891. private _workingVector;
  112892. private _workingQuaternion;
  112893. private _workingMatrix;
  112894. /**
  112895. * Time Constant Teleportation Mode
  112896. */
  112897. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  112898. /**
  112899. * Speed Constant Teleportation Mode
  112900. */
  112901. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  112902. /**
  112903. * Teleports the users feet to the desired location
  112904. * @param location The location where the user's feet should be placed
  112905. */
  112906. teleportCamera(location: Vector3): void;
  112907. private _convertNormalToDirectionOfRay;
  112908. private _castRayAndSelectObject;
  112909. private _notifySelectedMeshUnselected;
  112910. /**
  112911. * Sets the color of the laser ray from the vr controllers.
  112912. * @param color new color for the ray.
  112913. */
  112914. changeLaserColor(color: Color3): void;
  112915. /**
  112916. * Sets the color of the ray from the vr headsets gaze.
  112917. * @param color new color for the ray.
  112918. */
  112919. changeGazeColor(color: Color3): void;
  112920. /**
  112921. * Exits VR and disposes of the vr experience helper
  112922. */
  112923. dispose(): void;
  112924. /**
  112925. * Gets the name of the VRExperienceHelper class
  112926. * @returns "VRExperienceHelper"
  112927. */
  112928. getClassName(): string;
  112929. }
  112930. }
  112931. declare module BABYLON {
  112932. /**
  112933. * Contains an array of blocks representing the octree
  112934. */
  112935. export interface IOctreeContainer<T> {
  112936. /**
  112937. * Blocks within the octree
  112938. */
  112939. blocks: Array<OctreeBlock<T>>;
  112940. }
  112941. /**
  112942. * Class used to store a cell in an octree
  112943. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  112944. */
  112945. export class OctreeBlock<T> {
  112946. /**
  112947. * Gets the content of the current block
  112948. */
  112949. entries: T[];
  112950. /**
  112951. * Gets the list of block children
  112952. */
  112953. blocks: Array<OctreeBlock<T>>;
  112954. private _depth;
  112955. private _maxDepth;
  112956. private _capacity;
  112957. private _minPoint;
  112958. private _maxPoint;
  112959. private _boundingVectors;
  112960. private _creationFunc;
  112961. /**
  112962. * Creates a new block
  112963. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  112964. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  112965. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112966. * @param depth defines the current depth of this block in the octree
  112967. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  112968. * @param creationFunc defines a callback to call when an element is added to the block
  112969. */
  112970. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  112971. /**
  112972. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  112973. */
  112974. readonly capacity: number;
  112975. /**
  112976. * Gets the minimum vector (in world space) of the block's bounding box
  112977. */
  112978. readonly minPoint: Vector3;
  112979. /**
  112980. * Gets the maximum vector (in world space) of the block's bounding box
  112981. */
  112982. readonly maxPoint: Vector3;
  112983. /**
  112984. * Add a new element to this block
  112985. * @param entry defines the element to add
  112986. */
  112987. addEntry(entry: T): void;
  112988. /**
  112989. * Remove an element from this block
  112990. * @param entry defines the element to remove
  112991. */
  112992. removeEntry(entry: T): void;
  112993. /**
  112994. * Add an array of elements to this block
  112995. * @param entries defines the array of elements to add
  112996. */
  112997. addEntries(entries: T[]): void;
  112998. /**
  112999. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  113000. * @param frustumPlanes defines the frustum planes to test
  113001. * @param selection defines the array to store current content if selection is positive
  113002. * @param allowDuplicate defines if the selection array can contains duplicated entries
  113003. */
  113004. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  113005. /**
  113006. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  113007. * @param sphereCenter defines the bounding sphere center
  113008. * @param sphereRadius defines the bounding sphere radius
  113009. * @param selection defines the array to store current content if selection is positive
  113010. * @param allowDuplicate defines if the selection array can contains duplicated entries
  113011. */
  113012. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  113013. /**
  113014. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  113015. * @param ray defines the ray to test with
  113016. * @param selection defines the array to store current content if selection is positive
  113017. */
  113018. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  113019. /**
  113020. * Subdivide the content into child blocks (this block will then be empty)
  113021. */
  113022. createInnerBlocks(): void;
  113023. /**
  113024. * @hidden
  113025. */
  113026. 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;
  113027. }
  113028. }
  113029. declare module BABYLON {
  113030. /**
  113031. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  113032. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113033. */
  113034. export class Octree<T> {
  113035. /** 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.) */
  113036. maxDepth: number;
  113037. /**
  113038. * Blocks within the octree containing objects
  113039. */
  113040. blocks: Array<OctreeBlock<T>>;
  113041. /**
  113042. * Content stored in the octree
  113043. */
  113044. dynamicContent: T[];
  113045. private _maxBlockCapacity;
  113046. private _selectionContent;
  113047. private _creationFunc;
  113048. /**
  113049. * Creates a octree
  113050. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113051. * @param creationFunc function to be used to instatiate the octree
  113052. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  113053. * @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.)
  113054. */
  113055. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  113056. /** 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.) */
  113057. maxDepth?: number);
  113058. /**
  113059. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  113060. * @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);
  113061. * @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);
  113062. * @param entries meshes to be added to the octree blocks
  113063. */
  113064. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  113065. /**
  113066. * Adds a mesh to the octree
  113067. * @param entry Mesh to add to the octree
  113068. */
  113069. addMesh(entry: T): void;
  113070. /**
  113071. * Remove an element from the octree
  113072. * @param entry defines the element to remove
  113073. */
  113074. removeMesh(entry: T): void;
  113075. /**
  113076. * Selects an array of meshes within the frustum
  113077. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  113078. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  113079. * @returns array of meshes within the frustum
  113080. */
  113081. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  113082. /**
  113083. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  113084. * @param sphereCenter defines the bounding sphere center
  113085. * @param sphereRadius defines the bounding sphere radius
  113086. * @param allowDuplicate defines if the selection array can contains duplicated entries
  113087. * @returns an array of objects that intersect the sphere
  113088. */
  113089. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  113090. /**
  113091. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  113092. * @param ray defines the ray to test with
  113093. * @returns array of intersected objects
  113094. */
  113095. intersectsRay(ray: Ray): SmartArray<T>;
  113096. /**
  113097. * Adds a mesh into the octree block if it intersects the block
  113098. */
  113099. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  113100. /**
  113101. * Adds a submesh into the octree block if it intersects the block
  113102. */
  113103. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  113104. }
  113105. }
  113106. declare module BABYLON {
  113107. interface Scene {
  113108. /**
  113109. * @hidden
  113110. * Backing Filed
  113111. */
  113112. _selectionOctree: Octree<AbstractMesh>;
  113113. /**
  113114. * Gets the octree used to boost mesh selection (picking)
  113115. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113116. */
  113117. selectionOctree: Octree<AbstractMesh>;
  113118. /**
  113119. * Creates or updates the octree used to boost selection (picking)
  113120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113121. * @param maxCapacity defines the maximum capacity per leaf
  113122. * @param maxDepth defines the maximum depth of the octree
  113123. * @returns an octree of AbstractMesh
  113124. */
  113125. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  113126. }
  113127. interface AbstractMesh {
  113128. /**
  113129. * @hidden
  113130. * Backing Field
  113131. */
  113132. _submeshesOctree: Octree<SubMesh>;
  113133. /**
  113134. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  113135. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  113136. * @param maxCapacity defines the maximum size of each block (64 by default)
  113137. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  113138. * @returns the new octree
  113139. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  113140. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  113141. */
  113142. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  113143. }
  113144. /**
  113145. * Defines the octree scene component responsible to manage any octrees
  113146. * in a given scene.
  113147. */
  113148. export class OctreeSceneComponent {
  113149. /**
  113150. * The component name help to identify the component in the list of scene components.
  113151. */
  113152. readonly name: string;
  113153. /**
  113154. * The scene the component belongs to.
  113155. */
  113156. scene: Scene;
  113157. /**
  113158. * Indicates if the meshes have been checked to make sure they are isEnabled()
  113159. */
  113160. readonly checksIsEnabled: boolean;
  113161. /**
  113162. * Creates a new instance of the component for the given scene
  113163. * @param scene Defines the scene to register the component in
  113164. */
  113165. constructor(scene: Scene);
  113166. /**
  113167. * Registers the component in a given scene
  113168. */
  113169. register(): void;
  113170. /**
  113171. * Return the list of active meshes
  113172. * @returns the list of active meshes
  113173. */
  113174. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  113175. /**
  113176. * Return the list of active sub meshes
  113177. * @param mesh The mesh to get the candidates sub meshes from
  113178. * @returns the list of active sub meshes
  113179. */
  113180. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  113181. private _tempRay;
  113182. /**
  113183. * Return the list of sub meshes intersecting with a given local ray
  113184. * @param mesh defines the mesh to find the submesh for
  113185. * @param localRay defines the ray in local space
  113186. * @returns the list of intersecting sub meshes
  113187. */
  113188. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  113189. /**
  113190. * Return the list of sub meshes colliding with a collider
  113191. * @param mesh defines the mesh to find the submesh for
  113192. * @param collider defines the collider to evaluate the collision against
  113193. * @returns the list of colliding sub meshes
  113194. */
  113195. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  113196. /**
  113197. * Rebuilds the elements related to this component in case of
  113198. * context lost for instance.
  113199. */
  113200. rebuild(): void;
  113201. /**
  113202. * Disposes the component and the associated ressources.
  113203. */
  113204. dispose(): void;
  113205. }
  113206. }
  113207. declare module BABYLON {
  113208. /**
  113209. * Renders a layer on top of an existing scene
  113210. */
  113211. export class UtilityLayerRenderer implements IDisposable {
  113212. /** the original scene that will be rendered on top of */
  113213. originalScene: Scene;
  113214. private _pointerCaptures;
  113215. private _lastPointerEvents;
  113216. private static _DefaultUtilityLayer;
  113217. private static _DefaultKeepDepthUtilityLayer;
  113218. private _sharedGizmoLight;
  113219. private _renderCamera;
  113220. /**
  113221. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  113222. * @returns the camera that is used when rendering the utility layer
  113223. */
  113224. getRenderCamera(): Nullable<Camera>;
  113225. /**
  113226. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  113227. * @param cam the camera that should be used when rendering the utility layer
  113228. */
  113229. setRenderCamera(cam: Nullable<Camera>): void;
  113230. /**
  113231. * @hidden
  113232. * Light which used by gizmos to get light shading
  113233. */
  113234. _getSharedGizmoLight(): HemisphericLight;
  113235. /**
  113236. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  113237. */
  113238. pickUtilitySceneFirst: boolean;
  113239. /**
  113240. * 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)
  113241. */
  113242. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  113243. /**
  113244. * 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)
  113245. */
  113246. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  113247. /**
  113248. * The scene that is rendered on top of the original scene
  113249. */
  113250. utilityLayerScene: Scene;
  113251. /**
  113252. * If the utility layer should automatically be rendered on top of existing scene
  113253. */
  113254. shouldRender: boolean;
  113255. /**
  113256. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  113257. */
  113258. onlyCheckPointerDownEvents: boolean;
  113259. /**
  113260. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  113261. */
  113262. processAllEvents: boolean;
  113263. /**
  113264. * Observable raised when the pointer move from the utility layer scene to the main scene
  113265. */
  113266. onPointerOutObservable: Observable<number>;
  113267. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  113268. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  113269. private _afterRenderObserver;
  113270. private _sceneDisposeObserver;
  113271. private _originalPointerObserver;
  113272. /**
  113273. * Instantiates a UtilityLayerRenderer
  113274. * @param originalScene the original scene that will be rendered on top of
  113275. * @param handleEvents boolean indicating if the utility layer should handle events
  113276. */
  113277. constructor(
  113278. /** the original scene that will be rendered on top of */
  113279. originalScene: Scene, handleEvents?: boolean);
  113280. private _notifyObservers;
  113281. /**
  113282. * Renders the utility layers scene on top of the original scene
  113283. */
  113284. render(): void;
  113285. /**
  113286. * Disposes of the renderer
  113287. */
  113288. dispose(): void;
  113289. private _updateCamera;
  113290. }
  113291. }
  113292. declare module BABYLON {
  113293. /**
  113294. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  113295. */
  113296. export class Gizmo implements IDisposable {
  113297. /** The utility layer the gizmo will be added to */
  113298. gizmoLayer: UtilityLayerRenderer;
  113299. /**
  113300. * The root mesh of the gizmo
  113301. */
  113302. _rootMesh: Mesh;
  113303. private _attachedMesh;
  113304. /**
  113305. * Ratio for the scale of the gizmo (Default: 1)
  113306. */
  113307. scaleRatio: number;
  113308. /**
  113309. * If a custom mesh has been set (Default: false)
  113310. */
  113311. protected _customMeshSet: boolean;
  113312. /**
  113313. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  113314. * * When set, interactions will be enabled
  113315. */
  113316. attachedMesh: Nullable<AbstractMesh>;
  113317. /**
  113318. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  113319. * @param mesh The mesh to replace the default mesh of the gizmo
  113320. */
  113321. setCustomMesh(mesh: Mesh): void;
  113322. /**
  113323. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  113324. */
  113325. updateGizmoRotationToMatchAttachedMesh: boolean;
  113326. /**
  113327. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  113328. */
  113329. updateGizmoPositionToMatchAttachedMesh: boolean;
  113330. /**
  113331. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  113332. */
  113333. updateScale: boolean;
  113334. protected _interactionsEnabled: boolean;
  113335. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113336. private _beforeRenderObserver;
  113337. private _tempVector;
  113338. /**
  113339. * Creates a gizmo
  113340. * @param gizmoLayer The utility layer the gizmo will be added to
  113341. */
  113342. constructor(
  113343. /** The utility layer the gizmo will be added to */
  113344. gizmoLayer?: UtilityLayerRenderer);
  113345. /**
  113346. * Updates the gizmo to match the attached mesh's position/rotation
  113347. */
  113348. protected _update(): void;
  113349. /**
  113350. * Disposes of the gizmo
  113351. */
  113352. dispose(): void;
  113353. }
  113354. }
  113355. declare module BABYLON {
  113356. /**
  113357. * Single plane drag gizmo
  113358. */
  113359. export class PlaneDragGizmo extends Gizmo {
  113360. /**
  113361. * Drag behavior responsible for the gizmos dragging interactions
  113362. */
  113363. dragBehavior: PointerDragBehavior;
  113364. private _pointerObserver;
  113365. /**
  113366. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113367. */
  113368. snapDistance: number;
  113369. /**
  113370. * Event that fires each time the gizmo snaps to a new location.
  113371. * * snapDistance is the the change in distance
  113372. */
  113373. onSnapObservable: Observable<{
  113374. snapDistance: number;
  113375. }>;
  113376. private _plane;
  113377. private _coloredMaterial;
  113378. private _hoverMaterial;
  113379. private _isEnabled;
  113380. private _parent;
  113381. /** @hidden */
  113382. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  113383. /** @hidden */
  113384. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  113385. /**
  113386. * Creates a PlaneDragGizmo
  113387. * @param gizmoLayer The utility layer the gizmo will be added to
  113388. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  113389. * @param color The color of the gizmo
  113390. */
  113391. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  113392. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113393. /**
  113394. * If the gizmo is enabled
  113395. */
  113396. isEnabled: boolean;
  113397. /**
  113398. * Disposes of the gizmo
  113399. */
  113400. dispose(): void;
  113401. }
  113402. }
  113403. declare module BABYLON {
  113404. /**
  113405. * Gizmo that enables dragging a mesh along 3 axis
  113406. */
  113407. export class PositionGizmo extends Gizmo {
  113408. /**
  113409. * Internal gizmo used for interactions on the x axis
  113410. */
  113411. xGizmo: AxisDragGizmo;
  113412. /**
  113413. * Internal gizmo used for interactions on the y axis
  113414. */
  113415. yGizmo: AxisDragGizmo;
  113416. /**
  113417. * Internal gizmo used for interactions on the z axis
  113418. */
  113419. zGizmo: AxisDragGizmo;
  113420. /**
  113421. * Internal gizmo used for interactions on the yz plane
  113422. */
  113423. xPlaneGizmo: PlaneDragGizmo;
  113424. /**
  113425. * Internal gizmo used for interactions on the xz plane
  113426. */
  113427. yPlaneGizmo: PlaneDragGizmo;
  113428. /**
  113429. * Internal gizmo used for interactions on the xy plane
  113430. */
  113431. zPlaneGizmo: PlaneDragGizmo;
  113432. /**
  113433. * private variables
  113434. */
  113435. private _meshAttached;
  113436. private _updateGizmoRotationToMatchAttachedMesh;
  113437. private _snapDistance;
  113438. private _scaleRatio;
  113439. /** Fires an event when any of it's sub gizmos are dragged */
  113440. onDragStartObservable: Observable<unknown>;
  113441. /** Fires an event when any of it's sub gizmos are released from dragging */
  113442. onDragEndObservable: Observable<unknown>;
  113443. /**
  113444. * If set to true, planar drag is enabled
  113445. */
  113446. private _planarGizmoEnabled;
  113447. attachedMesh: Nullable<AbstractMesh>;
  113448. /**
  113449. * Creates a PositionGizmo
  113450. * @param gizmoLayer The utility layer the gizmo will be added to
  113451. */
  113452. constructor(gizmoLayer?: UtilityLayerRenderer);
  113453. /**
  113454. * If the planar drag gizmo is enabled
  113455. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  113456. */
  113457. planarGizmoEnabled: boolean;
  113458. updateGizmoRotationToMatchAttachedMesh: boolean;
  113459. /**
  113460. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113461. */
  113462. snapDistance: number;
  113463. /**
  113464. * Ratio for the scale of the gizmo (Default: 1)
  113465. */
  113466. scaleRatio: number;
  113467. /**
  113468. * Disposes of the gizmo
  113469. */
  113470. dispose(): void;
  113471. /**
  113472. * CustomMeshes are not supported by this gizmo
  113473. * @param mesh The mesh to replace the default mesh of the gizmo
  113474. */
  113475. setCustomMesh(mesh: Mesh): void;
  113476. }
  113477. }
  113478. declare module BABYLON {
  113479. /**
  113480. * Single axis drag gizmo
  113481. */
  113482. export class AxisDragGizmo extends Gizmo {
  113483. /**
  113484. * Drag behavior responsible for the gizmos dragging interactions
  113485. */
  113486. dragBehavior: PointerDragBehavior;
  113487. private _pointerObserver;
  113488. /**
  113489. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  113490. */
  113491. snapDistance: number;
  113492. /**
  113493. * Event that fires each time the gizmo snaps to a new location.
  113494. * * snapDistance is the the change in distance
  113495. */
  113496. onSnapObservable: Observable<{
  113497. snapDistance: number;
  113498. }>;
  113499. private _isEnabled;
  113500. private _parent;
  113501. private _arrow;
  113502. private _coloredMaterial;
  113503. private _hoverMaterial;
  113504. /** @hidden */
  113505. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  113506. /** @hidden */
  113507. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  113508. /**
  113509. * Creates an AxisDragGizmo
  113510. * @param gizmoLayer The utility layer the gizmo will be added to
  113511. * @param dragAxis The axis which the gizmo will be able to drag on
  113512. * @param color The color of the gizmo
  113513. */
  113514. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  113515. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  113516. /**
  113517. * If the gizmo is enabled
  113518. */
  113519. isEnabled: boolean;
  113520. /**
  113521. * Disposes of the gizmo
  113522. */
  113523. dispose(): void;
  113524. }
  113525. }
  113526. declare module BABYLON.Debug {
  113527. /**
  113528. * The Axes viewer will show 3 axes in a specific point in space
  113529. */
  113530. export class AxesViewer {
  113531. private _xAxis;
  113532. private _yAxis;
  113533. private _zAxis;
  113534. private _scaleLinesFactor;
  113535. private _instanced;
  113536. /**
  113537. * Gets the hosting scene
  113538. */
  113539. scene: Scene;
  113540. /**
  113541. * Gets or sets a number used to scale line length
  113542. */
  113543. scaleLines: number;
  113544. /** Gets the node hierarchy used to render x-axis */
  113545. readonly xAxis: TransformNode;
  113546. /** Gets the node hierarchy used to render y-axis */
  113547. readonly yAxis: TransformNode;
  113548. /** Gets the node hierarchy used to render z-axis */
  113549. readonly zAxis: TransformNode;
  113550. /**
  113551. * Creates a new AxesViewer
  113552. * @param scene defines the hosting scene
  113553. * @param scaleLines defines a number used to scale line length (1 by default)
  113554. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  113555. * @param xAxis defines the node hierarchy used to render the x-axis
  113556. * @param yAxis defines the node hierarchy used to render the y-axis
  113557. * @param zAxis defines the node hierarchy used to render the z-axis
  113558. */
  113559. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  113560. /**
  113561. * Force the viewer to update
  113562. * @param position defines the position of the viewer
  113563. * @param xaxis defines the x axis of the viewer
  113564. * @param yaxis defines the y axis of the viewer
  113565. * @param zaxis defines the z axis of the viewer
  113566. */
  113567. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  113568. /**
  113569. * Creates an instance of this axes viewer.
  113570. * @returns a new axes viewer with instanced meshes
  113571. */
  113572. createInstance(): AxesViewer;
  113573. /** Releases resources */
  113574. dispose(): void;
  113575. private static _SetRenderingGroupId;
  113576. }
  113577. }
  113578. declare module BABYLON.Debug {
  113579. /**
  113580. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  113581. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  113582. */
  113583. export class BoneAxesViewer extends AxesViewer {
  113584. /**
  113585. * Gets or sets the target mesh where to display the axes viewer
  113586. */
  113587. mesh: Nullable<Mesh>;
  113588. /**
  113589. * Gets or sets the target bone where to display the axes viewer
  113590. */
  113591. bone: Nullable<Bone>;
  113592. /** Gets current position */
  113593. pos: Vector3;
  113594. /** Gets direction of X axis */
  113595. xaxis: Vector3;
  113596. /** Gets direction of Y axis */
  113597. yaxis: Vector3;
  113598. /** Gets direction of Z axis */
  113599. zaxis: Vector3;
  113600. /**
  113601. * Creates a new BoneAxesViewer
  113602. * @param scene defines the hosting scene
  113603. * @param bone defines the target bone
  113604. * @param mesh defines the target mesh
  113605. * @param scaleLines defines a scaling factor for line length (1 by default)
  113606. */
  113607. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  113608. /**
  113609. * Force the viewer to update
  113610. */
  113611. update(): void;
  113612. /** Releases resources */
  113613. dispose(): void;
  113614. }
  113615. }
  113616. declare module BABYLON {
  113617. /**
  113618. * Interface used to define scene explorer extensibility option
  113619. */
  113620. export interface IExplorerExtensibilityOption {
  113621. /**
  113622. * Define the option label
  113623. */
  113624. label: string;
  113625. /**
  113626. * Defines the action to execute on click
  113627. */
  113628. action: (entity: any) => void;
  113629. }
  113630. /**
  113631. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  113632. */
  113633. export interface IExplorerExtensibilityGroup {
  113634. /**
  113635. * Defines a predicate to test if a given type mut be extended
  113636. */
  113637. predicate: (entity: any) => boolean;
  113638. /**
  113639. * Gets the list of options added to a type
  113640. */
  113641. entries: IExplorerExtensibilityOption[];
  113642. }
  113643. /**
  113644. * Interface used to define the options to use to create the Inspector
  113645. */
  113646. export interface IInspectorOptions {
  113647. /**
  113648. * Display in overlay mode (default: false)
  113649. */
  113650. overlay?: boolean;
  113651. /**
  113652. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  113653. */
  113654. globalRoot?: HTMLElement;
  113655. /**
  113656. * Display the Scene explorer
  113657. */
  113658. showExplorer?: boolean;
  113659. /**
  113660. * Display the property inspector
  113661. */
  113662. showInspector?: boolean;
  113663. /**
  113664. * Display in embed mode (both panes on the right)
  113665. */
  113666. embedMode?: boolean;
  113667. /**
  113668. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  113669. */
  113670. handleResize?: boolean;
  113671. /**
  113672. * Allow the panes to popup (default: true)
  113673. */
  113674. enablePopup?: boolean;
  113675. /**
  113676. * Allow the panes to be closed by users (default: true)
  113677. */
  113678. enableClose?: boolean;
  113679. /**
  113680. * Optional list of extensibility entries
  113681. */
  113682. explorerExtensibility?: IExplorerExtensibilityGroup[];
  113683. /**
  113684. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  113685. */
  113686. inspectorURL?: string;
  113687. /**
  113688. * Optional initial tab (default to DebugLayerTab.Properties)
  113689. */
  113690. initialTab?: DebugLayerTab;
  113691. }
  113692. interface Scene {
  113693. /**
  113694. * @hidden
  113695. * Backing field
  113696. */
  113697. _debugLayer: DebugLayer;
  113698. /**
  113699. * Gets the debug layer (aka Inspector) associated with the scene
  113700. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113701. */
  113702. debugLayer: DebugLayer;
  113703. }
  113704. /**
  113705. * Enum of inspector action tab
  113706. */
  113707. export enum DebugLayerTab {
  113708. /**
  113709. * Properties tag (default)
  113710. */
  113711. Properties = 0,
  113712. /**
  113713. * Debug tab
  113714. */
  113715. Debug = 1,
  113716. /**
  113717. * Statistics tab
  113718. */
  113719. Statistics = 2,
  113720. /**
  113721. * Tools tab
  113722. */
  113723. Tools = 3,
  113724. /**
  113725. * Settings tab
  113726. */
  113727. Settings = 4
  113728. }
  113729. /**
  113730. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113731. * what is happening in your scene
  113732. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113733. */
  113734. export class DebugLayer {
  113735. /**
  113736. * Define the url to get the inspector script from.
  113737. * By default it uses the babylonjs CDN.
  113738. * @ignoreNaming
  113739. */
  113740. static InspectorURL: string;
  113741. private _scene;
  113742. private BJSINSPECTOR;
  113743. private _onPropertyChangedObservable?;
  113744. /**
  113745. * Observable triggered when a property is changed through the inspector.
  113746. */
  113747. readonly onPropertyChangedObservable: any;
  113748. /**
  113749. * Instantiates a new debug layer.
  113750. * The debug layer (aka Inspector) is the go to tool in order to better understand
  113751. * what is happening in your scene
  113752. * @see http://doc.babylonjs.com/features/playground_debuglayer
  113753. * @param scene Defines the scene to inspect
  113754. */
  113755. constructor(scene: Scene);
  113756. /** Creates the inspector window. */
  113757. private _createInspector;
  113758. /**
  113759. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  113760. * @param entity defines the entity to select
  113761. * @param lineContainerTitle defines the specific block to highlight
  113762. */
  113763. select(entity: any, lineContainerTitle?: string): void;
  113764. /** Get the inspector from bundle or global */
  113765. private _getGlobalInspector;
  113766. /**
  113767. * Get if the inspector is visible or not.
  113768. * @returns true if visible otherwise, false
  113769. */
  113770. isVisible(): boolean;
  113771. /**
  113772. * Hide the inspector and close its window.
  113773. */
  113774. hide(): void;
  113775. /**
  113776. * Launch the debugLayer.
  113777. * @param config Define the configuration of the inspector
  113778. * @return a promise fulfilled when the debug layer is visible
  113779. */
  113780. show(config?: IInspectorOptions): Promise<DebugLayer>;
  113781. }
  113782. }
  113783. declare module BABYLON {
  113784. /**
  113785. * Class containing static functions to help procedurally build meshes
  113786. */
  113787. export class BoxBuilder {
  113788. /**
  113789. * Creates a box mesh
  113790. * * The parameter `size` sets the size (float) of each box side (default 1)
  113791. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  113792. * * 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)
  113793. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113797. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  113798. * @param name defines the name of the mesh
  113799. * @param options defines the options used to create the mesh
  113800. * @param scene defines the hosting scene
  113801. * @returns the box mesh
  113802. */
  113803. static CreateBox(name: string, options: {
  113804. size?: number;
  113805. width?: number;
  113806. height?: number;
  113807. depth?: number;
  113808. faceUV?: Vector4[];
  113809. faceColors?: Color4[];
  113810. sideOrientation?: number;
  113811. frontUVs?: Vector4;
  113812. backUVs?: Vector4;
  113813. wrap?: boolean;
  113814. topBaseAt?: number;
  113815. bottomBaseAt?: number;
  113816. updatable?: boolean;
  113817. }, scene?: Nullable<Scene>): Mesh;
  113818. }
  113819. }
  113820. declare module BABYLON {
  113821. /**
  113822. * Class containing static functions to help procedurally build meshes
  113823. */
  113824. export class SphereBuilder {
  113825. /**
  113826. * Creates a sphere mesh
  113827. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  113828. * * 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`)
  113829. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  113830. * * 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
  113831. * * 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)
  113832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113835. * @param name defines the name of the mesh
  113836. * @param options defines the options used to create the mesh
  113837. * @param scene defines the hosting scene
  113838. * @returns the sphere mesh
  113839. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  113840. */
  113841. static CreateSphere(name: string, options: {
  113842. segments?: number;
  113843. diameter?: number;
  113844. diameterX?: number;
  113845. diameterY?: number;
  113846. diameterZ?: number;
  113847. arc?: number;
  113848. slice?: number;
  113849. sideOrientation?: number;
  113850. frontUVs?: Vector4;
  113851. backUVs?: Vector4;
  113852. updatable?: boolean;
  113853. }, scene?: Nullable<Scene>): Mesh;
  113854. }
  113855. }
  113856. declare module BABYLON.Debug {
  113857. /**
  113858. * Used to show the physics impostor around the specific mesh
  113859. */
  113860. export class PhysicsViewer {
  113861. /** @hidden */
  113862. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  113863. /** @hidden */
  113864. protected _meshes: Array<Nullable<AbstractMesh>>;
  113865. /** @hidden */
  113866. protected _scene: Nullable<Scene>;
  113867. /** @hidden */
  113868. protected _numMeshes: number;
  113869. /** @hidden */
  113870. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  113871. private _renderFunction;
  113872. private _utilityLayer;
  113873. private _debugBoxMesh;
  113874. private _debugSphereMesh;
  113875. private _debugCylinderMesh;
  113876. private _debugMaterial;
  113877. private _debugMeshMeshes;
  113878. /**
  113879. * Creates a new PhysicsViewer
  113880. * @param scene defines the hosting scene
  113881. */
  113882. constructor(scene: Scene);
  113883. /** @hidden */
  113884. protected _updateDebugMeshes(): void;
  113885. /**
  113886. * Renders a specified physic impostor
  113887. * @param impostor defines the impostor to render
  113888. * @param targetMesh defines the mesh represented by the impostor
  113889. * @returns the new debug mesh used to render the impostor
  113890. */
  113891. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  113892. /**
  113893. * Hides a specified physic impostor
  113894. * @param impostor defines the impostor to hide
  113895. */
  113896. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  113897. private _getDebugMaterial;
  113898. private _getDebugBoxMesh;
  113899. private _getDebugSphereMesh;
  113900. private _getDebugCylinderMesh;
  113901. private _getDebugMeshMesh;
  113902. private _getDebugMesh;
  113903. /** Releases all resources */
  113904. dispose(): void;
  113905. }
  113906. }
  113907. declare module BABYLON {
  113908. /**
  113909. * Class containing static functions to help procedurally build meshes
  113910. */
  113911. export class LinesBuilder {
  113912. /**
  113913. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  113914. * * 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
  113915. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  113916. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  113917. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  113918. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  113919. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  113920. * * 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
  113921. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  113922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  113924. * @param name defines the name of the new line system
  113925. * @param options defines the options used to create the line system
  113926. * @param scene defines the hosting scene
  113927. * @returns a new line system mesh
  113928. */
  113929. static CreateLineSystem(name: string, options: {
  113930. lines: Vector3[][];
  113931. updatable?: boolean;
  113932. instance?: Nullable<LinesMesh>;
  113933. colors?: Nullable<Color4[][]>;
  113934. useVertexAlpha?: boolean;
  113935. }, scene: Nullable<Scene>): LinesMesh;
  113936. /**
  113937. * Creates a line mesh
  113938. * 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
  113939. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113940. * * The parameter `points` is an array successive Vector3
  113941. * * 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
  113942. * * The optional parameter `colors` is an array of successive Color4, one per line point
  113943. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  113944. * * When updating an instance, remember that only point positions can change, not the number of points
  113945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  113947. * @param name defines the name of the new line system
  113948. * @param options defines the options used to create the line system
  113949. * @param scene defines the hosting scene
  113950. * @returns a new line mesh
  113951. */
  113952. static CreateLines(name: string, options: {
  113953. points: Vector3[];
  113954. updatable?: boolean;
  113955. instance?: Nullable<LinesMesh>;
  113956. colors?: Color4[];
  113957. useVertexAlpha?: boolean;
  113958. }, scene?: Nullable<Scene>): LinesMesh;
  113959. /**
  113960. * Creates a dashed line mesh
  113961. * * 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
  113962. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  113963. * * The parameter `points` is an array successive Vector3
  113964. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  113965. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  113966. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  113967. * * 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
  113968. * * When updating an instance, remember that only point positions can change, not the number of points
  113969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113970. * @param name defines the name of the mesh
  113971. * @param options defines the options used to create the mesh
  113972. * @param scene defines the hosting scene
  113973. * @returns the dashed line mesh
  113974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  113975. */
  113976. static CreateDashedLines(name: string, options: {
  113977. points: Vector3[];
  113978. dashSize?: number;
  113979. gapSize?: number;
  113980. dashNb?: number;
  113981. updatable?: boolean;
  113982. instance?: LinesMesh;
  113983. }, scene?: Nullable<Scene>): LinesMesh;
  113984. }
  113985. }
  113986. declare module BABYLON {
  113987. /**
  113988. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  113989. * in order to better appreciate the issue one might have.
  113990. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  113991. */
  113992. export class RayHelper {
  113993. /**
  113994. * Defines the ray we are currently tryin to visualize.
  113995. */
  113996. ray: Nullable<Ray>;
  113997. private _renderPoints;
  113998. private _renderLine;
  113999. private _renderFunction;
  114000. private _scene;
  114001. private _updateToMeshFunction;
  114002. private _attachedToMesh;
  114003. private _meshSpaceDirection;
  114004. private _meshSpaceOrigin;
  114005. /**
  114006. * Helper function to create a colored helper in a scene in one line.
  114007. * @param ray Defines the ray we are currently tryin to visualize
  114008. * @param scene Defines the scene the ray is used in
  114009. * @param color Defines the color we want to see the ray in
  114010. * @returns The newly created ray helper.
  114011. */
  114012. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  114013. /**
  114014. * Instantiate a new ray helper.
  114015. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  114016. * in order to better appreciate the issue one might have.
  114017. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  114018. * @param ray Defines the ray we are currently tryin to visualize
  114019. */
  114020. constructor(ray: Ray);
  114021. /**
  114022. * Shows the ray we are willing to debug.
  114023. * @param scene Defines the scene the ray needs to be rendered in
  114024. * @param color Defines the color the ray needs to be rendered in
  114025. */
  114026. show(scene: Scene, color?: Color3): void;
  114027. /**
  114028. * Hides the ray we are debugging.
  114029. */
  114030. hide(): void;
  114031. private _render;
  114032. /**
  114033. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  114034. * @param mesh Defines the mesh we want the helper attached to
  114035. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  114036. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  114037. * @param length Defines the length of the ray
  114038. */
  114039. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  114040. /**
  114041. * Detach the ray helper from the mesh it has previously been attached to.
  114042. */
  114043. detachFromMesh(): void;
  114044. private _updateToMesh;
  114045. /**
  114046. * Dispose the helper and release its associated resources.
  114047. */
  114048. dispose(): void;
  114049. }
  114050. }
  114051. declare module BABYLON.Debug {
  114052. /**
  114053. * Class used to render a debug view of a given skeleton
  114054. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  114055. */
  114056. export class SkeletonViewer {
  114057. /** defines the skeleton to render */
  114058. skeleton: Skeleton;
  114059. /** defines the mesh attached to the skeleton */
  114060. mesh: AbstractMesh;
  114061. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  114062. autoUpdateBonesMatrices: boolean;
  114063. /** defines the rendering group id to use with the viewer */
  114064. renderingGroupId: number;
  114065. /** Gets or sets the color used to render the skeleton */
  114066. color: Color3;
  114067. private _scene;
  114068. private _debugLines;
  114069. private _debugMesh;
  114070. private _isEnabled;
  114071. private _renderFunction;
  114072. private _utilityLayer;
  114073. /**
  114074. * Returns the mesh used to render the bones
  114075. */
  114076. readonly debugMesh: Nullable<LinesMesh>;
  114077. /**
  114078. * Creates a new SkeletonViewer
  114079. * @param skeleton defines the skeleton to render
  114080. * @param mesh defines the mesh attached to the skeleton
  114081. * @param scene defines the hosting scene
  114082. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  114083. * @param renderingGroupId defines the rendering group id to use with the viewer
  114084. */
  114085. constructor(
  114086. /** defines the skeleton to render */
  114087. skeleton: Skeleton,
  114088. /** defines the mesh attached to the skeleton */
  114089. mesh: AbstractMesh, scene: Scene,
  114090. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  114091. autoUpdateBonesMatrices?: boolean,
  114092. /** defines the rendering group id to use with the viewer */
  114093. renderingGroupId?: number);
  114094. /** Gets or sets a boolean indicating if the viewer is enabled */
  114095. isEnabled: boolean;
  114096. private _getBonePosition;
  114097. private _getLinesForBonesWithLength;
  114098. private _getLinesForBonesNoLength;
  114099. /** Update the viewer to sync with current skeleton state */
  114100. update(): void;
  114101. /** Release associated resources */
  114102. dispose(): void;
  114103. }
  114104. }
  114105. declare module BABYLON {
  114106. /**
  114107. * Options to create the null engine
  114108. */
  114109. export class NullEngineOptions {
  114110. /**
  114111. * Render width (Default: 512)
  114112. */
  114113. renderWidth: number;
  114114. /**
  114115. * Render height (Default: 256)
  114116. */
  114117. renderHeight: number;
  114118. /**
  114119. * Texture size (Default: 512)
  114120. */
  114121. textureSize: number;
  114122. /**
  114123. * If delta time between frames should be constant
  114124. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114125. */
  114126. deterministicLockstep: boolean;
  114127. /**
  114128. * Maximum about of steps between frames (Default: 4)
  114129. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114130. */
  114131. lockstepMaxSteps: number;
  114132. }
  114133. /**
  114134. * The null engine class provides support for headless version of babylon.js.
  114135. * This can be used in server side scenario or for testing purposes
  114136. */
  114137. export class NullEngine extends Engine {
  114138. private _options;
  114139. /**
  114140. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114141. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114142. * @returns true if engine is in deterministic lock step mode
  114143. */
  114144. isDeterministicLockStep(): boolean;
  114145. /**
  114146. * Gets the max steps when engine is running in deterministic lock step
  114147. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114148. * @returns the max steps
  114149. */
  114150. getLockstepMaxSteps(): number;
  114151. /**
  114152. * Gets the current hardware scaling level.
  114153. * By default the hardware scaling level is computed from the window device ratio.
  114154. * 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.
  114155. * @returns a number indicating the current hardware scaling level
  114156. */
  114157. getHardwareScalingLevel(): number;
  114158. constructor(options?: NullEngineOptions);
  114159. /**
  114160. * Creates a vertex buffer
  114161. * @param vertices the data for the vertex buffer
  114162. * @returns the new WebGL static buffer
  114163. */
  114164. createVertexBuffer(vertices: FloatArray): DataBuffer;
  114165. /**
  114166. * Creates a new index buffer
  114167. * @param indices defines the content of the index buffer
  114168. * @param updatable defines if the index buffer must be updatable
  114169. * @returns a new webGL buffer
  114170. */
  114171. createIndexBuffer(indices: IndicesArray): DataBuffer;
  114172. /**
  114173. * Clear the current render buffer or the current render target (if any is set up)
  114174. * @param color defines the color to use
  114175. * @param backBuffer defines if the back buffer must be cleared
  114176. * @param depth defines if the depth buffer must be cleared
  114177. * @param stencil defines if the stencil buffer must be cleared
  114178. */
  114179. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  114180. /**
  114181. * Gets the current render width
  114182. * @param useScreen defines if screen size must be used (or the current render target if any)
  114183. * @returns a number defining the current render width
  114184. */
  114185. getRenderWidth(useScreen?: boolean): number;
  114186. /**
  114187. * Gets the current render height
  114188. * @param useScreen defines if screen size must be used (or the current render target if any)
  114189. * @returns a number defining the current render height
  114190. */
  114191. getRenderHeight(useScreen?: boolean): number;
  114192. /**
  114193. * Set the WebGL's viewport
  114194. * @param viewport defines the viewport element to be used
  114195. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  114196. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  114197. */
  114198. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  114199. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  114200. /**
  114201. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  114202. * @param pipelineContext defines the pipeline context to use
  114203. * @param uniformsNames defines the list of uniform names
  114204. * @returns an array of webGL uniform locations
  114205. */
  114206. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  114207. /**
  114208. * Gets the lsit of active attributes for a given webGL program
  114209. * @param pipelineContext defines the pipeline context to use
  114210. * @param attributesNames defines the list of attribute names to get
  114211. * @returns an array of indices indicating the offset of each attribute
  114212. */
  114213. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  114214. /**
  114215. * Binds an effect to the webGL context
  114216. * @param effect defines the effect to bind
  114217. */
  114218. bindSamplers(effect: Effect): void;
  114219. /**
  114220. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  114221. * @param effect defines the effect to activate
  114222. */
  114223. enableEffect(effect: Effect): void;
  114224. /**
  114225. * Set various states to the webGL context
  114226. * @param culling defines backface culling state
  114227. * @param zOffset defines the value to apply to zOffset (0 by default)
  114228. * @param force defines if states must be applied even if cache is up to date
  114229. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114230. */
  114231. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114232. /**
  114233. * Set the value of an uniform to an array of int32
  114234. * @param uniform defines the webGL uniform location where to store the value
  114235. * @param array defines the array of int32 to store
  114236. */
  114237. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  114238. /**
  114239. * Set the value of an uniform to an array of int32 (stored as vec2)
  114240. * @param uniform defines the webGL uniform location where to store the value
  114241. * @param array defines the array of int32 to store
  114242. */
  114243. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  114244. /**
  114245. * Set the value of an uniform to an array of int32 (stored as vec3)
  114246. * @param uniform defines the webGL uniform location where to store the value
  114247. * @param array defines the array of int32 to store
  114248. */
  114249. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  114250. /**
  114251. * Set the value of an uniform to an array of int32 (stored as vec4)
  114252. * @param uniform defines the webGL uniform location where to store the value
  114253. * @param array defines the array of int32 to store
  114254. */
  114255. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  114256. /**
  114257. * Set the value of an uniform to an array of float32
  114258. * @param uniform defines the webGL uniform location where to store the value
  114259. * @param array defines the array of float32 to store
  114260. */
  114261. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  114262. /**
  114263. * Set the value of an uniform to an array of float32 (stored as vec2)
  114264. * @param uniform defines the webGL uniform location where to store the value
  114265. * @param array defines the array of float32 to store
  114266. */
  114267. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  114268. /**
  114269. * Set the value of an uniform to an array of float32 (stored as vec3)
  114270. * @param uniform defines the webGL uniform location where to store the value
  114271. * @param array defines the array of float32 to store
  114272. */
  114273. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  114274. /**
  114275. * Set the value of an uniform to an array of float32 (stored as vec4)
  114276. * @param uniform defines the webGL uniform location where to store the value
  114277. * @param array defines the array of float32 to store
  114278. */
  114279. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  114280. /**
  114281. * Set the value of an uniform to an array of number
  114282. * @param uniform defines the webGL uniform location where to store the value
  114283. * @param array defines the array of number to store
  114284. */
  114285. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  114286. /**
  114287. * Set the value of an uniform to an array of number (stored as vec2)
  114288. * @param uniform defines the webGL uniform location where to store the value
  114289. * @param array defines the array of number to store
  114290. */
  114291. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  114292. /**
  114293. * Set the value of an uniform to an array of number (stored as vec3)
  114294. * @param uniform defines the webGL uniform location where to store the value
  114295. * @param array defines the array of number to store
  114296. */
  114297. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  114298. /**
  114299. * Set the value of an uniform to an array of number (stored as vec4)
  114300. * @param uniform defines the webGL uniform location where to store the value
  114301. * @param array defines the array of number to store
  114302. */
  114303. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  114304. /**
  114305. * Set the value of an uniform to an array of float32 (stored as matrices)
  114306. * @param uniform defines the webGL uniform location where to store the value
  114307. * @param matrices defines the array of float32 to store
  114308. */
  114309. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  114310. /**
  114311. * Set the value of an uniform to a matrix (3x3)
  114312. * @param uniform defines the webGL uniform location where to store the value
  114313. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  114314. */
  114315. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114316. /**
  114317. * Set the value of an uniform to a matrix (2x2)
  114318. * @param uniform defines the webGL uniform location where to store the value
  114319. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  114320. */
  114321. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  114322. /**
  114323. * Set the value of an uniform to a number (float)
  114324. * @param uniform defines the webGL uniform location where to store the value
  114325. * @param value defines the float number to store
  114326. */
  114327. setFloat(uniform: WebGLUniformLocation, value: number): void;
  114328. /**
  114329. * Set the value of an uniform to a vec2
  114330. * @param uniform defines the webGL uniform location where to store the value
  114331. * @param x defines the 1st component of the value
  114332. * @param y defines the 2nd component of the value
  114333. */
  114334. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  114335. /**
  114336. * Set the value of an uniform to a vec3
  114337. * @param uniform defines the webGL uniform location where to store the value
  114338. * @param x defines the 1st component of the value
  114339. * @param y defines the 2nd component of the value
  114340. * @param z defines the 3rd component of the value
  114341. */
  114342. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  114343. /**
  114344. * Set the value of an uniform to a boolean
  114345. * @param uniform defines the webGL uniform location where to store the value
  114346. * @param bool defines the boolean to store
  114347. */
  114348. setBool(uniform: WebGLUniformLocation, bool: number): void;
  114349. /**
  114350. * Set the value of an uniform to a vec4
  114351. * @param uniform defines the webGL uniform location where to store the value
  114352. * @param x defines the 1st component of the value
  114353. * @param y defines the 2nd component of the value
  114354. * @param z defines the 3rd component of the value
  114355. * @param w defines the 4th component of the value
  114356. */
  114357. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  114358. /**
  114359. * Sets the current alpha mode
  114360. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114361. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114362. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114363. */
  114364. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114365. /**
  114366. * Bind webGl buffers directly to the webGL context
  114367. * @param vertexBuffers defines the vertex buffer to bind
  114368. * @param indexBuffer defines the index buffer to bind
  114369. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  114370. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  114371. * @param effect defines the effect associated with the vertex buffer
  114372. */
  114373. bindBuffers(vertexBuffers: {
  114374. [key: string]: VertexBuffer;
  114375. }, indexBuffer: DataBuffer, effect: Effect): void;
  114376. /**
  114377. * Force the entire cache to be cleared
  114378. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  114379. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  114380. */
  114381. wipeCaches(bruteForce?: boolean): void;
  114382. /**
  114383. * Send a draw order
  114384. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  114385. * @param indexStart defines the starting index
  114386. * @param indexCount defines the number of index to draw
  114387. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114388. */
  114389. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  114390. /**
  114391. * Draw a list of indexed primitives
  114392. * @param fillMode defines the primitive to use
  114393. * @param indexStart defines the starting index
  114394. * @param indexCount defines the number of index to draw
  114395. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114396. */
  114397. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  114398. /**
  114399. * Draw a list of unindexed primitives
  114400. * @param fillMode defines the primitive to use
  114401. * @param verticesStart defines the index of first vertex to draw
  114402. * @param verticesCount defines the count of vertices to draw
  114403. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  114404. */
  114405. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  114406. /** @hidden */
  114407. _createTexture(): WebGLTexture;
  114408. /** @hidden */
  114409. _releaseTexture(texture: InternalTexture): void;
  114410. /**
  114411. * Usually called from Texture.ts.
  114412. * Passed information to create a WebGLTexture
  114413. * @param urlArg defines a value which contains one of the following:
  114414. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  114415. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  114416. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  114417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  114418. * @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)
  114419. * @param scene needed for loading to the correct scene
  114420. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  114421. * @param onLoad optional callback to be called upon successful completion
  114422. * @param onError optional callback to be called upon failure
  114423. * @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
  114424. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  114425. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  114426. * @param forcedExtension defines the extension to use to pick the right loader
  114427. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  114428. * @returns a InternalTexture for assignment back into BABYLON.Texture
  114429. */
  114430. 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;
  114431. /**
  114432. * Creates a new render target texture
  114433. * @param size defines the size of the texture
  114434. * @param options defines the options used to create the texture
  114435. * @returns a new render target texture stored in an InternalTexture
  114436. */
  114437. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  114438. /**
  114439. * Update the sampling mode of a given texture
  114440. * @param samplingMode defines the required sampling mode
  114441. * @param texture defines the texture to update
  114442. */
  114443. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  114444. /**
  114445. * Binds the frame buffer to the specified texture.
  114446. * @param texture The texture to render to or null for the default canvas
  114447. * @param faceIndex The face of the texture to render to in case of cube texture
  114448. * @param requiredWidth The width of the target to render to
  114449. * @param requiredHeight The height of the target to render to
  114450. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  114451. * @param depthStencilTexture The depth stencil texture to use to render
  114452. * @param lodLevel defines le lod level to bind to the frame buffer
  114453. */
  114454. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  114455. /**
  114456. * Unbind the current render target texture from the webGL context
  114457. * @param texture defines the render target texture to unbind
  114458. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114459. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114460. */
  114461. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  114462. /**
  114463. * Creates a dynamic vertex buffer
  114464. * @param vertices the data for the dynamic vertex buffer
  114465. * @returns the new WebGL dynamic buffer
  114466. */
  114467. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  114468. /**
  114469. * Update the content of a dynamic texture
  114470. * @param texture defines the texture to update
  114471. * @param canvas defines the canvas containing the source
  114472. * @param invertY defines if data must be stored with Y axis inverted
  114473. * @param premulAlpha defines if alpha is stored as premultiplied
  114474. * @param format defines the format of the data
  114475. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114476. */
  114477. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  114478. /**
  114479. * Gets a boolean indicating if all created effects are ready
  114480. * @returns true if all effects are ready
  114481. */
  114482. areAllEffectsReady(): boolean;
  114483. /**
  114484. * @hidden
  114485. * Get the current error code of the webGL context
  114486. * @returns the error code
  114487. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  114488. */
  114489. getError(): number;
  114490. /** @hidden */
  114491. _getUnpackAlignement(): number;
  114492. /** @hidden */
  114493. _unpackFlipY(value: boolean): void;
  114494. /**
  114495. * Update a dynamic index buffer
  114496. * @param indexBuffer defines the target index buffer
  114497. * @param indices defines the data to update
  114498. * @param offset defines the offset in the target index buffer where update should start
  114499. */
  114500. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  114501. /**
  114502. * Updates a dynamic vertex buffer.
  114503. * @param vertexBuffer the vertex buffer to update
  114504. * @param vertices the data used to update the vertex buffer
  114505. * @param byteOffset the byte offset of the data (optional)
  114506. * @param byteLength the byte length of the data (optional)
  114507. */
  114508. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  114509. /** @hidden */
  114510. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  114511. /** @hidden */
  114512. _bindTexture(channel: number, texture: InternalTexture): void;
  114513. protected _deleteBuffer(buffer: WebGLBuffer): void;
  114514. /**
  114515. * 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
  114516. */
  114517. releaseEffects(): void;
  114518. displayLoadingUI(): void;
  114519. hideLoadingUI(): void;
  114520. /** @hidden */
  114521. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114522. /** @hidden */
  114523. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114524. /** @hidden */
  114525. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  114526. /** @hidden */
  114527. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  114528. }
  114529. }
  114530. declare module BABYLON {
  114531. /** @hidden */
  114532. export class _OcclusionDataStorage {
  114533. /** @hidden */
  114534. occlusionInternalRetryCounter: number;
  114535. /** @hidden */
  114536. isOcclusionQueryInProgress: boolean;
  114537. /** @hidden */
  114538. isOccluded: boolean;
  114539. /** @hidden */
  114540. occlusionRetryCount: number;
  114541. /** @hidden */
  114542. occlusionType: number;
  114543. /** @hidden */
  114544. occlusionQueryAlgorithmType: number;
  114545. }
  114546. interface Engine {
  114547. /**
  114548. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  114549. * @return the new query
  114550. */
  114551. createQuery(): WebGLQuery;
  114552. /**
  114553. * Delete and release a webGL query
  114554. * @param query defines the query to delete
  114555. * @return the current engine
  114556. */
  114557. deleteQuery(query: WebGLQuery): Engine;
  114558. /**
  114559. * Check if a given query has resolved and got its value
  114560. * @param query defines the query to check
  114561. * @returns true if the query got its value
  114562. */
  114563. isQueryResultAvailable(query: WebGLQuery): boolean;
  114564. /**
  114565. * Gets the value of a given query
  114566. * @param query defines the query to check
  114567. * @returns the value of the query
  114568. */
  114569. getQueryResult(query: WebGLQuery): number;
  114570. /**
  114571. * Initiates an occlusion query
  114572. * @param algorithmType defines the algorithm to use
  114573. * @param query defines the query to use
  114574. * @returns the current engine
  114575. * @see http://doc.babylonjs.com/features/occlusionquery
  114576. */
  114577. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  114578. /**
  114579. * Ends an occlusion query
  114580. * @see http://doc.babylonjs.com/features/occlusionquery
  114581. * @param algorithmType defines the algorithm to use
  114582. * @returns the current engine
  114583. */
  114584. endOcclusionQuery(algorithmType: number): Engine;
  114585. /**
  114586. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  114587. * Please note that only one query can be issued at a time
  114588. * @returns a time token used to track the time span
  114589. */
  114590. startTimeQuery(): Nullable<_TimeToken>;
  114591. /**
  114592. * Ends a time query
  114593. * @param token defines the token used to measure the time span
  114594. * @returns the time spent (in ns)
  114595. */
  114596. endTimeQuery(token: _TimeToken): int;
  114597. /** @hidden */
  114598. _currentNonTimestampToken: Nullable<_TimeToken>;
  114599. /** @hidden */
  114600. _createTimeQuery(): WebGLQuery;
  114601. /** @hidden */
  114602. _deleteTimeQuery(query: WebGLQuery): void;
  114603. /** @hidden */
  114604. _getGlAlgorithmType(algorithmType: number): number;
  114605. /** @hidden */
  114606. _getTimeQueryResult(query: WebGLQuery): any;
  114607. /** @hidden */
  114608. _getTimeQueryAvailability(query: WebGLQuery): any;
  114609. }
  114610. interface AbstractMesh {
  114611. /**
  114612. * Backing filed
  114613. * @hidden
  114614. */
  114615. __occlusionDataStorage: _OcclusionDataStorage;
  114616. /**
  114617. * Access property
  114618. * @hidden
  114619. */
  114620. _occlusionDataStorage: _OcclusionDataStorage;
  114621. /**
  114622. * 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.
  114623. * The default value is -1 which means don't break the query and wait till the result
  114624. * @see http://doc.babylonjs.com/features/occlusionquery
  114625. */
  114626. occlusionRetryCount: number;
  114627. /**
  114628. * 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:
  114629. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  114630. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  114631. * * 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.
  114632. * @see http://doc.babylonjs.com/features/occlusionquery
  114633. */
  114634. occlusionType: number;
  114635. /**
  114636. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  114637. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  114638. * * 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.
  114639. * @see http://doc.babylonjs.com/features/occlusionquery
  114640. */
  114641. occlusionQueryAlgorithmType: number;
  114642. /**
  114643. * 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
  114644. * @see http://doc.babylonjs.com/features/occlusionquery
  114645. */
  114646. isOccluded: boolean;
  114647. /**
  114648. * Flag to check the progress status of the query
  114649. * @see http://doc.babylonjs.com/features/occlusionquery
  114650. */
  114651. isOcclusionQueryInProgress: boolean;
  114652. }
  114653. }
  114654. declare module BABYLON {
  114655. /** @hidden */
  114656. export var _forceTransformFeedbackToBundle: boolean;
  114657. interface Engine {
  114658. /**
  114659. * Creates a webGL transform feedback object
  114660. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  114661. * @returns the webGL transform feedback object
  114662. */
  114663. createTransformFeedback(): WebGLTransformFeedback;
  114664. /**
  114665. * Delete a webGL transform feedback object
  114666. * @param value defines the webGL transform feedback object to delete
  114667. */
  114668. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  114669. /**
  114670. * Bind a webGL transform feedback object to the webgl context
  114671. * @param value defines the webGL transform feedback object to bind
  114672. */
  114673. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  114674. /**
  114675. * Begins a transform feedback operation
  114676. * @param usePoints defines if points or triangles must be used
  114677. */
  114678. beginTransformFeedback(usePoints: boolean): void;
  114679. /**
  114680. * Ends a transform feedback operation
  114681. */
  114682. endTransformFeedback(): void;
  114683. /**
  114684. * Specify the varyings to use with transform feedback
  114685. * @param program defines the associated webGL program
  114686. * @param value defines the list of strings representing the varying names
  114687. */
  114688. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  114689. /**
  114690. * Bind a webGL buffer for a transform feedback operation
  114691. * @param value defines the webGL buffer to bind
  114692. */
  114693. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  114694. }
  114695. }
  114696. declare module BABYLON {
  114697. /**
  114698. * Creation options of the multi render target texture.
  114699. */
  114700. export interface IMultiRenderTargetOptions {
  114701. /**
  114702. * Define if the texture needs to create mip maps after render.
  114703. */
  114704. generateMipMaps?: boolean;
  114705. /**
  114706. * Define the types of all the draw buffers we want to create
  114707. */
  114708. types?: number[];
  114709. /**
  114710. * Define the sampling modes of all the draw buffers we want to create
  114711. */
  114712. samplingModes?: number[];
  114713. /**
  114714. * Define if a depth buffer is required
  114715. */
  114716. generateDepthBuffer?: boolean;
  114717. /**
  114718. * Define if a stencil buffer is required
  114719. */
  114720. generateStencilBuffer?: boolean;
  114721. /**
  114722. * Define if a depth texture is required instead of a depth buffer
  114723. */
  114724. generateDepthTexture?: boolean;
  114725. /**
  114726. * Define the number of desired draw buffers
  114727. */
  114728. textureCount?: number;
  114729. /**
  114730. * Define if aspect ratio should be adapted to the texture or stay the scene one
  114731. */
  114732. doNotChangeAspectRatio?: boolean;
  114733. /**
  114734. * Define the default type of the buffers we are creating
  114735. */
  114736. defaultType?: number;
  114737. }
  114738. /**
  114739. * A multi render target, like a render target provides the ability to render to a texture.
  114740. * Unlike the render target, it can render to several draw buffers in one draw.
  114741. * This is specially interesting in deferred rendering or for any effects requiring more than
  114742. * just one color from a single pass.
  114743. */
  114744. export class MultiRenderTarget extends RenderTargetTexture {
  114745. private _internalTextures;
  114746. private _textures;
  114747. private _multiRenderTargetOptions;
  114748. /**
  114749. * Get if draw buffers are currently supported by the used hardware and browser.
  114750. */
  114751. readonly isSupported: boolean;
  114752. /**
  114753. * Get the list of textures generated by the multi render target.
  114754. */
  114755. readonly textures: Texture[];
  114756. /**
  114757. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  114758. */
  114759. readonly depthTexture: Texture;
  114760. /**
  114761. * Set the wrapping mode on U of all the textures we are rendering to.
  114762. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114763. */
  114764. wrapU: number;
  114765. /**
  114766. * Set the wrapping mode on V of all the textures we are rendering to.
  114767. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  114768. */
  114769. wrapV: number;
  114770. /**
  114771. * Instantiate a new multi render target texture.
  114772. * A multi render target, like a render target provides the ability to render to a texture.
  114773. * Unlike the render target, it can render to several draw buffers in one draw.
  114774. * This is specially interesting in deferred rendering or for any effects requiring more than
  114775. * just one color from a single pass.
  114776. * @param name Define the name of the texture
  114777. * @param size Define the size of the buffers to render to
  114778. * @param count Define the number of target we are rendering into
  114779. * @param scene Define the scene the texture belongs to
  114780. * @param options Define the options used to create the multi render target
  114781. */
  114782. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  114783. /** @hidden */
  114784. _rebuild(): void;
  114785. private _createInternalTextures;
  114786. private _createTextures;
  114787. /**
  114788. * Define the number of samples used if MSAA is enabled.
  114789. */
  114790. samples: number;
  114791. /**
  114792. * Resize all the textures in the multi render target.
  114793. * Be carrefull as it will recreate all the data in the new texture.
  114794. * @param size Define the new size
  114795. */
  114796. resize(size: any): void;
  114797. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  114798. /**
  114799. * Dispose the render targets and their associated resources
  114800. */
  114801. dispose(): void;
  114802. /**
  114803. * Release all the underlying texture used as draw buffers.
  114804. */
  114805. releaseInternalTextures(): void;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. interface ThinEngine {
  114810. /**
  114811. * Unbind a list of render target textures from the webGL context
  114812. * This is used only when drawBuffer extension or webGL2 are active
  114813. * @param textures defines the render target textures to unbind
  114814. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  114815. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  114816. */
  114817. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  114818. /**
  114819. * Create a multi render target texture
  114820. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  114821. * @param size defines the size of the texture
  114822. * @param options defines the creation options
  114823. * @returns the cube texture as an InternalTexture
  114824. */
  114825. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  114826. /**
  114827. * Update the sample count for a given multiple render target texture
  114828. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114829. * @param textures defines the textures to update
  114830. * @param samples defines the sample count to set
  114831. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114832. */
  114833. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  114834. }
  114835. }
  114836. declare module BABYLON {
  114837. /**
  114838. * Class used to define an additional view for the engine
  114839. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114840. */
  114841. export class EngineView {
  114842. /** Defines the canvas where to render the view */
  114843. target: HTMLCanvasElement;
  114844. /** Defines an optional camera used to render the view (will use active camera else) */
  114845. camera?: Camera;
  114846. }
  114847. interface Engine {
  114848. /**
  114849. * Gets or sets the HTML element to use for attaching events
  114850. */
  114851. inputElement: Nullable<HTMLElement>;
  114852. /**
  114853. * Gets the current engine view
  114854. * @see https://doc.babylonjs.com/how_to/multi_canvases
  114855. */
  114856. activeView: Nullable<EngineView>;
  114857. /** Gets or sets the list of views */
  114858. views: EngineView[];
  114859. /**
  114860. * Register a new child canvas
  114861. * @param canvas defines the canvas to register
  114862. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  114863. * @returns the associated view
  114864. */
  114865. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  114866. /**
  114867. * Remove a registered child canvas
  114868. * @param canvas defines the canvas to remove
  114869. * @returns the current engine
  114870. */
  114871. unRegisterView(canvas: HTMLCanvasElement): Engine;
  114872. }
  114873. }
  114874. declare module BABYLON {
  114875. /**
  114876. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  114877. */
  114878. export interface CubeMapInfo {
  114879. /**
  114880. * The pixel array for the front face.
  114881. * This is stored in format, left to right, up to down format.
  114882. */
  114883. front: Nullable<ArrayBufferView>;
  114884. /**
  114885. * The pixel array for the back face.
  114886. * This is stored in format, left to right, up to down format.
  114887. */
  114888. back: Nullable<ArrayBufferView>;
  114889. /**
  114890. * The pixel array for the left face.
  114891. * This is stored in format, left to right, up to down format.
  114892. */
  114893. left: Nullable<ArrayBufferView>;
  114894. /**
  114895. * The pixel array for the right face.
  114896. * This is stored in format, left to right, up to down format.
  114897. */
  114898. right: Nullable<ArrayBufferView>;
  114899. /**
  114900. * The pixel array for the up face.
  114901. * This is stored in format, left to right, up to down format.
  114902. */
  114903. up: Nullable<ArrayBufferView>;
  114904. /**
  114905. * The pixel array for the down face.
  114906. * This is stored in format, left to right, up to down format.
  114907. */
  114908. down: Nullable<ArrayBufferView>;
  114909. /**
  114910. * The size of the cubemap stored.
  114911. *
  114912. * Each faces will be size * size pixels.
  114913. */
  114914. size: number;
  114915. /**
  114916. * The format of the texture.
  114917. *
  114918. * RGBA, RGB.
  114919. */
  114920. format: number;
  114921. /**
  114922. * The type of the texture data.
  114923. *
  114924. * UNSIGNED_INT, FLOAT.
  114925. */
  114926. type: number;
  114927. /**
  114928. * Specifies whether the texture is in gamma space.
  114929. */
  114930. gammaSpace: boolean;
  114931. }
  114932. /**
  114933. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  114934. */
  114935. export class PanoramaToCubeMapTools {
  114936. private static FACE_FRONT;
  114937. private static FACE_BACK;
  114938. private static FACE_RIGHT;
  114939. private static FACE_LEFT;
  114940. private static FACE_DOWN;
  114941. private static FACE_UP;
  114942. /**
  114943. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  114944. *
  114945. * @param float32Array The source data.
  114946. * @param inputWidth The width of the input panorama.
  114947. * @param inputHeight The height of the input panorama.
  114948. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  114949. * @return The cubemap data
  114950. */
  114951. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  114952. private static CreateCubemapTexture;
  114953. private static CalcProjectionSpherical;
  114954. }
  114955. }
  114956. declare module BABYLON {
  114957. /**
  114958. * Helper class dealing with the extraction of spherical polynomial dataArray
  114959. * from a cube map.
  114960. */
  114961. export class CubeMapToSphericalPolynomialTools {
  114962. private static FileFaces;
  114963. /**
  114964. * Converts a texture to the according Spherical Polynomial data.
  114965. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114966. *
  114967. * @param texture The texture to extract the information from.
  114968. * @return The Spherical Polynomial data.
  114969. */
  114970. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  114971. /**
  114972. * Converts a cubemap to the according Spherical Polynomial data.
  114973. * This extracts the first 3 orders only as they are the only one used in the lighting.
  114974. *
  114975. * @param cubeInfo The Cube map to extract the information from.
  114976. * @return The Spherical Polynomial data.
  114977. */
  114978. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  114979. }
  114980. }
  114981. declare module BABYLON {
  114982. interface BaseTexture {
  114983. /**
  114984. * Get the polynomial representation of the texture data.
  114985. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  114986. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  114987. */
  114988. sphericalPolynomial: Nullable<SphericalPolynomial>;
  114989. }
  114990. }
  114991. declare module BABYLON {
  114992. /** @hidden */
  114993. export var rgbdEncodePixelShader: {
  114994. name: string;
  114995. shader: string;
  114996. };
  114997. }
  114998. declare module BABYLON {
  114999. /** @hidden */
  115000. export var rgbdDecodePixelShader: {
  115001. name: string;
  115002. shader: string;
  115003. };
  115004. }
  115005. declare module BABYLON {
  115006. /**
  115007. * Raw texture data and descriptor sufficient for WebGL texture upload
  115008. */
  115009. export interface EnvironmentTextureInfo {
  115010. /**
  115011. * Version of the environment map
  115012. */
  115013. version: number;
  115014. /**
  115015. * Width of image
  115016. */
  115017. width: number;
  115018. /**
  115019. * Irradiance information stored in the file.
  115020. */
  115021. irradiance: any;
  115022. /**
  115023. * Specular information stored in the file.
  115024. */
  115025. specular: any;
  115026. }
  115027. /**
  115028. * Defines One Image in the file. It requires only the position in the file
  115029. * as well as the length.
  115030. */
  115031. interface BufferImageData {
  115032. /**
  115033. * Length of the image data.
  115034. */
  115035. length: number;
  115036. /**
  115037. * Position of the data from the null terminator delimiting the end of the JSON.
  115038. */
  115039. position: number;
  115040. }
  115041. /**
  115042. * Defines the specular data enclosed in the file.
  115043. * This corresponds to the version 1 of the data.
  115044. */
  115045. export interface EnvironmentTextureSpecularInfoV1 {
  115046. /**
  115047. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  115048. */
  115049. specularDataPosition?: number;
  115050. /**
  115051. * This contains all the images data needed to reconstruct the cubemap.
  115052. */
  115053. mipmaps: Array<BufferImageData>;
  115054. /**
  115055. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  115056. */
  115057. lodGenerationScale: number;
  115058. }
  115059. /**
  115060. * Sets of helpers addressing the serialization and deserialization of environment texture
  115061. * stored in a BabylonJS env file.
  115062. * Those files are usually stored as .env files.
  115063. */
  115064. export class EnvironmentTextureTools {
  115065. /**
  115066. * Magic number identifying the env file.
  115067. */
  115068. private static _MagicBytes;
  115069. /**
  115070. * Gets the environment info from an env file.
  115071. * @param data The array buffer containing the .env bytes.
  115072. * @returns the environment file info (the json header) if successfully parsed.
  115073. */
  115074. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  115075. /**
  115076. * Creates an environment texture from a loaded cube texture.
  115077. * @param texture defines the cube texture to convert in env file
  115078. * @return a promise containing the environment data if succesfull.
  115079. */
  115080. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  115081. /**
  115082. * Creates a JSON representation of the spherical data.
  115083. * @param texture defines the texture containing the polynomials
  115084. * @return the JSON representation of the spherical info
  115085. */
  115086. private static _CreateEnvTextureIrradiance;
  115087. /**
  115088. * Creates the ArrayBufferViews used for initializing environment texture image data.
  115089. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  115090. * @param info parameters that determine what views will be created for accessing the underlying buffer
  115091. * @return the views described by info providing access to the underlying buffer
  115092. */
  115093. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  115094. /**
  115095. * Uploads the texture info contained in the env file to the GPU.
  115096. * @param texture defines the internal texture to upload to
  115097. * @param arrayBuffer defines the buffer cotaining the data to load
  115098. * @param info defines the texture info retrieved through the GetEnvInfo method
  115099. * @returns a promise
  115100. */
  115101. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  115102. private static _OnImageReadyAsync;
  115103. /**
  115104. * Uploads the levels of image data to the GPU.
  115105. * @param texture defines the internal texture to upload to
  115106. * @param imageData defines the array buffer views of image data [mipmap][face]
  115107. * @returns a promise
  115108. */
  115109. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  115110. /**
  115111. * Uploads spherical polynomials information to the texture.
  115112. * @param texture defines the texture we are trying to upload the information to
  115113. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  115114. */
  115115. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  115116. /** @hidden */
  115117. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115118. }
  115119. }
  115120. declare module BABYLON {
  115121. /**
  115122. * Contains position and normal vectors for a vertex
  115123. */
  115124. export class PositionNormalVertex {
  115125. /** the position of the vertex (defaut: 0,0,0) */
  115126. position: Vector3;
  115127. /** the normal of the vertex (defaut: 0,1,0) */
  115128. normal: Vector3;
  115129. /**
  115130. * Creates a PositionNormalVertex
  115131. * @param position the position of the vertex (defaut: 0,0,0)
  115132. * @param normal the normal of the vertex (defaut: 0,1,0)
  115133. */
  115134. constructor(
  115135. /** the position of the vertex (defaut: 0,0,0) */
  115136. position?: Vector3,
  115137. /** the normal of the vertex (defaut: 0,1,0) */
  115138. normal?: Vector3);
  115139. /**
  115140. * Clones the PositionNormalVertex
  115141. * @returns the cloned PositionNormalVertex
  115142. */
  115143. clone(): PositionNormalVertex;
  115144. }
  115145. /**
  115146. * Contains position, normal and uv vectors for a vertex
  115147. */
  115148. export class PositionNormalTextureVertex {
  115149. /** the position of the vertex (defaut: 0,0,0) */
  115150. position: Vector3;
  115151. /** the normal of the vertex (defaut: 0,1,0) */
  115152. normal: Vector3;
  115153. /** the uv of the vertex (default: 0,0) */
  115154. uv: Vector2;
  115155. /**
  115156. * Creates a PositionNormalTextureVertex
  115157. * @param position the position of the vertex (defaut: 0,0,0)
  115158. * @param normal the normal of the vertex (defaut: 0,1,0)
  115159. * @param uv the uv of the vertex (default: 0,0)
  115160. */
  115161. constructor(
  115162. /** the position of the vertex (defaut: 0,0,0) */
  115163. position?: Vector3,
  115164. /** the normal of the vertex (defaut: 0,1,0) */
  115165. normal?: Vector3,
  115166. /** the uv of the vertex (default: 0,0) */
  115167. uv?: Vector2);
  115168. /**
  115169. * Clones the PositionNormalTextureVertex
  115170. * @returns the cloned PositionNormalTextureVertex
  115171. */
  115172. clone(): PositionNormalTextureVertex;
  115173. }
  115174. }
  115175. declare module BABYLON {
  115176. /** @hidden */
  115177. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  115178. private _genericAttributeLocation;
  115179. private _varyingLocationCount;
  115180. private _varyingLocationMap;
  115181. private _replacements;
  115182. private _textureCount;
  115183. private _uniforms;
  115184. lineProcessor(line: string): string;
  115185. attributeProcessor(attribute: string): string;
  115186. varyingProcessor(varying: string, isFragment: boolean): string;
  115187. uniformProcessor(uniform: string): string;
  115188. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  115189. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115190. }
  115191. }
  115192. declare module BABYLON {
  115193. /**
  115194. * Container for accessors for natively-stored mesh data buffers.
  115195. */
  115196. class NativeDataBuffer extends DataBuffer {
  115197. /**
  115198. * Accessor value used to identify/retrieve a natively-stored index buffer.
  115199. */
  115200. nativeIndexBuffer?: any;
  115201. /**
  115202. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  115203. */
  115204. nativeVertexBuffer?: any;
  115205. }
  115206. /** @hidden */
  115207. class NativeTexture extends InternalTexture {
  115208. getInternalTexture(): InternalTexture;
  115209. getViewCount(): number;
  115210. }
  115211. /** @hidden */
  115212. export class NativeEngine extends Engine {
  115213. private readonly _native;
  115214. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  115215. private readonly INVALID_HANDLE;
  115216. getHardwareScalingLevel(): number;
  115217. constructor();
  115218. /**
  115219. * Can be used to override the current requestAnimationFrame requester.
  115220. * @hidden
  115221. */
  115222. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115223. /**
  115224. * Override default engine behavior.
  115225. * @param color
  115226. * @param backBuffer
  115227. * @param depth
  115228. * @param stencil
  115229. */
  115230. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115231. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115232. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  115233. createVertexBuffer(data: DataArray): NativeDataBuffer;
  115234. recordVertexArrayObject(vertexBuffers: {
  115235. [key: string]: VertexBuffer;
  115236. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115237. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  115238. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  115239. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115240. /**
  115241. * Draw a list of indexed primitives
  115242. * @param fillMode defines the primitive to use
  115243. * @param indexStart defines the starting index
  115244. * @param indexCount defines the number of index to draw
  115245. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115246. */
  115247. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115248. /**
  115249. * Draw a list of unindexed primitives
  115250. * @param fillMode defines the primitive to use
  115251. * @param verticesStart defines the index of first vertex to draw
  115252. * @param verticesCount defines the count of vertices to draw
  115253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115254. */
  115255. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115256. createPipelineContext(): IPipelineContext;
  115257. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115258. /** @hidden */
  115259. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115260. /** @hidden */
  115261. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115262. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  115263. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  115264. protected _setProgram(program: WebGLProgram): void;
  115265. _releaseEffect(effect: Effect): void;
  115266. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115267. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  115268. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  115269. bindSamplers(effect: Effect): void;
  115270. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  115271. getRenderWidth(useScreen?: boolean): number;
  115272. getRenderHeight(useScreen?: boolean): number;
  115273. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  115274. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  115275. /**
  115276. * Set the z offset to apply to current rendering
  115277. * @param value defines the offset to apply
  115278. */
  115279. setZOffset(value: number): void;
  115280. /**
  115281. * Gets the current value of the zOffset
  115282. * @returns the current zOffset state
  115283. */
  115284. getZOffset(): number;
  115285. /**
  115286. * Enable or disable depth buffering
  115287. * @param enable defines the state to set
  115288. */
  115289. setDepthBuffer(enable: boolean): void;
  115290. /**
  115291. * Gets a boolean indicating if depth writing is enabled
  115292. * @returns the current depth writing state
  115293. */
  115294. getDepthWrite(): boolean;
  115295. /**
  115296. * Enable or disable depth writing
  115297. * @param enable defines the state to set
  115298. */
  115299. setDepthWrite(enable: boolean): void;
  115300. /**
  115301. * Enable or disable color writing
  115302. * @param enable defines the state to set
  115303. */
  115304. setColorWrite(enable: boolean): void;
  115305. /**
  115306. * Gets a boolean indicating if color writing is enabled
  115307. * @returns the current color writing state
  115308. */
  115309. getColorWrite(): boolean;
  115310. /**
  115311. * Sets alpha constants used by some alpha blending modes
  115312. * @param r defines the red component
  115313. * @param g defines the green component
  115314. * @param b defines the blue component
  115315. * @param a defines the alpha component
  115316. */
  115317. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  115318. /**
  115319. * Sets the current alpha mode
  115320. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  115321. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  115322. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115323. */
  115324. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  115325. /**
  115326. * Gets the current alpha mode
  115327. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  115328. * @returns the current alpha mode
  115329. */
  115330. getAlphaMode(): number;
  115331. setInt(uniform: WebGLUniformLocation, int: number): void;
  115332. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  115333. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  115334. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  115335. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  115336. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  115337. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  115338. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  115339. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  115340. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  115341. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  115342. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  115343. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  115344. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  115345. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115346. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  115347. setFloat(uniform: WebGLUniformLocation, value: number): void;
  115348. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  115349. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  115350. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  115351. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  115352. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  115353. wipeCaches(bruteForce?: boolean): void;
  115354. _createTexture(): WebGLTexture;
  115355. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115356. /**
  115357. * Usually called from BABYLON.Texture.ts.
  115358. * Passed information to create a WebGLTexture
  115359. * @param urlArg defines a value which contains one of the following:
  115360. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115361. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115362. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115363. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115364. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  115365. * @param scene needed for loading to the correct scene
  115366. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  115367. * @param onLoad optional callback to be called upon successful completion
  115368. * @param onError optional callback to be called upon failure
  115369. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  115370. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115371. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115372. * @param forcedExtension defines the extension to use to pick the right loader
  115373. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115374. */
  115375. 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;
  115376. /**
  115377. * Creates a cube texture
  115378. * @param rootUrl defines the url where the files to load is located
  115379. * @param scene defines the current scene
  115380. * @param files defines the list of files to load (1 per face)
  115381. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  115382. * @param onLoad defines an optional callback raised when the texture is loaded
  115383. * @param onError defines an optional callback raised if there is an issue to load the texture
  115384. * @param format defines the format of the data
  115385. * @param forcedExtension defines the extension to use to pick the right loader
  115386. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  115387. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115388. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115389. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  115390. * @returns the cube texture as an InternalTexture
  115391. */
  115392. 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;
  115393. private _getSamplingFilter;
  115394. private static _GetNativeTextureFormat;
  115395. createRenderTargetTexture(size: number | {
  115396. width: number;
  115397. height: number;
  115398. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  115399. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  115400. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  115401. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115402. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115403. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115404. /**
  115405. * Updates a dynamic vertex buffer.
  115406. * @param vertexBuffer the vertex buffer to update
  115407. * @param data the data used to update the vertex buffer
  115408. * @param byteOffset the byte offset of the data (optional)
  115409. * @param byteLength the byte length of the data (optional)
  115410. */
  115411. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115412. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115413. private _updateAnisotropicLevel;
  115414. private _getAddressMode;
  115415. /** @hidden */
  115416. _bindTexture(channel: number, texture: InternalTexture): void;
  115417. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  115418. releaseEffects(): void;
  115419. /** @hidden */
  115420. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115421. /** @hidden */
  115422. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115423. /** @hidden */
  115424. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115425. /** @hidden */
  115426. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  115427. }
  115428. }
  115429. declare module BABYLON {
  115430. /**
  115431. * Gather the list of clipboard event types as constants.
  115432. */
  115433. export class ClipboardEventTypes {
  115434. /**
  115435. * The clipboard event is fired when a copy command is active (pressed).
  115436. */
  115437. static readonly COPY: number;
  115438. /**
  115439. * The clipboard event is fired when a cut command is active (pressed).
  115440. */
  115441. static readonly CUT: number;
  115442. /**
  115443. * The clipboard event is fired when a paste command is active (pressed).
  115444. */
  115445. static readonly PASTE: number;
  115446. }
  115447. /**
  115448. * This class is used to store clipboard related info for the onClipboardObservable event.
  115449. */
  115450. export class ClipboardInfo {
  115451. /**
  115452. * Defines the type of event (BABYLON.ClipboardEventTypes)
  115453. */
  115454. type: number;
  115455. /**
  115456. * Defines the related dom event
  115457. */
  115458. event: ClipboardEvent;
  115459. /**
  115460. *Creates an instance of ClipboardInfo.
  115461. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  115462. * @param event Defines the related dom event
  115463. */
  115464. constructor(
  115465. /**
  115466. * Defines the type of event (BABYLON.ClipboardEventTypes)
  115467. */
  115468. type: number,
  115469. /**
  115470. * Defines the related dom event
  115471. */
  115472. event: ClipboardEvent);
  115473. /**
  115474. * Get the clipboard event's type from the keycode.
  115475. * @param keyCode Defines the keyCode for the current keyboard event.
  115476. * @return {number}
  115477. */
  115478. static GetTypeFromCharacter(keyCode: number): number;
  115479. }
  115480. }
  115481. declare module BABYLON {
  115482. /**
  115483. * Google Daydream controller
  115484. */
  115485. export class DaydreamController extends WebVRController {
  115486. /**
  115487. * Base Url for the controller model.
  115488. */
  115489. static MODEL_BASE_URL: string;
  115490. /**
  115491. * File name for the controller model.
  115492. */
  115493. static MODEL_FILENAME: string;
  115494. /**
  115495. * Gamepad Id prefix used to identify Daydream Controller.
  115496. */
  115497. static readonly GAMEPAD_ID_PREFIX: string;
  115498. /**
  115499. * Creates a new DaydreamController from a gamepad
  115500. * @param vrGamepad the gamepad that the controller should be created from
  115501. */
  115502. constructor(vrGamepad: any);
  115503. /**
  115504. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  115505. * @param scene scene in which to add meshes
  115506. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  115507. */
  115508. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  115509. /**
  115510. * Called once for each button that changed state since the last frame
  115511. * @param buttonIdx Which button index changed
  115512. * @param state New state of the button
  115513. * @param changes Which properties on the state changed since last frame
  115514. */
  115515. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115516. }
  115517. }
  115518. declare module BABYLON {
  115519. /**
  115520. * Gear VR Controller
  115521. */
  115522. export class GearVRController extends WebVRController {
  115523. /**
  115524. * Base Url for the controller model.
  115525. */
  115526. static MODEL_BASE_URL: string;
  115527. /**
  115528. * File name for the controller model.
  115529. */
  115530. static MODEL_FILENAME: string;
  115531. /**
  115532. * Gamepad Id prefix used to identify this controller.
  115533. */
  115534. static readonly GAMEPAD_ID_PREFIX: string;
  115535. private readonly _buttonIndexToObservableNameMap;
  115536. /**
  115537. * Creates a new GearVRController from a gamepad
  115538. * @param vrGamepad the gamepad that the controller should be created from
  115539. */
  115540. constructor(vrGamepad: any);
  115541. /**
  115542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  115543. * @param scene scene in which to add meshes
  115544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  115545. */
  115546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  115547. /**
  115548. * Called once for each button that changed state since the last frame
  115549. * @param buttonIdx Which button index changed
  115550. * @param state New state of the button
  115551. * @param changes Which properties on the state changed since last frame
  115552. */
  115553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  115554. }
  115555. }
  115556. declare module BABYLON {
  115557. /**
  115558. * Class containing static functions to help procedurally build meshes
  115559. */
  115560. export class PolyhedronBuilder {
  115561. /**
  115562. * Creates a polyhedron mesh
  115563. * * 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
  115564. * * The parameter `size` (positive float, default 1) sets the polygon size
  115565. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115566. * * 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`
  115567. * * 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
  115568. * * 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)`)
  115569. * * 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
  115570. * * 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
  115571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115574. * @param name defines the name of the mesh
  115575. * @param options defines the options used to create the mesh
  115576. * @param scene defines the hosting scene
  115577. * @returns the polyhedron mesh
  115578. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115579. */
  115580. static CreatePolyhedron(name: string, options: {
  115581. type?: number;
  115582. size?: number;
  115583. sizeX?: number;
  115584. sizeY?: number;
  115585. sizeZ?: number;
  115586. custom?: any;
  115587. faceUV?: Vector4[];
  115588. faceColors?: Color4[];
  115589. flat?: boolean;
  115590. updatable?: boolean;
  115591. sideOrientation?: number;
  115592. frontUVs?: Vector4;
  115593. backUVs?: Vector4;
  115594. }, scene?: Nullable<Scene>): Mesh;
  115595. }
  115596. }
  115597. declare module BABYLON {
  115598. /**
  115599. * Gizmo that enables scaling a mesh along 3 axis
  115600. */
  115601. export class ScaleGizmo extends Gizmo {
  115602. /**
  115603. * Internal gizmo used for interactions on the x axis
  115604. */
  115605. xGizmo: AxisScaleGizmo;
  115606. /**
  115607. * Internal gizmo used for interactions on the y axis
  115608. */
  115609. yGizmo: AxisScaleGizmo;
  115610. /**
  115611. * Internal gizmo used for interactions on the z axis
  115612. */
  115613. zGizmo: AxisScaleGizmo;
  115614. /**
  115615. * Internal gizmo used to scale all axis equally
  115616. */
  115617. uniformScaleGizmo: AxisScaleGizmo;
  115618. private _meshAttached;
  115619. private _updateGizmoRotationToMatchAttachedMesh;
  115620. private _snapDistance;
  115621. private _scaleRatio;
  115622. private _uniformScalingMesh;
  115623. private _octahedron;
  115624. private _sensitivity;
  115625. /** Fires an event when any of it's sub gizmos are dragged */
  115626. onDragStartObservable: Observable<unknown>;
  115627. /** Fires an event when any of it's sub gizmos are released from dragging */
  115628. onDragEndObservable: Observable<unknown>;
  115629. attachedMesh: Nullable<AbstractMesh>;
  115630. /**
  115631. * Creates a ScaleGizmo
  115632. * @param gizmoLayer The utility layer the gizmo will be added to
  115633. */
  115634. constructor(gizmoLayer?: UtilityLayerRenderer);
  115635. updateGizmoRotationToMatchAttachedMesh: boolean;
  115636. /**
  115637. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115638. */
  115639. snapDistance: number;
  115640. /**
  115641. * Ratio for the scale of the gizmo (Default: 1)
  115642. */
  115643. scaleRatio: number;
  115644. /**
  115645. * Sensitivity factor for dragging (Default: 1)
  115646. */
  115647. sensitivity: number;
  115648. /**
  115649. * Disposes of the gizmo
  115650. */
  115651. dispose(): void;
  115652. }
  115653. }
  115654. declare module BABYLON {
  115655. /**
  115656. * Single axis scale gizmo
  115657. */
  115658. export class AxisScaleGizmo extends Gizmo {
  115659. /**
  115660. * Drag behavior responsible for the gizmos dragging interactions
  115661. */
  115662. dragBehavior: PointerDragBehavior;
  115663. private _pointerObserver;
  115664. /**
  115665. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115666. */
  115667. snapDistance: number;
  115668. /**
  115669. * Event that fires each time the gizmo snaps to a new location.
  115670. * * snapDistance is the the change in distance
  115671. */
  115672. onSnapObservable: Observable<{
  115673. snapDistance: number;
  115674. }>;
  115675. /**
  115676. * If the scaling operation should be done on all axis (default: false)
  115677. */
  115678. uniformScaling: boolean;
  115679. /**
  115680. * Custom sensitivity value for the drag strength
  115681. */
  115682. sensitivity: number;
  115683. private _isEnabled;
  115684. private _parent;
  115685. private _arrow;
  115686. private _coloredMaterial;
  115687. private _hoverMaterial;
  115688. /**
  115689. * Creates an AxisScaleGizmo
  115690. * @param gizmoLayer The utility layer the gizmo will be added to
  115691. * @param dragAxis The axis which the gizmo will be able to scale on
  115692. * @param color The color of the gizmo
  115693. */
  115694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  115695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115696. /**
  115697. * If the gizmo is enabled
  115698. */
  115699. isEnabled: boolean;
  115700. /**
  115701. * Disposes of the gizmo
  115702. */
  115703. dispose(): void;
  115704. /**
  115705. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115706. * @param mesh The mesh to replace the default mesh of the gizmo
  115707. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  115708. */
  115709. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  115710. }
  115711. }
  115712. declare module BABYLON {
  115713. /**
  115714. * Bounding box gizmo
  115715. */
  115716. export class BoundingBoxGizmo extends Gizmo {
  115717. private _lineBoundingBox;
  115718. private _rotateSpheresParent;
  115719. private _scaleBoxesParent;
  115720. private _boundingDimensions;
  115721. private _renderObserver;
  115722. private _pointerObserver;
  115723. private _scaleDragSpeed;
  115724. private _tmpQuaternion;
  115725. private _tmpVector;
  115726. private _tmpRotationMatrix;
  115727. /**
  115728. * 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)
  115729. */
  115730. ignoreChildren: boolean;
  115731. /**
  115732. * 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)
  115733. */
  115734. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  115735. /**
  115736. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  115737. */
  115738. rotationSphereSize: number;
  115739. /**
  115740. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  115741. */
  115742. scaleBoxSize: number;
  115743. /**
  115744. * 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)
  115745. */
  115746. fixedDragMeshScreenSize: boolean;
  115747. /**
  115748. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  115749. */
  115750. fixedDragMeshScreenSizeDistanceFactor: number;
  115751. /**
  115752. * Fired when a rotation sphere or scale box is dragged
  115753. */
  115754. onDragStartObservable: Observable<{}>;
  115755. /**
  115756. * Fired when a scale box is dragged
  115757. */
  115758. onScaleBoxDragObservable: Observable<{}>;
  115759. /**
  115760. * Fired when a scale box drag is ended
  115761. */
  115762. onScaleBoxDragEndObservable: Observable<{}>;
  115763. /**
  115764. * Fired when a rotation sphere is dragged
  115765. */
  115766. onRotationSphereDragObservable: Observable<{}>;
  115767. /**
  115768. * Fired when a rotation sphere drag is ended
  115769. */
  115770. onRotationSphereDragEndObservable: Observable<{}>;
  115771. /**
  115772. * 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)
  115773. */
  115774. scalePivot: Nullable<Vector3>;
  115775. /**
  115776. * Mesh used as a pivot to rotate the attached mesh
  115777. */
  115778. private _anchorMesh;
  115779. private _existingMeshScale;
  115780. private _dragMesh;
  115781. private pointerDragBehavior;
  115782. private coloredMaterial;
  115783. private hoverColoredMaterial;
  115784. /**
  115785. * Sets the color of the bounding box gizmo
  115786. * @param color the color to set
  115787. */
  115788. setColor(color: Color3): void;
  115789. /**
  115790. * Creates an BoundingBoxGizmo
  115791. * @param gizmoLayer The utility layer the gizmo will be added to
  115792. * @param color The color of the gizmo
  115793. */
  115794. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  115795. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115796. private _selectNode;
  115797. /**
  115798. * Updates the bounding box information for the Gizmo
  115799. */
  115800. updateBoundingBox(): void;
  115801. private _updateRotationSpheres;
  115802. private _updateScaleBoxes;
  115803. /**
  115804. * Enables rotation on the specified axis and disables rotation on the others
  115805. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  115806. */
  115807. setEnabledRotationAxis(axis: string): void;
  115808. /**
  115809. * Enables/disables scaling
  115810. * @param enable if scaling should be enabled
  115811. */
  115812. setEnabledScaling(enable: boolean): void;
  115813. private _updateDummy;
  115814. /**
  115815. * Enables a pointer drag behavior on the bounding box of the gizmo
  115816. */
  115817. enableDragBehavior(): void;
  115818. /**
  115819. * Disposes of the gizmo
  115820. */
  115821. dispose(): void;
  115822. /**
  115823. * 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)
  115824. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  115825. * @returns the bounding box mesh with the passed in mesh as a child
  115826. */
  115827. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  115828. /**
  115829. * CustomMeshes are not supported by this gizmo
  115830. * @param mesh The mesh to replace the default mesh of the gizmo
  115831. */
  115832. setCustomMesh(mesh: Mesh): void;
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * Single plane rotation gizmo
  115838. */
  115839. export class PlaneRotationGizmo extends Gizmo {
  115840. /**
  115841. * Drag behavior responsible for the gizmos dragging interactions
  115842. */
  115843. dragBehavior: PointerDragBehavior;
  115844. private _pointerObserver;
  115845. /**
  115846. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  115847. */
  115848. snapDistance: number;
  115849. /**
  115850. * Event that fires each time the gizmo snaps to a new location.
  115851. * * snapDistance is the the change in distance
  115852. */
  115853. onSnapObservable: Observable<{
  115854. snapDistance: number;
  115855. }>;
  115856. private _isEnabled;
  115857. private _parent;
  115858. /**
  115859. * Creates a PlaneRotationGizmo
  115860. * @param gizmoLayer The utility layer the gizmo will be added to
  115861. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  115862. * @param color The color of the gizmo
  115863. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115864. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115865. */
  115866. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  115867. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115868. /**
  115869. * If the gizmo is enabled
  115870. */
  115871. isEnabled: boolean;
  115872. /**
  115873. * Disposes of the gizmo
  115874. */
  115875. dispose(): void;
  115876. }
  115877. }
  115878. declare module BABYLON {
  115879. /**
  115880. * Gizmo that enables rotating a mesh along 3 axis
  115881. */
  115882. export class RotationGizmo extends Gizmo {
  115883. /**
  115884. * Internal gizmo used for interactions on the x axis
  115885. */
  115886. xGizmo: PlaneRotationGizmo;
  115887. /**
  115888. * Internal gizmo used for interactions on the y axis
  115889. */
  115890. yGizmo: PlaneRotationGizmo;
  115891. /**
  115892. * Internal gizmo used for interactions on the z axis
  115893. */
  115894. zGizmo: PlaneRotationGizmo;
  115895. /** Fires an event when any of it's sub gizmos are dragged */
  115896. onDragStartObservable: Observable<unknown>;
  115897. /** Fires an event when any of it's sub gizmos are released from dragging */
  115898. onDragEndObservable: Observable<unknown>;
  115899. private _meshAttached;
  115900. attachedMesh: Nullable<AbstractMesh>;
  115901. /**
  115902. * Creates a RotationGizmo
  115903. * @param gizmoLayer The utility layer the gizmo will be added to
  115904. * @param tessellation Amount of tessellation to be used when creating rotation circles
  115905. * @param useEulerRotation Use and update Euler angle instead of quaternion
  115906. */
  115907. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  115908. updateGizmoRotationToMatchAttachedMesh: boolean;
  115909. /**
  115910. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115911. */
  115912. snapDistance: number;
  115913. /**
  115914. * Ratio for the scale of the gizmo (Default: 1)
  115915. */
  115916. scaleRatio: number;
  115917. /**
  115918. * Disposes of the gizmo
  115919. */
  115920. dispose(): void;
  115921. /**
  115922. * CustomMeshes are not supported by this gizmo
  115923. * @param mesh The mesh to replace the default mesh of the gizmo
  115924. */
  115925. setCustomMesh(mesh: Mesh): void;
  115926. }
  115927. }
  115928. declare module BABYLON {
  115929. /**
  115930. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  115931. */
  115932. export class GizmoManager implements IDisposable {
  115933. private scene;
  115934. /**
  115935. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  115936. */
  115937. gizmos: {
  115938. positionGizmo: Nullable<PositionGizmo>;
  115939. rotationGizmo: Nullable<RotationGizmo>;
  115940. scaleGizmo: Nullable<ScaleGizmo>;
  115941. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  115942. };
  115943. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  115944. clearGizmoOnEmptyPointerEvent: boolean;
  115945. /** Fires an event when the manager is attached to a mesh */
  115946. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  115947. private _gizmosEnabled;
  115948. private _pointerObserver;
  115949. private _attachedMesh;
  115950. private _boundingBoxColor;
  115951. private _defaultUtilityLayer;
  115952. private _defaultKeepDepthUtilityLayer;
  115953. /**
  115954. * When bounding box gizmo is enabled, this can be used to track drag/end events
  115955. */
  115956. boundingBoxDragBehavior: SixDofDragBehavior;
  115957. /**
  115958. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  115959. */
  115960. attachableMeshes: Nullable<Array<AbstractMesh>>;
  115961. /**
  115962. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  115963. */
  115964. usePointerToAttachGizmos: boolean;
  115965. /**
  115966. * Utility layer that the bounding box gizmo belongs to
  115967. */
  115968. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  115969. /**
  115970. * Utility layer that all gizmos besides bounding box belong to
  115971. */
  115972. readonly utilityLayer: UtilityLayerRenderer;
  115973. /**
  115974. * Instatiates a gizmo manager
  115975. * @param scene the scene to overlay the gizmos on top of
  115976. */
  115977. constructor(scene: Scene);
  115978. /**
  115979. * Attaches a set of gizmos to the specified mesh
  115980. * @param mesh The mesh the gizmo's should be attached to
  115981. */
  115982. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  115983. /**
  115984. * If the position gizmo is enabled
  115985. */
  115986. positionGizmoEnabled: boolean;
  115987. /**
  115988. * If the rotation gizmo is enabled
  115989. */
  115990. rotationGizmoEnabled: boolean;
  115991. /**
  115992. * If the scale gizmo is enabled
  115993. */
  115994. scaleGizmoEnabled: boolean;
  115995. /**
  115996. * If the boundingBox gizmo is enabled
  115997. */
  115998. boundingBoxGizmoEnabled: boolean;
  115999. /**
  116000. * Disposes of the gizmo manager
  116001. */
  116002. dispose(): void;
  116003. }
  116004. }
  116005. declare module BABYLON {
  116006. /**
  116007. * A directional light is defined by a direction (what a surprise!).
  116008. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  116009. * 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.
  116010. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116011. */
  116012. export class DirectionalLight extends ShadowLight {
  116013. private _shadowFrustumSize;
  116014. /**
  116015. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  116016. */
  116017. /**
  116018. * Specifies a fix frustum size for the shadow generation.
  116019. */
  116020. shadowFrustumSize: number;
  116021. private _shadowOrthoScale;
  116022. /**
  116023. * Gets the shadow projection scale against the optimal computed one.
  116024. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  116025. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  116026. */
  116027. /**
  116028. * Sets the shadow projection scale against the optimal computed one.
  116029. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  116030. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  116031. */
  116032. shadowOrthoScale: number;
  116033. /**
  116034. * Automatically compute the projection matrix to best fit (including all the casters)
  116035. * on each frame.
  116036. */
  116037. autoUpdateExtends: boolean;
  116038. private _orthoLeft;
  116039. private _orthoRight;
  116040. private _orthoTop;
  116041. private _orthoBottom;
  116042. /**
  116043. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  116044. * The directional light is emitted from everywhere in the given direction.
  116045. * It can cast shadows.
  116046. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116047. * @param name The friendly name of the light
  116048. * @param direction The direction of the light
  116049. * @param scene The scene the light belongs to
  116050. */
  116051. constructor(name: string, direction: Vector3, scene: Scene);
  116052. /**
  116053. * Returns the string "DirectionalLight".
  116054. * @return The class name
  116055. */
  116056. getClassName(): string;
  116057. /**
  116058. * Returns the integer 1.
  116059. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116060. */
  116061. getTypeID(): number;
  116062. /**
  116063. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  116064. * Returns the DirectionalLight Shadow projection matrix.
  116065. */
  116066. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116067. /**
  116068. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  116069. * Returns the DirectionalLight Shadow projection matrix.
  116070. */
  116071. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  116072. /**
  116073. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  116074. * Returns the DirectionalLight Shadow projection matrix.
  116075. */
  116076. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116077. protected _buildUniformLayout(): void;
  116078. /**
  116079. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  116080. * @param effect The effect to update
  116081. * @param lightIndex The index of the light in the effect to update
  116082. * @returns The directional light
  116083. */
  116084. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  116085. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  116086. /**
  116087. * Gets the minZ used for shadow according to both the scene and the light.
  116088. *
  116089. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  116090. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  116091. * @param activeCamera The camera we are returning the min for
  116092. * @returns the depth min z
  116093. */
  116094. getDepthMinZ(activeCamera: Camera): number;
  116095. /**
  116096. * Gets the maxZ used for shadow according to both the scene and the light.
  116097. *
  116098. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  116099. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  116100. * @param activeCamera The camera we are returning the max for
  116101. * @returns the depth max z
  116102. */
  116103. getDepthMaxZ(activeCamera: Camera): number;
  116104. /**
  116105. * Prepares the list of defines specific to the light type.
  116106. * @param defines the list of defines
  116107. * @param lightIndex defines the index of the light for the effect
  116108. */
  116109. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116110. }
  116111. }
  116112. declare module BABYLON {
  116113. /**
  116114. * Class containing static functions to help procedurally build meshes
  116115. */
  116116. export class HemisphereBuilder {
  116117. /**
  116118. * Creates a hemisphere mesh
  116119. * @param name defines the name of the mesh
  116120. * @param options defines the options used to create the mesh
  116121. * @param scene defines the hosting scene
  116122. * @returns the hemisphere mesh
  116123. */
  116124. static CreateHemisphere(name: string, options: {
  116125. segments?: number;
  116126. diameter?: number;
  116127. sideOrientation?: number;
  116128. }, scene: any): Mesh;
  116129. }
  116130. }
  116131. declare module BABYLON {
  116132. /**
  116133. * A spot light is defined by a position, a direction, an angle, and an exponent.
  116134. * These values define a cone of light starting from the position, emitting toward the direction.
  116135. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  116136. * and the exponent defines the speed of the decay of the light with distance (reach).
  116137. * Documentation: https://doc.babylonjs.com/babylon101/lights
  116138. */
  116139. export class SpotLight extends ShadowLight {
  116140. private _angle;
  116141. private _innerAngle;
  116142. private _cosHalfAngle;
  116143. private _lightAngleScale;
  116144. private _lightAngleOffset;
  116145. /**
  116146. * Gets the cone angle of the spot light in Radians.
  116147. */
  116148. /**
  116149. * Sets the cone angle of the spot light in Radians.
  116150. */
  116151. angle: number;
  116152. /**
  116153. * Only used in gltf falloff mode, this defines the angle where
  116154. * the directional falloff will start before cutting at angle which could be seen
  116155. * as outer angle.
  116156. */
  116157. /**
  116158. * Only used in gltf falloff mode, this defines the angle where
  116159. * the directional falloff will start before cutting at angle which could be seen
  116160. * as outer angle.
  116161. */
  116162. innerAngle: number;
  116163. private _shadowAngleScale;
  116164. /**
  116165. * Allows scaling the angle of the light for shadow generation only.
  116166. */
  116167. /**
  116168. * Allows scaling the angle of the light for shadow generation only.
  116169. */
  116170. shadowAngleScale: number;
  116171. /**
  116172. * The light decay speed with the distance from the emission spot.
  116173. */
  116174. exponent: number;
  116175. private _projectionTextureMatrix;
  116176. /**
  116177. * Allows reading the projecton texture
  116178. */
  116179. readonly projectionTextureMatrix: Matrix;
  116180. protected _projectionTextureLightNear: number;
  116181. /**
  116182. * Gets the near clip of the Spotlight for texture projection.
  116183. */
  116184. /**
  116185. * Sets the near clip of the Spotlight for texture projection.
  116186. */
  116187. projectionTextureLightNear: number;
  116188. protected _projectionTextureLightFar: number;
  116189. /**
  116190. * Gets the far clip of the Spotlight for texture projection.
  116191. */
  116192. /**
  116193. * Sets the far clip of the Spotlight for texture projection.
  116194. */
  116195. projectionTextureLightFar: number;
  116196. protected _projectionTextureUpDirection: Vector3;
  116197. /**
  116198. * Gets the Up vector of the Spotlight for texture projection.
  116199. */
  116200. /**
  116201. * Sets the Up vector of the Spotlight for texture projection.
  116202. */
  116203. projectionTextureUpDirection: Vector3;
  116204. private _projectionTexture;
  116205. /**
  116206. * Gets the projection texture of the light.
  116207. */
  116208. /**
  116209. * Sets the projection texture of the light.
  116210. */
  116211. projectionTexture: Nullable<BaseTexture>;
  116212. private _projectionTextureViewLightDirty;
  116213. private _projectionTextureProjectionLightDirty;
  116214. private _projectionTextureDirty;
  116215. private _projectionTextureViewTargetVector;
  116216. private _projectionTextureViewLightMatrix;
  116217. private _projectionTextureProjectionLightMatrix;
  116218. private _projectionTextureScalingMatrix;
  116219. /**
  116220. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  116221. * It can cast shadows.
  116222. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116223. * @param name The light friendly name
  116224. * @param position The position of the spot light in the scene
  116225. * @param direction The direction of the light in the scene
  116226. * @param angle The cone angle of the light in Radians
  116227. * @param exponent The light decay speed with the distance from the emission spot
  116228. * @param scene The scene the lights belongs to
  116229. */
  116230. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  116231. /**
  116232. * Returns the string "SpotLight".
  116233. * @returns the class name
  116234. */
  116235. getClassName(): string;
  116236. /**
  116237. * Returns the integer 2.
  116238. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116239. */
  116240. getTypeID(): number;
  116241. /**
  116242. * Overrides the direction setter to recompute the projection texture view light Matrix.
  116243. */
  116244. protected _setDirection(value: Vector3): void;
  116245. /**
  116246. * Overrides the position setter to recompute the projection texture view light Matrix.
  116247. */
  116248. protected _setPosition(value: Vector3): void;
  116249. /**
  116250. * 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.
  116251. * Returns the SpotLight.
  116252. */
  116253. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116254. protected _computeProjectionTextureViewLightMatrix(): void;
  116255. protected _computeProjectionTextureProjectionLightMatrix(): void;
  116256. /**
  116257. * Main function for light texture projection matrix computing.
  116258. */
  116259. protected _computeProjectionTextureMatrix(): void;
  116260. protected _buildUniformLayout(): void;
  116261. private _computeAngleValues;
  116262. /**
  116263. * Sets the passed Effect "effect" with the Light textures.
  116264. * @param effect The effect to update
  116265. * @param lightIndex The index of the light in the effect to update
  116266. * @returns The light
  116267. */
  116268. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  116269. /**
  116270. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  116271. * @param effect The effect to update
  116272. * @param lightIndex The index of the light in the effect to update
  116273. * @returns The spot light
  116274. */
  116275. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  116276. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116277. /**
  116278. * Disposes the light and the associated resources.
  116279. */
  116280. dispose(): void;
  116281. /**
  116282. * Prepares the list of defines specific to the light type.
  116283. * @param defines the list of defines
  116284. * @param lightIndex defines the index of the light for the effect
  116285. */
  116286. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116287. }
  116288. }
  116289. declare module BABYLON {
  116290. /**
  116291. * Gizmo that enables viewing a light
  116292. */
  116293. export class LightGizmo extends Gizmo {
  116294. private _lightMesh;
  116295. private _material;
  116296. private _cachedPosition;
  116297. private _cachedForward;
  116298. private _attachedMeshParent;
  116299. /**
  116300. * Creates a LightGizmo
  116301. * @param gizmoLayer The utility layer the gizmo will be added to
  116302. */
  116303. constructor(gizmoLayer?: UtilityLayerRenderer);
  116304. private _light;
  116305. /**
  116306. * The light that the gizmo is attached to
  116307. */
  116308. light: Nullable<Light>;
  116309. /**
  116310. * Gets the material used to render the light gizmo
  116311. */
  116312. readonly material: StandardMaterial;
  116313. /**
  116314. * @hidden
  116315. * Updates the gizmo to match the attached mesh's position/rotation
  116316. */
  116317. protected _update(): void;
  116318. private static _Scale;
  116319. /**
  116320. * Creates the lines for a light mesh
  116321. */
  116322. private static _CreateLightLines;
  116323. /**
  116324. * Disposes of the light gizmo
  116325. */
  116326. dispose(): void;
  116327. private static _CreateHemisphericLightMesh;
  116328. private static _CreatePointLightMesh;
  116329. private static _CreateSpotLightMesh;
  116330. private static _CreateDirectionalLightMesh;
  116331. }
  116332. }
  116333. declare module BABYLON {
  116334. /** @hidden */
  116335. export var backgroundFragmentDeclaration: {
  116336. name: string;
  116337. shader: string;
  116338. };
  116339. }
  116340. declare module BABYLON {
  116341. /** @hidden */
  116342. export var backgroundUboDeclaration: {
  116343. name: string;
  116344. shader: string;
  116345. };
  116346. }
  116347. declare module BABYLON {
  116348. /** @hidden */
  116349. export var backgroundPixelShader: {
  116350. name: string;
  116351. shader: string;
  116352. };
  116353. }
  116354. declare module BABYLON {
  116355. /** @hidden */
  116356. export var backgroundVertexDeclaration: {
  116357. name: string;
  116358. shader: string;
  116359. };
  116360. }
  116361. declare module BABYLON {
  116362. /** @hidden */
  116363. export var backgroundVertexShader: {
  116364. name: string;
  116365. shader: string;
  116366. };
  116367. }
  116368. declare module BABYLON {
  116369. /**
  116370. * Background material used to create an efficient environement around your scene.
  116371. */
  116372. export class BackgroundMaterial extends PushMaterial {
  116373. /**
  116374. * Standard reflectance value at parallel view angle.
  116375. */
  116376. static StandardReflectance0: number;
  116377. /**
  116378. * Standard reflectance value at grazing angle.
  116379. */
  116380. static StandardReflectance90: number;
  116381. protected _primaryColor: Color3;
  116382. /**
  116383. * Key light Color (multiply against the environement texture)
  116384. */
  116385. primaryColor: Color3;
  116386. protected __perceptualColor: Nullable<Color3>;
  116387. /**
  116388. * Experimental Internal Use Only.
  116389. *
  116390. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  116391. * This acts as a helper to set the primary color to a more "human friendly" value.
  116392. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  116393. * output color as close as possible from the chosen value.
  116394. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  116395. * part of lighting setup.)
  116396. */
  116397. _perceptualColor: Nullable<Color3>;
  116398. protected _primaryColorShadowLevel: float;
  116399. /**
  116400. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  116401. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  116402. */
  116403. primaryColorShadowLevel: float;
  116404. protected _primaryColorHighlightLevel: float;
  116405. /**
  116406. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  116407. * The primary color is used at the level chosen to define what the white area would look.
  116408. */
  116409. primaryColorHighlightLevel: float;
  116410. protected _reflectionTexture: Nullable<BaseTexture>;
  116411. /**
  116412. * Reflection Texture used in the material.
  116413. * Should be author in a specific way for the best result (refer to the documentation).
  116414. */
  116415. reflectionTexture: Nullable<BaseTexture>;
  116416. protected _reflectionBlur: float;
  116417. /**
  116418. * Reflection Texture level of blur.
  116419. *
  116420. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  116421. * texture twice.
  116422. */
  116423. reflectionBlur: float;
  116424. protected _diffuseTexture: Nullable<BaseTexture>;
  116425. /**
  116426. * Diffuse Texture used in the material.
  116427. * Should be author in a specific way for the best result (refer to the documentation).
  116428. */
  116429. diffuseTexture: Nullable<BaseTexture>;
  116430. protected _shadowLights: Nullable<IShadowLight[]>;
  116431. /**
  116432. * Specify the list of lights casting shadow on the material.
  116433. * All scene shadow lights will be included if null.
  116434. */
  116435. shadowLights: Nullable<IShadowLight[]>;
  116436. protected _shadowLevel: float;
  116437. /**
  116438. * Helps adjusting the shadow to a softer level if required.
  116439. * 0 means black shadows and 1 means no shadows.
  116440. */
  116441. shadowLevel: float;
  116442. protected _sceneCenter: Vector3;
  116443. /**
  116444. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  116445. * It is usually zero but might be interesting to modify according to your setup.
  116446. */
  116447. sceneCenter: Vector3;
  116448. protected _opacityFresnel: boolean;
  116449. /**
  116450. * This helps specifying that the material is falling off to the sky box at grazing angle.
  116451. * This helps ensuring a nice transition when the camera goes under the ground.
  116452. */
  116453. opacityFresnel: boolean;
  116454. protected _reflectionFresnel: boolean;
  116455. /**
  116456. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  116457. * This helps adding a mirror texture on the ground.
  116458. */
  116459. reflectionFresnel: boolean;
  116460. protected _reflectionFalloffDistance: number;
  116461. /**
  116462. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  116463. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  116464. */
  116465. reflectionFalloffDistance: number;
  116466. protected _reflectionAmount: number;
  116467. /**
  116468. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  116469. */
  116470. reflectionAmount: number;
  116471. protected _reflectionReflectance0: number;
  116472. /**
  116473. * This specifies the weight of the reflection at grazing angle.
  116474. */
  116475. reflectionReflectance0: number;
  116476. protected _reflectionReflectance90: number;
  116477. /**
  116478. * This specifies the weight of the reflection at a perpendicular point of view.
  116479. */
  116480. reflectionReflectance90: number;
  116481. /**
  116482. * Sets the reflection reflectance fresnel values according to the default standard
  116483. * empirically know to work well :-)
  116484. */
  116485. reflectionStandardFresnelWeight: number;
  116486. protected _useRGBColor: boolean;
  116487. /**
  116488. * Helps to directly use the maps channels instead of their level.
  116489. */
  116490. useRGBColor: boolean;
  116491. protected _enableNoise: boolean;
  116492. /**
  116493. * This helps reducing the banding effect that could occur on the background.
  116494. */
  116495. enableNoise: boolean;
  116496. /**
  116497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  116498. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  116499. * Recommended to be keep at 1.0 except for special cases.
  116500. */
  116501. fovMultiplier: number;
  116502. private _fovMultiplier;
  116503. /**
  116504. * Enable the FOV adjustment feature controlled by fovMultiplier.
  116505. */
  116506. useEquirectangularFOV: boolean;
  116507. private _maxSimultaneousLights;
  116508. /**
  116509. * Number of Simultaneous lights allowed on the material.
  116510. */
  116511. maxSimultaneousLights: int;
  116512. /**
  116513. * Default configuration related to image processing available in the Background Material.
  116514. */
  116515. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116516. /**
  116517. * Keep track of the image processing observer to allow dispose and replace.
  116518. */
  116519. private _imageProcessingObserver;
  116520. /**
  116521. * Attaches a new image processing configuration to the PBR Material.
  116522. * @param configuration (if null the scene configuration will be use)
  116523. */
  116524. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  116525. /**
  116526. * Gets the image processing configuration used either in this material.
  116527. */
  116528. /**
  116529. * Sets the Default image processing configuration used either in the this material.
  116530. *
  116531. * If sets to null, the scene one is in use.
  116532. */
  116533. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  116534. /**
  116535. * Gets wether the color curves effect is enabled.
  116536. */
  116537. /**
  116538. * Sets wether the color curves effect is enabled.
  116539. */
  116540. cameraColorCurvesEnabled: boolean;
  116541. /**
  116542. * Gets wether the color grading effect is enabled.
  116543. */
  116544. /**
  116545. * Gets wether the color grading effect is enabled.
  116546. */
  116547. cameraColorGradingEnabled: boolean;
  116548. /**
  116549. * Gets wether tonemapping is enabled or not.
  116550. */
  116551. /**
  116552. * Sets wether tonemapping is enabled or not
  116553. */
  116554. cameraToneMappingEnabled: boolean;
  116555. /**
  116556. * The camera exposure used on this material.
  116557. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116558. * This corresponds to a photographic exposure.
  116559. */
  116560. /**
  116561. * The camera exposure used on this material.
  116562. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  116563. * This corresponds to a photographic exposure.
  116564. */
  116565. cameraExposure: float;
  116566. /**
  116567. * Gets The camera contrast used on this material.
  116568. */
  116569. /**
  116570. * Sets The camera contrast used on this material.
  116571. */
  116572. cameraContrast: float;
  116573. /**
  116574. * Gets the Color Grading 2D Lookup Texture.
  116575. */
  116576. /**
  116577. * Sets the Color Grading 2D Lookup Texture.
  116578. */
  116579. cameraColorGradingTexture: Nullable<BaseTexture>;
  116580. /**
  116581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116583. * 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;
  116584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116585. */
  116586. /**
  116587. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  116588. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  116589. * 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;
  116590. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  116591. */
  116592. cameraColorCurves: Nullable<ColorCurves>;
  116593. /**
  116594. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  116595. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  116596. */
  116597. switchToBGR: boolean;
  116598. private _renderTargets;
  116599. private _reflectionControls;
  116600. private _white;
  116601. private _primaryShadowColor;
  116602. private _primaryHighlightColor;
  116603. /**
  116604. * Instantiates a Background Material in the given scene
  116605. * @param name The friendly name of the material
  116606. * @param scene The scene to add the material to
  116607. */
  116608. constructor(name: string, scene: Scene);
  116609. /**
  116610. * Gets a boolean indicating that current material needs to register RTT
  116611. */
  116612. readonly hasRenderTargetTextures: boolean;
  116613. /**
  116614. * The entire material has been created in order to prevent overdraw.
  116615. * @returns false
  116616. */
  116617. needAlphaTesting(): boolean;
  116618. /**
  116619. * The entire material has been created in order to prevent overdraw.
  116620. * @returns true if blending is enable
  116621. */
  116622. needAlphaBlending(): boolean;
  116623. /**
  116624. * Checks wether the material is ready to be rendered for a given mesh.
  116625. * @param mesh The mesh to render
  116626. * @param subMesh The submesh to check against
  116627. * @param useInstances Specify wether or not the material is used with instances
  116628. * @returns true if all the dependencies are ready (Textures, Effects...)
  116629. */
  116630. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  116631. /**
  116632. * Compute the primary color according to the chosen perceptual color.
  116633. */
  116634. private _computePrimaryColorFromPerceptualColor;
  116635. /**
  116636. * Compute the highlights and shadow colors according to their chosen levels.
  116637. */
  116638. private _computePrimaryColors;
  116639. /**
  116640. * Build the uniform buffer used in the material.
  116641. */
  116642. buildUniformLayout(): void;
  116643. /**
  116644. * Unbind the material.
  116645. */
  116646. unbind(): void;
  116647. /**
  116648. * Bind only the world matrix to the material.
  116649. * @param world The world matrix to bind.
  116650. */
  116651. bindOnlyWorldMatrix(world: Matrix): void;
  116652. /**
  116653. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  116654. * @param world The world matrix to bind.
  116655. * @param subMesh The submesh to bind for.
  116656. */
  116657. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116658. /**
  116659. * Checks to see if a texture is used in the material.
  116660. * @param texture - Base texture to use.
  116661. * @returns - Boolean specifying if a texture is used in the material.
  116662. */
  116663. hasTexture(texture: BaseTexture): boolean;
  116664. /**
  116665. * Dispose the material.
  116666. * @param forceDisposeEffect Force disposal of the associated effect.
  116667. * @param forceDisposeTextures Force disposal of the associated textures.
  116668. */
  116669. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  116670. /**
  116671. * Clones the material.
  116672. * @param name The cloned name.
  116673. * @returns The cloned material.
  116674. */
  116675. clone(name: string): BackgroundMaterial;
  116676. /**
  116677. * Serializes the current material to its JSON representation.
  116678. * @returns The JSON representation.
  116679. */
  116680. serialize(): any;
  116681. /**
  116682. * Gets the class name of the material
  116683. * @returns "BackgroundMaterial"
  116684. */
  116685. getClassName(): string;
  116686. /**
  116687. * Parse a JSON input to create back a background material.
  116688. * @param source The JSON data to parse
  116689. * @param scene The scene to create the parsed material in
  116690. * @param rootUrl The root url of the assets the material depends upon
  116691. * @returns the instantiated BackgroundMaterial.
  116692. */
  116693. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  116694. }
  116695. }
  116696. declare module BABYLON {
  116697. /**
  116698. * Represents the different options available during the creation of
  116699. * a Environment helper.
  116700. *
  116701. * This can control the default ground, skybox and image processing setup of your scene.
  116702. */
  116703. export interface IEnvironmentHelperOptions {
  116704. /**
  116705. * Specifies wether or not to create a ground.
  116706. * True by default.
  116707. */
  116708. createGround: boolean;
  116709. /**
  116710. * Specifies the ground size.
  116711. * 15 by default.
  116712. */
  116713. groundSize: number;
  116714. /**
  116715. * The texture used on the ground for the main color.
  116716. * Comes from the BabylonJS CDN by default.
  116717. *
  116718. * Remarks: Can be either a texture or a url.
  116719. */
  116720. groundTexture: string | BaseTexture;
  116721. /**
  116722. * The color mixed in the ground texture by default.
  116723. * BabylonJS clearColor by default.
  116724. */
  116725. groundColor: Color3;
  116726. /**
  116727. * Specifies the ground opacity.
  116728. * 1 by default.
  116729. */
  116730. groundOpacity: number;
  116731. /**
  116732. * Enables the ground to receive shadows.
  116733. * True by default.
  116734. */
  116735. enableGroundShadow: boolean;
  116736. /**
  116737. * Helps preventing the shadow to be fully black on the ground.
  116738. * 0.5 by default.
  116739. */
  116740. groundShadowLevel: number;
  116741. /**
  116742. * Creates a mirror texture attach to the ground.
  116743. * false by default.
  116744. */
  116745. enableGroundMirror: boolean;
  116746. /**
  116747. * Specifies the ground mirror size ratio.
  116748. * 0.3 by default as the default kernel is 64.
  116749. */
  116750. groundMirrorSizeRatio: number;
  116751. /**
  116752. * Specifies the ground mirror blur kernel size.
  116753. * 64 by default.
  116754. */
  116755. groundMirrorBlurKernel: number;
  116756. /**
  116757. * Specifies the ground mirror visibility amount.
  116758. * 1 by default
  116759. */
  116760. groundMirrorAmount: number;
  116761. /**
  116762. * Specifies the ground mirror reflectance weight.
  116763. * This uses the standard weight of the background material to setup the fresnel effect
  116764. * of the mirror.
  116765. * 1 by default.
  116766. */
  116767. groundMirrorFresnelWeight: number;
  116768. /**
  116769. * Specifies the ground mirror Falloff distance.
  116770. * This can helps reducing the size of the reflection.
  116771. * 0 by Default.
  116772. */
  116773. groundMirrorFallOffDistance: number;
  116774. /**
  116775. * Specifies the ground mirror texture type.
  116776. * Unsigned Int by Default.
  116777. */
  116778. groundMirrorTextureType: number;
  116779. /**
  116780. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  116781. * the shown objects.
  116782. */
  116783. groundYBias: number;
  116784. /**
  116785. * Specifies wether or not to create a skybox.
  116786. * True by default.
  116787. */
  116788. createSkybox: boolean;
  116789. /**
  116790. * Specifies the skybox size.
  116791. * 20 by default.
  116792. */
  116793. skyboxSize: number;
  116794. /**
  116795. * The texture used on the skybox for the main color.
  116796. * Comes from the BabylonJS CDN by default.
  116797. *
  116798. * Remarks: Can be either a texture or a url.
  116799. */
  116800. skyboxTexture: string | BaseTexture;
  116801. /**
  116802. * The color mixed in the skybox texture by default.
  116803. * BabylonJS clearColor by default.
  116804. */
  116805. skyboxColor: Color3;
  116806. /**
  116807. * The background rotation around the Y axis of the scene.
  116808. * This helps aligning the key lights of your scene with the background.
  116809. * 0 by default.
  116810. */
  116811. backgroundYRotation: number;
  116812. /**
  116813. * Compute automatically the size of the elements to best fit with the scene.
  116814. */
  116815. sizeAuto: boolean;
  116816. /**
  116817. * Default position of the rootMesh if autoSize is not true.
  116818. */
  116819. rootPosition: Vector3;
  116820. /**
  116821. * Sets up the image processing in the scene.
  116822. * true by default.
  116823. */
  116824. setupImageProcessing: boolean;
  116825. /**
  116826. * The texture used as your environment texture in the scene.
  116827. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  116828. *
  116829. * Remarks: Can be either a texture or a url.
  116830. */
  116831. environmentTexture: string | BaseTexture;
  116832. /**
  116833. * The value of the exposure to apply to the scene.
  116834. * 0.6 by default if setupImageProcessing is true.
  116835. */
  116836. cameraExposure: number;
  116837. /**
  116838. * The value of the contrast to apply to the scene.
  116839. * 1.6 by default if setupImageProcessing is true.
  116840. */
  116841. cameraContrast: number;
  116842. /**
  116843. * Specifies wether or not tonemapping should be enabled in the scene.
  116844. * true by default if setupImageProcessing is true.
  116845. */
  116846. toneMappingEnabled: boolean;
  116847. }
  116848. /**
  116849. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  116850. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  116851. * It also helps with the default setup of your imageProcessing configuration.
  116852. */
  116853. export class EnvironmentHelper {
  116854. /**
  116855. * Default ground texture URL.
  116856. */
  116857. private static _groundTextureCDNUrl;
  116858. /**
  116859. * Default skybox texture URL.
  116860. */
  116861. private static _skyboxTextureCDNUrl;
  116862. /**
  116863. * Default environment texture URL.
  116864. */
  116865. private static _environmentTextureCDNUrl;
  116866. /**
  116867. * Creates the default options for the helper.
  116868. */
  116869. private static _getDefaultOptions;
  116870. private _rootMesh;
  116871. /**
  116872. * Gets the root mesh created by the helper.
  116873. */
  116874. readonly rootMesh: Mesh;
  116875. private _skybox;
  116876. /**
  116877. * Gets the skybox created by the helper.
  116878. */
  116879. readonly skybox: Nullable<Mesh>;
  116880. private _skyboxTexture;
  116881. /**
  116882. * Gets the skybox texture created by the helper.
  116883. */
  116884. readonly skyboxTexture: Nullable<BaseTexture>;
  116885. private _skyboxMaterial;
  116886. /**
  116887. * Gets the skybox material created by the helper.
  116888. */
  116889. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  116890. private _ground;
  116891. /**
  116892. * Gets the ground mesh created by the helper.
  116893. */
  116894. readonly ground: Nullable<Mesh>;
  116895. private _groundTexture;
  116896. /**
  116897. * Gets the ground texture created by the helper.
  116898. */
  116899. readonly groundTexture: Nullable<BaseTexture>;
  116900. private _groundMirror;
  116901. /**
  116902. * Gets the ground mirror created by the helper.
  116903. */
  116904. readonly groundMirror: Nullable<MirrorTexture>;
  116905. /**
  116906. * Gets the ground mirror render list to helps pushing the meshes
  116907. * you wish in the ground reflection.
  116908. */
  116909. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  116910. private _groundMaterial;
  116911. /**
  116912. * Gets the ground material created by the helper.
  116913. */
  116914. readonly groundMaterial: Nullable<BackgroundMaterial>;
  116915. /**
  116916. * Stores the creation options.
  116917. */
  116918. private readonly _scene;
  116919. private _options;
  116920. /**
  116921. * This observable will be notified with any error during the creation of the environment,
  116922. * mainly texture creation errors.
  116923. */
  116924. onErrorObservable: Observable<{
  116925. message?: string;
  116926. exception?: any;
  116927. }>;
  116928. /**
  116929. * constructor
  116930. * @param options Defines the options we want to customize the helper
  116931. * @param scene The scene to add the material to
  116932. */
  116933. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  116934. /**
  116935. * Updates the background according to the new options
  116936. * @param options
  116937. */
  116938. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  116939. /**
  116940. * Sets the primary color of all the available elements.
  116941. * @param color the main color to affect to the ground and the background
  116942. */
  116943. setMainColor(color: Color3): void;
  116944. /**
  116945. * Setup the image processing according to the specified options.
  116946. */
  116947. private _setupImageProcessing;
  116948. /**
  116949. * Setup the environment texture according to the specified options.
  116950. */
  116951. private _setupEnvironmentTexture;
  116952. /**
  116953. * Setup the background according to the specified options.
  116954. */
  116955. private _setupBackground;
  116956. /**
  116957. * Get the scene sizes according to the setup.
  116958. */
  116959. private _getSceneSize;
  116960. /**
  116961. * Setup the ground according to the specified options.
  116962. */
  116963. private _setupGround;
  116964. /**
  116965. * Setup the ground material according to the specified options.
  116966. */
  116967. private _setupGroundMaterial;
  116968. /**
  116969. * Setup the ground diffuse texture according to the specified options.
  116970. */
  116971. private _setupGroundDiffuseTexture;
  116972. /**
  116973. * Setup the ground mirror texture according to the specified options.
  116974. */
  116975. private _setupGroundMirrorTexture;
  116976. /**
  116977. * Setup the ground to receive the mirror texture.
  116978. */
  116979. private _setupMirrorInGroundMaterial;
  116980. /**
  116981. * Setup the skybox according to the specified options.
  116982. */
  116983. private _setupSkybox;
  116984. /**
  116985. * Setup the skybox material according to the specified options.
  116986. */
  116987. private _setupSkyboxMaterial;
  116988. /**
  116989. * Setup the skybox reflection texture according to the specified options.
  116990. */
  116991. private _setupSkyboxReflectionTexture;
  116992. private _errorHandler;
  116993. /**
  116994. * Dispose all the elements created by the Helper.
  116995. */
  116996. dispose(): void;
  116997. }
  116998. }
  116999. declare module BABYLON {
  117000. /**
  117001. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  117002. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  117003. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  117004. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  117005. */
  117006. export class PhotoDome extends TransformNode {
  117007. /**
  117008. * Define the image as a Monoscopic panoramic 360 image.
  117009. */
  117010. static readonly MODE_MONOSCOPIC: number;
  117011. /**
  117012. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  117013. */
  117014. static readonly MODE_TOPBOTTOM: number;
  117015. /**
  117016. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  117017. */
  117018. static readonly MODE_SIDEBYSIDE: number;
  117019. private _useDirectMapping;
  117020. /**
  117021. * The texture being displayed on the sphere
  117022. */
  117023. protected _photoTexture: Texture;
  117024. /**
  117025. * Gets or sets the texture being displayed on the sphere
  117026. */
  117027. photoTexture: Texture;
  117028. /**
  117029. * Observable raised when an error occured while loading the 360 image
  117030. */
  117031. onLoadErrorObservable: Observable<string>;
  117032. /**
  117033. * The skybox material
  117034. */
  117035. protected _material: BackgroundMaterial;
  117036. /**
  117037. * The surface used for the skybox
  117038. */
  117039. protected _mesh: Mesh;
  117040. /**
  117041. * Gets the mesh used for the skybox.
  117042. */
  117043. readonly mesh: Mesh;
  117044. /**
  117045. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  117046. * Also see the options.resolution property.
  117047. */
  117048. fovMultiplier: number;
  117049. private _imageMode;
  117050. /**
  117051. * Gets or set the current video mode for the video. It can be:
  117052. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  117053. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  117054. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  117055. */
  117056. imageMode: number;
  117057. /**
  117058. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  117059. * @param name Element's name, child elements will append suffixes for their own names.
  117060. * @param urlsOfPhoto defines the url of the photo to display
  117061. * @param options defines an object containing optional or exposed sub element properties
  117062. * @param onError defines a callback called when an error occured while loading the texture
  117063. */
  117064. constructor(name: string, urlOfPhoto: string, options: {
  117065. resolution?: number;
  117066. size?: number;
  117067. useDirectMapping?: boolean;
  117068. faceForward?: boolean;
  117069. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  117070. private _onBeforeCameraRenderObserver;
  117071. private _changeImageMode;
  117072. /**
  117073. * Releases resources associated with this node.
  117074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117076. */
  117077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117078. }
  117079. }
  117080. declare module BABYLON {
  117081. /**
  117082. * Class used to host RGBD texture specific utilities
  117083. */
  117084. export class RGBDTextureTools {
  117085. /**
  117086. * Expand the RGBD Texture from RGBD to Half Float if possible.
  117087. * @param texture the texture to expand.
  117088. */
  117089. static ExpandRGBDTexture(texture: Texture): void;
  117090. }
  117091. }
  117092. declare module BABYLON {
  117093. /**
  117094. * Class used to host texture specific utilities
  117095. */
  117096. export class BRDFTextureTools {
  117097. /**
  117098. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  117099. * @param scene defines the hosting scene
  117100. * @returns the environment BRDF texture
  117101. */
  117102. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  117103. private static _environmentBRDFBase64Texture;
  117104. }
  117105. }
  117106. declare module BABYLON {
  117107. /**
  117108. * @hidden
  117109. */
  117110. export interface IMaterialClearCoatDefines {
  117111. CLEARCOAT: boolean;
  117112. CLEARCOAT_DEFAULTIOR: boolean;
  117113. CLEARCOAT_TEXTURE: boolean;
  117114. CLEARCOAT_TEXTUREDIRECTUV: number;
  117115. CLEARCOAT_BUMP: boolean;
  117116. CLEARCOAT_BUMPDIRECTUV: number;
  117117. CLEARCOAT_TINT: boolean;
  117118. CLEARCOAT_TINT_TEXTURE: boolean;
  117119. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  117120. /** @hidden */
  117121. _areTexturesDirty: boolean;
  117122. }
  117123. /**
  117124. * Define the code related to the clear coat parameters of the pbr material.
  117125. */
  117126. export class PBRClearCoatConfiguration {
  117127. /**
  117128. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  117129. * The default fits with a polyurethane material.
  117130. */
  117131. private static readonly _DefaultIndexOfRefraction;
  117132. private _isEnabled;
  117133. /**
  117134. * Defines if the clear coat is enabled in the material.
  117135. */
  117136. isEnabled: boolean;
  117137. /**
  117138. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  117139. */
  117140. intensity: number;
  117141. /**
  117142. * Defines the clear coat layer roughness.
  117143. */
  117144. roughness: number;
  117145. private _indexOfRefraction;
  117146. /**
  117147. * Defines the index of refraction of the clear coat.
  117148. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  117149. * The default fits with a polyurethane material.
  117150. * Changing the default value is more performance intensive.
  117151. */
  117152. indexOfRefraction: number;
  117153. private _texture;
  117154. /**
  117155. * Stores the clear coat values in a texture.
  117156. */
  117157. texture: Nullable<BaseTexture>;
  117158. private _bumpTexture;
  117159. /**
  117160. * Define the clear coat specific bump texture.
  117161. */
  117162. bumpTexture: Nullable<BaseTexture>;
  117163. private _isTintEnabled;
  117164. /**
  117165. * Defines if the clear coat tint is enabled in the material.
  117166. */
  117167. isTintEnabled: boolean;
  117168. /**
  117169. * Defines the clear coat tint of the material.
  117170. * This is only use if tint is enabled
  117171. */
  117172. tintColor: Color3;
  117173. /**
  117174. * Defines the distance at which the tint color should be found in the
  117175. * clear coat media.
  117176. * This is only use if tint is enabled
  117177. */
  117178. tintColorAtDistance: number;
  117179. /**
  117180. * Defines the clear coat layer thickness.
  117181. * This is only use if tint is enabled
  117182. */
  117183. tintThickness: number;
  117184. private _tintTexture;
  117185. /**
  117186. * Stores the clear tint values in a texture.
  117187. * rgb is tint
  117188. * a is a thickness factor
  117189. */
  117190. tintTexture: Nullable<BaseTexture>;
  117191. /** @hidden */
  117192. private _internalMarkAllSubMeshesAsTexturesDirty;
  117193. /** @hidden */
  117194. _markAllSubMeshesAsTexturesDirty(): void;
  117195. /**
  117196. * Instantiate a new istance of clear coat configuration.
  117197. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117198. */
  117199. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117200. /**
  117201. * Gets wehter the submesh is ready to be used or not.
  117202. * @param defines the list of "defines" to update.
  117203. * @param scene defines the scene the material belongs to.
  117204. * @param engine defines the engine the material belongs to.
  117205. * @param disableBumpMap defines wether the material disables bump or not.
  117206. * @returns - boolean indicating that the submesh is ready or not.
  117207. */
  117208. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  117209. /**
  117210. * Checks to see if a texture is used in the material.
  117211. * @param defines the list of "defines" to update.
  117212. * @param scene defines the scene to the material belongs to.
  117213. */
  117214. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  117215. /**
  117216. * Binds the material data.
  117217. * @param uniformBuffer defines the Uniform buffer to fill in.
  117218. * @param scene defines the scene the material belongs to.
  117219. * @param engine defines the engine the material belongs to.
  117220. * @param disableBumpMap defines wether the material disables bump or not.
  117221. * @param isFrozen defines wether the material is frozen or not.
  117222. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  117223. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  117224. */
  117225. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  117226. /**
  117227. * Checks to see if a texture is used in the material.
  117228. * @param texture - Base texture to use.
  117229. * @returns - Boolean specifying if a texture is used in the material.
  117230. */
  117231. hasTexture(texture: BaseTexture): boolean;
  117232. /**
  117233. * Returns an array of the actively used textures.
  117234. * @param activeTextures Array of BaseTextures
  117235. */
  117236. getActiveTextures(activeTextures: BaseTexture[]): void;
  117237. /**
  117238. * Returns the animatable textures.
  117239. * @param animatables Array of animatable textures.
  117240. */
  117241. getAnimatables(animatables: IAnimatable[]): void;
  117242. /**
  117243. * Disposes the resources of the material.
  117244. * @param forceDisposeTextures - Forces the disposal of all textures.
  117245. */
  117246. dispose(forceDisposeTextures?: boolean): void;
  117247. /**
  117248. * Get the current class name of the texture useful for serialization or dynamic coding.
  117249. * @returns "PBRClearCoatConfiguration"
  117250. */
  117251. getClassName(): string;
  117252. /**
  117253. * Add fallbacks to the effect fallbacks list.
  117254. * @param defines defines the Base texture to use.
  117255. * @param fallbacks defines the current fallback list.
  117256. * @param currentRank defines the current fallback rank.
  117257. * @returns the new fallback rank.
  117258. */
  117259. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117260. /**
  117261. * Add the required uniforms to the current list.
  117262. * @param uniforms defines the current uniform list.
  117263. */
  117264. static AddUniforms(uniforms: string[]): void;
  117265. /**
  117266. * Add the required samplers to the current list.
  117267. * @param samplers defines the current sampler list.
  117268. */
  117269. static AddSamplers(samplers: string[]): void;
  117270. /**
  117271. * Add the required uniforms to the current buffer.
  117272. * @param uniformBuffer defines the current uniform buffer.
  117273. */
  117274. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117275. /**
  117276. * Makes a duplicate of the current configuration into another one.
  117277. * @param clearCoatConfiguration define the config where to copy the info
  117278. */
  117279. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  117280. /**
  117281. * Serializes this clear coat configuration.
  117282. * @returns - An object with the serialized config.
  117283. */
  117284. serialize(): any;
  117285. /**
  117286. * Parses a anisotropy Configuration from a serialized object.
  117287. * @param source - Serialized object.
  117288. * @param scene Defines the scene we are parsing for
  117289. * @param rootUrl Defines the rootUrl to load from
  117290. */
  117291. parse(source: any, scene: Scene, rootUrl: string): void;
  117292. }
  117293. }
  117294. declare module BABYLON {
  117295. /**
  117296. * @hidden
  117297. */
  117298. export interface IMaterialAnisotropicDefines {
  117299. ANISOTROPIC: boolean;
  117300. ANISOTROPIC_TEXTURE: boolean;
  117301. ANISOTROPIC_TEXTUREDIRECTUV: number;
  117302. MAINUV1: boolean;
  117303. _areTexturesDirty: boolean;
  117304. _needUVs: boolean;
  117305. }
  117306. /**
  117307. * Define the code related to the anisotropic parameters of the pbr material.
  117308. */
  117309. export class PBRAnisotropicConfiguration {
  117310. private _isEnabled;
  117311. /**
  117312. * Defines if the anisotropy is enabled in the material.
  117313. */
  117314. isEnabled: boolean;
  117315. /**
  117316. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  117317. */
  117318. intensity: number;
  117319. /**
  117320. * Defines if the effect is along the tangents, bitangents or in between.
  117321. * By default, the effect is "strectching" the highlights along the tangents.
  117322. */
  117323. direction: Vector2;
  117324. private _texture;
  117325. /**
  117326. * Stores the anisotropy values in a texture.
  117327. * rg is direction (like normal from -1 to 1)
  117328. * b is a intensity
  117329. */
  117330. texture: Nullable<BaseTexture>;
  117331. /** @hidden */
  117332. private _internalMarkAllSubMeshesAsTexturesDirty;
  117333. /** @hidden */
  117334. _markAllSubMeshesAsTexturesDirty(): void;
  117335. /**
  117336. * Instantiate a new istance of anisotropy configuration.
  117337. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117338. */
  117339. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117340. /**
  117341. * Specifies that the submesh is ready to be used.
  117342. * @param defines the list of "defines" to update.
  117343. * @param scene defines the scene the material belongs to.
  117344. * @returns - boolean indicating that the submesh is ready or not.
  117345. */
  117346. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  117347. /**
  117348. * Checks to see if a texture is used in the material.
  117349. * @param defines the list of "defines" to update.
  117350. * @param mesh the mesh we are preparing the defines for.
  117351. * @param scene defines the scene the material belongs to.
  117352. */
  117353. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  117354. /**
  117355. * Binds the material data.
  117356. * @param uniformBuffer defines the Uniform buffer to fill in.
  117357. * @param scene defines the scene the material belongs to.
  117358. * @param isFrozen defines wether the material is frozen or not.
  117359. */
  117360. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117361. /**
  117362. * Checks to see if a texture is used in the material.
  117363. * @param texture - Base texture to use.
  117364. * @returns - Boolean specifying if a texture is used in the material.
  117365. */
  117366. hasTexture(texture: BaseTexture): boolean;
  117367. /**
  117368. * Returns an array of the actively used textures.
  117369. * @param activeTextures Array of BaseTextures
  117370. */
  117371. getActiveTextures(activeTextures: BaseTexture[]): void;
  117372. /**
  117373. * Returns the animatable textures.
  117374. * @param animatables Array of animatable textures.
  117375. */
  117376. getAnimatables(animatables: IAnimatable[]): void;
  117377. /**
  117378. * Disposes the resources of the material.
  117379. * @param forceDisposeTextures - Forces the disposal of all textures.
  117380. */
  117381. dispose(forceDisposeTextures?: boolean): void;
  117382. /**
  117383. * Get the current class name of the texture useful for serialization or dynamic coding.
  117384. * @returns "PBRAnisotropicConfiguration"
  117385. */
  117386. getClassName(): string;
  117387. /**
  117388. * Add fallbacks to the effect fallbacks list.
  117389. * @param defines defines the Base texture to use.
  117390. * @param fallbacks defines the current fallback list.
  117391. * @param currentRank defines the current fallback rank.
  117392. * @returns the new fallback rank.
  117393. */
  117394. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117395. /**
  117396. * Add the required uniforms to the current list.
  117397. * @param uniforms defines the current uniform list.
  117398. */
  117399. static AddUniforms(uniforms: string[]): void;
  117400. /**
  117401. * Add the required uniforms to the current buffer.
  117402. * @param uniformBuffer defines the current uniform buffer.
  117403. */
  117404. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117405. /**
  117406. * Add the required samplers to the current list.
  117407. * @param samplers defines the current sampler list.
  117408. */
  117409. static AddSamplers(samplers: string[]): void;
  117410. /**
  117411. * Makes a duplicate of the current configuration into another one.
  117412. * @param anisotropicConfiguration define the config where to copy the info
  117413. */
  117414. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  117415. /**
  117416. * Serializes this anisotropy configuration.
  117417. * @returns - An object with the serialized config.
  117418. */
  117419. serialize(): any;
  117420. /**
  117421. * Parses a anisotropy Configuration from a serialized object.
  117422. * @param source - Serialized object.
  117423. * @param scene Defines the scene we are parsing for
  117424. * @param rootUrl Defines the rootUrl to load from
  117425. */
  117426. parse(source: any, scene: Scene, rootUrl: string): void;
  117427. }
  117428. }
  117429. declare module BABYLON {
  117430. /**
  117431. * @hidden
  117432. */
  117433. export interface IMaterialBRDFDefines {
  117434. BRDF_V_HEIGHT_CORRELATED: boolean;
  117435. MS_BRDF_ENERGY_CONSERVATION: boolean;
  117436. SPHERICAL_HARMONICS: boolean;
  117437. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  117438. /** @hidden */
  117439. _areMiscDirty: boolean;
  117440. }
  117441. /**
  117442. * Define the code related to the BRDF parameters of the pbr material.
  117443. */
  117444. export class PBRBRDFConfiguration {
  117445. /**
  117446. * Default value used for the energy conservation.
  117447. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  117448. */
  117449. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  117450. /**
  117451. * Default value used for the Smith Visibility Height Correlated mode.
  117452. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  117453. */
  117454. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  117455. /**
  117456. * Default value used for the IBL diffuse part.
  117457. * This can help switching back to the polynomials mode globally which is a tiny bit
  117458. * less GPU intensive at the drawback of a lower quality.
  117459. */
  117460. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  117461. /**
  117462. * Default value used for activating energy conservation for the specular workflow.
  117463. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  117464. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  117465. */
  117466. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  117467. private _useEnergyConservation;
  117468. /**
  117469. * Defines if the material uses energy conservation.
  117470. */
  117471. useEnergyConservation: boolean;
  117472. private _useSmithVisibilityHeightCorrelated;
  117473. /**
  117474. * LEGACY Mode set to false
  117475. * Defines if the material uses height smith correlated visibility term.
  117476. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  117477. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  117478. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  117479. * Not relying on height correlated will also disable energy conservation.
  117480. */
  117481. useSmithVisibilityHeightCorrelated: boolean;
  117482. private _useSphericalHarmonics;
  117483. /**
  117484. * LEGACY Mode set to false
  117485. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  117486. * diffuse part of the IBL.
  117487. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  117488. * to the ground truth.
  117489. */
  117490. useSphericalHarmonics: boolean;
  117491. private _useSpecularGlossinessInputEnergyConservation;
  117492. /**
  117493. * Defines if the material uses energy conservation, when the specular workflow is active.
  117494. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  117495. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  117496. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  117497. */
  117498. useSpecularGlossinessInputEnergyConservation: boolean;
  117499. /** @hidden */
  117500. private _internalMarkAllSubMeshesAsMiscDirty;
  117501. /** @hidden */
  117502. _markAllSubMeshesAsMiscDirty(): void;
  117503. /**
  117504. * Instantiate a new istance of clear coat configuration.
  117505. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  117506. */
  117507. constructor(markAllSubMeshesAsMiscDirty: () => void);
  117508. /**
  117509. * Checks to see if a texture is used in the material.
  117510. * @param defines the list of "defines" to update.
  117511. */
  117512. prepareDefines(defines: IMaterialBRDFDefines): void;
  117513. /**
  117514. * Get the current class name of the texture useful for serialization or dynamic coding.
  117515. * @returns "PBRClearCoatConfiguration"
  117516. */
  117517. getClassName(): string;
  117518. /**
  117519. * Makes a duplicate of the current configuration into another one.
  117520. * @param brdfConfiguration define the config where to copy the info
  117521. */
  117522. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  117523. /**
  117524. * Serializes this BRDF configuration.
  117525. * @returns - An object with the serialized config.
  117526. */
  117527. serialize(): any;
  117528. /**
  117529. * Parses a anisotropy Configuration from a serialized object.
  117530. * @param source - Serialized object.
  117531. * @param scene Defines the scene we are parsing for
  117532. * @param rootUrl Defines the rootUrl to load from
  117533. */
  117534. parse(source: any, scene: Scene, rootUrl: string): void;
  117535. }
  117536. }
  117537. declare module BABYLON {
  117538. /**
  117539. * @hidden
  117540. */
  117541. export interface IMaterialSheenDefines {
  117542. SHEEN: boolean;
  117543. SHEEN_TEXTURE: boolean;
  117544. SHEEN_TEXTUREDIRECTUV: number;
  117545. SHEEN_LINKWITHALBEDO: boolean;
  117546. /** @hidden */
  117547. _areTexturesDirty: boolean;
  117548. }
  117549. /**
  117550. * Define the code related to the Sheen parameters of the pbr material.
  117551. */
  117552. export class PBRSheenConfiguration {
  117553. private _isEnabled;
  117554. /**
  117555. * Defines if the material uses sheen.
  117556. */
  117557. isEnabled: boolean;
  117558. private _linkSheenWithAlbedo;
  117559. /**
  117560. * Defines if the sheen is linked to the sheen color.
  117561. */
  117562. linkSheenWithAlbedo: boolean;
  117563. /**
  117564. * Defines the sheen intensity.
  117565. */
  117566. intensity: number;
  117567. /**
  117568. * Defines the sheen color.
  117569. */
  117570. color: Color3;
  117571. private _texture;
  117572. /**
  117573. * Stores the sheen tint values in a texture.
  117574. * rgb is tint
  117575. * a is a intensity
  117576. */
  117577. texture: Nullable<BaseTexture>;
  117578. /** @hidden */
  117579. private _internalMarkAllSubMeshesAsTexturesDirty;
  117580. /** @hidden */
  117581. _markAllSubMeshesAsTexturesDirty(): void;
  117582. /**
  117583. * Instantiate a new istance of clear coat configuration.
  117584. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117585. */
  117586. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117587. /**
  117588. * Specifies that the submesh is ready to be used.
  117589. * @param defines the list of "defines" to update.
  117590. * @param scene defines the scene the material belongs to.
  117591. * @returns - boolean indicating that the submesh is ready or not.
  117592. */
  117593. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  117594. /**
  117595. * Checks to see if a texture is used in the material.
  117596. * @param defines the list of "defines" to update.
  117597. * @param scene defines the scene the material belongs to.
  117598. */
  117599. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  117600. /**
  117601. * Binds the material data.
  117602. * @param uniformBuffer defines the Uniform buffer to fill in.
  117603. * @param scene defines the scene the material belongs to.
  117604. * @param isFrozen defines wether the material is frozen or not.
  117605. */
  117606. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  117607. /**
  117608. * Checks to see if a texture is used in the material.
  117609. * @param texture - Base texture to use.
  117610. * @returns - Boolean specifying if a texture is used in the material.
  117611. */
  117612. hasTexture(texture: BaseTexture): boolean;
  117613. /**
  117614. * Returns an array of the actively used textures.
  117615. * @param activeTextures Array of BaseTextures
  117616. */
  117617. getActiveTextures(activeTextures: BaseTexture[]): void;
  117618. /**
  117619. * Returns the animatable textures.
  117620. * @param animatables Array of animatable textures.
  117621. */
  117622. getAnimatables(animatables: IAnimatable[]): void;
  117623. /**
  117624. * Disposes the resources of the material.
  117625. * @param forceDisposeTextures - Forces the disposal of all textures.
  117626. */
  117627. dispose(forceDisposeTextures?: boolean): void;
  117628. /**
  117629. * Get the current class name of the texture useful for serialization or dynamic coding.
  117630. * @returns "PBRSheenConfiguration"
  117631. */
  117632. getClassName(): string;
  117633. /**
  117634. * Add fallbacks to the effect fallbacks list.
  117635. * @param defines defines the Base texture to use.
  117636. * @param fallbacks defines the current fallback list.
  117637. * @param currentRank defines the current fallback rank.
  117638. * @returns the new fallback rank.
  117639. */
  117640. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117641. /**
  117642. * Add the required uniforms to the current list.
  117643. * @param uniforms defines the current uniform list.
  117644. */
  117645. static AddUniforms(uniforms: string[]): void;
  117646. /**
  117647. * Add the required uniforms to the current buffer.
  117648. * @param uniformBuffer defines the current uniform buffer.
  117649. */
  117650. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117651. /**
  117652. * Add the required samplers to the current list.
  117653. * @param samplers defines the current sampler list.
  117654. */
  117655. static AddSamplers(samplers: string[]): void;
  117656. /**
  117657. * Makes a duplicate of the current configuration into another one.
  117658. * @param sheenConfiguration define the config where to copy the info
  117659. */
  117660. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  117661. /**
  117662. * Serializes this BRDF configuration.
  117663. * @returns - An object with the serialized config.
  117664. */
  117665. serialize(): any;
  117666. /**
  117667. * Parses a anisotropy Configuration from a serialized object.
  117668. * @param source - Serialized object.
  117669. * @param scene Defines the scene we are parsing for
  117670. * @param rootUrl Defines the rootUrl to load from
  117671. */
  117672. parse(source: any, scene: Scene, rootUrl: string): void;
  117673. }
  117674. }
  117675. declare module BABYLON {
  117676. /**
  117677. * @hidden
  117678. */
  117679. export interface IMaterialSubSurfaceDefines {
  117680. SUBSURFACE: boolean;
  117681. SS_REFRACTION: boolean;
  117682. SS_TRANSLUCENCY: boolean;
  117683. SS_SCATERRING: boolean;
  117684. SS_THICKNESSANDMASK_TEXTURE: boolean;
  117685. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  117686. SS_REFRACTIONMAP_3D: boolean;
  117687. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  117688. SS_LODINREFRACTIONALPHA: boolean;
  117689. SS_GAMMAREFRACTION: boolean;
  117690. SS_RGBDREFRACTION: boolean;
  117691. SS_LINEARSPECULARREFRACTION: boolean;
  117692. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  117693. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  117694. /** @hidden */
  117695. _areTexturesDirty: boolean;
  117696. }
  117697. /**
  117698. * Define the code related to the sub surface parameters of the pbr material.
  117699. */
  117700. export class PBRSubSurfaceConfiguration {
  117701. private _isRefractionEnabled;
  117702. /**
  117703. * Defines if the refraction is enabled in the material.
  117704. */
  117705. isRefractionEnabled: boolean;
  117706. private _isTranslucencyEnabled;
  117707. /**
  117708. * Defines if the translucency is enabled in the material.
  117709. */
  117710. isTranslucencyEnabled: boolean;
  117711. private _isScatteringEnabled;
  117712. /**
  117713. * Defines the refraction intensity of the material.
  117714. * The refraction when enabled replaces the Diffuse part of the material.
  117715. * The intensity helps transitionning between diffuse and refraction.
  117716. */
  117717. refractionIntensity: number;
  117718. /**
  117719. * Defines the translucency intensity of the material.
  117720. * When translucency has been enabled, this defines how much of the "translucency"
  117721. * is addded to the diffuse part of the material.
  117722. */
  117723. translucencyIntensity: number;
  117724. /**
  117725. * Defines the scattering intensity of the material.
  117726. * When scattering has been enabled, this defines how much of the "scattered light"
  117727. * is addded to the diffuse part of the material.
  117728. */
  117729. scatteringIntensity: number;
  117730. private _thicknessTexture;
  117731. /**
  117732. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  117733. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  117734. * 0 would mean minimumThickness
  117735. * 1 would mean maximumThickness
  117736. * The other channels might be use as a mask to vary the different effects intensity.
  117737. */
  117738. thicknessTexture: Nullable<BaseTexture>;
  117739. private _refractionTexture;
  117740. /**
  117741. * Defines the texture to use for refraction.
  117742. */
  117743. refractionTexture: Nullable<BaseTexture>;
  117744. private _indexOfRefraction;
  117745. /**
  117746. * Defines the index of refraction used in the material.
  117747. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  117748. */
  117749. indexOfRefraction: number;
  117750. private _invertRefractionY;
  117751. /**
  117752. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117753. */
  117754. invertRefractionY: boolean;
  117755. private _linkRefractionWithTransparency;
  117756. /**
  117757. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117758. * Materials half opaque for instance using refraction could benefit from this control.
  117759. */
  117760. linkRefractionWithTransparency: boolean;
  117761. /**
  117762. * Defines the minimum thickness stored in the thickness map.
  117763. * If no thickness map is defined, this value will be used to simulate thickness.
  117764. */
  117765. minimumThickness: number;
  117766. /**
  117767. * Defines the maximum thickness stored in the thickness map.
  117768. */
  117769. maximumThickness: number;
  117770. /**
  117771. * Defines the volume tint of the material.
  117772. * This is used for both translucency and scattering.
  117773. */
  117774. tintColor: Color3;
  117775. /**
  117776. * Defines the distance at which the tint color should be found in the media.
  117777. * This is used for refraction only.
  117778. */
  117779. tintColorAtDistance: number;
  117780. /**
  117781. * Defines how far each channel transmit through the media.
  117782. * It is defined as a color to simplify it selection.
  117783. */
  117784. diffusionDistance: Color3;
  117785. private _useMaskFromThicknessTexture;
  117786. /**
  117787. * Stores the intensity of the different subsurface effects in the thickness texture.
  117788. * * the green channel is the translucency intensity.
  117789. * * the blue channel is the scattering intensity.
  117790. * * the alpha channel is the refraction intensity.
  117791. */
  117792. useMaskFromThicknessTexture: boolean;
  117793. /** @hidden */
  117794. private _internalMarkAllSubMeshesAsTexturesDirty;
  117795. /** @hidden */
  117796. _markAllSubMeshesAsTexturesDirty(): void;
  117797. /**
  117798. * Instantiate a new istance of sub surface configuration.
  117799. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  117800. */
  117801. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  117802. /**
  117803. * Gets wehter the submesh is ready to be used or not.
  117804. * @param defines the list of "defines" to update.
  117805. * @param scene defines the scene the material belongs to.
  117806. * @returns - boolean indicating that the submesh is ready or not.
  117807. */
  117808. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  117809. /**
  117810. * Checks to see if a texture is used in the material.
  117811. * @param defines the list of "defines" to update.
  117812. * @param scene defines the scene to the material belongs to.
  117813. */
  117814. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  117815. /**
  117816. * Binds the material data.
  117817. * @param uniformBuffer defines the Uniform buffer to fill in.
  117818. * @param scene defines the scene the material belongs to.
  117819. * @param engine defines the engine the material belongs to.
  117820. * @param isFrozen defines wether the material is frozen or not.
  117821. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  117822. */
  117823. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  117824. /**
  117825. * Unbinds the material from the mesh.
  117826. * @param activeEffect defines the effect that should be unbound from.
  117827. * @returns true if unbound, otherwise false
  117828. */
  117829. unbind(activeEffect: Effect): boolean;
  117830. /**
  117831. * Returns the texture used for refraction or null if none is used.
  117832. * @param scene defines the scene the material belongs to.
  117833. * @returns - Refraction texture if present. If no refraction texture and refraction
  117834. * is linked with transparency, returns environment texture. Otherwise, returns null.
  117835. */
  117836. private _getRefractionTexture;
  117837. /**
  117838. * Returns true if alpha blending should be disabled.
  117839. */
  117840. readonly disableAlphaBlending: boolean;
  117841. /**
  117842. * Fills the list of render target textures.
  117843. * @param renderTargets the list of render targets to update
  117844. */
  117845. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  117846. /**
  117847. * Checks to see if a texture is used in the material.
  117848. * @param texture - Base texture to use.
  117849. * @returns - Boolean specifying if a texture is used in the material.
  117850. */
  117851. hasTexture(texture: BaseTexture): boolean;
  117852. /**
  117853. * Gets a boolean indicating that current material needs to register RTT
  117854. * @returns true if this uses a render target otherwise false.
  117855. */
  117856. hasRenderTargetTextures(): boolean;
  117857. /**
  117858. * Returns an array of the actively used textures.
  117859. * @param activeTextures Array of BaseTextures
  117860. */
  117861. getActiveTextures(activeTextures: BaseTexture[]): void;
  117862. /**
  117863. * Returns the animatable textures.
  117864. * @param animatables Array of animatable textures.
  117865. */
  117866. getAnimatables(animatables: IAnimatable[]): void;
  117867. /**
  117868. * Disposes the resources of the material.
  117869. * @param forceDisposeTextures - Forces the disposal of all textures.
  117870. */
  117871. dispose(forceDisposeTextures?: boolean): void;
  117872. /**
  117873. * Get the current class name of the texture useful for serialization or dynamic coding.
  117874. * @returns "PBRSubSurfaceConfiguration"
  117875. */
  117876. getClassName(): string;
  117877. /**
  117878. * Add fallbacks to the effect fallbacks list.
  117879. * @param defines defines the Base texture to use.
  117880. * @param fallbacks defines the current fallback list.
  117881. * @param currentRank defines the current fallback rank.
  117882. * @returns the new fallback rank.
  117883. */
  117884. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  117885. /**
  117886. * Add the required uniforms to the current list.
  117887. * @param uniforms defines the current uniform list.
  117888. */
  117889. static AddUniforms(uniforms: string[]): void;
  117890. /**
  117891. * Add the required samplers to the current list.
  117892. * @param samplers defines the current sampler list.
  117893. */
  117894. static AddSamplers(samplers: string[]): void;
  117895. /**
  117896. * Add the required uniforms to the current buffer.
  117897. * @param uniformBuffer defines the current uniform buffer.
  117898. */
  117899. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  117900. /**
  117901. * Makes a duplicate of the current configuration into another one.
  117902. * @param configuration define the config where to copy the info
  117903. */
  117904. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  117905. /**
  117906. * Serializes this Sub Surface configuration.
  117907. * @returns - An object with the serialized config.
  117908. */
  117909. serialize(): any;
  117910. /**
  117911. * Parses a anisotropy Configuration from a serialized object.
  117912. * @param source - Serialized object.
  117913. * @param scene Defines the scene we are parsing for
  117914. * @param rootUrl Defines the rootUrl to load from
  117915. */
  117916. parse(source: any, scene: Scene, rootUrl: string): void;
  117917. }
  117918. }
  117919. declare module BABYLON {
  117920. /** @hidden */
  117921. export var pbrFragmentDeclaration: {
  117922. name: string;
  117923. shader: string;
  117924. };
  117925. }
  117926. declare module BABYLON {
  117927. /** @hidden */
  117928. export var pbrUboDeclaration: {
  117929. name: string;
  117930. shader: string;
  117931. };
  117932. }
  117933. declare module BABYLON {
  117934. /** @hidden */
  117935. export var pbrFragmentExtraDeclaration: {
  117936. name: string;
  117937. shader: string;
  117938. };
  117939. }
  117940. declare module BABYLON {
  117941. /** @hidden */
  117942. export var pbrFragmentSamplersDeclaration: {
  117943. name: string;
  117944. shader: string;
  117945. };
  117946. }
  117947. declare module BABYLON {
  117948. /** @hidden */
  117949. export var pbrHelperFunctions: {
  117950. name: string;
  117951. shader: string;
  117952. };
  117953. }
  117954. declare module BABYLON {
  117955. /** @hidden */
  117956. export var harmonicsFunctions: {
  117957. name: string;
  117958. shader: string;
  117959. };
  117960. }
  117961. declare module BABYLON {
  117962. /** @hidden */
  117963. export var pbrDirectLightingSetupFunctions: {
  117964. name: string;
  117965. shader: string;
  117966. };
  117967. }
  117968. declare module BABYLON {
  117969. /** @hidden */
  117970. export var pbrDirectLightingFalloffFunctions: {
  117971. name: string;
  117972. shader: string;
  117973. };
  117974. }
  117975. declare module BABYLON {
  117976. /** @hidden */
  117977. export var pbrBRDFFunctions: {
  117978. name: string;
  117979. shader: string;
  117980. };
  117981. }
  117982. declare module BABYLON {
  117983. /** @hidden */
  117984. export var pbrDirectLightingFunctions: {
  117985. name: string;
  117986. shader: string;
  117987. };
  117988. }
  117989. declare module BABYLON {
  117990. /** @hidden */
  117991. export var pbrIBLFunctions: {
  117992. name: string;
  117993. shader: string;
  117994. };
  117995. }
  117996. declare module BABYLON {
  117997. /** @hidden */
  117998. export var pbrDebug: {
  117999. name: string;
  118000. shader: string;
  118001. };
  118002. }
  118003. declare module BABYLON {
  118004. /** @hidden */
  118005. export var pbrPixelShader: {
  118006. name: string;
  118007. shader: string;
  118008. };
  118009. }
  118010. declare module BABYLON {
  118011. /** @hidden */
  118012. export var pbrVertexDeclaration: {
  118013. name: string;
  118014. shader: string;
  118015. };
  118016. }
  118017. declare module BABYLON {
  118018. /** @hidden */
  118019. export var pbrVertexShader: {
  118020. name: string;
  118021. shader: string;
  118022. };
  118023. }
  118024. declare module BABYLON {
  118025. /**
  118026. * Manages the defines for the PBR Material.
  118027. * @hidden
  118028. */
  118029. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  118030. PBR: boolean;
  118031. MAINUV1: boolean;
  118032. MAINUV2: boolean;
  118033. UV1: boolean;
  118034. UV2: boolean;
  118035. ALBEDO: boolean;
  118036. ALBEDODIRECTUV: number;
  118037. VERTEXCOLOR: boolean;
  118038. AMBIENT: boolean;
  118039. AMBIENTDIRECTUV: number;
  118040. AMBIENTINGRAYSCALE: boolean;
  118041. OPACITY: boolean;
  118042. VERTEXALPHA: boolean;
  118043. OPACITYDIRECTUV: number;
  118044. OPACITYRGB: boolean;
  118045. ALPHATEST: boolean;
  118046. DEPTHPREPASS: boolean;
  118047. ALPHABLEND: boolean;
  118048. ALPHAFROMALBEDO: boolean;
  118049. ALPHATESTVALUE: string;
  118050. SPECULAROVERALPHA: boolean;
  118051. RADIANCEOVERALPHA: boolean;
  118052. ALPHAFRESNEL: boolean;
  118053. LINEARALPHAFRESNEL: boolean;
  118054. PREMULTIPLYALPHA: boolean;
  118055. EMISSIVE: boolean;
  118056. EMISSIVEDIRECTUV: number;
  118057. REFLECTIVITY: boolean;
  118058. REFLECTIVITYDIRECTUV: number;
  118059. SPECULARTERM: boolean;
  118060. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  118061. MICROSURFACEAUTOMATIC: boolean;
  118062. LODBASEDMICROSFURACE: boolean;
  118063. MICROSURFACEMAP: boolean;
  118064. MICROSURFACEMAPDIRECTUV: number;
  118065. METALLICWORKFLOW: boolean;
  118066. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  118067. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  118068. METALLNESSSTOREINMETALMAPBLUE: boolean;
  118069. AOSTOREINMETALMAPRED: boolean;
  118070. METALLICF0FACTORFROMMETALLICMAP: boolean;
  118071. ENVIRONMENTBRDF: boolean;
  118072. ENVIRONMENTBRDF_RGBD: boolean;
  118073. NORMAL: boolean;
  118074. TANGENT: boolean;
  118075. BUMP: boolean;
  118076. BUMPDIRECTUV: number;
  118077. OBJECTSPACE_NORMALMAP: boolean;
  118078. PARALLAX: boolean;
  118079. PARALLAXOCCLUSION: boolean;
  118080. NORMALXYSCALE: boolean;
  118081. LIGHTMAP: boolean;
  118082. LIGHTMAPDIRECTUV: number;
  118083. USELIGHTMAPASSHADOWMAP: boolean;
  118084. GAMMALIGHTMAP: boolean;
  118085. RGBDLIGHTMAP: boolean;
  118086. REFLECTION: boolean;
  118087. REFLECTIONMAP_3D: boolean;
  118088. REFLECTIONMAP_SPHERICAL: boolean;
  118089. REFLECTIONMAP_PLANAR: boolean;
  118090. REFLECTIONMAP_CUBIC: boolean;
  118091. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  118092. REFLECTIONMAP_PROJECTION: boolean;
  118093. REFLECTIONMAP_SKYBOX: boolean;
  118094. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  118095. REFLECTIONMAP_EXPLICIT: boolean;
  118096. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  118097. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  118098. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  118099. INVERTCUBICMAP: boolean;
  118100. USESPHERICALFROMREFLECTIONMAP: boolean;
  118101. USEIRRADIANCEMAP: boolean;
  118102. SPHERICAL_HARMONICS: boolean;
  118103. USESPHERICALINVERTEX: boolean;
  118104. REFLECTIONMAP_OPPOSITEZ: boolean;
  118105. LODINREFLECTIONALPHA: boolean;
  118106. GAMMAREFLECTION: boolean;
  118107. RGBDREFLECTION: boolean;
  118108. LINEARSPECULARREFLECTION: boolean;
  118109. RADIANCEOCCLUSION: boolean;
  118110. HORIZONOCCLUSION: boolean;
  118111. INSTANCES: boolean;
  118112. NUM_BONE_INFLUENCERS: number;
  118113. BonesPerMesh: number;
  118114. BONETEXTURE: boolean;
  118115. NONUNIFORMSCALING: boolean;
  118116. MORPHTARGETS: boolean;
  118117. MORPHTARGETS_NORMAL: boolean;
  118118. MORPHTARGETS_TANGENT: boolean;
  118119. MORPHTARGETS_UV: boolean;
  118120. NUM_MORPH_INFLUENCERS: number;
  118121. IMAGEPROCESSING: boolean;
  118122. VIGNETTE: boolean;
  118123. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118124. VIGNETTEBLENDMODEOPAQUE: boolean;
  118125. TONEMAPPING: boolean;
  118126. TONEMAPPING_ACES: boolean;
  118127. CONTRAST: boolean;
  118128. COLORCURVES: boolean;
  118129. COLORGRADING: boolean;
  118130. COLORGRADING3D: boolean;
  118131. SAMPLER3DGREENDEPTH: boolean;
  118132. SAMPLER3DBGRMAP: boolean;
  118133. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118134. EXPOSURE: boolean;
  118135. MULTIVIEW: boolean;
  118136. USEPHYSICALLIGHTFALLOFF: boolean;
  118137. USEGLTFLIGHTFALLOFF: boolean;
  118138. TWOSIDEDLIGHTING: boolean;
  118139. SHADOWFLOAT: boolean;
  118140. CLIPPLANE: boolean;
  118141. CLIPPLANE2: boolean;
  118142. CLIPPLANE3: boolean;
  118143. CLIPPLANE4: boolean;
  118144. POINTSIZE: boolean;
  118145. FOG: boolean;
  118146. LOGARITHMICDEPTH: boolean;
  118147. FORCENORMALFORWARD: boolean;
  118148. SPECULARAA: boolean;
  118149. CLEARCOAT: boolean;
  118150. CLEARCOAT_DEFAULTIOR: boolean;
  118151. CLEARCOAT_TEXTURE: boolean;
  118152. CLEARCOAT_TEXTUREDIRECTUV: number;
  118153. CLEARCOAT_BUMP: boolean;
  118154. CLEARCOAT_BUMPDIRECTUV: number;
  118155. CLEARCOAT_TINT: boolean;
  118156. CLEARCOAT_TINT_TEXTURE: boolean;
  118157. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  118158. ANISOTROPIC: boolean;
  118159. ANISOTROPIC_TEXTURE: boolean;
  118160. ANISOTROPIC_TEXTUREDIRECTUV: number;
  118161. BRDF_V_HEIGHT_CORRELATED: boolean;
  118162. MS_BRDF_ENERGY_CONSERVATION: boolean;
  118163. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  118164. SHEEN: boolean;
  118165. SHEEN_TEXTURE: boolean;
  118166. SHEEN_TEXTUREDIRECTUV: number;
  118167. SHEEN_LINKWITHALBEDO: boolean;
  118168. SUBSURFACE: boolean;
  118169. SS_REFRACTION: boolean;
  118170. SS_TRANSLUCENCY: boolean;
  118171. SS_SCATERRING: boolean;
  118172. SS_THICKNESSANDMASK_TEXTURE: boolean;
  118173. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  118174. SS_REFRACTIONMAP_3D: boolean;
  118175. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  118176. SS_LODINREFRACTIONALPHA: boolean;
  118177. SS_GAMMAREFRACTION: boolean;
  118178. SS_RGBDREFRACTION: boolean;
  118179. SS_LINEARSPECULARREFRACTION: boolean;
  118180. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  118181. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  118182. UNLIT: boolean;
  118183. DEBUGMODE: number;
  118184. /**
  118185. * Initializes the PBR Material defines.
  118186. */
  118187. constructor();
  118188. /**
  118189. * Resets the PBR Material defines.
  118190. */
  118191. reset(): void;
  118192. }
  118193. /**
  118194. * The Physically based material base class of BJS.
  118195. *
  118196. * This offers the main features of a standard PBR material.
  118197. * For more information, please refer to the documentation :
  118198. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118199. */
  118200. export abstract class PBRBaseMaterial extends PushMaterial {
  118201. /**
  118202. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118203. */
  118204. static readonly PBRMATERIAL_OPAQUE: number;
  118205. /**
  118206. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118207. */
  118208. static readonly PBRMATERIAL_ALPHATEST: number;
  118209. /**
  118210. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118211. */
  118212. static readonly PBRMATERIAL_ALPHABLEND: number;
  118213. /**
  118214. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118215. * They are also discarded below the alpha cutoff threshold to improve performances.
  118216. */
  118217. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118218. /**
  118219. * Defines the default value of how much AO map is occluding the analytical lights
  118220. * (point spot...).
  118221. */
  118222. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118223. /**
  118224. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  118225. */
  118226. static readonly LIGHTFALLOFF_PHYSICAL: number;
  118227. /**
  118228. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  118229. * to enhance interoperability with other engines.
  118230. */
  118231. static readonly LIGHTFALLOFF_GLTF: number;
  118232. /**
  118233. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  118234. * to enhance interoperability with other materials.
  118235. */
  118236. static readonly LIGHTFALLOFF_STANDARD: number;
  118237. /**
  118238. * Intensity of the direct lights e.g. the four lights available in your scene.
  118239. * This impacts both the direct diffuse and specular highlights.
  118240. */
  118241. protected _directIntensity: number;
  118242. /**
  118243. * Intensity of the emissive part of the material.
  118244. * This helps controlling the emissive effect without modifying the emissive color.
  118245. */
  118246. protected _emissiveIntensity: number;
  118247. /**
  118248. * Intensity of the environment e.g. how much the environment will light the object
  118249. * either through harmonics for rough material or through the refelction for shiny ones.
  118250. */
  118251. protected _environmentIntensity: number;
  118252. /**
  118253. * This is a special control allowing the reduction of the specular highlights coming from the
  118254. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118255. */
  118256. protected _specularIntensity: number;
  118257. /**
  118258. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  118259. */
  118260. private _lightingInfos;
  118261. /**
  118262. * Debug Control allowing disabling the bump map on this material.
  118263. */
  118264. protected _disableBumpMap: boolean;
  118265. /**
  118266. * AKA Diffuse Texture in standard nomenclature.
  118267. */
  118268. protected _albedoTexture: Nullable<BaseTexture>;
  118269. /**
  118270. * AKA Occlusion Texture in other nomenclature.
  118271. */
  118272. protected _ambientTexture: Nullable<BaseTexture>;
  118273. /**
  118274. * AKA Occlusion Texture Intensity in other nomenclature.
  118275. */
  118276. protected _ambientTextureStrength: number;
  118277. /**
  118278. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118279. * 1 means it completely occludes it
  118280. * 0 mean it has no impact
  118281. */
  118282. protected _ambientTextureImpactOnAnalyticalLights: number;
  118283. /**
  118284. * Stores the alpha values in a texture.
  118285. */
  118286. protected _opacityTexture: Nullable<BaseTexture>;
  118287. /**
  118288. * Stores the reflection values in a texture.
  118289. */
  118290. protected _reflectionTexture: Nullable<BaseTexture>;
  118291. /**
  118292. * Stores the emissive values in a texture.
  118293. */
  118294. protected _emissiveTexture: Nullable<BaseTexture>;
  118295. /**
  118296. * AKA Specular texture in other nomenclature.
  118297. */
  118298. protected _reflectivityTexture: Nullable<BaseTexture>;
  118299. /**
  118300. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118301. */
  118302. protected _metallicTexture: Nullable<BaseTexture>;
  118303. /**
  118304. * Specifies the metallic scalar of the metallic/roughness workflow.
  118305. * Can also be used to scale the metalness values of the metallic texture.
  118306. */
  118307. protected _metallic: Nullable<number>;
  118308. /**
  118309. * Specifies the roughness scalar of the metallic/roughness workflow.
  118310. * Can also be used to scale the roughness values of the metallic texture.
  118311. */
  118312. protected _roughness: Nullable<number>;
  118313. /**
  118314. * Specifies the an F0 factor to help configuring the material F0.
  118315. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118316. * to 0.5 the previously hard coded value stays the same.
  118317. * Can also be used to scale the F0 values of the metallic texture.
  118318. */
  118319. protected _metallicF0Factor: number;
  118320. /**
  118321. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118322. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118323. * your expectation as it multiplies with the texture data.
  118324. */
  118325. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  118326. /**
  118327. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118328. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118329. */
  118330. protected _microSurfaceTexture: Nullable<BaseTexture>;
  118331. /**
  118332. * Stores surface normal data used to displace a mesh in a texture.
  118333. */
  118334. protected _bumpTexture: Nullable<BaseTexture>;
  118335. /**
  118336. * Stores the pre-calculated light information of a mesh in a texture.
  118337. */
  118338. protected _lightmapTexture: Nullable<BaseTexture>;
  118339. /**
  118340. * The color of a material in ambient lighting.
  118341. */
  118342. protected _ambientColor: Color3;
  118343. /**
  118344. * AKA Diffuse Color in other nomenclature.
  118345. */
  118346. protected _albedoColor: Color3;
  118347. /**
  118348. * AKA Specular Color in other nomenclature.
  118349. */
  118350. protected _reflectivityColor: Color3;
  118351. /**
  118352. * The color applied when light is reflected from a material.
  118353. */
  118354. protected _reflectionColor: Color3;
  118355. /**
  118356. * The color applied when light is emitted from a material.
  118357. */
  118358. protected _emissiveColor: Color3;
  118359. /**
  118360. * AKA Glossiness in other nomenclature.
  118361. */
  118362. protected _microSurface: number;
  118363. /**
  118364. * Specifies that the material will use the light map as a show map.
  118365. */
  118366. protected _useLightmapAsShadowmap: boolean;
  118367. /**
  118368. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  118369. * makes the reflect vector face the model (under horizon).
  118370. */
  118371. protected _useHorizonOcclusion: boolean;
  118372. /**
  118373. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  118374. * too much the area relying on ambient texture to define their ambient occlusion.
  118375. */
  118376. protected _useRadianceOcclusion: boolean;
  118377. /**
  118378. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118379. */
  118380. protected _useAlphaFromAlbedoTexture: boolean;
  118381. /**
  118382. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  118383. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118384. */
  118385. protected _useSpecularOverAlpha: boolean;
  118386. /**
  118387. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118388. */
  118389. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118390. /**
  118391. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118392. */
  118393. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  118394. /**
  118395. * Specifies if the metallic texture contains the roughness information in its green channel.
  118396. */
  118397. protected _useRoughnessFromMetallicTextureGreen: boolean;
  118398. /**
  118399. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118400. */
  118401. protected _useMetallnessFromMetallicTextureBlue: boolean;
  118402. /**
  118403. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118404. */
  118405. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  118406. /**
  118407. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118408. */
  118409. protected _useAmbientInGrayScale: boolean;
  118410. /**
  118411. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118412. * The material will try to infer what glossiness each pixel should be.
  118413. */
  118414. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  118415. /**
  118416. * Defines the falloff type used in this material.
  118417. * It by default is Physical.
  118418. */
  118419. protected _lightFalloff: number;
  118420. /**
  118421. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118422. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118423. */
  118424. protected _useRadianceOverAlpha: boolean;
  118425. /**
  118426. * Allows using an object space normal map (instead of tangent space).
  118427. */
  118428. protected _useObjectSpaceNormalMap: boolean;
  118429. /**
  118430. * Allows using the bump map in parallax mode.
  118431. */
  118432. protected _useParallax: boolean;
  118433. /**
  118434. * Allows using the bump map in parallax occlusion mode.
  118435. */
  118436. protected _useParallaxOcclusion: boolean;
  118437. /**
  118438. * Controls the scale bias of the parallax mode.
  118439. */
  118440. protected _parallaxScaleBias: number;
  118441. /**
  118442. * If sets to true, disables all the lights affecting the material.
  118443. */
  118444. protected _disableLighting: boolean;
  118445. /**
  118446. * Number of Simultaneous lights allowed on the material.
  118447. */
  118448. protected _maxSimultaneousLights: number;
  118449. /**
  118450. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  118451. */
  118452. protected _invertNormalMapX: boolean;
  118453. /**
  118454. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  118455. */
  118456. protected _invertNormalMapY: boolean;
  118457. /**
  118458. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118459. */
  118460. protected _twoSidedLighting: boolean;
  118461. /**
  118462. * Defines the alpha limits in alpha test mode.
  118463. */
  118464. protected _alphaCutOff: number;
  118465. /**
  118466. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118467. */
  118468. protected _forceAlphaTest: boolean;
  118469. /**
  118470. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118471. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118472. */
  118473. protected _useAlphaFresnel: boolean;
  118474. /**
  118475. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118476. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118477. */
  118478. protected _useLinearAlphaFresnel: boolean;
  118479. /**
  118480. * The transparency mode of the material.
  118481. */
  118482. protected _transparencyMode: Nullable<number>;
  118483. /**
  118484. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  118485. * from cos thetav and roughness:
  118486. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  118487. */
  118488. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  118489. /**
  118490. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118491. */
  118492. protected _forceIrradianceInFragment: boolean;
  118493. /**
  118494. * Force normal to face away from face.
  118495. */
  118496. protected _forceNormalForward: boolean;
  118497. /**
  118498. * Enables specular anti aliasing in the PBR shader.
  118499. * It will both interacts on the Geometry for analytical and IBL lighting.
  118500. * It also prefilter the roughness map based on the bump values.
  118501. */
  118502. protected _enableSpecularAntiAliasing: boolean;
  118503. /**
  118504. * Default configuration related to image processing available in the PBR Material.
  118505. */
  118506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118507. /**
  118508. * Keep track of the image processing observer to allow dispose and replace.
  118509. */
  118510. private _imageProcessingObserver;
  118511. /**
  118512. * Attaches a new image processing configuration to the PBR Material.
  118513. * @param configuration
  118514. */
  118515. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118516. /**
  118517. * Stores the available render targets.
  118518. */
  118519. private _renderTargets;
  118520. /**
  118521. * Sets the global ambient color for the material used in lighting calculations.
  118522. */
  118523. private _globalAmbientColor;
  118524. /**
  118525. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  118526. */
  118527. private _useLogarithmicDepth;
  118528. /**
  118529. * If set to true, no lighting calculations will be applied.
  118530. */
  118531. private _unlit;
  118532. private _debugMode;
  118533. /**
  118534. * @hidden
  118535. * This is reserved for the inspector.
  118536. * Defines the material debug mode.
  118537. * It helps seeing only some components of the material while troubleshooting.
  118538. */
  118539. debugMode: number;
  118540. /**
  118541. * @hidden
  118542. * This is reserved for the inspector.
  118543. * Specify from where on screen the debug mode should start.
  118544. * The value goes from -1 (full screen) to 1 (not visible)
  118545. * It helps with side by side comparison against the final render
  118546. * This defaults to -1
  118547. */
  118548. private debugLimit;
  118549. /**
  118550. * @hidden
  118551. * This is reserved for the inspector.
  118552. * As the default viewing range might not be enough (if the ambient is really small for instance)
  118553. * You can use the factor to better multiply the final value.
  118554. */
  118555. private debugFactor;
  118556. /**
  118557. * Defines the clear coat layer parameters for the material.
  118558. */
  118559. readonly clearCoat: PBRClearCoatConfiguration;
  118560. /**
  118561. * Defines the anisotropic parameters for the material.
  118562. */
  118563. readonly anisotropy: PBRAnisotropicConfiguration;
  118564. /**
  118565. * Defines the BRDF parameters for the material.
  118566. */
  118567. readonly brdf: PBRBRDFConfiguration;
  118568. /**
  118569. * Defines the Sheen parameters for the material.
  118570. */
  118571. readonly sheen: PBRSheenConfiguration;
  118572. /**
  118573. * Defines the SubSurface parameters for the material.
  118574. */
  118575. readonly subSurface: PBRSubSurfaceConfiguration;
  118576. /**
  118577. * Custom callback helping to override the default shader used in the material.
  118578. */
  118579. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  118580. protected _rebuildInParallel: boolean;
  118581. /**
  118582. * Instantiates a new PBRMaterial instance.
  118583. *
  118584. * @param name The material name
  118585. * @param scene The scene the material will be use in.
  118586. */
  118587. constructor(name: string, scene: Scene);
  118588. /**
  118589. * Gets a boolean indicating that current material needs to register RTT
  118590. */
  118591. readonly hasRenderTargetTextures: boolean;
  118592. /**
  118593. * Gets the name of the material class.
  118594. */
  118595. getClassName(): string;
  118596. /**
  118597. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118598. */
  118599. /**
  118600. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  118601. */
  118602. useLogarithmicDepth: boolean;
  118603. /**
  118604. * Gets the current transparency mode.
  118605. */
  118606. /**
  118607. * Sets the transparency mode of the material.
  118608. *
  118609. * | Value | Type | Description |
  118610. * | ----- | ----------------------------------- | ----------- |
  118611. * | 0 | OPAQUE | |
  118612. * | 1 | ALPHATEST | |
  118613. * | 2 | ALPHABLEND | |
  118614. * | 3 | ALPHATESTANDBLEND | |
  118615. *
  118616. */
  118617. transparencyMode: Nullable<number>;
  118618. /**
  118619. * Returns true if alpha blending should be disabled.
  118620. */
  118621. private readonly _disableAlphaBlending;
  118622. /**
  118623. * Specifies whether or not this material should be rendered in alpha blend mode.
  118624. */
  118625. needAlphaBlending(): boolean;
  118626. /**
  118627. * Specifies if the mesh will require alpha blending.
  118628. * @param mesh - BJS mesh.
  118629. */
  118630. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  118631. /**
  118632. * Specifies whether or not this material should be rendered in alpha test mode.
  118633. */
  118634. needAlphaTesting(): boolean;
  118635. /**
  118636. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  118637. */
  118638. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  118639. /**
  118640. * Gets the texture used for the alpha test.
  118641. */
  118642. getAlphaTestTexture(): Nullable<BaseTexture>;
  118643. /**
  118644. * Specifies that the submesh is ready to be used.
  118645. * @param mesh - BJS mesh.
  118646. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  118647. * @param useInstances - Specifies that instances should be used.
  118648. * @returns - boolean indicating that the submesh is ready or not.
  118649. */
  118650. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118651. /**
  118652. * Specifies if the material uses metallic roughness workflow.
  118653. * @returns boolean specifiying if the material uses metallic roughness workflow.
  118654. */
  118655. isMetallicWorkflow(): boolean;
  118656. private _prepareEffect;
  118657. private _prepareDefines;
  118658. /**
  118659. * Force shader compilation
  118660. */
  118661. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  118662. /**
  118663. * Initializes the uniform buffer layout for the shader.
  118664. */
  118665. buildUniformLayout(): void;
  118666. /**
  118667. * Unbinds the material from the mesh
  118668. */
  118669. unbind(): void;
  118670. /**
  118671. * Binds the submesh data.
  118672. * @param world - The world matrix.
  118673. * @param mesh - The BJS mesh.
  118674. * @param subMesh - A submesh of the BJS mesh.
  118675. */
  118676. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118677. /**
  118678. * Returns the animatable textures.
  118679. * @returns - Array of animatable textures.
  118680. */
  118681. getAnimatables(): IAnimatable[];
  118682. /**
  118683. * Returns the texture used for reflections.
  118684. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  118685. */
  118686. private _getReflectionTexture;
  118687. /**
  118688. * Returns an array of the actively used textures.
  118689. * @returns - Array of BaseTextures
  118690. */
  118691. getActiveTextures(): BaseTexture[];
  118692. /**
  118693. * Checks to see if a texture is used in the material.
  118694. * @param texture - Base texture to use.
  118695. * @returns - Boolean specifying if a texture is used in the material.
  118696. */
  118697. hasTexture(texture: BaseTexture): boolean;
  118698. /**
  118699. * Disposes the resources of the material.
  118700. * @param forceDisposeEffect - Forces the disposal of effects.
  118701. * @param forceDisposeTextures - Forces the disposal of all textures.
  118702. */
  118703. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  118704. }
  118705. }
  118706. declare module BABYLON {
  118707. /**
  118708. * The Physically based material of BJS.
  118709. *
  118710. * This offers the main features of a standard PBR material.
  118711. * For more information, please refer to the documentation :
  118712. * https://doc.babylonjs.com/how_to/physically_based_rendering
  118713. */
  118714. export class PBRMaterial extends PBRBaseMaterial {
  118715. /**
  118716. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  118717. */
  118718. static readonly PBRMATERIAL_OPAQUE: number;
  118719. /**
  118720. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  118721. */
  118722. static readonly PBRMATERIAL_ALPHATEST: number;
  118723. /**
  118724. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118725. */
  118726. static readonly PBRMATERIAL_ALPHABLEND: number;
  118727. /**
  118728. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  118729. * They are also discarded below the alpha cutoff threshold to improve performances.
  118730. */
  118731. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  118732. /**
  118733. * Defines the default value of how much AO map is occluding the analytical lights
  118734. * (point spot...).
  118735. */
  118736. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  118737. /**
  118738. * Intensity of the direct lights e.g. the four lights available in your scene.
  118739. * This impacts both the direct diffuse and specular highlights.
  118740. */
  118741. directIntensity: number;
  118742. /**
  118743. * Intensity of the emissive part of the material.
  118744. * This helps controlling the emissive effect without modifying the emissive color.
  118745. */
  118746. emissiveIntensity: number;
  118747. /**
  118748. * Intensity of the environment e.g. how much the environment will light the object
  118749. * either through harmonics for rough material or through the refelction for shiny ones.
  118750. */
  118751. environmentIntensity: number;
  118752. /**
  118753. * This is a special control allowing the reduction of the specular highlights coming from the
  118754. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  118755. */
  118756. specularIntensity: number;
  118757. /**
  118758. * Debug Control allowing disabling the bump map on this material.
  118759. */
  118760. disableBumpMap: boolean;
  118761. /**
  118762. * AKA Diffuse Texture in standard nomenclature.
  118763. */
  118764. albedoTexture: BaseTexture;
  118765. /**
  118766. * AKA Occlusion Texture in other nomenclature.
  118767. */
  118768. ambientTexture: BaseTexture;
  118769. /**
  118770. * AKA Occlusion Texture Intensity in other nomenclature.
  118771. */
  118772. ambientTextureStrength: number;
  118773. /**
  118774. * Defines how much the AO map is occluding the analytical lights (point spot...).
  118775. * 1 means it completely occludes it
  118776. * 0 mean it has no impact
  118777. */
  118778. ambientTextureImpactOnAnalyticalLights: number;
  118779. /**
  118780. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  118781. */
  118782. opacityTexture: BaseTexture;
  118783. /**
  118784. * Stores the reflection values in a texture.
  118785. */
  118786. reflectionTexture: Nullable<BaseTexture>;
  118787. /**
  118788. * Stores the emissive values in a texture.
  118789. */
  118790. emissiveTexture: BaseTexture;
  118791. /**
  118792. * AKA Specular texture in other nomenclature.
  118793. */
  118794. reflectivityTexture: BaseTexture;
  118795. /**
  118796. * Used to switch from specular/glossiness to metallic/roughness workflow.
  118797. */
  118798. metallicTexture: BaseTexture;
  118799. /**
  118800. * Specifies the metallic scalar of the metallic/roughness workflow.
  118801. * Can also be used to scale the metalness values of the metallic texture.
  118802. */
  118803. metallic: Nullable<number>;
  118804. /**
  118805. * Specifies the roughness scalar of the metallic/roughness workflow.
  118806. * Can also be used to scale the roughness values of the metallic texture.
  118807. */
  118808. roughness: Nullable<number>;
  118809. /**
  118810. * Specifies the an F0 factor to help configuring the material F0.
  118811. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  118812. * to 0.5 the previously hard coded value stays the same.
  118813. * Can also be used to scale the F0 values of the metallic texture.
  118814. */
  118815. metallicF0Factor: number;
  118816. /**
  118817. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  118818. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  118819. * your expectation as it multiplies with the texture data.
  118820. */
  118821. useMetallicF0FactorFromMetallicTexture: boolean;
  118822. /**
  118823. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  118824. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  118825. */
  118826. microSurfaceTexture: BaseTexture;
  118827. /**
  118828. * Stores surface normal data used to displace a mesh in a texture.
  118829. */
  118830. bumpTexture: BaseTexture;
  118831. /**
  118832. * Stores the pre-calculated light information of a mesh in a texture.
  118833. */
  118834. lightmapTexture: BaseTexture;
  118835. /**
  118836. * Stores the refracted light information in a texture.
  118837. */
  118838. refractionTexture: Nullable<BaseTexture>;
  118839. /**
  118840. * The color of a material in ambient lighting.
  118841. */
  118842. ambientColor: Color3;
  118843. /**
  118844. * AKA Diffuse Color in other nomenclature.
  118845. */
  118846. albedoColor: Color3;
  118847. /**
  118848. * AKA Specular Color in other nomenclature.
  118849. */
  118850. reflectivityColor: Color3;
  118851. /**
  118852. * The color reflected from the material.
  118853. */
  118854. reflectionColor: Color3;
  118855. /**
  118856. * The color emitted from the material.
  118857. */
  118858. emissiveColor: Color3;
  118859. /**
  118860. * AKA Glossiness in other nomenclature.
  118861. */
  118862. microSurface: number;
  118863. /**
  118864. * source material index of refraction (IOR)' / 'destination material IOR.
  118865. */
  118866. indexOfRefraction: number;
  118867. /**
  118868. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  118869. */
  118870. invertRefractionY: boolean;
  118871. /**
  118872. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  118873. * Materials half opaque for instance using refraction could benefit from this control.
  118874. */
  118875. linkRefractionWithTransparency: boolean;
  118876. /**
  118877. * If true, the light map contains occlusion information instead of lighting info.
  118878. */
  118879. useLightmapAsShadowmap: boolean;
  118880. /**
  118881. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  118882. */
  118883. useAlphaFromAlbedoTexture: boolean;
  118884. /**
  118885. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  118886. */
  118887. forceAlphaTest: boolean;
  118888. /**
  118889. * Defines the alpha limits in alpha test mode.
  118890. */
  118891. alphaCutOff: number;
  118892. /**
  118893. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  118894. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  118895. */
  118896. useSpecularOverAlpha: boolean;
  118897. /**
  118898. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  118899. */
  118900. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  118901. /**
  118902. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  118903. */
  118904. useRoughnessFromMetallicTextureAlpha: boolean;
  118905. /**
  118906. * Specifies if the metallic texture contains the roughness information in its green channel.
  118907. */
  118908. useRoughnessFromMetallicTextureGreen: boolean;
  118909. /**
  118910. * Specifies if the metallic texture contains the metallness information in its blue channel.
  118911. */
  118912. useMetallnessFromMetallicTextureBlue: boolean;
  118913. /**
  118914. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  118915. */
  118916. useAmbientOcclusionFromMetallicTextureRed: boolean;
  118917. /**
  118918. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  118919. */
  118920. useAmbientInGrayScale: boolean;
  118921. /**
  118922. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  118923. * The material will try to infer what glossiness each pixel should be.
  118924. */
  118925. useAutoMicroSurfaceFromReflectivityMap: boolean;
  118926. /**
  118927. * BJS is using an harcoded light falloff based on a manually sets up range.
  118928. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118929. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118930. */
  118931. /**
  118932. * BJS is using an harcoded light falloff based on a manually sets up range.
  118933. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  118934. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  118935. */
  118936. usePhysicalLightFalloff: boolean;
  118937. /**
  118938. * In order to support the falloff compatibility with gltf, a special mode has been added
  118939. * to reproduce the gltf light falloff.
  118940. */
  118941. /**
  118942. * In order to support the falloff compatibility with gltf, a special mode has been added
  118943. * to reproduce the gltf light falloff.
  118944. */
  118945. useGLTFLightFalloff: boolean;
  118946. /**
  118947. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  118948. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  118949. */
  118950. useRadianceOverAlpha: boolean;
  118951. /**
  118952. * Allows using an object space normal map (instead of tangent space).
  118953. */
  118954. useObjectSpaceNormalMap: boolean;
  118955. /**
  118956. * Allows using the bump map in parallax mode.
  118957. */
  118958. useParallax: boolean;
  118959. /**
  118960. * Allows using the bump map in parallax occlusion mode.
  118961. */
  118962. useParallaxOcclusion: boolean;
  118963. /**
  118964. * Controls the scale bias of the parallax mode.
  118965. */
  118966. parallaxScaleBias: number;
  118967. /**
  118968. * If sets to true, disables all the lights affecting the material.
  118969. */
  118970. disableLighting: boolean;
  118971. /**
  118972. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  118973. */
  118974. forceIrradianceInFragment: boolean;
  118975. /**
  118976. * Number of Simultaneous lights allowed on the material.
  118977. */
  118978. maxSimultaneousLights: number;
  118979. /**
  118980. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118981. */
  118982. invertNormalMapX: boolean;
  118983. /**
  118984. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118985. */
  118986. invertNormalMapY: boolean;
  118987. /**
  118988. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118989. */
  118990. twoSidedLighting: boolean;
  118991. /**
  118992. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118993. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  118994. */
  118995. useAlphaFresnel: boolean;
  118996. /**
  118997. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  118998. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  118999. */
  119000. useLinearAlphaFresnel: boolean;
  119001. /**
  119002. * Let user defines the brdf lookup texture used for IBL.
  119003. * A default 8bit version is embedded but you could point at :
  119004. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  119005. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119006. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  119007. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119008. */
  119009. environmentBRDFTexture: Nullable<BaseTexture>;
  119010. /**
  119011. * Force normal to face away from face.
  119012. */
  119013. forceNormalForward: boolean;
  119014. /**
  119015. * Enables specular anti aliasing in the PBR shader.
  119016. * It will both interacts on the Geometry for analytical and IBL lighting.
  119017. * It also prefilter the roughness map based on the bump values.
  119018. */
  119019. enableSpecularAntiAliasing: boolean;
  119020. /**
  119021. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  119022. * makes the reflect vector face the model (under horizon).
  119023. */
  119024. useHorizonOcclusion: boolean;
  119025. /**
  119026. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  119027. * too much the area relying on ambient texture to define their ambient occlusion.
  119028. */
  119029. useRadianceOcclusion: boolean;
  119030. /**
  119031. * If set to true, no lighting calculations will be applied.
  119032. */
  119033. unlit: boolean;
  119034. /**
  119035. * Gets the image processing configuration used either in this material.
  119036. */
  119037. /**
  119038. * Sets the Default image processing configuration used either in the this material.
  119039. *
  119040. * If sets to null, the scene one is in use.
  119041. */
  119042. imageProcessingConfiguration: ImageProcessingConfiguration;
  119043. /**
  119044. * Gets wether the color curves effect is enabled.
  119045. */
  119046. /**
  119047. * Sets wether the color curves effect is enabled.
  119048. */
  119049. cameraColorCurvesEnabled: boolean;
  119050. /**
  119051. * Gets wether the color grading effect is enabled.
  119052. */
  119053. /**
  119054. * Gets wether the color grading effect is enabled.
  119055. */
  119056. cameraColorGradingEnabled: boolean;
  119057. /**
  119058. * Gets wether tonemapping is enabled or not.
  119059. */
  119060. /**
  119061. * Sets wether tonemapping is enabled or not
  119062. */
  119063. cameraToneMappingEnabled: boolean;
  119064. /**
  119065. * The camera exposure used on this material.
  119066. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119067. * This corresponds to a photographic exposure.
  119068. */
  119069. /**
  119070. * The camera exposure used on this material.
  119071. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  119072. * This corresponds to a photographic exposure.
  119073. */
  119074. cameraExposure: number;
  119075. /**
  119076. * Gets The camera contrast used on this material.
  119077. */
  119078. /**
  119079. * Sets The camera contrast used on this material.
  119080. */
  119081. cameraContrast: number;
  119082. /**
  119083. * Gets the Color Grading 2D Lookup Texture.
  119084. */
  119085. /**
  119086. * Sets the Color Grading 2D Lookup Texture.
  119087. */
  119088. cameraColorGradingTexture: Nullable<BaseTexture>;
  119089. /**
  119090. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119091. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119092. * 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;
  119093. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119094. */
  119095. /**
  119096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  119097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  119098. * 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;
  119099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  119100. */
  119101. cameraColorCurves: Nullable<ColorCurves>;
  119102. /**
  119103. * Instantiates a new PBRMaterial instance.
  119104. *
  119105. * @param name The material name
  119106. * @param scene The scene the material will be use in.
  119107. */
  119108. constructor(name: string, scene: Scene);
  119109. /**
  119110. * Returns the name of this material class.
  119111. */
  119112. getClassName(): string;
  119113. /**
  119114. * Makes a duplicate of the current material.
  119115. * @param name - name to use for the new material.
  119116. */
  119117. clone(name: string): PBRMaterial;
  119118. /**
  119119. * Serializes this PBR Material.
  119120. * @returns - An object with the serialized material.
  119121. */
  119122. serialize(): any;
  119123. /**
  119124. * Parses a PBR Material from a serialized object.
  119125. * @param source - Serialized object.
  119126. * @param scene - BJS scene instance.
  119127. * @param rootUrl - url for the scene object
  119128. * @returns - PBRMaterial
  119129. */
  119130. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  119131. }
  119132. }
  119133. declare module BABYLON {
  119134. /**
  119135. * Direct draw surface info
  119136. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  119137. */
  119138. export interface DDSInfo {
  119139. /**
  119140. * Width of the texture
  119141. */
  119142. width: number;
  119143. /**
  119144. * Width of the texture
  119145. */
  119146. height: number;
  119147. /**
  119148. * Number of Mipmaps for the texture
  119149. * @see https://en.wikipedia.org/wiki/Mipmap
  119150. */
  119151. mipmapCount: number;
  119152. /**
  119153. * If the textures format is a known fourCC format
  119154. * @see https://www.fourcc.org/
  119155. */
  119156. isFourCC: boolean;
  119157. /**
  119158. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  119159. */
  119160. isRGB: boolean;
  119161. /**
  119162. * If the texture is a lumincance format
  119163. */
  119164. isLuminance: boolean;
  119165. /**
  119166. * If this is a cube texture
  119167. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  119168. */
  119169. isCube: boolean;
  119170. /**
  119171. * If the texture is a compressed format eg. FOURCC_DXT1
  119172. */
  119173. isCompressed: boolean;
  119174. /**
  119175. * The dxgiFormat of the texture
  119176. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  119177. */
  119178. dxgiFormat: number;
  119179. /**
  119180. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  119181. */
  119182. textureType: number;
  119183. /**
  119184. * Sphericle polynomial created for the dds texture
  119185. */
  119186. sphericalPolynomial?: SphericalPolynomial;
  119187. }
  119188. /**
  119189. * Class used to provide DDS decompression tools
  119190. */
  119191. export class DDSTools {
  119192. /**
  119193. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  119194. */
  119195. static StoreLODInAlphaChannel: boolean;
  119196. /**
  119197. * Gets DDS information from an array buffer
  119198. * @param arrayBuffer defines the array buffer to read data from
  119199. * @returns the DDS information
  119200. */
  119201. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  119202. private static _FloatView;
  119203. private static _Int32View;
  119204. private static _ToHalfFloat;
  119205. private static _FromHalfFloat;
  119206. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  119207. private static _GetHalfFloatRGBAArrayBuffer;
  119208. private static _GetFloatRGBAArrayBuffer;
  119209. private static _GetFloatAsUIntRGBAArrayBuffer;
  119210. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  119211. private static _GetRGBAArrayBuffer;
  119212. private static _ExtractLongWordOrder;
  119213. private static _GetRGBArrayBuffer;
  119214. private static _GetLuminanceArrayBuffer;
  119215. /**
  119216. * Uploads DDS Levels to a Babylon Texture
  119217. * @hidden
  119218. */
  119219. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  119220. }
  119221. interface ThinEngine {
  119222. /**
  119223. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  119224. * @param rootUrl defines the url where the file to load is located
  119225. * @param scene defines the current scene
  119226. * @param lodScale defines scale to apply to the mip map selection
  119227. * @param lodOffset defines offset to apply to the mip map selection
  119228. * @param onLoad defines an optional callback raised when the texture is loaded
  119229. * @param onError defines an optional callback raised if there is an issue to load the texture
  119230. * @param format defines the format of the data
  119231. * @param forcedExtension defines the extension to use to pick the right loader
  119232. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  119233. * @returns the cube texture as an InternalTexture
  119234. */
  119235. 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;
  119236. }
  119237. }
  119238. declare module BABYLON {
  119239. /**
  119240. * Implementation of the DDS Texture Loader.
  119241. * @hidden
  119242. */
  119243. export class _DDSTextureLoader implements IInternalTextureLoader {
  119244. /**
  119245. * Defines wether the loader supports cascade loading the different faces.
  119246. */
  119247. readonly supportCascades: boolean;
  119248. /**
  119249. * This returns if the loader support the current file information.
  119250. * @param extension defines the file extension of the file being loaded
  119251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119252. * @param fallback defines the fallback internal texture if any
  119253. * @param isBase64 defines whether the texture is encoded as a base64
  119254. * @param isBuffer defines whether the texture data are stored as a buffer
  119255. * @returns true if the loader can load the specified file
  119256. */
  119257. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119258. /**
  119259. * Transform the url before loading if required.
  119260. * @param rootUrl the url of the texture
  119261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119262. * @returns the transformed texture
  119263. */
  119264. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119265. /**
  119266. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119267. * @param rootUrl the url of the texture
  119268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119269. * @returns the fallback texture
  119270. */
  119271. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119272. /**
  119273. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119274. * @param data contains the texture data
  119275. * @param texture defines the BabylonJS internal texture
  119276. * @param createPolynomials will be true if polynomials have been requested
  119277. * @param onLoad defines the callback to trigger once the texture is ready
  119278. * @param onError defines the callback to trigger in case of error
  119279. */
  119280. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119281. /**
  119282. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119283. * @param data contains the texture data
  119284. * @param texture defines the BabylonJS internal texture
  119285. * @param callback defines the method to call once ready to upload
  119286. */
  119287. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119288. }
  119289. }
  119290. declare module BABYLON {
  119291. /**
  119292. * Implementation of the ENV Texture Loader.
  119293. * @hidden
  119294. */
  119295. export class _ENVTextureLoader implements IInternalTextureLoader {
  119296. /**
  119297. * Defines wether the loader supports cascade loading the different faces.
  119298. */
  119299. readonly supportCascades: boolean;
  119300. /**
  119301. * This returns if the loader support the current file information.
  119302. * @param extension defines the file extension of the file being loaded
  119303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119304. * @param fallback defines the fallback internal texture if any
  119305. * @param isBase64 defines whether the texture is encoded as a base64
  119306. * @param isBuffer defines whether the texture data are stored as a buffer
  119307. * @returns true if the loader can load the specified file
  119308. */
  119309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119310. /**
  119311. * Transform the url before loading if required.
  119312. * @param rootUrl the url of the texture
  119313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119314. * @returns the transformed texture
  119315. */
  119316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119317. /**
  119318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119319. * @param rootUrl the url of the texture
  119320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119321. * @returns the fallback texture
  119322. */
  119323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119324. /**
  119325. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119326. * @param data contains the texture data
  119327. * @param texture defines the BabylonJS internal texture
  119328. * @param createPolynomials will be true if polynomials have been requested
  119329. * @param onLoad defines the callback to trigger once the texture is ready
  119330. * @param onError defines the callback to trigger in case of error
  119331. */
  119332. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119333. /**
  119334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119335. * @param data contains the texture data
  119336. * @param texture defines the BabylonJS internal texture
  119337. * @param callback defines the method to call once ready to upload
  119338. */
  119339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119340. }
  119341. }
  119342. declare module BABYLON {
  119343. /**
  119344. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  119345. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  119346. */
  119347. export class KhronosTextureContainer {
  119348. /** contents of the KTX container file */
  119349. arrayBuffer: any;
  119350. private static HEADER_LEN;
  119351. private static COMPRESSED_2D;
  119352. private static COMPRESSED_3D;
  119353. private static TEX_2D;
  119354. private static TEX_3D;
  119355. /**
  119356. * Gets the openGL type
  119357. */
  119358. glType: number;
  119359. /**
  119360. * Gets the openGL type size
  119361. */
  119362. glTypeSize: number;
  119363. /**
  119364. * Gets the openGL format
  119365. */
  119366. glFormat: number;
  119367. /**
  119368. * Gets the openGL internal format
  119369. */
  119370. glInternalFormat: number;
  119371. /**
  119372. * Gets the base internal format
  119373. */
  119374. glBaseInternalFormat: number;
  119375. /**
  119376. * Gets image width in pixel
  119377. */
  119378. pixelWidth: number;
  119379. /**
  119380. * Gets image height in pixel
  119381. */
  119382. pixelHeight: number;
  119383. /**
  119384. * Gets image depth in pixels
  119385. */
  119386. pixelDepth: number;
  119387. /**
  119388. * Gets the number of array elements
  119389. */
  119390. numberOfArrayElements: number;
  119391. /**
  119392. * Gets the number of faces
  119393. */
  119394. numberOfFaces: number;
  119395. /**
  119396. * Gets the number of mipmap levels
  119397. */
  119398. numberOfMipmapLevels: number;
  119399. /**
  119400. * Gets the bytes of key value data
  119401. */
  119402. bytesOfKeyValueData: number;
  119403. /**
  119404. * Gets the load type
  119405. */
  119406. loadType: number;
  119407. /**
  119408. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  119409. */
  119410. isInvalid: boolean;
  119411. /**
  119412. * Creates a new KhronosTextureContainer
  119413. * @param arrayBuffer contents of the KTX container file
  119414. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  119415. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  119416. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  119417. */
  119418. constructor(
  119419. /** contents of the KTX container file */
  119420. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  119421. /**
  119422. * Uploads KTX content to a Babylon Texture.
  119423. * It is assumed that the texture has already been created & is currently bound
  119424. * @hidden
  119425. */
  119426. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  119427. private _upload2DCompressedLevels;
  119428. }
  119429. }
  119430. declare module BABYLON {
  119431. /**
  119432. * Implementation of the KTX Texture Loader.
  119433. * @hidden
  119434. */
  119435. export class _KTXTextureLoader implements IInternalTextureLoader {
  119436. /**
  119437. * Defines wether the loader supports cascade loading the different faces.
  119438. */
  119439. readonly supportCascades: boolean;
  119440. /**
  119441. * This returns if the loader support the current file information.
  119442. * @param extension defines the file extension of the file being loaded
  119443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119444. * @param fallback defines the fallback internal texture if any
  119445. * @param isBase64 defines whether the texture is encoded as a base64
  119446. * @param isBuffer defines whether the texture data are stored as a buffer
  119447. * @returns true if the loader can load the specified file
  119448. */
  119449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119450. /**
  119451. * Transform the url before loading if required.
  119452. * @param rootUrl the url of the texture
  119453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119454. * @returns the transformed texture
  119455. */
  119456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119457. /**
  119458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119459. * @param rootUrl the url of the texture
  119460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119461. * @returns the fallback texture
  119462. */
  119463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119464. /**
  119465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  119466. * @param data contains the texture data
  119467. * @param texture defines the BabylonJS internal texture
  119468. * @param createPolynomials will be true if polynomials have been requested
  119469. * @param onLoad defines the callback to trigger once the texture is ready
  119470. * @param onError defines the callback to trigger in case of error
  119471. */
  119472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119473. /**
  119474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119475. * @param data contains the texture data
  119476. * @param texture defines the BabylonJS internal texture
  119477. * @param callback defines the method to call once ready to upload
  119478. */
  119479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  119480. }
  119481. }
  119482. declare module BABYLON {
  119483. /** @hidden */
  119484. export var _forceSceneHelpersToBundle: boolean;
  119485. interface Scene {
  119486. /**
  119487. * Creates a default light for the scene.
  119488. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  119489. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  119490. */
  119491. createDefaultLight(replace?: boolean): void;
  119492. /**
  119493. * Creates a default camera for the scene.
  119494. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  119495. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  119496. * @param replace has default false, when true replaces the active camera in the scene
  119497. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  119498. */
  119499. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  119500. /**
  119501. * Creates a default camera and a default light.
  119502. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  119503. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  119504. * @param replace has the default false, when true replaces the active camera/light in the scene
  119505. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  119506. */
  119507. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  119508. /**
  119509. * Creates a new sky box
  119510. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  119511. * @param environmentTexture defines the texture to use as environment texture
  119512. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  119513. * @param scale defines the overall scale of the skybox
  119514. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  119515. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  119516. * @returns a new mesh holding the sky box
  119517. */
  119518. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  119519. /**
  119520. * Creates a new environment
  119521. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  119522. * @param options defines the options you can use to configure the environment
  119523. * @returns the new EnvironmentHelper
  119524. */
  119525. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  119526. /**
  119527. * Creates a new VREXperienceHelper
  119528. * @see http://doc.babylonjs.com/how_to/webvr_helper
  119529. * @param webVROptions defines the options used to create the new VREXperienceHelper
  119530. * @returns a new VREXperienceHelper
  119531. */
  119532. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  119533. /**
  119534. * Creates a new WebXRDefaultExperience
  119535. * @see http://doc.babylonjs.com/how_to/webxr
  119536. * @param options experience options
  119537. * @returns a promise for a new WebXRDefaultExperience
  119538. */
  119539. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119540. }
  119541. }
  119542. declare module BABYLON {
  119543. /**
  119544. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  119545. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  119546. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  119547. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119548. */
  119549. export class VideoDome extends TransformNode {
  119550. /**
  119551. * Define the video source as a Monoscopic panoramic 360 video.
  119552. */
  119553. static readonly MODE_MONOSCOPIC: number;
  119554. /**
  119555. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119556. */
  119557. static readonly MODE_TOPBOTTOM: number;
  119558. /**
  119559. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119560. */
  119561. static readonly MODE_SIDEBYSIDE: number;
  119562. private _halfDome;
  119563. private _useDirectMapping;
  119564. /**
  119565. * The video texture being displayed on the sphere
  119566. */
  119567. protected _videoTexture: VideoTexture;
  119568. /**
  119569. * Gets the video texture being displayed on the sphere
  119570. */
  119571. readonly videoTexture: VideoTexture;
  119572. /**
  119573. * The skybox material
  119574. */
  119575. protected _material: BackgroundMaterial;
  119576. /**
  119577. * The surface used for the skybox
  119578. */
  119579. protected _mesh: Mesh;
  119580. /**
  119581. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  119582. */
  119583. private _halfDomeMask;
  119584. /**
  119585. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119586. * Also see the options.resolution property.
  119587. */
  119588. fovMultiplier: number;
  119589. private _videoMode;
  119590. /**
  119591. * Gets or set the current video mode for the video. It can be:
  119592. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  119593. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  119594. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  119595. */
  119596. videoMode: number;
  119597. /**
  119598. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  119599. *
  119600. */
  119601. /**
  119602. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  119603. */
  119604. halfDome: boolean;
  119605. /**
  119606. * Oberserver used in Stereoscopic VR Mode.
  119607. */
  119608. private _onBeforeCameraRenderObserver;
  119609. /**
  119610. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  119611. * @param name Element's name, child elements will append suffixes for their own names.
  119612. * @param urlsOrVideo defines the url(s) or the video element to use
  119613. * @param options An object containing optional or exposed sub element properties
  119614. */
  119615. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  119616. resolution?: number;
  119617. clickToPlay?: boolean;
  119618. autoPlay?: boolean;
  119619. loop?: boolean;
  119620. size?: number;
  119621. poster?: string;
  119622. faceForward?: boolean;
  119623. useDirectMapping?: boolean;
  119624. halfDomeMode?: boolean;
  119625. }, scene: Scene);
  119626. private _changeVideoMode;
  119627. /**
  119628. * Releases resources associated with this node.
  119629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119631. */
  119632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119633. }
  119634. }
  119635. declare module BABYLON {
  119636. /**
  119637. * This class can be used to get instrumentation data from a Babylon engine
  119638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119639. */
  119640. export class EngineInstrumentation implements IDisposable {
  119641. /**
  119642. * Define the instrumented engine.
  119643. */
  119644. engine: Engine;
  119645. private _captureGPUFrameTime;
  119646. private _gpuFrameTimeToken;
  119647. private _gpuFrameTime;
  119648. private _captureShaderCompilationTime;
  119649. private _shaderCompilationTime;
  119650. private _onBeginFrameObserver;
  119651. private _onEndFrameObserver;
  119652. private _onBeforeShaderCompilationObserver;
  119653. private _onAfterShaderCompilationObserver;
  119654. /**
  119655. * Gets the perf counter used for GPU frame time
  119656. */
  119657. readonly gpuFrameTimeCounter: PerfCounter;
  119658. /**
  119659. * Gets the GPU frame time capture status
  119660. */
  119661. /**
  119662. * Enable or disable the GPU frame time capture
  119663. */
  119664. captureGPUFrameTime: boolean;
  119665. /**
  119666. * Gets the perf counter used for shader compilation time
  119667. */
  119668. readonly shaderCompilationTimeCounter: PerfCounter;
  119669. /**
  119670. * Gets the shader compilation time capture status
  119671. */
  119672. /**
  119673. * Enable or disable the shader compilation time capture
  119674. */
  119675. captureShaderCompilationTime: boolean;
  119676. /**
  119677. * Instantiates a new engine instrumentation.
  119678. * This class can be used to get instrumentation data from a Babylon engine
  119679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  119680. * @param engine Defines the engine to instrument
  119681. */
  119682. constructor(
  119683. /**
  119684. * Define the instrumented engine.
  119685. */
  119686. engine: Engine);
  119687. /**
  119688. * Dispose and release associated resources.
  119689. */
  119690. dispose(): void;
  119691. }
  119692. }
  119693. declare module BABYLON {
  119694. /**
  119695. * This class can be used to get instrumentation data from a Babylon engine
  119696. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119697. */
  119698. export class SceneInstrumentation implements IDisposable {
  119699. /**
  119700. * Defines the scene to instrument
  119701. */
  119702. scene: Scene;
  119703. private _captureActiveMeshesEvaluationTime;
  119704. private _activeMeshesEvaluationTime;
  119705. private _captureRenderTargetsRenderTime;
  119706. private _renderTargetsRenderTime;
  119707. private _captureFrameTime;
  119708. private _frameTime;
  119709. private _captureRenderTime;
  119710. private _renderTime;
  119711. private _captureInterFrameTime;
  119712. private _interFrameTime;
  119713. private _captureParticlesRenderTime;
  119714. private _particlesRenderTime;
  119715. private _captureSpritesRenderTime;
  119716. private _spritesRenderTime;
  119717. private _capturePhysicsTime;
  119718. private _physicsTime;
  119719. private _captureAnimationsTime;
  119720. private _animationsTime;
  119721. private _captureCameraRenderTime;
  119722. private _cameraRenderTime;
  119723. private _onBeforeActiveMeshesEvaluationObserver;
  119724. private _onAfterActiveMeshesEvaluationObserver;
  119725. private _onBeforeRenderTargetsRenderObserver;
  119726. private _onAfterRenderTargetsRenderObserver;
  119727. private _onAfterRenderObserver;
  119728. private _onBeforeDrawPhaseObserver;
  119729. private _onAfterDrawPhaseObserver;
  119730. private _onBeforeAnimationsObserver;
  119731. private _onBeforeParticlesRenderingObserver;
  119732. private _onAfterParticlesRenderingObserver;
  119733. private _onBeforeSpritesRenderingObserver;
  119734. private _onAfterSpritesRenderingObserver;
  119735. private _onBeforePhysicsObserver;
  119736. private _onAfterPhysicsObserver;
  119737. private _onAfterAnimationsObserver;
  119738. private _onBeforeCameraRenderObserver;
  119739. private _onAfterCameraRenderObserver;
  119740. /**
  119741. * Gets the perf counter used for active meshes evaluation time
  119742. */
  119743. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  119744. /**
  119745. * Gets the active meshes evaluation time capture status
  119746. */
  119747. /**
  119748. * Enable or disable the active meshes evaluation time capture
  119749. */
  119750. captureActiveMeshesEvaluationTime: boolean;
  119751. /**
  119752. * Gets the perf counter used for render targets render time
  119753. */
  119754. readonly renderTargetsRenderTimeCounter: PerfCounter;
  119755. /**
  119756. * Gets the render targets render time capture status
  119757. */
  119758. /**
  119759. * Enable or disable the render targets render time capture
  119760. */
  119761. captureRenderTargetsRenderTime: boolean;
  119762. /**
  119763. * Gets the perf counter used for particles render time
  119764. */
  119765. readonly particlesRenderTimeCounter: PerfCounter;
  119766. /**
  119767. * Gets the particles render time capture status
  119768. */
  119769. /**
  119770. * Enable or disable the particles render time capture
  119771. */
  119772. captureParticlesRenderTime: boolean;
  119773. /**
  119774. * Gets the perf counter used for sprites render time
  119775. */
  119776. readonly spritesRenderTimeCounter: PerfCounter;
  119777. /**
  119778. * Gets the sprites render time capture status
  119779. */
  119780. /**
  119781. * Enable or disable the sprites render time capture
  119782. */
  119783. captureSpritesRenderTime: boolean;
  119784. /**
  119785. * Gets the perf counter used for physics time
  119786. */
  119787. readonly physicsTimeCounter: PerfCounter;
  119788. /**
  119789. * Gets the physics time capture status
  119790. */
  119791. /**
  119792. * Enable or disable the physics time capture
  119793. */
  119794. capturePhysicsTime: boolean;
  119795. /**
  119796. * Gets the perf counter used for animations time
  119797. */
  119798. readonly animationsTimeCounter: PerfCounter;
  119799. /**
  119800. * Gets the animations time capture status
  119801. */
  119802. /**
  119803. * Enable or disable the animations time capture
  119804. */
  119805. captureAnimationsTime: boolean;
  119806. /**
  119807. * Gets the perf counter used for frame time capture
  119808. */
  119809. readonly frameTimeCounter: PerfCounter;
  119810. /**
  119811. * Gets the frame time capture status
  119812. */
  119813. /**
  119814. * Enable or disable the frame time capture
  119815. */
  119816. captureFrameTime: boolean;
  119817. /**
  119818. * Gets the perf counter used for inter-frames time capture
  119819. */
  119820. readonly interFrameTimeCounter: PerfCounter;
  119821. /**
  119822. * Gets the inter-frames time capture status
  119823. */
  119824. /**
  119825. * Enable or disable the inter-frames time capture
  119826. */
  119827. captureInterFrameTime: boolean;
  119828. /**
  119829. * Gets the perf counter used for render time capture
  119830. */
  119831. readonly renderTimeCounter: PerfCounter;
  119832. /**
  119833. * Gets the render time capture status
  119834. */
  119835. /**
  119836. * Enable or disable the render time capture
  119837. */
  119838. captureRenderTime: boolean;
  119839. /**
  119840. * Gets the perf counter used for camera render time capture
  119841. */
  119842. readonly cameraRenderTimeCounter: PerfCounter;
  119843. /**
  119844. * Gets the camera render time capture status
  119845. */
  119846. /**
  119847. * Enable or disable the camera render time capture
  119848. */
  119849. captureCameraRenderTime: boolean;
  119850. /**
  119851. * Gets the perf counter used for draw calls
  119852. */
  119853. readonly drawCallsCounter: PerfCounter;
  119854. /**
  119855. * Instantiates a new scene instrumentation.
  119856. * This class can be used to get instrumentation data from a Babylon engine
  119857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  119858. * @param scene Defines the scene to instrument
  119859. */
  119860. constructor(
  119861. /**
  119862. * Defines the scene to instrument
  119863. */
  119864. scene: Scene);
  119865. /**
  119866. * Dispose and release associated resources.
  119867. */
  119868. dispose(): void;
  119869. }
  119870. }
  119871. declare module BABYLON {
  119872. /** @hidden */
  119873. export var glowMapGenerationPixelShader: {
  119874. name: string;
  119875. shader: string;
  119876. };
  119877. }
  119878. declare module BABYLON {
  119879. /** @hidden */
  119880. export var glowMapGenerationVertexShader: {
  119881. name: string;
  119882. shader: string;
  119883. };
  119884. }
  119885. declare module BABYLON {
  119886. /**
  119887. * Effect layer options. This helps customizing the behaviour
  119888. * of the effect layer.
  119889. */
  119890. export interface IEffectLayerOptions {
  119891. /**
  119892. * Multiplication factor apply to the canvas size to compute the render target size
  119893. * used to generated the objects (the smaller the faster).
  119894. */
  119895. mainTextureRatio: number;
  119896. /**
  119897. * Enforces a fixed size texture to ensure effect stability across devices.
  119898. */
  119899. mainTextureFixedSize?: number;
  119900. /**
  119901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  119902. */
  119903. alphaBlendingMode: number;
  119904. /**
  119905. * The camera attached to the layer.
  119906. */
  119907. camera: Nullable<Camera>;
  119908. /**
  119909. * The rendering group to draw the layer in.
  119910. */
  119911. renderingGroupId: number;
  119912. }
  119913. /**
  119914. * The effect layer Helps adding post process effect blended with the main pass.
  119915. *
  119916. * This can be for instance use to generate glow or higlight effects on the scene.
  119917. *
  119918. * The effect layer class can not be used directly and is intented to inherited from to be
  119919. * customized per effects.
  119920. */
  119921. export abstract class EffectLayer {
  119922. private _vertexBuffers;
  119923. private _indexBuffer;
  119924. private _cachedDefines;
  119925. private _effectLayerMapGenerationEffect;
  119926. private _effectLayerOptions;
  119927. private _mergeEffect;
  119928. protected _scene: Scene;
  119929. protected _engine: Engine;
  119930. protected _maxSize: number;
  119931. protected _mainTextureDesiredSize: ISize;
  119932. protected _mainTexture: RenderTargetTexture;
  119933. protected _shouldRender: boolean;
  119934. protected _postProcesses: PostProcess[];
  119935. protected _textures: BaseTexture[];
  119936. protected _emissiveTextureAndColor: {
  119937. texture: Nullable<BaseTexture>;
  119938. color: Color4;
  119939. };
  119940. /**
  119941. * The name of the layer
  119942. */
  119943. name: string;
  119944. /**
  119945. * The clear color of the texture used to generate the glow map.
  119946. */
  119947. neutralColor: Color4;
  119948. /**
  119949. * Specifies wether the highlight layer is enabled or not.
  119950. */
  119951. isEnabled: boolean;
  119952. /**
  119953. * Gets the camera attached to the layer.
  119954. */
  119955. readonly camera: Nullable<Camera>;
  119956. /**
  119957. * Gets the rendering group id the layer should render in.
  119958. */
  119959. renderingGroupId: number;
  119960. /**
  119961. * An event triggered when the effect layer has been disposed.
  119962. */
  119963. onDisposeObservable: Observable<EffectLayer>;
  119964. /**
  119965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  119966. */
  119967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  119968. /**
  119969. * An event triggered when the generated texture is being merged in the scene.
  119970. */
  119971. onBeforeComposeObservable: Observable<EffectLayer>;
  119972. /**
  119973. * An event triggered when the mesh is rendered into the effect render target.
  119974. */
  119975. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  119976. /**
  119977. * An event triggered after the mesh has been rendered into the effect render target.
  119978. */
  119979. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  119980. /**
  119981. * An event triggered when the generated texture has been merged in the scene.
  119982. */
  119983. onAfterComposeObservable: Observable<EffectLayer>;
  119984. /**
  119985. * An event triggered when the efffect layer changes its size.
  119986. */
  119987. onSizeChangedObservable: Observable<EffectLayer>;
  119988. /** @hidden */
  119989. static _SceneComponentInitialization: (scene: Scene) => void;
  119990. /**
  119991. * Instantiates a new effect Layer and references it in the scene.
  119992. * @param name The name of the layer
  119993. * @param scene The scene to use the layer in
  119994. */
  119995. constructor(
  119996. /** The Friendly of the effect in the scene */
  119997. name: string, scene: Scene);
  119998. /**
  119999. * Get the effect name of the layer.
  120000. * @return The effect name
  120001. */
  120002. abstract getEffectName(): string;
  120003. /**
  120004. * Checks for the readiness of the element composing the layer.
  120005. * @param subMesh the mesh to check for
  120006. * @param useInstances specify wether or not to use instances to render the mesh
  120007. * @return true if ready otherwise, false
  120008. */
  120009. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120010. /**
  120011. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120012. * @returns true if the effect requires stencil during the main canvas render pass.
  120013. */
  120014. abstract needStencil(): boolean;
  120015. /**
  120016. * Create the merge effect. This is the shader use to blit the information back
  120017. * to the main canvas at the end of the scene rendering.
  120018. * @returns The effect containing the shader used to merge the effect on the main canvas
  120019. */
  120020. protected abstract _createMergeEffect(): Effect;
  120021. /**
  120022. * Creates the render target textures and post processes used in the effect layer.
  120023. */
  120024. protected abstract _createTextureAndPostProcesses(): void;
  120025. /**
  120026. * Implementation specific of rendering the generating effect on the main canvas.
  120027. * @param effect The effect used to render through
  120028. */
  120029. protected abstract _internalRender(effect: Effect): void;
  120030. /**
  120031. * Sets the required values for both the emissive texture and and the main color.
  120032. */
  120033. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120034. /**
  120035. * Free any resources and references associated to a mesh.
  120036. * Internal use
  120037. * @param mesh The mesh to free.
  120038. */
  120039. abstract _disposeMesh(mesh: Mesh): void;
  120040. /**
  120041. * Serializes this layer (Glow or Highlight for example)
  120042. * @returns a serialized layer object
  120043. */
  120044. abstract serialize?(): any;
  120045. /**
  120046. * Initializes the effect layer with the required options.
  120047. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  120048. */
  120049. protected _init(options: Partial<IEffectLayerOptions>): void;
  120050. /**
  120051. * Generates the index buffer of the full screen quad blending to the main canvas.
  120052. */
  120053. private _generateIndexBuffer;
  120054. /**
  120055. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  120056. */
  120057. private _generateVertexBuffer;
  120058. /**
  120059. * Sets the main texture desired size which is the closest power of two
  120060. * of the engine canvas size.
  120061. */
  120062. private _setMainTextureSize;
  120063. /**
  120064. * Creates the main texture for the effect layer.
  120065. */
  120066. protected _createMainTexture(): void;
  120067. /**
  120068. * Adds specific effects defines.
  120069. * @param defines The defines to add specifics to.
  120070. */
  120071. protected _addCustomEffectDefines(defines: string[]): void;
  120072. /**
  120073. * Checks for the readiness of the element composing the layer.
  120074. * @param subMesh the mesh to check for
  120075. * @param useInstances specify wether or not to use instances to render the mesh
  120076. * @param emissiveTexture the associated emissive texture used to generate the glow
  120077. * @return true if ready otherwise, false
  120078. */
  120079. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  120080. /**
  120081. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  120082. */
  120083. render(): void;
  120084. /**
  120085. * Determine if a given mesh will be used in the current effect.
  120086. * @param mesh mesh to test
  120087. * @returns true if the mesh will be used
  120088. */
  120089. hasMesh(mesh: AbstractMesh): boolean;
  120090. /**
  120091. * Returns true if the layer contains information to display, otherwise false.
  120092. * @returns true if the glow layer should be rendered
  120093. */
  120094. shouldRender(): boolean;
  120095. /**
  120096. * Returns true if the mesh should render, otherwise false.
  120097. * @param mesh The mesh to render
  120098. * @returns true if it should render otherwise false
  120099. */
  120100. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  120101. /**
  120102. * Returns true if the mesh can be rendered, otherwise false.
  120103. * @param mesh The mesh to render
  120104. * @param material The material used on the mesh
  120105. * @returns true if it can be rendered otherwise false
  120106. */
  120107. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  120108. /**
  120109. * Returns true if the mesh should render, otherwise false.
  120110. * @param mesh The mesh to render
  120111. * @returns true if it should render otherwise false
  120112. */
  120113. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  120114. /**
  120115. * Renders the submesh passed in parameter to the generation map.
  120116. */
  120117. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  120118. /**
  120119. * Defines wether the current material of the mesh should be use to render the effect.
  120120. * @param mesh defines the current mesh to render
  120121. */
  120122. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  120123. /**
  120124. * Rebuild the required buffers.
  120125. * @hidden Internal use only.
  120126. */
  120127. _rebuild(): void;
  120128. /**
  120129. * Dispose only the render target textures and post process.
  120130. */
  120131. private _disposeTextureAndPostProcesses;
  120132. /**
  120133. * Dispose the highlight layer and free resources.
  120134. */
  120135. dispose(): void;
  120136. /**
  120137. * Gets the class name of the effect layer
  120138. * @returns the string with the class name of the effect layer
  120139. */
  120140. getClassName(): string;
  120141. /**
  120142. * Creates an effect layer from parsed effect layer data
  120143. * @param parsedEffectLayer defines effect layer data
  120144. * @param scene defines the current scene
  120145. * @param rootUrl defines the root URL containing the effect layer information
  120146. * @returns a parsed effect Layer
  120147. */
  120148. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  120149. }
  120150. }
  120151. declare module BABYLON {
  120152. interface AbstractScene {
  120153. /**
  120154. * The list of effect layers (highlights/glow) added to the scene
  120155. * @see http://doc.babylonjs.com/how_to/highlight_layer
  120156. * @see http://doc.babylonjs.com/how_to/glow_layer
  120157. */
  120158. effectLayers: Array<EffectLayer>;
  120159. /**
  120160. * Removes the given effect layer from this scene.
  120161. * @param toRemove defines the effect layer to remove
  120162. * @returns the index of the removed effect layer
  120163. */
  120164. removeEffectLayer(toRemove: EffectLayer): number;
  120165. /**
  120166. * Adds the given effect layer to this scene
  120167. * @param newEffectLayer defines the effect layer to add
  120168. */
  120169. addEffectLayer(newEffectLayer: EffectLayer): void;
  120170. }
  120171. /**
  120172. * Defines the layer scene component responsible to manage any effect layers
  120173. * in a given scene.
  120174. */
  120175. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  120176. /**
  120177. * The component name helpfull to identify the component in the list of scene components.
  120178. */
  120179. readonly name: string;
  120180. /**
  120181. * The scene the component belongs to.
  120182. */
  120183. scene: Scene;
  120184. private _engine;
  120185. private _renderEffects;
  120186. private _needStencil;
  120187. private _previousStencilState;
  120188. /**
  120189. * Creates a new instance of the component for the given scene
  120190. * @param scene Defines the scene to register the component in
  120191. */
  120192. constructor(scene: Scene);
  120193. /**
  120194. * Registers the component in a given scene
  120195. */
  120196. register(): void;
  120197. /**
  120198. * Rebuilds the elements related to this component in case of
  120199. * context lost for instance.
  120200. */
  120201. rebuild(): void;
  120202. /**
  120203. * Serializes the component data to the specified json object
  120204. * @param serializationObject The object to serialize to
  120205. */
  120206. serialize(serializationObject: any): void;
  120207. /**
  120208. * Adds all the elements from the container to the scene
  120209. * @param container the container holding the elements
  120210. */
  120211. addFromContainer(container: AbstractScene): void;
  120212. /**
  120213. * Removes all the elements in the container from the scene
  120214. * @param container contains the elements to remove
  120215. * @param dispose if the removed element should be disposed (default: false)
  120216. */
  120217. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120218. /**
  120219. * Disposes the component and the associated ressources.
  120220. */
  120221. dispose(): void;
  120222. private _isReadyForMesh;
  120223. private _renderMainTexture;
  120224. private _setStencil;
  120225. private _setStencilBack;
  120226. private _draw;
  120227. private _drawCamera;
  120228. private _drawRenderingGroup;
  120229. }
  120230. }
  120231. declare module BABYLON {
  120232. /** @hidden */
  120233. export var glowMapMergePixelShader: {
  120234. name: string;
  120235. shader: string;
  120236. };
  120237. }
  120238. declare module BABYLON {
  120239. /** @hidden */
  120240. export var glowMapMergeVertexShader: {
  120241. name: string;
  120242. shader: string;
  120243. };
  120244. }
  120245. declare module BABYLON {
  120246. interface AbstractScene {
  120247. /**
  120248. * Return a the first highlight layer of the scene with a given name.
  120249. * @param name The name of the highlight layer to look for.
  120250. * @return The highlight layer if found otherwise null.
  120251. */
  120252. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  120253. }
  120254. /**
  120255. * Glow layer options. This helps customizing the behaviour
  120256. * of the glow layer.
  120257. */
  120258. export interface IGlowLayerOptions {
  120259. /**
  120260. * Multiplication factor apply to the canvas size to compute the render target size
  120261. * used to generated the glowing objects (the smaller the faster).
  120262. */
  120263. mainTextureRatio: number;
  120264. /**
  120265. * Enforces a fixed size texture to ensure resize independant blur.
  120266. */
  120267. mainTextureFixedSize?: number;
  120268. /**
  120269. * How big is the kernel of the blur texture.
  120270. */
  120271. blurKernelSize: number;
  120272. /**
  120273. * The camera attached to the layer.
  120274. */
  120275. camera: Nullable<Camera>;
  120276. /**
  120277. * Enable MSAA by chosing the number of samples.
  120278. */
  120279. mainTextureSamples?: number;
  120280. /**
  120281. * The rendering group to draw the layer in.
  120282. */
  120283. renderingGroupId: number;
  120284. }
  120285. /**
  120286. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  120287. *
  120288. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  120289. *
  120290. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  120291. */
  120292. export class GlowLayer extends EffectLayer {
  120293. /**
  120294. * Effect Name of the layer.
  120295. */
  120296. static readonly EffectName: string;
  120297. /**
  120298. * The default blur kernel size used for the glow.
  120299. */
  120300. static DefaultBlurKernelSize: number;
  120301. /**
  120302. * The default texture size ratio used for the glow.
  120303. */
  120304. static DefaultTextureRatio: number;
  120305. /**
  120306. * Sets the kernel size of the blur.
  120307. */
  120308. /**
  120309. * Gets the kernel size of the blur.
  120310. */
  120311. blurKernelSize: number;
  120312. /**
  120313. * Sets the glow intensity.
  120314. */
  120315. /**
  120316. * Gets the glow intensity.
  120317. */
  120318. intensity: number;
  120319. private _options;
  120320. private _intensity;
  120321. private _horizontalBlurPostprocess1;
  120322. private _verticalBlurPostprocess1;
  120323. private _horizontalBlurPostprocess2;
  120324. private _verticalBlurPostprocess2;
  120325. private _blurTexture1;
  120326. private _blurTexture2;
  120327. private _postProcesses1;
  120328. private _postProcesses2;
  120329. private _includedOnlyMeshes;
  120330. private _excludedMeshes;
  120331. private _meshesUsingTheirOwnMaterials;
  120332. /**
  120333. * Callback used to let the user override the color selection on a per mesh basis
  120334. */
  120335. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  120336. /**
  120337. * Callback used to let the user override the texture selection on a per mesh basis
  120338. */
  120339. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  120340. /**
  120341. * Instantiates a new glow Layer and references it to the scene.
  120342. * @param name The name of the layer
  120343. * @param scene The scene to use the layer in
  120344. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  120345. */
  120346. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  120347. /**
  120348. * Get the effect name of the layer.
  120349. * @return The effect name
  120350. */
  120351. getEffectName(): string;
  120352. /**
  120353. * Create the merge effect. This is the shader use to blit the information back
  120354. * to the main canvas at the end of the scene rendering.
  120355. */
  120356. protected _createMergeEffect(): Effect;
  120357. /**
  120358. * Creates the render target textures and post processes used in the glow layer.
  120359. */
  120360. protected _createTextureAndPostProcesses(): void;
  120361. /**
  120362. * Checks for the readiness of the element composing the layer.
  120363. * @param subMesh the mesh to check for
  120364. * @param useInstances specify wether or not to use instances to render the mesh
  120365. * @param emissiveTexture the associated emissive texture used to generate the glow
  120366. * @return true if ready otherwise, false
  120367. */
  120368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120369. /**
  120370. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120371. */
  120372. needStencil(): boolean;
  120373. /**
  120374. * Returns true if the mesh can be rendered, otherwise false.
  120375. * @param mesh The mesh to render
  120376. * @param material The material used on the mesh
  120377. * @returns true if it can be rendered otherwise false
  120378. */
  120379. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  120380. /**
  120381. * Implementation specific of rendering the generating effect on the main canvas.
  120382. * @param effect The effect used to render through
  120383. */
  120384. protected _internalRender(effect: Effect): void;
  120385. /**
  120386. * Sets the required values for both the emissive texture and and the main color.
  120387. */
  120388. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120389. /**
  120390. * Returns true if the mesh should render, otherwise false.
  120391. * @param mesh The mesh to render
  120392. * @returns true if it should render otherwise false
  120393. */
  120394. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120395. /**
  120396. * Adds specific effects defines.
  120397. * @param defines The defines to add specifics to.
  120398. */
  120399. protected _addCustomEffectDefines(defines: string[]): void;
  120400. /**
  120401. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  120402. * @param mesh The mesh to exclude from the glow layer
  120403. */
  120404. addExcludedMesh(mesh: Mesh): void;
  120405. /**
  120406. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  120407. * @param mesh The mesh to remove
  120408. */
  120409. removeExcludedMesh(mesh: Mesh): void;
  120410. /**
  120411. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  120412. * @param mesh The mesh to include in the glow layer
  120413. */
  120414. addIncludedOnlyMesh(mesh: Mesh): void;
  120415. /**
  120416. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  120417. * @param mesh The mesh to remove
  120418. */
  120419. removeIncludedOnlyMesh(mesh: Mesh): void;
  120420. /**
  120421. * Determine if a given mesh will be used in the glow layer
  120422. * @param mesh The mesh to test
  120423. * @returns true if the mesh will be highlighted by the current glow layer
  120424. */
  120425. hasMesh(mesh: AbstractMesh): boolean;
  120426. /**
  120427. * Defines wether the current material of the mesh should be use to render the effect.
  120428. * @param mesh defines the current mesh to render
  120429. */
  120430. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  120431. /**
  120432. * Add a mesh to be rendered through its own material and not with emissive only.
  120433. * @param mesh The mesh for which we need to use its material
  120434. */
  120435. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  120436. /**
  120437. * Remove a mesh from being rendered through its own material and not with emissive only.
  120438. * @param mesh The mesh for which we need to not use its material
  120439. */
  120440. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  120441. /**
  120442. * Free any resources and references associated to a mesh.
  120443. * Internal use
  120444. * @param mesh The mesh to free.
  120445. * @hidden
  120446. */
  120447. _disposeMesh(mesh: Mesh): void;
  120448. /**
  120449. * Gets the class name of the effect layer
  120450. * @returns the string with the class name of the effect layer
  120451. */
  120452. getClassName(): string;
  120453. /**
  120454. * Serializes this glow layer
  120455. * @returns a serialized glow layer object
  120456. */
  120457. serialize(): any;
  120458. /**
  120459. * Creates a Glow Layer from parsed glow layer data
  120460. * @param parsedGlowLayer defines glow layer data
  120461. * @param scene defines the current scene
  120462. * @param rootUrl defines the root URL containing the glow layer information
  120463. * @returns a parsed Glow Layer
  120464. */
  120465. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  120466. }
  120467. }
  120468. declare module BABYLON {
  120469. /** @hidden */
  120470. export var glowBlurPostProcessPixelShader: {
  120471. name: string;
  120472. shader: string;
  120473. };
  120474. }
  120475. declare module BABYLON {
  120476. interface AbstractScene {
  120477. /**
  120478. * Return a the first highlight layer of the scene with a given name.
  120479. * @param name The name of the highlight layer to look for.
  120480. * @return The highlight layer if found otherwise null.
  120481. */
  120482. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  120483. }
  120484. /**
  120485. * Highlight layer options. This helps customizing the behaviour
  120486. * of the highlight layer.
  120487. */
  120488. export interface IHighlightLayerOptions {
  120489. /**
  120490. * Multiplication factor apply to the canvas size to compute the render target size
  120491. * used to generated the glowing objects (the smaller the faster).
  120492. */
  120493. mainTextureRatio: number;
  120494. /**
  120495. * Enforces a fixed size texture to ensure resize independant blur.
  120496. */
  120497. mainTextureFixedSize?: number;
  120498. /**
  120499. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  120500. * of the picture to blur (the smaller the faster).
  120501. */
  120502. blurTextureSizeRatio: number;
  120503. /**
  120504. * How big in texel of the blur texture is the vertical blur.
  120505. */
  120506. blurVerticalSize: number;
  120507. /**
  120508. * How big in texel of the blur texture is the horizontal blur.
  120509. */
  120510. blurHorizontalSize: number;
  120511. /**
  120512. * Alpha blending mode used to apply the blur. Default is combine.
  120513. */
  120514. alphaBlendingMode: number;
  120515. /**
  120516. * The camera attached to the layer.
  120517. */
  120518. camera: Nullable<Camera>;
  120519. /**
  120520. * Should we display highlight as a solid stroke?
  120521. */
  120522. isStroke?: boolean;
  120523. /**
  120524. * The rendering group to draw the layer in.
  120525. */
  120526. renderingGroupId: number;
  120527. }
  120528. /**
  120529. * The highlight layer Helps adding a glow effect around a mesh.
  120530. *
  120531. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  120532. * glowy meshes to your scene.
  120533. *
  120534. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  120535. */
  120536. export class HighlightLayer extends EffectLayer {
  120537. name: string;
  120538. /**
  120539. * Effect Name of the highlight layer.
  120540. */
  120541. static readonly EffectName: string;
  120542. /**
  120543. * The neutral color used during the preparation of the glow effect.
  120544. * This is black by default as the blend operation is a blend operation.
  120545. */
  120546. static NeutralColor: Color4;
  120547. /**
  120548. * Stencil value used for glowing meshes.
  120549. */
  120550. static GlowingMeshStencilReference: number;
  120551. /**
  120552. * Stencil value used for the other meshes in the scene.
  120553. */
  120554. static NormalMeshStencilReference: number;
  120555. /**
  120556. * Specifies whether or not the inner glow is ACTIVE in the layer.
  120557. */
  120558. innerGlow: boolean;
  120559. /**
  120560. * Specifies whether or not the outer glow is ACTIVE in the layer.
  120561. */
  120562. outerGlow: boolean;
  120563. /**
  120564. * Specifies the horizontal size of the blur.
  120565. */
  120566. /**
  120567. * Gets the horizontal size of the blur.
  120568. */
  120569. blurHorizontalSize: number;
  120570. /**
  120571. * Specifies the vertical size of the blur.
  120572. */
  120573. /**
  120574. * Gets the vertical size of the blur.
  120575. */
  120576. blurVerticalSize: number;
  120577. /**
  120578. * An event triggered when the highlight layer is being blurred.
  120579. */
  120580. onBeforeBlurObservable: Observable<HighlightLayer>;
  120581. /**
  120582. * An event triggered when the highlight layer has been blurred.
  120583. */
  120584. onAfterBlurObservable: Observable<HighlightLayer>;
  120585. private _instanceGlowingMeshStencilReference;
  120586. private _options;
  120587. private _downSamplePostprocess;
  120588. private _horizontalBlurPostprocess;
  120589. private _verticalBlurPostprocess;
  120590. private _blurTexture;
  120591. private _meshes;
  120592. private _excludedMeshes;
  120593. /**
  120594. * Instantiates a new highlight Layer and references it to the scene..
  120595. * @param name The name of the layer
  120596. * @param scene The scene to use the layer in
  120597. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  120598. */
  120599. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  120600. /**
  120601. * Get the effect name of the layer.
  120602. * @return The effect name
  120603. */
  120604. getEffectName(): string;
  120605. /**
  120606. * Create the merge effect. This is the shader use to blit the information back
  120607. * to the main canvas at the end of the scene rendering.
  120608. */
  120609. protected _createMergeEffect(): Effect;
  120610. /**
  120611. * Creates the render target textures and post processes used in the highlight layer.
  120612. */
  120613. protected _createTextureAndPostProcesses(): void;
  120614. /**
  120615. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  120616. */
  120617. needStencil(): boolean;
  120618. /**
  120619. * Checks for the readiness of the element composing the layer.
  120620. * @param subMesh the mesh to check for
  120621. * @param useInstances specify wether or not to use instances to render the mesh
  120622. * @param emissiveTexture the associated emissive texture used to generate the glow
  120623. * @return true if ready otherwise, false
  120624. */
  120625. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120626. /**
  120627. * Implementation specific of rendering the generating effect on the main canvas.
  120628. * @param effect The effect used to render through
  120629. */
  120630. protected _internalRender(effect: Effect): void;
  120631. /**
  120632. * Returns true if the layer contains information to display, otherwise false.
  120633. */
  120634. shouldRender(): boolean;
  120635. /**
  120636. * Returns true if the mesh should render, otherwise false.
  120637. * @param mesh The mesh to render
  120638. * @returns true if it should render otherwise false
  120639. */
  120640. protected _shouldRenderMesh(mesh: Mesh): boolean;
  120641. /**
  120642. * Sets the required values for both the emissive texture and and the main color.
  120643. */
  120644. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  120645. /**
  120646. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  120647. * @param mesh The mesh to exclude from the highlight layer
  120648. */
  120649. addExcludedMesh(mesh: Mesh): void;
  120650. /**
  120651. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  120652. * @param mesh The mesh to highlight
  120653. */
  120654. removeExcludedMesh(mesh: Mesh): void;
  120655. /**
  120656. * Determine if a given mesh will be highlighted by the current HighlightLayer
  120657. * @param mesh mesh to test
  120658. * @returns true if the mesh will be highlighted by the current HighlightLayer
  120659. */
  120660. hasMesh(mesh: AbstractMesh): boolean;
  120661. /**
  120662. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  120663. * @param mesh The mesh to highlight
  120664. * @param color The color of the highlight
  120665. * @param glowEmissiveOnly Extract the glow from the emissive texture
  120666. */
  120667. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  120668. /**
  120669. * Remove a mesh from the highlight layer in order to make it stop glowing.
  120670. * @param mesh The mesh to highlight
  120671. */
  120672. removeMesh(mesh: Mesh): void;
  120673. /**
  120674. * Force the stencil to the normal expected value for none glowing parts
  120675. */
  120676. private _defaultStencilReference;
  120677. /**
  120678. * Free any resources and references associated to a mesh.
  120679. * Internal use
  120680. * @param mesh The mesh to free.
  120681. * @hidden
  120682. */
  120683. _disposeMesh(mesh: Mesh): void;
  120684. /**
  120685. * Dispose the highlight layer and free resources.
  120686. */
  120687. dispose(): void;
  120688. /**
  120689. * Gets the class name of the effect layer
  120690. * @returns the string with the class name of the effect layer
  120691. */
  120692. getClassName(): string;
  120693. /**
  120694. * Serializes this Highlight layer
  120695. * @returns a serialized Highlight layer object
  120696. */
  120697. serialize(): any;
  120698. /**
  120699. * Creates a Highlight layer from parsed Highlight layer data
  120700. * @param parsedHightlightLayer defines the Highlight layer data
  120701. * @param scene defines the current scene
  120702. * @param rootUrl defines the root URL containing the Highlight layer information
  120703. * @returns a parsed Highlight layer
  120704. */
  120705. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  120706. }
  120707. }
  120708. declare module BABYLON {
  120709. interface AbstractScene {
  120710. /**
  120711. * The list of layers (background and foreground) of the scene
  120712. */
  120713. layers: Array<Layer>;
  120714. }
  120715. /**
  120716. * Defines the layer scene component responsible to manage any layers
  120717. * in a given scene.
  120718. */
  120719. export class LayerSceneComponent implements ISceneComponent {
  120720. /**
  120721. * The component name helpfull to identify the component in the list of scene components.
  120722. */
  120723. readonly name: string;
  120724. /**
  120725. * The scene the component belongs to.
  120726. */
  120727. scene: Scene;
  120728. private _engine;
  120729. /**
  120730. * Creates a new instance of the component for the given scene
  120731. * @param scene Defines the scene to register the component in
  120732. */
  120733. constructor(scene: Scene);
  120734. /**
  120735. * Registers the component in a given scene
  120736. */
  120737. register(): void;
  120738. /**
  120739. * Rebuilds the elements related to this component in case of
  120740. * context lost for instance.
  120741. */
  120742. rebuild(): void;
  120743. /**
  120744. * Disposes the component and the associated ressources.
  120745. */
  120746. dispose(): void;
  120747. private _draw;
  120748. private _drawCameraPredicate;
  120749. private _drawCameraBackground;
  120750. private _drawCameraForeground;
  120751. private _drawRenderTargetPredicate;
  120752. private _drawRenderTargetBackground;
  120753. private _drawRenderTargetForeground;
  120754. /**
  120755. * Adds all the elements from the container to the scene
  120756. * @param container the container holding the elements
  120757. */
  120758. addFromContainer(container: AbstractScene): void;
  120759. /**
  120760. * Removes all the elements in the container from the scene
  120761. * @param container contains the elements to remove
  120762. * @param dispose if the removed element should be disposed (default: false)
  120763. */
  120764. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  120765. }
  120766. }
  120767. declare module BABYLON {
  120768. /** @hidden */
  120769. export var layerPixelShader: {
  120770. name: string;
  120771. shader: string;
  120772. };
  120773. }
  120774. declare module BABYLON {
  120775. /** @hidden */
  120776. export var layerVertexShader: {
  120777. name: string;
  120778. shader: string;
  120779. };
  120780. }
  120781. declare module BABYLON {
  120782. /**
  120783. * This represents a full screen 2d layer.
  120784. * This can be useful to display a picture in the background of your scene for instance.
  120785. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120786. */
  120787. export class Layer {
  120788. /**
  120789. * Define the name of the layer.
  120790. */
  120791. name: string;
  120792. /**
  120793. * Define the texture the layer should display.
  120794. */
  120795. texture: Nullable<Texture>;
  120796. /**
  120797. * Is the layer in background or foreground.
  120798. */
  120799. isBackground: boolean;
  120800. /**
  120801. * Define the color of the layer (instead of texture).
  120802. */
  120803. color: Color4;
  120804. /**
  120805. * Define the scale of the layer in order to zoom in out of the texture.
  120806. */
  120807. scale: Vector2;
  120808. /**
  120809. * Define an offset for the layer in order to shift the texture.
  120810. */
  120811. offset: Vector2;
  120812. /**
  120813. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  120814. */
  120815. alphaBlendingMode: number;
  120816. /**
  120817. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  120818. * Alpha test will not mix with the background color in case of transparency.
  120819. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  120820. */
  120821. alphaTest: boolean;
  120822. /**
  120823. * Define a mask to restrict the layer to only some of the scene cameras.
  120824. */
  120825. layerMask: number;
  120826. /**
  120827. * Define the list of render target the layer is visible into.
  120828. */
  120829. renderTargetTextures: RenderTargetTexture[];
  120830. /**
  120831. * Define if the layer is only used in renderTarget or if it also
  120832. * renders in the main frame buffer of the canvas.
  120833. */
  120834. renderOnlyInRenderTargetTextures: boolean;
  120835. private _scene;
  120836. private _vertexBuffers;
  120837. private _indexBuffer;
  120838. private _effect;
  120839. private _previousDefines;
  120840. /**
  120841. * An event triggered when the layer is disposed.
  120842. */
  120843. onDisposeObservable: Observable<Layer>;
  120844. private _onDisposeObserver;
  120845. /**
  120846. * Back compatibility with callback before the onDisposeObservable existed.
  120847. * The set callback will be triggered when the layer has been disposed.
  120848. */
  120849. onDispose: () => void;
  120850. /**
  120851. * An event triggered before rendering the scene
  120852. */
  120853. onBeforeRenderObservable: Observable<Layer>;
  120854. private _onBeforeRenderObserver;
  120855. /**
  120856. * Back compatibility with callback before the onBeforeRenderObservable existed.
  120857. * The set callback will be triggered just before rendering the layer.
  120858. */
  120859. onBeforeRender: () => void;
  120860. /**
  120861. * An event triggered after rendering the scene
  120862. */
  120863. onAfterRenderObservable: Observable<Layer>;
  120864. private _onAfterRenderObserver;
  120865. /**
  120866. * Back compatibility with callback before the onAfterRenderObservable existed.
  120867. * The set callback will be triggered just after rendering the layer.
  120868. */
  120869. onAfterRender: () => void;
  120870. /**
  120871. * Instantiates a new layer.
  120872. * This represents a full screen 2d layer.
  120873. * This can be useful to display a picture in the background of your scene for instance.
  120874. * @see https://www.babylonjs-playground.com/#08A2BS#1
  120875. * @param name Define the name of the layer in the scene
  120876. * @param imgUrl Define the url of the texture to display in the layer
  120877. * @param scene Define the scene the layer belongs to
  120878. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  120879. * @param color Defines a color for the layer
  120880. */
  120881. constructor(
  120882. /**
  120883. * Define the name of the layer.
  120884. */
  120885. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  120886. private _createIndexBuffer;
  120887. /** @hidden */
  120888. _rebuild(): void;
  120889. /**
  120890. * Renders the layer in the scene.
  120891. */
  120892. render(): void;
  120893. /**
  120894. * Disposes and releases the associated ressources.
  120895. */
  120896. dispose(): void;
  120897. }
  120898. }
  120899. declare module BABYLON {
  120900. /** @hidden */
  120901. export var lensFlarePixelShader: {
  120902. name: string;
  120903. shader: string;
  120904. };
  120905. }
  120906. declare module BABYLON {
  120907. /** @hidden */
  120908. export var lensFlareVertexShader: {
  120909. name: string;
  120910. shader: string;
  120911. };
  120912. }
  120913. declare module BABYLON {
  120914. /**
  120915. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120916. * It is usually composed of several `lensFlare`.
  120917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120918. */
  120919. export class LensFlareSystem {
  120920. /**
  120921. * Define the name of the lens flare system
  120922. */
  120923. name: string;
  120924. /**
  120925. * List of lens flares used in this system.
  120926. */
  120927. lensFlares: LensFlare[];
  120928. /**
  120929. * Define a limit from the border the lens flare can be visible.
  120930. */
  120931. borderLimit: number;
  120932. /**
  120933. * Define a viewport border we do not want to see the lens flare in.
  120934. */
  120935. viewportBorder: number;
  120936. /**
  120937. * Define a predicate which could limit the list of meshes able to occlude the effect.
  120938. */
  120939. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  120940. /**
  120941. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  120942. */
  120943. layerMask: number;
  120944. /**
  120945. * Define the id of the lens flare system in the scene.
  120946. * (equal to name by default)
  120947. */
  120948. id: string;
  120949. private _scene;
  120950. private _emitter;
  120951. private _vertexBuffers;
  120952. private _indexBuffer;
  120953. private _effect;
  120954. private _positionX;
  120955. private _positionY;
  120956. private _isEnabled;
  120957. /** @hidden */
  120958. static _SceneComponentInitialization: (scene: Scene) => void;
  120959. /**
  120960. * Instantiates a lens flare system.
  120961. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  120962. * It is usually composed of several `lensFlare`.
  120963. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  120964. * @param name Define the name of the lens flare system in the scene
  120965. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  120966. * @param scene Define the scene the lens flare system belongs to
  120967. */
  120968. constructor(
  120969. /**
  120970. * Define the name of the lens flare system
  120971. */
  120972. name: string, emitter: any, scene: Scene);
  120973. /**
  120974. * Define if the lens flare system is enabled.
  120975. */
  120976. isEnabled: boolean;
  120977. /**
  120978. * Get the scene the effects belongs to.
  120979. * @returns the scene holding the lens flare system
  120980. */
  120981. getScene(): Scene;
  120982. /**
  120983. * Get the emitter of the lens flare system.
  120984. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120985. * @returns the emitter of the lens flare system
  120986. */
  120987. getEmitter(): any;
  120988. /**
  120989. * Set the emitter of the lens flare system.
  120990. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  120991. * @param newEmitter Define the new emitter of the system
  120992. */
  120993. setEmitter(newEmitter: any): void;
  120994. /**
  120995. * Get the lens flare system emitter position.
  120996. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  120997. * @returns the position
  120998. */
  120999. getEmitterPosition(): Vector3;
  121000. /**
  121001. * @hidden
  121002. */
  121003. computeEffectivePosition(globalViewport: Viewport): boolean;
  121004. /** @hidden */
  121005. _isVisible(): boolean;
  121006. /**
  121007. * @hidden
  121008. */
  121009. render(): boolean;
  121010. /**
  121011. * Dispose and release the lens flare with its associated resources.
  121012. */
  121013. dispose(): void;
  121014. /**
  121015. * Parse a lens flare system from a JSON repressentation
  121016. * @param parsedLensFlareSystem Define the JSON to parse
  121017. * @param scene Define the scene the parsed system should be instantiated in
  121018. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  121019. * @returns the parsed system
  121020. */
  121021. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  121022. /**
  121023. * Serialize the current Lens Flare System into a JSON representation.
  121024. * @returns the serialized JSON
  121025. */
  121026. serialize(): any;
  121027. }
  121028. }
  121029. declare module BABYLON {
  121030. /**
  121031. * This represents one of the lens effect in a `lensFlareSystem`.
  121032. * It controls one of the indiviual texture used in the effect.
  121033. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121034. */
  121035. export class LensFlare {
  121036. /**
  121037. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  121038. */
  121039. size: number;
  121040. /**
  121041. * 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.
  121042. */
  121043. position: number;
  121044. /**
  121045. * Define the lens color.
  121046. */
  121047. color: Color3;
  121048. /**
  121049. * Define the lens texture.
  121050. */
  121051. texture: Nullable<Texture>;
  121052. /**
  121053. * Define the alpha mode to render this particular lens.
  121054. */
  121055. alphaMode: number;
  121056. private _system;
  121057. /**
  121058. * Creates a new Lens Flare.
  121059. * This represents one of the lens effect in a `lensFlareSystem`.
  121060. * It controls one of the indiviual texture used in the effect.
  121061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121062. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  121063. * @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.
  121064. * @param color Define the lens color
  121065. * @param imgUrl Define the lens texture url
  121066. * @param system Define the `lensFlareSystem` this flare is part of
  121067. * @returns The newly created Lens Flare
  121068. */
  121069. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  121070. /**
  121071. * Instantiates a new Lens Flare.
  121072. * This represents one of the lens effect in a `lensFlareSystem`.
  121073. * It controls one of the indiviual texture used in the effect.
  121074. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121075. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  121076. * @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.
  121077. * @param color Define the lens color
  121078. * @param imgUrl Define the lens texture url
  121079. * @param system Define the `lensFlareSystem` this flare is part of
  121080. */
  121081. constructor(
  121082. /**
  121083. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  121084. */
  121085. size: number,
  121086. /**
  121087. * 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.
  121088. */
  121089. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  121090. /**
  121091. * Dispose and release the lens flare with its associated resources.
  121092. */
  121093. dispose(): void;
  121094. }
  121095. }
  121096. declare module BABYLON {
  121097. interface AbstractScene {
  121098. /**
  121099. * The list of lens flare system added to the scene
  121100. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  121101. */
  121102. lensFlareSystems: Array<LensFlareSystem>;
  121103. /**
  121104. * Removes the given lens flare system from this scene.
  121105. * @param toRemove The lens flare system to remove
  121106. * @returns The index of the removed lens flare system
  121107. */
  121108. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  121109. /**
  121110. * Adds the given lens flare system to this scene
  121111. * @param newLensFlareSystem The lens flare system to add
  121112. */
  121113. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  121114. /**
  121115. * Gets a lens flare system using its name
  121116. * @param name defines the name to look for
  121117. * @returns the lens flare system or null if not found
  121118. */
  121119. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  121120. /**
  121121. * Gets a lens flare system using its id
  121122. * @param id defines the id to look for
  121123. * @returns the lens flare system or null if not found
  121124. */
  121125. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  121126. }
  121127. /**
  121128. * Defines the lens flare scene component responsible to manage any lens flares
  121129. * in a given scene.
  121130. */
  121131. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  121132. /**
  121133. * The component name helpfull to identify the component in the list of scene components.
  121134. */
  121135. readonly name: string;
  121136. /**
  121137. * The scene the component belongs to.
  121138. */
  121139. scene: Scene;
  121140. /**
  121141. * Creates a new instance of the component for the given scene
  121142. * @param scene Defines the scene to register the component in
  121143. */
  121144. constructor(scene: Scene);
  121145. /**
  121146. * Registers the component in a given scene
  121147. */
  121148. register(): void;
  121149. /**
  121150. * Rebuilds the elements related to this component in case of
  121151. * context lost for instance.
  121152. */
  121153. rebuild(): void;
  121154. /**
  121155. * Adds all the elements from the container to the scene
  121156. * @param container the container holding the elements
  121157. */
  121158. addFromContainer(container: AbstractScene): void;
  121159. /**
  121160. * Removes all the elements in the container from the scene
  121161. * @param container contains the elements to remove
  121162. * @param dispose if the removed element should be disposed (default: false)
  121163. */
  121164. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121165. /**
  121166. * Serializes the component data to the specified json object
  121167. * @param serializationObject The object to serialize to
  121168. */
  121169. serialize(serializationObject: any): void;
  121170. /**
  121171. * Disposes the component and the associated ressources.
  121172. */
  121173. dispose(): void;
  121174. private _draw;
  121175. }
  121176. }
  121177. declare module BABYLON {
  121178. /**
  121179. * Defines the shadow generator component responsible to manage any shadow generators
  121180. * in a given scene.
  121181. */
  121182. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  121183. /**
  121184. * The component name helpfull to identify the component in the list of scene components.
  121185. */
  121186. readonly name: string;
  121187. /**
  121188. * The scene the component belongs to.
  121189. */
  121190. scene: Scene;
  121191. /**
  121192. * Creates a new instance of the component for the given scene
  121193. * @param scene Defines the scene to register the component in
  121194. */
  121195. constructor(scene: Scene);
  121196. /**
  121197. * Registers the component in a given scene
  121198. */
  121199. register(): void;
  121200. /**
  121201. * Rebuilds the elements related to this component in case of
  121202. * context lost for instance.
  121203. */
  121204. rebuild(): void;
  121205. /**
  121206. * Serializes the component data to the specified json object
  121207. * @param serializationObject The object to serialize to
  121208. */
  121209. serialize(serializationObject: any): void;
  121210. /**
  121211. * Adds all the elements from the container to the scene
  121212. * @param container the container holding the elements
  121213. */
  121214. addFromContainer(container: AbstractScene): void;
  121215. /**
  121216. * Removes all the elements in the container from the scene
  121217. * @param container contains the elements to remove
  121218. * @param dispose if the removed element should be disposed (default: false)
  121219. */
  121220. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121221. /**
  121222. * Rebuilds the elements related to this component in case of
  121223. * context lost for instance.
  121224. */
  121225. dispose(): void;
  121226. private _gatherRenderTargets;
  121227. }
  121228. }
  121229. declare module BABYLON {
  121230. /**
  121231. * A point light is a light defined by an unique point in world space.
  121232. * The light is emitted in every direction from this point.
  121233. * A good example of a point light is a standard light bulb.
  121234. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121235. */
  121236. export class PointLight extends ShadowLight {
  121237. private _shadowAngle;
  121238. /**
  121239. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121240. * This specifies what angle the shadow will use to be created.
  121241. *
  121242. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  121243. */
  121244. /**
  121245. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121246. * This specifies what angle the shadow will use to be created.
  121247. *
  121248. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  121249. */
  121250. shadowAngle: number;
  121251. /**
  121252. * Gets the direction if it has been set.
  121253. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121254. */
  121255. /**
  121256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  121257. */
  121258. direction: Vector3;
  121259. /**
  121260. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  121261. * A PointLight emits the light in every direction.
  121262. * It can cast shadows.
  121263. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  121264. * ```javascript
  121265. * var pointLight = new PointLight("pl", camera.position, scene);
  121266. * ```
  121267. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121268. * @param name The light friendly name
  121269. * @param position The position of the point light in the scene
  121270. * @param scene The scene the lights belongs to
  121271. */
  121272. constructor(name: string, position: Vector3, scene: Scene);
  121273. /**
  121274. * Returns the string "PointLight"
  121275. * @returns the class name
  121276. */
  121277. getClassName(): string;
  121278. /**
  121279. * Returns the integer 0.
  121280. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121281. */
  121282. getTypeID(): number;
  121283. /**
  121284. * Specifies wether or not the shadowmap should be a cube texture.
  121285. * @returns true if the shadowmap needs to be a cube texture.
  121286. */
  121287. needCube(): boolean;
  121288. /**
  121289. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  121290. * @param faceIndex The index of the face we are computed the direction to generate shadow
  121291. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  121292. */
  121293. getShadowDirection(faceIndex?: number): Vector3;
  121294. /**
  121295. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  121296. * - fov = PI / 2
  121297. * - aspect ratio : 1.0
  121298. * - z-near and far equal to the active camera minZ and maxZ.
  121299. * Returns the PointLight.
  121300. */
  121301. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121302. protected _buildUniformLayout(): void;
  121303. /**
  121304. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  121305. * @param effect The effect to update
  121306. * @param lightIndex The index of the light in the effect to update
  121307. * @returns The point light
  121308. */
  121309. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  121310. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  121311. /**
  121312. * Prepares the list of defines specific to the light type.
  121313. * @param defines the list of defines
  121314. * @param lightIndex defines the index of the light for the effect
  121315. */
  121316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  121317. }
  121318. }
  121319. declare module BABYLON {
  121320. /**
  121321. * Header information of HDR texture files.
  121322. */
  121323. export interface HDRInfo {
  121324. /**
  121325. * The height of the texture in pixels.
  121326. */
  121327. height: number;
  121328. /**
  121329. * The width of the texture in pixels.
  121330. */
  121331. width: number;
  121332. /**
  121333. * The index of the beginning of the data in the binary file.
  121334. */
  121335. dataPosition: number;
  121336. }
  121337. /**
  121338. * This groups tools to convert HDR texture to native colors array.
  121339. */
  121340. export class HDRTools {
  121341. private static Ldexp;
  121342. private static Rgbe2float;
  121343. private static readStringLine;
  121344. /**
  121345. * Reads header information from an RGBE texture stored in a native array.
  121346. * More information on this format are available here:
  121347. * https://en.wikipedia.org/wiki/RGBE_image_format
  121348. *
  121349. * @param uint8array The binary file stored in native array.
  121350. * @return The header information.
  121351. */
  121352. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  121353. /**
  121354. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  121355. * This RGBE texture needs to store the information as a panorama.
  121356. *
  121357. * More information on this format are available here:
  121358. * https://en.wikipedia.org/wiki/RGBE_image_format
  121359. *
  121360. * @param buffer The binary file stored in an array buffer.
  121361. * @param size The expected size of the extracted cubemap.
  121362. * @return The Cube Map information.
  121363. */
  121364. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  121365. /**
  121366. * Returns the pixels data extracted from an RGBE texture.
  121367. * This pixels will be stored left to right up to down in the R G B order in one array.
  121368. *
  121369. * More information on this format are available here:
  121370. * https://en.wikipedia.org/wiki/RGBE_image_format
  121371. *
  121372. * @param uint8array The binary file stored in an array buffer.
  121373. * @param hdrInfo The header information of the file.
  121374. * @return The pixels data in RGB right to left up to down order.
  121375. */
  121376. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  121377. private static RGBE_ReadPixels_RLE;
  121378. }
  121379. }
  121380. declare module BABYLON {
  121381. /**
  121382. * This represents a texture coming from an HDR input.
  121383. *
  121384. * The only supported format is currently panorama picture stored in RGBE format.
  121385. * Example of such files can be found on HDRLib: http://hdrlib.com/
  121386. */
  121387. export class HDRCubeTexture extends BaseTexture {
  121388. private static _facesMapping;
  121389. private _generateHarmonics;
  121390. private _noMipmap;
  121391. private _textureMatrix;
  121392. private _size;
  121393. private _onLoad;
  121394. private _onError;
  121395. /**
  121396. * The texture URL.
  121397. */
  121398. url: string;
  121399. /**
  121400. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  121401. */
  121402. coordinatesMode: number;
  121403. protected _isBlocking: boolean;
  121404. /**
  121405. * Sets wether or not the texture is blocking during loading.
  121406. */
  121407. /**
  121408. * Gets wether or not the texture is blocking during loading.
  121409. */
  121410. isBlocking: boolean;
  121411. protected _rotationY: number;
  121412. /**
  121413. * Sets texture matrix rotation angle around Y axis in radians.
  121414. */
  121415. /**
  121416. * Gets texture matrix rotation angle around Y axis radians.
  121417. */
  121418. rotationY: number;
  121419. /**
  121420. * Gets or sets the center of the bounding box associated with the cube texture
  121421. * It must define where the camera used to render the texture was set
  121422. */
  121423. boundingBoxPosition: Vector3;
  121424. private _boundingBoxSize;
  121425. /**
  121426. * Gets or sets the size of the bounding box associated with the cube texture
  121427. * When defined, the cubemap will switch to local mode
  121428. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  121429. * @example https://www.babylonjs-playground.com/#RNASML
  121430. */
  121431. boundingBoxSize: Vector3;
  121432. /**
  121433. * Instantiates an HDRTexture from the following parameters.
  121434. *
  121435. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  121436. * @param scene The scene the texture will be used in
  121437. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121438. * @param noMipmap Forces to not generate the mipmap if true
  121439. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  121440. * @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)
  121441. * @param reserved Reserved flag for internal use.
  121442. */
  121443. 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>);
  121444. /**
  121445. * Get the current class name of the texture useful for serialization or dynamic coding.
  121446. * @returns "HDRCubeTexture"
  121447. */
  121448. getClassName(): string;
  121449. /**
  121450. * Occurs when the file is raw .hdr file.
  121451. */
  121452. private loadTexture;
  121453. clone(): HDRCubeTexture;
  121454. delayLoad(): void;
  121455. /**
  121456. * Get the texture reflection matrix used to rotate/transform the reflection.
  121457. * @returns the reflection matrix
  121458. */
  121459. getReflectionTextureMatrix(): Matrix;
  121460. /**
  121461. * Set the texture reflection matrix used to rotate/transform the reflection.
  121462. * @param value Define the reflection matrix to set
  121463. */
  121464. setReflectionTextureMatrix(value: Matrix): void;
  121465. /**
  121466. * Parses a JSON representation of an HDR Texture in order to create the texture
  121467. * @param parsedTexture Define the JSON representation
  121468. * @param scene Define the scene the texture should be created in
  121469. * @param rootUrl Define the root url in case we need to load relative dependencies
  121470. * @returns the newly created texture after parsing
  121471. */
  121472. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  121473. serialize(): any;
  121474. }
  121475. }
  121476. declare module BABYLON {
  121477. /**
  121478. * Class used to control physics engine
  121479. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  121480. */
  121481. export class PhysicsEngine implements IPhysicsEngine {
  121482. private _physicsPlugin;
  121483. /**
  121484. * Global value used to control the smallest number supported by the simulation
  121485. */
  121486. static Epsilon: number;
  121487. private _impostors;
  121488. private _joints;
  121489. private _subTimeStep;
  121490. /**
  121491. * Gets the gravity vector used by the simulation
  121492. */
  121493. gravity: Vector3;
  121494. /**
  121495. * Factory used to create the default physics plugin.
  121496. * @returns The default physics plugin
  121497. */
  121498. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  121499. /**
  121500. * Creates a new Physics Engine
  121501. * @param gravity defines the gravity vector used by the simulation
  121502. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  121503. */
  121504. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  121505. /**
  121506. * Sets the gravity vector used by the simulation
  121507. * @param gravity defines the gravity vector to use
  121508. */
  121509. setGravity(gravity: Vector3): void;
  121510. /**
  121511. * Set the time step of the physics engine.
  121512. * Default is 1/60.
  121513. * To slow it down, enter 1/600 for example.
  121514. * To speed it up, 1/30
  121515. * @param newTimeStep defines the new timestep to apply to this world.
  121516. */
  121517. setTimeStep(newTimeStep?: number): void;
  121518. /**
  121519. * Get the time step of the physics engine.
  121520. * @returns the current time step
  121521. */
  121522. getTimeStep(): number;
  121523. /**
  121524. * Set the sub time step of the physics engine.
  121525. * Default is 0 meaning there is no sub steps
  121526. * To increase physics resolution precision, set a small value (like 1 ms)
  121527. * @param subTimeStep defines the new sub timestep used for physics resolution.
  121528. */
  121529. setSubTimeStep(subTimeStep?: number): void;
  121530. /**
  121531. * Get the sub time step of the physics engine.
  121532. * @returns the current sub time step
  121533. */
  121534. getSubTimeStep(): number;
  121535. /**
  121536. * Release all resources
  121537. */
  121538. dispose(): void;
  121539. /**
  121540. * Gets the name of the current physics plugin
  121541. * @returns the name of the plugin
  121542. */
  121543. getPhysicsPluginName(): string;
  121544. /**
  121545. * Adding a new impostor for the impostor tracking.
  121546. * This will be done by the impostor itself.
  121547. * @param impostor the impostor to add
  121548. */
  121549. addImpostor(impostor: PhysicsImpostor): void;
  121550. /**
  121551. * Remove an impostor from the engine.
  121552. * This impostor and its mesh will not longer be updated by the physics engine.
  121553. * @param impostor the impostor to remove
  121554. */
  121555. removeImpostor(impostor: PhysicsImpostor): void;
  121556. /**
  121557. * Add a joint to the physics engine
  121558. * @param mainImpostor defines the main impostor to which the joint is added.
  121559. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  121560. * @param joint defines the joint that will connect both impostors.
  121561. */
  121562. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121563. /**
  121564. * Removes a joint from the simulation
  121565. * @param mainImpostor defines the impostor used with the joint
  121566. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  121567. * @param joint defines the joint to remove
  121568. */
  121569. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  121570. /**
  121571. * Called by the scene. No need to call it.
  121572. * @param delta defines the timespam between frames
  121573. */
  121574. _step(delta: number): void;
  121575. /**
  121576. * Gets the current plugin used to run the simulation
  121577. * @returns current plugin
  121578. */
  121579. getPhysicsPlugin(): IPhysicsEnginePlugin;
  121580. /**
  121581. * Gets the list of physic impostors
  121582. * @returns an array of PhysicsImpostor
  121583. */
  121584. getImpostors(): Array<PhysicsImpostor>;
  121585. /**
  121586. * Gets the impostor for a physics enabled object
  121587. * @param object defines the object impersonated by the impostor
  121588. * @returns the PhysicsImpostor or null if not found
  121589. */
  121590. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  121591. /**
  121592. * Gets the impostor for a physics body object
  121593. * @param body defines physics body used by the impostor
  121594. * @returns the PhysicsImpostor or null if not found
  121595. */
  121596. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  121597. /**
  121598. * Does a raycast in the physics world
  121599. * @param from when should the ray start?
  121600. * @param to when should the ray end?
  121601. * @returns PhysicsRaycastResult
  121602. */
  121603. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121604. }
  121605. }
  121606. declare module BABYLON {
  121607. /** @hidden */
  121608. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  121609. private _useDeltaForWorldStep;
  121610. world: any;
  121611. name: string;
  121612. private _physicsMaterials;
  121613. private _fixedTimeStep;
  121614. private _cannonRaycastResult;
  121615. private _raycastResult;
  121616. private _physicsBodysToRemoveAfterStep;
  121617. BJSCANNON: any;
  121618. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  121619. setGravity(gravity: Vector3): void;
  121620. setTimeStep(timeStep: number): void;
  121621. getTimeStep(): number;
  121622. executeStep(delta: number): void;
  121623. private _removeMarkedPhysicsBodiesFromWorld;
  121624. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121625. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121626. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121627. private _processChildMeshes;
  121628. removePhysicsBody(impostor: PhysicsImpostor): void;
  121629. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121630. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121631. private _addMaterial;
  121632. private _checkWithEpsilon;
  121633. private _createShape;
  121634. private _createHeightmap;
  121635. private _minus90X;
  121636. private _plus90X;
  121637. private _tmpPosition;
  121638. private _tmpDeltaPosition;
  121639. private _tmpUnityRotation;
  121640. private _updatePhysicsBodyTransformation;
  121641. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121643. isSupported(): boolean;
  121644. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121645. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121646. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121647. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121648. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121649. getBodyMass(impostor: PhysicsImpostor): number;
  121650. getBodyFriction(impostor: PhysicsImpostor): number;
  121651. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121652. getBodyRestitution(impostor: PhysicsImpostor): number;
  121653. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121654. sleepBody(impostor: PhysicsImpostor): void;
  121655. wakeUpBody(impostor: PhysicsImpostor): void;
  121656. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  121657. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  121658. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  121659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121660. getRadius(impostor: PhysicsImpostor): number;
  121661. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121662. dispose(): void;
  121663. private _extendNamespace;
  121664. /**
  121665. * Does a raycast in the physics world
  121666. * @param from when should the ray start?
  121667. * @param to when should the ray end?
  121668. * @returns PhysicsRaycastResult
  121669. */
  121670. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121671. }
  121672. }
  121673. declare module BABYLON {
  121674. /** @hidden */
  121675. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  121676. world: any;
  121677. name: string;
  121678. BJSOIMO: any;
  121679. private _raycastResult;
  121680. constructor(iterations?: number, oimoInjection?: any);
  121681. setGravity(gravity: Vector3): void;
  121682. setTimeStep(timeStep: number): void;
  121683. getTimeStep(): number;
  121684. private _tmpImpostorsArray;
  121685. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121687. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121688. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121689. private _tmpPositionVector;
  121690. removePhysicsBody(impostor: PhysicsImpostor): void;
  121691. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121692. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121693. isSupported(): boolean;
  121694. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  121695. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  121696. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121697. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  121698. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121699. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  121700. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  121701. getBodyMass(impostor: PhysicsImpostor): number;
  121702. getBodyFriction(impostor: PhysicsImpostor): number;
  121703. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  121704. getBodyRestitution(impostor: PhysicsImpostor): number;
  121705. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  121706. sleepBody(impostor: PhysicsImpostor): void;
  121707. wakeUpBody(impostor: PhysicsImpostor): void;
  121708. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  121709. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  121710. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  121711. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  121712. getRadius(impostor: PhysicsImpostor): number;
  121713. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  121714. dispose(): void;
  121715. /**
  121716. * Does a raycast in the physics world
  121717. * @param from when should the ray start?
  121718. * @param to when should the ray end?
  121719. * @returns PhysicsRaycastResult
  121720. */
  121721. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  121722. }
  121723. }
  121724. declare module BABYLON {
  121725. /**
  121726. * Class containing static functions to help procedurally build meshes
  121727. */
  121728. export class RibbonBuilder {
  121729. /**
  121730. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121731. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121732. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121733. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121734. * * 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
  121735. * * 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
  121736. * * 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
  121737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121740. * * 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
  121741. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121742. * * 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
  121743. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121745. * @param name defines the name of the mesh
  121746. * @param options defines the options used to create the mesh
  121747. * @param scene defines the hosting scene
  121748. * @returns the ribbon mesh
  121749. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121751. */
  121752. static CreateRibbon(name: string, options: {
  121753. pathArray: Vector3[][];
  121754. closeArray?: boolean;
  121755. closePath?: boolean;
  121756. offset?: number;
  121757. updatable?: boolean;
  121758. sideOrientation?: number;
  121759. frontUVs?: Vector4;
  121760. backUVs?: Vector4;
  121761. instance?: Mesh;
  121762. invertUV?: boolean;
  121763. uvs?: Vector2[];
  121764. colors?: Color4[];
  121765. }, scene?: Nullable<Scene>): Mesh;
  121766. }
  121767. }
  121768. declare module BABYLON {
  121769. /**
  121770. * Class containing static functions to help procedurally build meshes
  121771. */
  121772. export class ShapeBuilder {
  121773. /**
  121774. * 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.
  121775. * * 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.
  121776. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121777. * * 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.
  121778. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121779. * * 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
  121780. * * 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
  121781. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121786. * @param name defines the name of the mesh
  121787. * @param options defines the options used to create the mesh
  121788. * @param scene defines the hosting scene
  121789. * @returns the extruded shape mesh
  121790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121792. */
  121793. static ExtrudeShape(name: string, options: {
  121794. shape: Vector3[];
  121795. path: Vector3[];
  121796. scale?: number;
  121797. rotation?: number;
  121798. cap?: number;
  121799. updatable?: boolean;
  121800. sideOrientation?: number;
  121801. frontUVs?: Vector4;
  121802. backUVs?: Vector4;
  121803. instance?: Mesh;
  121804. invertUV?: boolean;
  121805. }, scene?: Nullable<Scene>): Mesh;
  121806. /**
  121807. * Creates an custom extruded shape mesh.
  121808. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121809. * * 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.
  121810. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121811. * * 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
  121812. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121813. * * 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
  121814. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121815. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121816. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121817. * * 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
  121818. * * 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
  121819. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121824. * @param name defines the name of the mesh
  121825. * @param options defines the options used to create the mesh
  121826. * @param scene defines the hosting scene
  121827. * @returns the custom extruded shape mesh
  121828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121831. */
  121832. static ExtrudeShapeCustom(name: string, options: {
  121833. shape: Vector3[];
  121834. path: Vector3[];
  121835. scaleFunction?: any;
  121836. rotationFunction?: any;
  121837. ribbonCloseArray?: boolean;
  121838. ribbonClosePath?: boolean;
  121839. cap?: number;
  121840. updatable?: boolean;
  121841. sideOrientation?: number;
  121842. frontUVs?: Vector4;
  121843. backUVs?: Vector4;
  121844. instance?: Mesh;
  121845. invertUV?: boolean;
  121846. }, scene?: Nullable<Scene>): Mesh;
  121847. private static _ExtrudeShapeGeneric;
  121848. }
  121849. }
  121850. declare module BABYLON {
  121851. /**
  121852. * AmmoJS Physics plugin
  121853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  121854. * @see https://github.com/kripken/ammo.js/
  121855. */
  121856. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  121857. private _useDeltaForWorldStep;
  121858. /**
  121859. * Reference to the Ammo library
  121860. */
  121861. bjsAMMO: any;
  121862. /**
  121863. * Created ammoJS world which physics bodies are added to
  121864. */
  121865. world: any;
  121866. /**
  121867. * Name of the plugin
  121868. */
  121869. name: string;
  121870. private _timeStep;
  121871. private _fixedTimeStep;
  121872. private _maxSteps;
  121873. private _tmpQuaternion;
  121874. private _tmpAmmoTransform;
  121875. private _tmpAmmoQuaternion;
  121876. private _tmpAmmoConcreteContactResultCallback;
  121877. private _collisionConfiguration;
  121878. private _dispatcher;
  121879. private _overlappingPairCache;
  121880. private _solver;
  121881. private _softBodySolver;
  121882. private _tmpAmmoVectorA;
  121883. private _tmpAmmoVectorB;
  121884. private _tmpAmmoVectorC;
  121885. private _tmpAmmoVectorD;
  121886. private _tmpContactCallbackResult;
  121887. private _tmpAmmoVectorRCA;
  121888. private _tmpAmmoVectorRCB;
  121889. private _raycastResult;
  121890. private static readonly DISABLE_COLLISION_FLAG;
  121891. private static readonly KINEMATIC_FLAG;
  121892. private static readonly DISABLE_DEACTIVATION_FLAG;
  121893. /**
  121894. * Initializes the ammoJS plugin
  121895. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  121896. * @param ammoInjection can be used to inject your own ammo reference
  121897. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  121898. */
  121899. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  121900. /**
  121901. * Sets the gravity of the physics world (m/(s^2))
  121902. * @param gravity Gravity to set
  121903. */
  121904. setGravity(gravity: Vector3): void;
  121905. /**
  121906. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  121907. * @param timeStep timestep to use in seconds
  121908. */
  121909. setTimeStep(timeStep: number): void;
  121910. /**
  121911. * 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)
  121912. * @param fixedTimeStep fixedTimeStep to use in seconds
  121913. */
  121914. setFixedTimeStep(fixedTimeStep: number): void;
  121915. /**
  121916. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  121917. * @param maxSteps the maximum number of steps by the physics engine per frame
  121918. */
  121919. setMaxSteps(maxSteps: number): void;
  121920. /**
  121921. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  121922. * @returns the current timestep in seconds
  121923. */
  121924. getTimeStep(): number;
  121925. /**
  121926. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  121927. */
  121928. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  121929. private _isImpostorInContact;
  121930. private _isImpostorPairInContact;
  121931. private _stepSimulation;
  121932. /**
  121933. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  121934. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  121935. * After the step the babylon meshes are set to the position of the physics imposters
  121936. * @param delta amount of time to step forward
  121937. * @param impostors array of imposters to update before/after the step
  121938. */
  121939. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  121940. /**
  121941. * Update babylon mesh to match physics world object
  121942. * @param impostor imposter to match
  121943. */
  121944. private _afterSoftStep;
  121945. /**
  121946. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121947. * @param impostor imposter to match
  121948. */
  121949. private _ropeStep;
  121950. /**
  121951. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  121952. * @param impostor imposter to match
  121953. */
  121954. private _softbodyOrClothStep;
  121955. private _tmpVector;
  121956. private _tmpMatrix;
  121957. /**
  121958. * Applies an impulse on the imposter
  121959. * @param impostor imposter to apply impulse to
  121960. * @param force amount of force to be applied to the imposter
  121961. * @param contactPoint the location to apply the impulse on the imposter
  121962. */
  121963. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121964. /**
  121965. * Applies a force on the imposter
  121966. * @param impostor imposter to apply force
  121967. * @param force amount of force to be applied to the imposter
  121968. * @param contactPoint the location to apply the force on the imposter
  121969. */
  121970. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  121971. /**
  121972. * Creates a physics body using the plugin
  121973. * @param impostor the imposter to create the physics body on
  121974. */
  121975. generatePhysicsBody(impostor: PhysicsImpostor): void;
  121976. /**
  121977. * Removes the physics body from the imposter and disposes of the body's memory
  121978. * @param impostor imposter to remove the physics body from
  121979. */
  121980. removePhysicsBody(impostor: PhysicsImpostor): void;
  121981. /**
  121982. * Generates a joint
  121983. * @param impostorJoint the imposter joint to create the joint with
  121984. */
  121985. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  121986. /**
  121987. * Removes a joint
  121988. * @param impostorJoint the imposter joint to remove the joint from
  121989. */
  121990. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  121991. private _addMeshVerts;
  121992. /**
  121993. * Initialise the soft body vertices to match its object's (mesh) vertices
  121994. * Softbody vertices (nodes) are in world space and to match this
  121995. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  121996. * @param impostor to create the softbody for
  121997. */
  121998. private _softVertexData;
  121999. /**
  122000. * Create an impostor's soft body
  122001. * @param impostor to create the softbody for
  122002. */
  122003. private _createSoftbody;
  122004. /**
  122005. * Create cloth for an impostor
  122006. * @param impostor to create the softbody for
  122007. */
  122008. private _createCloth;
  122009. /**
  122010. * Create rope for an impostor
  122011. * @param impostor to create the softbody for
  122012. */
  122013. private _createRope;
  122014. /**
  122015. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  122016. * @param impostor to create the custom physics shape for
  122017. */
  122018. private _createCustom;
  122019. private _addHullVerts;
  122020. private _createShape;
  122021. /**
  122022. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  122023. * @param impostor imposter containing the physics body and babylon object
  122024. */
  122025. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  122026. /**
  122027. * Sets the babylon object's position/rotation from the physics body's position/rotation
  122028. * @param impostor imposter containing the physics body and babylon object
  122029. * @param newPosition new position
  122030. * @param newRotation new rotation
  122031. */
  122032. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  122033. /**
  122034. * If this plugin is supported
  122035. * @returns true if its supported
  122036. */
  122037. isSupported(): boolean;
  122038. /**
  122039. * Sets the linear velocity of the physics body
  122040. * @param impostor imposter to set the velocity on
  122041. * @param velocity velocity to set
  122042. */
  122043. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122044. /**
  122045. * Sets the angular velocity of the physics body
  122046. * @param impostor imposter to set the velocity on
  122047. * @param velocity velocity to set
  122048. */
  122049. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  122050. /**
  122051. * gets the linear velocity
  122052. * @param impostor imposter to get linear velocity from
  122053. * @returns linear velocity
  122054. */
  122055. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122056. /**
  122057. * gets the angular velocity
  122058. * @param impostor imposter to get angular velocity from
  122059. * @returns angular velocity
  122060. */
  122061. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  122062. /**
  122063. * Sets the mass of physics body
  122064. * @param impostor imposter to set the mass on
  122065. * @param mass mass to set
  122066. */
  122067. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  122068. /**
  122069. * Gets the mass of the physics body
  122070. * @param impostor imposter to get the mass from
  122071. * @returns mass
  122072. */
  122073. getBodyMass(impostor: PhysicsImpostor): number;
  122074. /**
  122075. * Gets friction of the impostor
  122076. * @param impostor impostor to get friction from
  122077. * @returns friction value
  122078. */
  122079. getBodyFriction(impostor: PhysicsImpostor): number;
  122080. /**
  122081. * Sets friction of the impostor
  122082. * @param impostor impostor to set friction on
  122083. * @param friction friction value
  122084. */
  122085. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  122086. /**
  122087. * Gets restitution of the impostor
  122088. * @param impostor impostor to get restitution from
  122089. * @returns restitution value
  122090. */
  122091. getBodyRestitution(impostor: PhysicsImpostor): number;
  122092. /**
  122093. * Sets resitution of the impostor
  122094. * @param impostor impostor to set resitution on
  122095. * @param restitution resitution value
  122096. */
  122097. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  122098. /**
  122099. * Gets pressure inside the impostor
  122100. * @param impostor impostor to get pressure from
  122101. * @returns pressure value
  122102. */
  122103. getBodyPressure(impostor: PhysicsImpostor): number;
  122104. /**
  122105. * Sets pressure inside a soft body impostor
  122106. * Cloth and rope must remain 0 pressure
  122107. * @param impostor impostor to set pressure on
  122108. * @param pressure pressure value
  122109. */
  122110. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  122111. /**
  122112. * Gets stiffness of the impostor
  122113. * @param impostor impostor to get stiffness from
  122114. * @returns pressure value
  122115. */
  122116. getBodyStiffness(impostor: PhysicsImpostor): number;
  122117. /**
  122118. * Sets stiffness of the impostor
  122119. * @param impostor impostor to set stiffness on
  122120. * @param stiffness stiffness value from 0 to 1
  122121. */
  122122. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  122123. /**
  122124. * Gets velocityIterations of the impostor
  122125. * @param impostor impostor to get velocity iterations from
  122126. * @returns velocityIterations value
  122127. */
  122128. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  122129. /**
  122130. * Sets velocityIterations of the impostor
  122131. * @param impostor impostor to set velocity iterations on
  122132. * @param velocityIterations velocityIterations value
  122133. */
  122134. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  122135. /**
  122136. * Gets positionIterations of the impostor
  122137. * @param impostor impostor to get position iterations from
  122138. * @returns positionIterations value
  122139. */
  122140. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  122141. /**
  122142. * Sets positionIterations of the impostor
  122143. * @param impostor impostor to set position on
  122144. * @param positionIterations positionIterations value
  122145. */
  122146. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  122147. /**
  122148. * Append an anchor to a cloth object
  122149. * @param impostor is the cloth impostor to add anchor to
  122150. * @param otherImpostor is the rigid impostor to anchor to
  122151. * @param width ratio across width from 0 to 1
  122152. * @param height ratio up height from 0 to 1
  122153. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  122154. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  122155. */
  122156. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  122157. /**
  122158. * Append an hook to a rope object
  122159. * @param impostor is the rope impostor to add hook to
  122160. * @param otherImpostor is the rigid impostor to hook to
  122161. * @param length ratio along the rope from 0 to 1
  122162. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  122163. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  122164. */
  122165. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  122166. /**
  122167. * Sleeps the physics body and stops it from being active
  122168. * @param impostor impostor to sleep
  122169. */
  122170. sleepBody(impostor: PhysicsImpostor): void;
  122171. /**
  122172. * Activates the physics body
  122173. * @param impostor impostor to activate
  122174. */
  122175. wakeUpBody(impostor: PhysicsImpostor): void;
  122176. /**
  122177. * Updates the distance parameters of the joint
  122178. * @param joint joint to update
  122179. * @param maxDistance maximum distance of the joint
  122180. * @param minDistance minimum distance of the joint
  122181. */
  122182. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  122183. /**
  122184. * Sets a motor on the joint
  122185. * @param joint joint to set motor on
  122186. * @param speed speed of the motor
  122187. * @param maxForce maximum force of the motor
  122188. * @param motorIndex index of the motor
  122189. */
  122190. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  122191. /**
  122192. * Sets the motors limit
  122193. * @param joint joint to set limit on
  122194. * @param upperLimit upper limit
  122195. * @param lowerLimit lower limit
  122196. */
  122197. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  122198. /**
  122199. * Syncs the position and rotation of a mesh with the impostor
  122200. * @param mesh mesh to sync
  122201. * @param impostor impostor to update the mesh with
  122202. */
  122203. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  122204. /**
  122205. * Gets the radius of the impostor
  122206. * @param impostor impostor to get radius from
  122207. * @returns the radius
  122208. */
  122209. getRadius(impostor: PhysicsImpostor): number;
  122210. /**
  122211. * Gets the box size of the impostor
  122212. * @param impostor impostor to get box size from
  122213. * @param result the resulting box size
  122214. */
  122215. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  122216. /**
  122217. * Disposes of the impostor
  122218. */
  122219. dispose(): void;
  122220. /**
  122221. * Does a raycast in the physics world
  122222. * @param from when should the ray start?
  122223. * @param to when should the ray end?
  122224. * @returns PhysicsRaycastResult
  122225. */
  122226. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  122227. }
  122228. }
  122229. declare module BABYLON {
  122230. interface AbstractScene {
  122231. /**
  122232. * The list of reflection probes added to the scene
  122233. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  122234. */
  122235. reflectionProbes: Array<ReflectionProbe>;
  122236. /**
  122237. * Removes the given reflection probe from this scene.
  122238. * @param toRemove The reflection probe to remove
  122239. * @returns The index of the removed reflection probe
  122240. */
  122241. removeReflectionProbe(toRemove: ReflectionProbe): number;
  122242. /**
  122243. * Adds the given reflection probe to this scene.
  122244. * @param newReflectionProbe The reflection probe to add
  122245. */
  122246. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  122247. }
  122248. /**
  122249. * Class used to generate realtime reflection / refraction cube textures
  122250. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  122251. */
  122252. export class ReflectionProbe {
  122253. /** defines the name of the probe */
  122254. name: string;
  122255. private _scene;
  122256. private _renderTargetTexture;
  122257. private _projectionMatrix;
  122258. private _viewMatrix;
  122259. private _target;
  122260. private _add;
  122261. private _attachedMesh;
  122262. private _invertYAxis;
  122263. /** Gets or sets probe position (center of the cube map) */
  122264. position: Vector3;
  122265. /**
  122266. * Creates a new reflection probe
  122267. * @param name defines the name of the probe
  122268. * @param size defines the texture resolution (for each face)
  122269. * @param scene defines the hosting scene
  122270. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  122271. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  122272. */
  122273. constructor(
  122274. /** defines the name of the probe */
  122275. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  122276. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  122277. samples: number;
  122278. /** Gets or sets the refresh rate to use (on every frame by default) */
  122279. refreshRate: number;
  122280. /**
  122281. * Gets the hosting scene
  122282. * @returns a Scene
  122283. */
  122284. getScene(): Scene;
  122285. /** Gets the internal CubeTexture used to render to */
  122286. readonly cubeTexture: RenderTargetTexture;
  122287. /** Gets the list of meshes to render */
  122288. readonly renderList: Nullable<AbstractMesh[]>;
  122289. /**
  122290. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  122291. * @param mesh defines the mesh to attach to
  122292. */
  122293. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122294. /**
  122295. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  122296. * @param renderingGroupId The rendering group id corresponding to its index
  122297. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  122298. */
  122299. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  122300. /**
  122301. * Clean all associated resources
  122302. */
  122303. dispose(): void;
  122304. /**
  122305. * Converts the reflection probe information to a readable string for debug purpose.
  122306. * @param fullDetails Supports for multiple levels of logging within scene loading
  122307. * @returns the human readable reflection probe info
  122308. */
  122309. toString(fullDetails?: boolean): string;
  122310. /**
  122311. * Get the class name of the relfection probe.
  122312. * @returns "ReflectionProbe"
  122313. */
  122314. getClassName(): string;
  122315. /**
  122316. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  122317. * @returns The JSON representation of the texture
  122318. */
  122319. serialize(): any;
  122320. /**
  122321. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  122322. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  122323. * @param scene Define the scene the parsed reflection probe should be instantiated in
  122324. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  122325. * @returns The parsed reflection probe if successful
  122326. */
  122327. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  122328. }
  122329. }
  122330. declare module BABYLON {
  122331. /** @hidden */
  122332. export var _BabylonLoaderRegistered: boolean;
  122333. /**
  122334. * Helps setting up some configuration for the babylon file loader.
  122335. */
  122336. export class BabylonFileLoaderConfiguration {
  122337. /**
  122338. * The loader does not allow injecting custom physix engine into the plugins.
  122339. * Unfortunately in ES6, we need to manually inject them into the plugin.
  122340. * So you could set this variable to your engine import to make it work.
  122341. */
  122342. static LoaderInjectedPhysicsEngine: any;
  122343. }
  122344. }
  122345. declare module BABYLON {
  122346. /**
  122347. * The Physically based simple base material of BJS.
  122348. *
  122349. * This enables better naming and convention enforcements on top of the pbrMaterial.
  122350. * It is used as the base class for both the specGloss and metalRough conventions.
  122351. */
  122352. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  122353. /**
  122354. * Number of Simultaneous lights allowed on the material.
  122355. */
  122356. maxSimultaneousLights: number;
  122357. /**
  122358. * If sets to true, disables all the lights affecting the material.
  122359. */
  122360. disableLighting: boolean;
  122361. /**
  122362. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  122363. */
  122364. environmentTexture: BaseTexture;
  122365. /**
  122366. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  122367. */
  122368. invertNormalMapX: boolean;
  122369. /**
  122370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  122371. */
  122372. invertNormalMapY: boolean;
  122373. /**
  122374. * Normal map used in the model.
  122375. */
  122376. normalTexture: BaseTexture;
  122377. /**
  122378. * Emissivie color used to self-illuminate the model.
  122379. */
  122380. emissiveColor: Color3;
  122381. /**
  122382. * Emissivie texture used to self-illuminate the model.
  122383. */
  122384. emissiveTexture: BaseTexture;
  122385. /**
  122386. * Occlusion Channel Strenght.
  122387. */
  122388. occlusionStrength: number;
  122389. /**
  122390. * Occlusion Texture of the material (adding extra occlusion effects).
  122391. */
  122392. occlusionTexture: BaseTexture;
  122393. /**
  122394. * Defines the alpha limits in alpha test mode.
  122395. */
  122396. alphaCutOff: number;
  122397. /**
  122398. * Gets the current double sided mode.
  122399. */
  122400. /**
  122401. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122402. */
  122403. doubleSided: boolean;
  122404. /**
  122405. * Stores the pre-calculated light information of a mesh in a texture.
  122406. */
  122407. lightmapTexture: BaseTexture;
  122408. /**
  122409. * If true, the light map contains occlusion information instead of lighting info.
  122410. */
  122411. useLightmapAsShadowmap: boolean;
  122412. /**
  122413. * Instantiates a new PBRMaterial instance.
  122414. *
  122415. * @param name The material name
  122416. * @param scene The scene the material will be use in.
  122417. */
  122418. constructor(name: string, scene: Scene);
  122419. getClassName(): string;
  122420. }
  122421. }
  122422. declare module BABYLON {
  122423. /**
  122424. * The PBR material of BJS following the metal roughness convention.
  122425. *
  122426. * This fits to the PBR convention in the GLTF definition:
  122427. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  122428. */
  122429. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  122430. /**
  122431. * The base color has two different interpretations depending on the value of metalness.
  122432. * When the material is a metal, the base color is the specific measured reflectance value
  122433. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  122434. * of the material.
  122435. */
  122436. baseColor: Color3;
  122437. /**
  122438. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  122439. * well as opacity information in the alpha channel.
  122440. */
  122441. baseTexture: BaseTexture;
  122442. /**
  122443. * Specifies the metallic scalar value of the material.
  122444. * Can also be used to scale the metalness values of the metallic texture.
  122445. */
  122446. metallic: number;
  122447. /**
  122448. * Specifies the roughness scalar value of the material.
  122449. * Can also be used to scale the roughness values of the metallic texture.
  122450. */
  122451. roughness: number;
  122452. /**
  122453. * Texture containing both the metallic value in the B channel and the
  122454. * roughness value in the G channel to keep better precision.
  122455. */
  122456. metallicRoughnessTexture: BaseTexture;
  122457. /**
  122458. * Instantiates a new PBRMetalRoughnessMaterial instance.
  122459. *
  122460. * @param name The material name
  122461. * @param scene The scene the material will be use in.
  122462. */
  122463. constructor(name: string, scene: Scene);
  122464. /**
  122465. * Return the currrent class name of the material.
  122466. */
  122467. getClassName(): string;
  122468. /**
  122469. * Makes a duplicate of the current material.
  122470. * @param name - name to use for the new material.
  122471. */
  122472. clone(name: string): PBRMetallicRoughnessMaterial;
  122473. /**
  122474. * Serialize the material to a parsable JSON object.
  122475. */
  122476. serialize(): any;
  122477. /**
  122478. * Parses a JSON object correponding to the serialize function.
  122479. */
  122480. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  122481. }
  122482. }
  122483. declare module BABYLON {
  122484. /**
  122485. * The PBR material of BJS following the specular glossiness convention.
  122486. *
  122487. * This fits to the PBR convention in the GLTF definition:
  122488. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  122489. */
  122490. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  122491. /**
  122492. * Specifies the diffuse color of the material.
  122493. */
  122494. diffuseColor: Color3;
  122495. /**
  122496. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  122497. * channel.
  122498. */
  122499. diffuseTexture: BaseTexture;
  122500. /**
  122501. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  122502. */
  122503. specularColor: Color3;
  122504. /**
  122505. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  122506. */
  122507. glossiness: number;
  122508. /**
  122509. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  122510. */
  122511. specularGlossinessTexture: BaseTexture;
  122512. /**
  122513. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  122514. *
  122515. * @param name The material name
  122516. * @param scene The scene the material will be use in.
  122517. */
  122518. constructor(name: string, scene: Scene);
  122519. /**
  122520. * Return the currrent class name of the material.
  122521. */
  122522. getClassName(): string;
  122523. /**
  122524. * Makes a duplicate of the current material.
  122525. * @param name - name to use for the new material.
  122526. */
  122527. clone(name: string): PBRSpecularGlossinessMaterial;
  122528. /**
  122529. * Serialize the material to a parsable JSON object.
  122530. */
  122531. serialize(): any;
  122532. /**
  122533. * Parses a JSON object correponding to the serialize function.
  122534. */
  122535. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  122536. }
  122537. }
  122538. declare module BABYLON {
  122539. /**
  122540. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  122541. * It can help converting any input color in a desired output one. This can then be used to create effects
  122542. * from sepia, black and white to sixties or futuristic rendering...
  122543. *
  122544. * The only supported format is currently 3dl.
  122545. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  122546. */
  122547. export class ColorGradingTexture extends BaseTexture {
  122548. /**
  122549. * The current texture matrix. (will always be identity in color grading texture)
  122550. */
  122551. private _textureMatrix;
  122552. /**
  122553. * The texture URL.
  122554. */
  122555. url: string;
  122556. /**
  122557. * Empty line regex stored for GC.
  122558. */
  122559. private static _noneEmptyLineRegex;
  122560. private _engine;
  122561. /**
  122562. * Instantiates a ColorGradingTexture from the following parameters.
  122563. *
  122564. * @param url The location of the color gradind data (currently only supporting 3dl)
  122565. * @param scene The scene the texture will be used in
  122566. */
  122567. constructor(url: string, scene: Scene);
  122568. /**
  122569. * Returns the texture matrix used in most of the material.
  122570. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  122571. */
  122572. getTextureMatrix(): Matrix;
  122573. /**
  122574. * Occurs when the file being loaded is a .3dl LUT file.
  122575. */
  122576. private load3dlTexture;
  122577. /**
  122578. * Starts the loading process of the texture.
  122579. */
  122580. private loadTexture;
  122581. /**
  122582. * Clones the color gradind texture.
  122583. */
  122584. clone(): ColorGradingTexture;
  122585. /**
  122586. * Called during delayed load for textures.
  122587. */
  122588. delayLoad(): void;
  122589. /**
  122590. * Parses a color grading texture serialized by Babylon.
  122591. * @param parsedTexture The texture information being parsedTexture
  122592. * @param scene The scene to load the texture in
  122593. * @param rootUrl The root url of the data assets to load
  122594. * @return A color gradind texture
  122595. */
  122596. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  122597. /**
  122598. * Serializes the LUT texture to json format.
  122599. */
  122600. serialize(): any;
  122601. }
  122602. }
  122603. declare module BABYLON {
  122604. /**
  122605. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  122606. */
  122607. export class EquiRectangularCubeTexture extends BaseTexture {
  122608. /** The six faces of the cube. */
  122609. private static _FacesMapping;
  122610. private _noMipmap;
  122611. private _onLoad;
  122612. private _onError;
  122613. /** The size of the cubemap. */
  122614. private _size;
  122615. /** The buffer of the image. */
  122616. private _buffer;
  122617. /** The width of the input image. */
  122618. private _width;
  122619. /** The height of the input image. */
  122620. private _height;
  122621. /** The URL to the image. */
  122622. url: string;
  122623. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  122624. coordinatesMode: number;
  122625. /**
  122626. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  122627. * @param url The location of the image
  122628. * @param scene The scene the texture will be used in
  122629. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  122630. * @param noMipmap Forces to not generate the mipmap if true
  122631. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  122632. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  122633. * @param onLoad — defines a callback called when texture is loaded
  122634. * @param onError — defines a callback called if there is an error
  122635. */
  122636. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  122637. /**
  122638. * Load the image data, by putting the image on a canvas and extracting its buffer.
  122639. */
  122640. private loadImage;
  122641. /**
  122642. * Convert the image buffer into a cubemap and create a CubeTexture.
  122643. */
  122644. private loadTexture;
  122645. /**
  122646. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  122647. * @param buffer The ArrayBuffer that should be converted.
  122648. * @returns The buffer as Float32Array.
  122649. */
  122650. private getFloat32ArrayFromArrayBuffer;
  122651. /**
  122652. * Get the current class name of the texture useful for serialization or dynamic coding.
  122653. * @returns "EquiRectangularCubeTexture"
  122654. */
  122655. getClassName(): string;
  122656. /**
  122657. * Create a clone of the current EquiRectangularCubeTexture and return it.
  122658. * @returns A clone of the current EquiRectangularCubeTexture.
  122659. */
  122660. clone(): EquiRectangularCubeTexture;
  122661. }
  122662. }
  122663. declare module BABYLON {
  122664. /**
  122665. * Based on jsTGALoader - Javascript loader for TGA file
  122666. * By Vincent Thibault
  122667. * @see http://blog.robrowser.com/javascript-tga-loader.html
  122668. */
  122669. export class TGATools {
  122670. private static _TYPE_INDEXED;
  122671. private static _TYPE_RGB;
  122672. private static _TYPE_GREY;
  122673. private static _TYPE_RLE_INDEXED;
  122674. private static _TYPE_RLE_RGB;
  122675. private static _TYPE_RLE_GREY;
  122676. private static _ORIGIN_MASK;
  122677. private static _ORIGIN_SHIFT;
  122678. private static _ORIGIN_BL;
  122679. private static _ORIGIN_BR;
  122680. private static _ORIGIN_UL;
  122681. private static _ORIGIN_UR;
  122682. /**
  122683. * Gets the header of a TGA file
  122684. * @param data defines the TGA data
  122685. * @returns the header
  122686. */
  122687. static GetTGAHeader(data: Uint8Array): any;
  122688. /**
  122689. * Uploads TGA content to a Babylon Texture
  122690. * @hidden
  122691. */
  122692. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  122693. /** @hidden */
  122694. 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;
  122695. /** @hidden */
  122696. 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;
  122697. /** @hidden */
  122698. 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;
  122699. /** @hidden */
  122700. 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;
  122701. /** @hidden */
  122702. 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;
  122703. /** @hidden */
  122704. 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;
  122705. }
  122706. }
  122707. declare module BABYLON {
  122708. /**
  122709. * Implementation of the TGA Texture Loader.
  122710. * @hidden
  122711. */
  122712. export class _TGATextureLoader implements IInternalTextureLoader {
  122713. /**
  122714. * Defines wether the loader supports cascade loading the different faces.
  122715. */
  122716. readonly supportCascades: boolean;
  122717. /**
  122718. * This returns if the loader support the current file information.
  122719. * @param extension defines the file extension of the file being loaded
  122720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122721. * @param fallback defines the fallback internal texture if any
  122722. * @param isBase64 defines whether the texture is encoded as a base64
  122723. * @param isBuffer defines whether the texture data are stored as a buffer
  122724. * @returns true if the loader can load the specified file
  122725. */
  122726. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122727. /**
  122728. * Transform the url before loading if required.
  122729. * @param rootUrl the url of the texture
  122730. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122731. * @returns the transformed texture
  122732. */
  122733. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122734. /**
  122735. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122736. * @param rootUrl the url of the texture
  122737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122738. * @returns the fallback texture
  122739. */
  122740. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122741. /**
  122742. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  122743. * @param data contains the texture data
  122744. * @param texture defines the BabylonJS internal texture
  122745. * @param createPolynomials will be true if polynomials have been requested
  122746. * @param onLoad defines the callback to trigger once the texture is ready
  122747. * @param onError defines the callback to trigger in case of error
  122748. */
  122749. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122750. /**
  122751. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122752. * @param data contains the texture data
  122753. * @param texture defines the BabylonJS internal texture
  122754. * @param callback defines the method to call once ready to upload
  122755. */
  122756. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122757. }
  122758. }
  122759. declare module BABYLON {
  122760. /**
  122761. * Info about the .basis files
  122762. */
  122763. class BasisFileInfo {
  122764. /**
  122765. * If the file has alpha
  122766. */
  122767. hasAlpha: boolean;
  122768. /**
  122769. * Info about each image of the basis file
  122770. */
  122771. images: Array<{
  122772. levels: Array<{
  122773. width: number;
  122774. height: number;
  122775. transcodedPixels: ArrayBufferView;
  122776. }>;
  122777. }>;
  122778. }
  122779. /**
  122780. * Result of transcoding a basis file
  122781. */
  122782. class TranscodeResult {
  122783. /**
  122784. * Info about the .basis file
  122785. */
  122786. fileInfo: BasisFileInfo;
  122787. /**
  122788. * Format to use when loading the file
  122789. */
  122790. format: number;
  122791. }
  122792. /**
  122793. * Configuration options for the Basis transcoder
  122794. */
  122795. export class BasisTranscodeConfiguration {
  122796. /**
  122797. * Supported compression formats used to determine the supported output format of the transcoder
  122798. */
  122799. supportedCompressionFormats?: {
  122800. /**
  122801. * etc1 compression format
  122802. */
  122803. etc1?: boolean;
  122804. /**
  122805. * s3tc compression format
  122806. */
  122807. s3tc?: boolean;
  122808. /**
  122809. * pvrtc compression format
  122810. */
  122811. pvrtc?: boolean;
  122812. /**
  122813. * etc2 compression format
  122814. */
  122815. etc2?: boolean;
  122816. };
  122817. /**
  122818. * If mipmap levels should be loaded for transcoded images (Default: true)
  122819. */
  122820. loadMipmapLevels?: boolean;
  122821. /**
  122822. * Index of a single image to load (Default: all images)
  122823. */
  122824. loadSingleImage?: number;
  122825. }
  122826. /**
  122827. * Used to load .Basis files
  122828. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  122829. */
  122830. export class BasisTools {
  122831. private static _IgnoreSupportedFormats;
  122832. /**
  122833. * URL to use when loading the basis transcoder
  122834. */
  122835. static JSModuleURL: string;
  122836. /**
  122837. * URL to use when loading the wasm module for the transcoder
  122838. */
  122839. static WasmModuleURL: string;
  122840. /**
  122841. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  122842. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  122843. * @returns internal format corresponding to the Basis format
  122844. */
  122845. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  122846. private static _WorkerPromise;
  122847. private static _Worker;
  122848. private static _actionId;
  122849. private static _CreateWorkerAsync;
  122850. /**
  122851. * Transcodes a loaded image file to compressed pixel data
  122852. * @param imageData image data to transcode
  122853. * @param config configuration options for the transcoding
  122854. * @returns a promise resulting in the transcoded image
  122855. */
  122856. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  122857. /**
  122858. * Loads a texture from the transcode result
  122859. * @param texture texture load to
  122860. * @param transcodeResult the result of transcoding the basis file to load from
  122861. */
  122862. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  122863. }
  122864. }
  122865. declare module BABYLON {
  122866. /**
  122867. * Loader for .basis file format
  122868. */
  122869. export class _BasisTextureLoader implements IInternalTextureLoader {
  122870. /**
  122871. * Defines whether the loader supports cascade loading the different faces.
  122872. */
  122873. readonly supportCascades: boolean;
  122874. /**
  122875. * This returns if the loader support the current file information.
  122876. * @param extension defines the file extension of the file being loaded
  122877. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122878. * @param fallback defines the fallback internal texture if any
  122879. * @param isBase64 defines whether the texture is encoded as a base64
  122880. * @param isBuffer defines whether the texture data are stored as a buffer
  122881. * @returns true if the loader can load the specified file
  122882. */
  122883. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  122884. /**
  122885. * Transform the url before loading if required.
  122886. * @param rootUrl the url of the texture
  122887. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122888. * @returns the transformed texture
  122889. */
  122890. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  122891. /**
  122892. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  122893. * @param rootUrl the url of the texture
  122894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  122895. * @returns the fallback texture
  122896. */
  122897. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  122898. /**
  122899. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  122900. * @param data contains the texture data
  122901. * @param texture defines the BabylonJS internal texture
  122902. * @param createPolynomials will be true if polynomials have been requested
  122903. * @param onLoad defines the callback to trigger once the texture is ready
  122904. * @param onError defines the callback to trigger in case of error
  122905. */
  122906. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  122907. /**
  122908. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  122909. * @param data contains the texture data
  122910. * @param texture defines the BabylonJS internal texture
  122911. * @param callback defines the method to call once ready to upload
  122912. */
  122913. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  122914. }
  122915. }
  122916. declare module BABYLON {
  122917. /**
  122918. * 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.
  122919. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122920. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122921. */
  122922. export class CustomProceduralTexture extends ProceduralTexture {
  122923. private _animate;
  122924. private _time;
  122925. private _config;
  122926. private _texturePath;
  122927. /**
  122928. * Instantiates a new Custom Procedural Texture.
  122929. * 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.
  122930. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  122931. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  122932. * @param name Define the name of the texture
  122933. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  122934. * @param size Define the size of the texture to create
  122935. * @param scene Define the scene the texture belongs to
  122936. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  122937. * @param generateMipMaps Define if the texture should creates mip maps or not
  122938. */
  122939. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122940. private _loadJson;
  122941. /**
  122942. * Is the texture ready to be used ? (rendered at least once)
  122943. * @returns true if ready, otherwise, false.
  122944. */
  122945. isReady(): boolean;
  122946. /**
  122947. * Render the texture to its associated render target.
  122948. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  122949. */
  122950. render(useCameraPostProcess?: boolean): void;
  122951. /**
  122952. * Update the list of dependant textures samplers in the shader.
  122953. */
  122954. updateTextures(): void;
  122955. /**
  122956. * Update the uniform values of the procedural texture in the shader.
  122957. */
  122958. updateShaderUniforms(): void;
  122959. /**
  122960. * Define if the texture animates or not.
  122961. */
  122962. animate: boolean;
  122963. }
  122964. }
  122965. declare module BABYLON {
  122966. /** @hidden */
  122967. export var noisePixelShader: {
  122968. name: string;
  122969. shader: string;
  122970. };
  122971. }
  122972. declare module BABYLON {
  122973. /**
  122974. * Class used to generate noise procedural textures
  122975. */
  122976. export class NoiseProceduralTexture extends ProceduralTexture {
  122977. private _time;
  122978. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  122979. brightness: number;
  122980. /** Defines the number of octaves to process */
  122981. octaves: number;
  122982. /** Defines the level of persistence (0.8 by default) */
  122983. persistence: number;
  122984. /** Gets or sets animation speed factor (default is 1) */
  122985. animationSpeedFactor: number;
  122986. /**
  122987. * Creates a new NoiseProceduralTexture
  122988. * @param name defines the name fo the texture
  122989. * @param size defines the size of the texture (default is 256)
  122990. * @param scene defines the hosting scene
  122991. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  122992. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  122993. */
  122994. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  122995. private _updateShaderUniforms;
  122996. protected _getDefines(): string;
  122997. /** Generate the current state of the procedural texture */
  122998. render(useCameraPostProcess?: boolean): void;
  122999. /**
  123000. * Serializes this noise procedural texture
  123001. * @returns a serialized noise procedural texture object
  123002. */
  123003. serialize(): any;
  123004. /**
  123005. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  123006. * @param parsedTexture defines parsed texture data
  123007. * @param scene defines the current scene
  123008. * @param rootUrl defines the root URL containing noise procedural texture information
  123009. * @returns a parsed NoiseProceduralTexture
  123010. */
  123011. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. /**
  123016. * Raw cube texture where the raw buffers are passed in
  123017. */
  123018. export class RawCubeTexture extends CubeTexture {
  123019. /**
  123020. * Creates a cube texture where the raw buffers are passed in.
  123021. * @param scene defines the scene the texture is attached to
  123022. * @param data defines the array of data to use to create each face
  123023. * @param size defines the size of the textures
  123024. * @param format defines the format of the data
  123025. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  123026. * @param generateMipMaps defines if the engine should generate the mip levels
  123027. * @param invertY defines if data must be stored with Y axis inverted
  123028. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  123029. * @param compression defines the compression used (null by default)
  123030. */
  123031. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  123032. /**
  123033. * Updates the raw cube texture.
  123034. * @param data defines the data to store
  123035. * @param format defines the data format
  123036. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123037. * @param invertY defines if data must be stored with Y axis inverted
  123038. * @param compression defines the compression used (null by default)
  123039. * @param level defines which level of the texture to update
  123040. */
  123041. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  123042. /**
  123043. * Updates a raw cube texture with RGBD encoded data.
  123044. * @param data defines the array of data [mipmap][face] to use to create each face
  123045. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  123046. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  123047. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  123048. * @returns a promsie that resolves when the operation is complete
  123049. */
  123050. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  123051. /**
  123052. * Clones the raw cube texture.
  123053. * @return a new cube texture
  123054. */
  123055. clone(): CubeTexture;
  123056. /** @hidden */
  123057. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  123058. }
  123059. }
  123060. declare module BABYLON {
  123061. /**
  123062. * Class used to store 3D textures containing user data
  123063. */
  123064. export class RawTexture3D extends Texture {
  123065. /** Gets or sets the texture format to use */
  123066. format: number;
  123067. private _engine;
  123068. /**
  123069. * Create a new RawTexture3D
  123070. * @param data defines the data of the texture
  123071. * @param width defines the width of the texture
  123072. * @param height defines the height of the texture
  123073. * @param depth defines the depth of the texture
  123074. * @param format defines the texture format to use
  123075. * @param scene defines the hosting scene
  123076. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  123077. * @param invertY defines if texture must be stored with Y axis inverted
  123078. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123079. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  123080. */
  123081. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  123082. /** Gets or sets the texture format to use */
  123083. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  123084. /**
  123085. * Update the texture with new data
  123086. * @param data defines the data to store in the texture
  123087. */
  123088. update(data: ArrayBufferView): void;
  123089. }
  123090. }
  123091. declare module BABYLON {
  123092. /**
  123093. * Class used to store 2D array textures containing user data
  123094. */
  123095. export class RawTexture2DArray extends Texture {
  123096. /** Gets or sets the texture format to use */
  123097. format: number;
  123098. private _engine;
  123099. /**
  123100. * Create a new RawTexture2DArray
  123101. * @param data defines the data of the texture
  123102. * @param width defines the width of the texture
  123103. * @param height defines the height of the texture
  123104. * @param depth defines the number of layers of the texture
  123105. * @param format defines the texture format to use
  123106. * @param scene defines the hosting scene
  123107. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  123108. * @param invertY defines if texture must be stored with Y axis inverted
  123109. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123110. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  123111. */
  123112. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  123113. /** Gets or sets the texture format to use */
  123114. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  123115. /**
  123116. * Update the texture with new data
  123117. * @param data defines the data to store in the texture
  123118. */
  123119. update(data: ArrayBufferView): void;
  123120. }
  123121. }
  123122. declare module BABYLON {
  123123. /**
  123124. * Creates a refraction texture used by refraction channel of the standard material.
  123125. * It is like a mirror but to see through a material.
  123126. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  123127. */
  123128. export class RefractionTexture extends RenderTargetTexture {
  123129. /**
  123130. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  123131. * 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.
  123132. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  123133. */
  123134. refractionPlane: Plane;
  123135. /**
  123136. * Define how deep under the surface we should see.
  123137. */
  123138. depth: number;
  123139. /**
  123140. * Creates a refraction texture used by refraction channel of the standard material.
  123141. * It is like a mirror but to see through a material.
  123142. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  123143. * @param name Define the texture name
  123144. * @param size Define the size of the underlying texture
  123145. * @param scene Define the scene the refraction belongs to
  123146. * @param generateMipMaps Define if we need to generate mips level for the refraction
  123147. */
  123148. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  123149. /**
  123150. * Clone the refraction texture.
  123151. * @returns the cloned texture
  123152. */
  123153. clone(): RefractionTexture;
  123154. /**
  123155. * Serialize the texture to a JSON representation you could use in Parse later on
  123156. * @returns the serialized JSON representation
  123157. */
  123158. serialize(): any;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Defines the options related to the creation of an HtmlElementTexture
  123164. */
  123165. export interface IHtmlElementTextureOptions {
  123166. /**
  123167. * Defines wether mip maps should be created or not.
  123168. */
  123169. generateMipMaps?: boolean;
  123170. /**
  123171. * Defines the sampling mode of the texture.
  123172. */
  123173. samplingMode?: number;
  123174. /**
  123175. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  123176. */
  123177. engine: Nullable<ThinEngine>;
  123178. /**
  123179. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  123180. */
  123181. scene: Nullable<Scene>;
  123182. }
  123183. /**
  123184. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  123185. * To be as efficient as possible depending on your constraints nothing aside the first upload
  123186. * is automatically managed.
  123187. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  123188. * in your application.
  123189. *
  123190. * As the update is not automatic, you need to call them manually.
  123191. */
  123192. export class HtmlElementTexture extends BaseTexture {
  123193. /**
  123194. * The texture URL.
  123195. */
  123196. element: HTMLVideoElement | HTMLCanvasElement;
  123197. private static readonly DefaultOptions;
  123198. private _textureMatrix;
  123199. private _engine;
  123200. private _isVideo;
  123201. private _generateMipMaps;
  123202. private _samplingMode;
  123203. /**
  123204. * Instantiates a HtmlElementTexture from the following parameters.
  123205. *
  123206. * @param name Defines the name of the texture
  123207. * @param element Defines the video or canvas the texture is filled with
  123208. * @param options Defines the other none mandatory texture creation options
  123209. */
  123210. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  123211. private _createInternalTexture;
  123212. /**
  123213. * Returns the texture matrix used in most of the material.
  123214. */
  123215. getTextureMatrix(): Matrix;
  123216. /**
  123217. * Updates the content of the texture.
  123218. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  123219. */
  123220. update(invertY?: Nullable<boolean>): void;
  123221. }
  123222. }
  123223. declare module BABYLON {
  123224. /**
  123225. * Enum used to define the target of a block
  123226. */
  123227. export enum NodeMaterialBlockTargets {
  123228. /** Vertex shader */
  123229. Vertex = 1,
  123230. /** Fragment shader */
  123231. Fragment = 2,
  123232. /** Neutral */
  123233. Neutral = 4,
  123234. /** Vertex and Fragment */
  123235. VertexAndFragment = 3
  123236. }
  123237. }
  123238. declare module BABYLON {
  123239. /**
  123240. * Defines the kind of connection point for node based material
  123241. */
  123242. export enum NodeMaterialBlockConnectionPointTypes {
  123243. /** Float */
  123244. Float = 1,
  123245. /** Int */
  123246. Int = 2,
  123247. /** Vector2 */
  123248. Vector2 = 4,
  123249. /** Vector3 */
  123250. Vector3 = 8,
  123251. /** Vector4 */
  123252. Vector4 = 16,
  123253. /** Color3 */
  123254. Color3 = 32,
  123255. /** Color4 */
  123256. Color4 = 64,
  123257. /** Matrix */
  123258. Matrix = 128,
  123259. /** Detect type based on connection */
  123260. AutoDetect = 1024,
  123261. /** Output type that will be defined by input type */
  123262. BasedOnInput = 2048
  123263. }
  123264. }
  123265. declare module BABYLON {
  123266. /**
  123267. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  123268. */
  123269. export enum NodeMaterialBlockConnectionPointMode {
  123270. /** Value is an uniform */
  123271. Uniform = 0,
  123272. /** Value is a mesh attribute */
  123273. Attribute = 1,
  123274. /** Value is a varying between vertex and fragment shaders */
  123275. Varying = 2,
  123276. /** Mode is undefined */
  123277. Undefined = 3
  123278. }
  123279. }
  123280. declare module BABYLON {
  123281. /**
  123282. * Enum used to define system values e.g. values automatically provided by the system
  123283. */
  123284. export enum NodeMaterialSystemValues {
  123285. /** World */
  123286. World = 1,
  123287. /** View */
  123288. View = 2,
  123289. /** Projection */
  123290. Projection = 3,
  123291. /** ViewProjection */
  123292. ViewProjection = 4,
  123293. /** WorldView */
  123294. WorldView = 5,
  123295. /** WorldViewProjection */
  123296. WorldViewProjection = 6,
  123297. /** CameraPosition */
  123298. CameraPosition = 7,
  123299. /** Fog Color */
  123300. FogColor = 8,
  123301. /** Delta time */
  123302. DeltaTime = 9
  123303. }
  123304. }
  123305. declare module BABYLON {
  123306. /**
  123307. * Root class for all node material optimizers
  123308. */
  123309. export class NodeMaterialOptimizer {
  123310. /**
  123311. * Function used to optimize a NodeMaterial graph
  123312. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  123313. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  123314. */
  123315. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  123316. }
  123317. }
  123318. declare module BABYLON {
  123319. /**
  123320. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  123321. */
  123322. export class TransformBlock extends NodeMaterialBlock {
  123323. /**
  123324. * Defines the value to use to complement W value to transform it to a Vector4
  123325. */
  123326. complementW: number;
  123327. /**
  123328. * Defines the value to use to complement z value to transform it to a Vector4
  123329. */
  123330. complementZ: number;
  123331. /**
  123332. * Creates a new TransformBlock
  123333. * @param name defines the block name
  123334. */
  123335. constructor(name: string);
  123336. /**
  123337. * Gets the current class name
  123338. * @returns the class name
  123339. */
  123340. getClassName(): string;
  123341. /**
  123342. * Gets the vector input
  123343. */
  123344. readonly vector: NodeMaterialConnectionPoint;
  123345. /**
  123346. * Gets the output component
  123347. */
  123348. readonly output: NodeMaterialConnectionPoint;
  123349. /**
  123350. * Gets the matrix transform input
  123351. */
  123352. readonly transform: NodeMaterialConnectionPoint;
  123353. protected _buildBlock(state: NodeMaterialBuildState): this;
  123354. serialize(): any;
  123355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123356. protected _dumpPropertiesCode(): string;
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. /**
  123361. * Block used to output the vertex position
  123362. */
  123363. export class VertexOutputBlock extends NodeMaterialBlock {
  123364. /**
  123365. * Creates a new VertexOutputBlock
  123366. * @param name defines the block name
  123367. */
  123368. constructor(name: string);
  123369. /**
  123370. * Gets the current class name
  123371. * @returns the class name
  123372. */
  123373. getClassName(): string;
  123374. /**
  123375. * Gets the vector input component
  123376. */
  123377. readonly vector: NodeMaterialConnectionPoint;
  123378. protected _buildBlock(state: NodeMaterialBuildState): this;
  123379. }
  123380. }
  123381. declare module BABYLON {
  123382. /**
  123383. * Block used to output the final color
  123384. */
  123385. export class FragmentOutputBlock extends NodeMaterialBlock {
  123386. /**
  123387. * Create a new FragmentOutputBlock
  123388. * @param name defines the block name
  123389. */
  123390. constructor(name: string);
  123391. /**
  123392. * Gets the current class name
  123393. * @returns the class name
  123394. */
  123395. getClassName(): string;
  123396. /**
  123397. * Gets the rgba input component
  123398. */
  123399. readonly rgba: NodeMaterialConnectionPoint;
  123400. /**
  123401. * Gets the rgb input component
  123402. */
  123403. readonly rgb: NodeMaterialConnectionPoint;
  123404. /**
  123405. * Gets the a input component
  123406. */
  123407. readonly a: NodeMaterialConnectionPoint;
  123408. protected _buildBlock(state: NodeMaterialBuildState): this;
  123409. }
  123410. }
  123411. declare module BABYLON {
  123412. /**
  123413. * Block used to read a reflection texture from a sampler
  123414. */
  123415. export class ReflectionTextureBlock extends NodeMaterialBlock {
  123416. private _define3DName;
  123417. private _defineCubicName;
  123418. private _defineExplicitName;
  123419. private _defineProjectionName;
  123420. private _defineLocalCubicName;
  123421. private _defineSphericalName;
  123422. private _definePlanarName;
  123423. private _defineEquirectangularName;
  123424. private _defineMirroredEquirectangularFixedName;
  123425. private _defineEquirectangularFixedName;
  123426. private _defineSkyboxName;
  123427. private _cubeSamplerName;
  123428. private _2DSamplerName;
  123429. private _positionUVWName;
  123430. private _directionWName;
  123431. private _reflectionCoordsName;
  123432. private _reflection2DCoordsName;
  123433. private _reflectionColorName;
  123434. private _reflectionMatrixName;
  123435. /**
  123436. * Gets or sets the texture associated with the node
  123437. */
  123438. texture: Nullable<BaseTexture>;
  123439. /**
  123440. * Create a new TextureBlock
  123441. * @param name defines the block name
  123442. */
  123443. constructor(name: string);
  123444. /**
  123445. * Gets the current class name
  123446. * @returns the class name
  123447. */
  123448. getClassName(): string;
  123449. /**
  123450. * Gets the world position input component
  123451. */
  123452. readonly position: NodeMaterialConnectionPoint;
  123453. /**
  123454. * Gets the world position input component
  123455. */
  123456. readonly worldPosition: NodeMaterialConnectionPoint;
  123457. /**
  123458. * Gets the world normal input component
  123459. */
  123460. readonly worldNormal: NodeMaterialConnectionPoint;
  123461. /**
  123462. * Gets the world input component
  123463. */
  123464. readonly world: NodeMaterialConnectionPoint;
  123465. /**
  123466. * Gets the camera (or eye) position component
  123467. */
  123468. readonly cameraPosition: NodeMaterialConnectionPoint;
  123469. /**
  123470. * Gets the view input component
  123471. */
  123472. readonly view: NodeMaterialConnectionPoint;
  123473. /**
  123474. * Gets the rgb output component
  123475. */
  123476. readonly rgb: NodeMaterialConnectionPoint;
  123477. /**
  123478. * Gets the r output component
  123479. */
  123480. readonly r: NodeMaterialConnectionPoint;
  123481. /**
  123482. * Gets the g output component
  123483. */
  123484. readonly g: NodeMaterialConnectionPoint;
  123485. /**
  123486. * Gets the b output component
  123487. */
  123488. readonly b: NodeMaterialConnectionPoint;
  123489. autoConfigure(material: NodeMaterial): void;
  123490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123491. isReady(): boolean;
  123492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123493. private _injectVertexCode;
  123494. private _writeOutput;
  123495. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123496. protected _dumpPropertiesCode(): string;
  123497. serialize(): any;
  123498. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123499. }
  123500. }
  123501. declare module BABYLON {
  123502. /**
  123503. * Interface used to configure the node material editor
  123504. */
  123505. export interface INodeMaterialEditorOptions {
  123506. /** Define the URl to load node editor script */
  123507. editorURL?: string;
  123508. }
  123509. /** @hidden */
  123510. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  123511. /** BONES */
  123512. NUM_BONE_INFLUENCERS: number;
  123513. BonesPerMesh: number;
  123514. BONETEXTURE: boolean;
  123515. /** MORPH TARGETS */
  123516. MORPHTARGETS: boolean;
  123517. MORPHTARGETS_NORMAL: boolean;
  123518. MORPHTARGETS_TANGENT: boolean;
  123519. MORPHTARGETS_UV: boolean;
  123520. NUM_MORPH_INFLUENCERS: number;
  123521. /** IMAGE PROCESSING */
  123522. IMAGEPROCESSING: boolean;
  123523. VIGNETTE: boolean;
  123524. VIGNETTEBLENDMODEMULTIPLY: boolean;
  123525. VIGNETTEBLENDMODEOPAQUE: boolean;
  123526. TONEMAPPING: boolean;
  123527. TONEMAPPING_ACES: boolean;
  123528. CONTRAST: boolean;
  123529. EXPOSURE: boolean;
  123530. COLORCURVES: boolean;
  123531. COLORGRADING: boolean;
  123532. COLORGRADING3D: boolean;
  123533. SAMPLER3DGREENDEPTH: boolean;
  123534. SAMPLER3DBGRMAP: boolean;
  123535. IMAGEPROCESSINGPOSTPROCESS: boolean;
  123536. /** MISC. */
  123537. BUMPDIRECTUV: number;
  123538. constructor();
  123539. setValue(name: string, value: boolean): void;
  123540. }
  123541. /**
  123542. * Class used to configure NodeMaterial
  123543. */
  123544. export interface INodeMaterialOptions {
  123545. /**
  123546. * Defines if blocks should emit comments
  123547. */
  123548. emitComments: boolean;
  123549. }
  123550. /**
  123551. * Class used to create a node based material built by assembling shader blocks
  123552. */
  123553. export class NodeMaterial extends PushMaterial {
  123554. private static _BuildIdGenerator;
  123555. private _options;
  123556. private _vertexCompilationState;
  123557. private _fragmentCompilationState;
  123558. private _sharedData;
  123559. private _buildId;
  123560. private _buildWasSuccessful;
  123561. private _cachedWorldViewMatrix;
  123562. private _cachedWorldViewProjectionMatrix;
  123563. private _optimizers;
  123564. private _animationFrame;
  123565. /** Define the URl to load node editor script */
  123566. static EditorURL: string;
  123567. private BJSNODEMATERIALEDITOR;
  123568. /** Get the inspector from bundle or global */
  123569. private _getGlobalNodeMaterialEditor;
  123570. /**
  123571. * Gets or sets data used by visual editor
  123572. * @see https://nme.babylonjs.com
  123573. */
  123574. editorData: any;
  123575. /**
  123576. * 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)
  123577. */
  123578. ignoreAlpha: boolean;
  123579. /**
  123580. * Defines the maximum number of lights that can be used in the material
  123581. */
  123582. maxSimultaneousLights: number;
  123583. /**
  123584. * Observable raised when the material is built
  123585. */
  123586. onBuildObservable: Observable<NodeMaterial>;
  123587. /**
  123588. * Gets or sets the root nodes of the material vertex shader
  123589. */
  123590. _vertexOutputNodes: NodeMaterialBlock[];
  123591. /**
  123592. * Gets or sets the root nodes of the material fragment (pixel) shader
  123593. */
  123594. _fragmentOutputNodes: NodeMaterialBlock[];
  123595. /** Gets or sets options to control the node material overall behavior */
  123596. options: INodeMaterialOptions;
  123597. /**
  123598. * Default configuration related to image processing available in the standard Material.
  123599. */
  123600. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123601. /**
  123602. * Gets the image processing configuration used either in this material.
  123603. */
  123604. /**
  123605. * Sets the Default image processing configuration used either in the this material.
  123606. *
  123607. * If sets to null, the scene one is in use.
  123608. */
  123609. imageProcessingConfiguration: ImageProcessingConfiguration;
  123610. /**
  123611. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  123612. */
  123613. attachedBlocks: NodeMaterialBlock[];
  123614. /**
  123615. * Create a new node based material
  123616. * @param name defines the material name
  123617. * @param scene defines the hosting scene
  123618. * @param options defines creation option
  123619. */
  123620. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  123621. /**
  123622. * Gets the current class name of the material e.g. "NodeMaterial"
  123623. * @returns the class name
  123624. */
  123625. getClassName(): string;
  123626. /**
  123627. * Keep track of the image processing observer to allow dispose and replace.
  123628. */
  123629. private _imageProcessingObserver;
  123630. /**
  123631. * Attaches a new image processing configuration to the Standard Material.
  123632. * @param configuration
  123633. */
  123634. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123635. /**
  123636. * Get a block by its name
  123637. * @param name defines the name of the block to retrieve
  123638. * @returns the required block or null if not found
  123639. */
  123640. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  123641. /**
  123642. * Get a block by its name
  123643. * @param predicate defines the predicate used to find the good candidate
  123644. * @returns the required block or null if not found
  123645. */
  123646. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  123647. /**
  123648. * Get an input block by its name
  123649. * @param predicate defines the predicate used to find the good candidate
  123650. * @returns the required input block or null if not found
  123651. */
  123652. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  123653. /**
  123654. * Gets the list of input blocks attached to this material
  123655. * @returns an array of InputBlocks
  123656. */
  123657. getInputBlocks(): InputBlock[];
  123658. /**
  123659. * Adds a new optimizer to the list of optimizers
  123660. * @param optimizer defines the optimizers to add
  123661. * @returns the current material
  123662. */
  123663. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123664. /**
  123665. * Remove an optimizer from the list of optimizers
  123666. * @param optimizer defines the optimizers to remove
  123667. * @returns the current material
  123668. */
  123669. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  123670. /**
  123671. * Add a new block to the list of output nodes
  123672. * @param node defines the node to add
  123673. * @returns the current material
  123674. */
  123675. addOutputNode(node: NodeMaterialBlock): this;
  123676. /**
  123677. * Remove a block from the list of root nodes
  123678. * @param node defines the node to remove
  123679. * @returns the current material
  123680. */
  123681. removeOutputNode(node: NodeMaterialBlock): this;
  123682. private _addVertexOutputNode;
  123683. private _removeVertexOutputNode;
  123684. private _addFragmentOutputNode;
  123685. private _removeFragmentOutputNode;
  123686. /**
  123687. * Specifies if the material will require alpha blending
  123688. * @returns a boolean specifying if alpha blending is needed
  123689. */
  123690. needAlphaBlending(): boolean;
  123691. /**
  123692. * Specifies if this material should be rendered in alpha test mode
  123693. * @returns a boolean specifying if an alpha test is needed.
  123694. */
  123695. needAlphaTesting(): boolean;
  123696. private _initializeBlock;
  123697. private _resetDualBlocks;
  123698. /**
  123699. * Remove a block from the current node material
  123700. * @param block defines the block to remove
  123701. */
  123702. removeBlock(block: NodeMaterialBlock): void;
  123703. /**
  123704. * Build the material and generates the inner effect
  123705. * @param verbose defines if the build should log activity
  123706. */
  123707. build(verbose?: boolean): void;
  123708. /**
  123709. * Runs an otpimization phase to try to improve the shader code
  123710. */
  123711. optimize(): void;
  123712. private _prepareDefinesForAttributes;
  123713. /**
  123714. * Get if the submesh is ready to be used and all its information available.
  123715. * Child classes can use it to update shaders
  123716. * @param mesh defines the mesh to check
  123717. * @param subMesh defines which submesh to check
  123718. * @param useInstances specifies that instances should be used
  123719. * @returns a boolean indicating that the submesh is ready or not
  123720. */
  123721. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  123722. /**
  123723. * Get a string representing the shaders built by the current node graph
  123724. */
  123725. readonly compiledShaders: string;
  123726. /**
  123727. * Binds the world matrix to the material
  123728. * @param world defines the world transformation matrix
  123729. */
  123730. bindOnlyWorldMatrix(world: Matrix): void;
  123731. /**
  123732. * Binds the submesh to this material by preparing the effect and shader to draw
  123733. * @param world defines the world transformation matrix
  123734. * @param mesh defines the mesh containing the submesh
  123735. * @param subMesh defines the submesh to bind the material to
  123736. */
  123737. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  123738. /**
  123739. * Gets the active textures from the material
  123740. * @returns an array of textures
  123741. */
  123742. getActiveTextures(): BaseTexture[];
  123743. /**
  123744. * Gets the list of texture blocks
  123745. * @returns an array of texture blocks
  123746. */
  123747. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  123748. /**
  123749. * Specifies if the material uses a texture
  123750. * @param texture defines the texture to check against the material
  123751. * @returns a boolean specifying if the material uses the texture
  123752. */
  123753. hasTexture(texture: BaseTexture): boolean;
  123754. /**
  123755. * Disposes the material
  123756. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  123757. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  123758. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  123759. */
  123760. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  123761. /** Creates the node editor window. */
  123762. private _createNodeEditor;
  123763. /**
  123764. * Launch the node material editor
  123765. * @param config Define the configuration of the editor
  123766. * @return a promise fulfilled when the node editor is visible
  123767. */
  123768. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  123769. /**
  123770. * Clear the current material
  123771. */
  123772. clear(): void;
  123773. /**
  123774. * Clear the current material and set it to a default state
  123775. */
  123776. setToDefault(): void;
  123777. /**
  123778. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  123779. * @param url defines the url to load from
  123780. * @returns a promise that will fullfil when the material is fully loaded
  123781. */
  123782. loadAsync(url: string): Promise<void>;
  123783. private _gatherBlocks;
  123784. /**
  123785. * Generate a string containing the code declaration required to create an equivalent of this material
  123786. * @returns a string
  123787. */
  123788. generateCode(): string;
  123789. /**
  123790. * Serializes this material in a JSON representation
  123791. * @returns the serialized material object
  123792. */
  123793. serialize(): any;
  123794. private _restoreConnections;
  123795. /**
  123796. * Clear the current graph and load a new one from a serialization object
  123797. * @param source defines the JSON representation of the material
  123798. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123799. */
  123800. loadFromSerialization(source: any, rootUrl?: string): void;
  123801. /**
  123802. * Creates a node material from parsed material data
  123803. * @param source defines the JSON representation of the material
  123804. * @param scene defines the hosting scene
  123805. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  123806. * @returns a new node material
  123807. */
  123808. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  123809. /**
  123810. * Creates a new node material set to default basic configuration
  123811. * @param name defines the name of the material
  123812. * @param scene defines the hosting scene
  123813. * @returns a new NodeMaterial
  123814. */
  123815. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  123816. }
  123817. }
  123818. declare module BABYLON {
  123819. /**
  123820. * Block used to read a texture from a sampler
  123821. */
  123822. export class TextureBlock extends NodeMaterialBlock {
  123823. private _defineName;
  123824. private _linearDefineName;
  123825. private _tempTextureRead;
  123826. private _samplerName;
  123827. private _transformedUVName;
  123828. private _textureTransformName;
  123829. private _textureInfoName;
  123830. private _mainUVName;
  123831. private _mainUVDefineName;
  123832. /**
  123833. * Gets or sets the texture associated with the node
  123834. */
  123835. texture: Nullable<Texture>;
  123836. /**
  123837. * Create a new TextureBlock
  123838. * @param name defines the block name
  123839. */
  123840. constructor(name: string);
  123841. /**
  123842. * Gets the current class name
  123843. * @returns the class name
  123844. */
  123845. getClassName(): string;
  123846. /**
  123847. * Gets the uv input component
  123848. */
  123849. readonly uv: NodeMaterialConnectionPoint;
  123850. /**
  123851. * Gets the rgba output component
  123852. */
  123853. readonly rgba: NodeMaterialConnectionPoint;
  123854. /**
  123855. * Gets the rgb output component
  123856. */
  123857. readonly rgb: NodeMaterialConnectionPoint;
  123858. /**
  123859. * Gets the r output component
  123860. */
  123861. readonly r: NodeMaterialConnectionPoint;
  123862. /**
  123863. * Gets the g output component
  123864. */
  123865. readonly g: NodeMaterialConnectionPoint;
  123866. /**
  123867. * Gets the b output component
  123868. */
  123869. readonly b: NodeMaterialConnectionPoint;
  123870. /**
  123871. * Gets the a output component
  123872. */
  123873. readonly a: NodeMaterialConnectionPoint;
  123874. readonly target: NodeMaterialBlockTargets;
  123875. autoConfigure(material: NodeMaterial): void;
  123876. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123878. private _getTextureBase;
  123879. isReady(): boolean;
  123880. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123881. private readonly _isMixed;
  123882. private _injectVertexCode;
  123883. private _writeTextureRead;
  123884. private _writeOutput;
  123885. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123886. protected _dumpPropertiesCode(): string;
  123887. serialize(): any;
  123888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123889. }
  123890. }
  123891. declare module BABYLON {
  123892. /**
  123893. * Class used to store shared data between 2 NodeMaterialBuildState
  123894. */
  123895. export class NodeMaterialBuildStateSharedData {
  123896. /**
  123897. * Gets the list of emitted varyings
  123898. */
  123899. temps: string[];
  123900. /**
  123901. * Gets the list of emitted varyings
  123902. */
  123903. varyings: string[];
  123904. /**
  123905. * Gets the varying declaration string
  123906. */
  123907. varyingDeclaration: string;
  123908. /**
  123909. * Input blocks
  123910. */
  123911. inputBlocks: InputBlock[];
  123912. /**
  123913. * Input blocks
  123914. */
  123915. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  123916. /**
  123917. * Bindable blocks (Blocks that need to set data to the effect)
  123918. */
  123919. bindableBlocks: NodeMaterialBlock[];
  123920. /**
  123921. * List of blocks that can provide a compilation fallback
  123922. */
  123923. blocksWithFallbacks: NodeMaterialBlock[];
  123924. /**
  123925. * List of blocks that can provide a define update
  123926. */
  123927. blocksWithDefines: NodeMaterialBlock[];
  123928. /**
  123929. * List of blocks that can provide a repeatable content
  123930. */
  123931. repeatableContentBlocks: NodeMaterialBlock[];
  123932. /**
  123933. * List of blocks that can provide a dynamic list of uniforms
  123934. */
  123935. dynamicUniformBlocks: NodeMaterialBlock[];
  123936. /**
  123937. * List of blocks that can block the isReady function for the material
  123938. */
  123939. blockingBlocks: NodeMaterialBlock[];
  123940. /**
  123941. * Gets the list of animated inputs
  123942. */
  123943. animatedInputs: InputBlock[];
  123944. /**
  123945. * Build Id used to avoid multiple recompilations
  123946. */
  123947. buildId: number;
  123948. /** List of emitted variables */
  123949. variableNames: {
  123950. [key: string]: number;
  123951. };
  123952. /** List of emitted defines */
  123953. defineNames: {
  123954. [key: string]: number;
  123955. };
  123956. /** Should emit comments? */
  123957. emitComments: boolean;
  123958. /** Emit build activity */
  123959. verbose: boolean;
  123960. /** Gets or sets the hosting scene */
  123961. scene: Scene;
  123962. /**
  123963. * Gets the compilation hints emitted at compilation time
  123964. */
  123965. hints: {
  123966. needWorldViewMatrix: boolean;
  123967. needWorldViewProjectionMatrix: boolean;
  123968. needAlphaBlending: boolean;
  123969. needAlphaTesting: boolean;
  123970. };
  123971. /**
  123972. * List of compilation checks
  123973. */
  123974. checks: {
  123975. emitVertex: boolean;
  123976. emitFragment: boolean;
  123977. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  123978. };
  123979. /** Creates a new shared data */
  123980. constructor();
  123981. /**
  123982. * Emits console errors and exceptions if there is a failing check
  123983. */
  123984. emitErrors(): void;
  123985. }
  123986. }
  123987. declare module BABYLON {
  123988. /**
  123989. * Class used to store node based material build state
  123990. */
  123991. export class NodeMaterialBuildState {
  123992. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  123993. supportUniformBuffers: boolean;
  123994. /**
  123995. * Gets the list of emitted attributes
  123996. */
  123997. attributes: string[];
  123998. /**
  123999. * Gets the list of emitted uniforms
  124000. */
  124001. uniforms: string[];
  124002. /**
  124003. * Gets the list of emitted constants
  124004. */
  124005. constants: string[];
  124006. /**
  124007. * Gets the list of emitted samplers
  124008. */
  124009. samplers: string[];
  124010. /**
  124011. * Gets the list of emitted functions
  124012. */
  124013. functions: {
  124014. [key: string]: string;
  124015. };
  124016. /**
  124017. * Gets the list of emitted extensions
  124018. */
  124019. extensions: {
  124020. [key: string]: string;
  124021. };
  124022. /**
  124023. * Gets the target of the compilation state
  124024. */
  124025. target: NodeMaterialBlockTargets;
  124026. /**
  124027. * Gets the list of emitted counters
  124028. */
  124029. counters: {
  124030. [key: string]: number;
  124031. };
  124032. /**
  124033. * Shared data between multiple NodeMaterialBuildState instances
  124034. */
  124035. sharedData: NodeMaterialBuildStateSharedData;
  124036. /** @hidden */
  124037. _vertexState: NodeMaterialBuildState;
  124038. /** @hidden */
  124039. _attributeDeclaration: string;
  124040. /** @hidden */
  124041. _uniformDeclaration: string;
  124042. /** @hidden */
  124043. _constantDeclaration: string;
  124044. /** @hidden */
  124045. _samplerDeclaration: string;
  124046. /** @hidden */
  124047. _varyingTransfer: string;
  124048. private _repeatableContentAnchorIndex;
  124049. /** @hidden */
  124050. _builtCompilationString: string;
  124051. /**
  124052. * Gets the emitted compilation strings
  124053. */
  124054. compilationString: string;
  124055. /**
  124056. * Finalize the compilation strings
  124057. * @param state defines the current compilation state
  124058. */
  124059. finalize(state: NodeMaterialBuildState): void;
  124060. /** @hidden */
  124061. readonly _repeatableContentAnchor: string;
  124062. /** @hidden */
  124063. _getFreeVariableName(prefix: string): string;
  124064. /** @hidden */
  124065. _getFreeDefineName(prefix: string): string;
  124066. /** @hidden */
  124067. _excludeVariableName(name: string): void;
  124068. /** @hidden */
  124069. _emit2DSampler(name: string): void;
  124070. /** @hidden */
  124071. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  124072. /** @hidden */
  124073. _emitExtension(name: string, extension: string): void;
  124074. /** @hidden */
  124075. _emitFunction(name: string, code: string, comments: string): void;
  124076. /** @hidden */
  124077. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  124078. replaceStrings?: {
  124079. search: RegExp;
  124080. replace: string;
  124081. }[];
  124082. repeatKey?: string;
  124083. }): string;
  124084. /** @hidden */
  124085. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  124086. repeatKey?: string;
  124087. removeAttributes?: boolean;
  124088. removeUniforms?: boolean;
  124089. removeVaryings?: boolean;
  124090. removeIfDef?: boolean;
  124091. replaceStrings?: {
  124092. search: RegExp;
  124093. replace: string;
  124094. }[];
  124095. }, storeKey?: string): void;
  124096. /** @hidden */
  124097. _registerTempVariable(name: string): boolean;
  124098. /** @hidden */
  124099. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  124100. /** @hidden */
  124101. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  124102. /** @hidden */
  124103. _emitFloat(value: number): string;
  124104. }
  124105. }
  124106. declare module BABYLON {
  124107. /**
  124108. * Defines a block that can be used inside a node based material
  124109. */
  124110. export class NodeMaterialBlock {
  124111. private _buildId;
  124112. private _buildTarget;
  124113. private _target;
  124114. private _isFinalMerger;
  124115. private _isInput;
  124116. protected _isUnique: boolean;
  124117. /** @hidden */
  124118. _codeVariableName: string;
  124119. /** @hidden */
  124120. _inputs: NodeMaterialConnectionPoint[];
  124121. /** @hidden */
  124122. _outputs: NodeMaterialConnectionPoint[];
  124123. /** @hidden */
  124124. _preparationId: number;
  124125. /**
  124126. * Gets or sets the name of the block
  124127. */
  124128. name: string;
  124129. /**
  124130. * Gets or sets the unique id of the node
  124131. */
  124132. uniqueId: number;
  124133. /**
  124134. * Gets or sets the comments associated with this block
  124135. */
  124136. comments: string;
  124137. /**
  124138. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  124139. */
  124140. readonly isUnique: boolean;
  124141. /**
  124142. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  124143. */
  124144. readonly isFinalMerger: boolean;
  124145. /**
  124146. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  124147. */
  124148. readonly isInput: boolean;
  124149. /**
  124150. * Gets or sets the build Id
  124151. */
  124152. buildId: number;
  124153. /**
  124154. * Gets or sets the target of the block
  124155. */
  124156. target: NodeMaterialBlockTargets;
  124157. /**
  124158. * Gets the list of input points
  124159. */
  124160. readonly inputs: NodeMaterialConnectionPoint[];
  124161. /** Gets the list of output points */
  124162. readonly outputs: NodeMaterialConnectionPoint[];
  124163. /**
  124164. * Find an input by its name
  124165. * @param name defines the name of the input to look for
  124166. * @returns the input or null if not found
  124167. */
  124168. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  124169. /**
  124170. * Find an output by its name
  124171. * @param name defines the name of the outputto look for
  124172. * @returns the output or null if not found
  124173. */
  124174. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  124175. /**
  124176. * Creates a new NodeMaterialBlock
  124177. * @param name defines the block name
  124178. * @param target defines the target of that block (Vertex by default)
  124179. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  124180. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  124181. */
  124182. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  124183. /**
  124184. * Initialize the block and prepare the context for build
  124185. * @param state defines the state that will be used for the build
  124186. */
  124187. initialize(state: NodeMaterialBuildState): void;
  124188. /**
  124189. * Bind data to effect. Will only be called for blocks with isBindable === true
  124190. * @param effect defines the effect to bind data to
  124191. * @param nodeMaterial defines the hosting NodeMaterial
  124192. * @param mesh defines the mesh that will be rendered
  124193. */
  124194. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124195. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  124196. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  124197. protected _writeFloat(value: number): string;
  124198. /**
  124199. * Gets the current class name e.g. "NodeMaterialBlock"
  124200. * @returns the class name
  124201. */
  124202. getClassName(): string;
  124203. /**
  124204. * Register a new input. Must be called inside a block constructor
  124205. * @param name defines the connection point name
  124206. * @param type defines the connection point type
  124207. * @param isOptional defines a boolean indicating that this input can be omitted
  124208. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  124209. * @returns the current block
  124210. */
  124211. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  124212. /**
  124213. * Register a new output. Must be called inside a block constructor
  124214. * @param name defines the connection point name
  124215. * @param type defines the connection point type
  124216. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  124217. * @returns the current block
  124218. */
  124219. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  124220. /**
  124221. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  124222. * @param forOutput defines an optional connection point to check compatibility with
  124223. * @returns the first available input or null
  124224. */
  124225. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  124226. /**
  124227. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  124228. * @param forBlock defines an optional block to check compatibility with
  124229. * @returns the first available input or null
  124230. */
  124231. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  124232. /**
  124233. * Gets the sibling of the given output
  124234. * @param current defines the current output
  124235. * @returns the next output in the list or null
  124236. */
  124237. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  124238. /**
  124239. * Connect current block with another block
  124240. * @param other defines the block to connect with
  124241. * @param options define the various options to help pick the right connections
  124242. * @returns the current block
  124243. */
  124244. connectTo(other: NodeMaterialBlock, options?: {
  124245. input?: string;
  124246. output?: string;
  124247. outputSwizzle?: string;
  124248. }): this | undefined;
  124249. protected _buildBlock(state: NodeMaterialBuildState): void;
  124250. /**
  124251. * Add uniforms, samplers and uniform buffers at compilation time
  124252. * @param state defines the state to update
  124253. * @param nodeMaterial defines the node material requesting the update
  124254. * @param defines defines the material defines to update
  124255. * @param uniformBuffers defines the list of uniform buffer names
  124256. */
  124257. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  124258. /**
  124259. * Add potential fallbacks if shader compilation fails
  124260. * @param mesh defines the mesh to be rendered
  124261. * @param fallbacks defines the current prioritized list of fallbacks
  124262. */
  124263. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124264. /**
  124265. * Initialize defines for shader compilation
  124266. * @param mesh defines the mesh to be rendered
  124267. * @param nodeMaterial defines the node material requesting the update
  124268. * @param defines defines the material defines to update
  124269. * @param useInstances specifies that instances should be used
  124270. */
  124271. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124272. /**
  124273. * Update defines for shader compilation
  124274. * @param mesh defines the mesh to be rendered
  124275. * @param nodeMaterial defines the node material requesting the update
  124276. * @param defines defines the material defines to update
  124277. * @param useInstances specifies that instances should be used
  124278. */
  124279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124280. /**
  124281. * Lets the block try to connect some inputs automatically
  124282. * @param material defines the hosting NodeMaterial
  124283. */
  124284. autoConfigure(material: NodeMaterial): void;
  124285. /**
  124286. * Function called when a block is declared as repeatable content generator
  124287. * @param vertexShaderState defines the current compilation state for the vertex shader
  124288. * @param fragmentShaderState defines the current compilation state for the fragment shader
  124289. * @param mesh defines the mesh to be rendered
  124290. * @param defines defines the material defines to update
  124291. */
  124292. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124293. /**
  124294. * Checks if the block is ready
  124295. * @param mesh defines the mesh to be rendered
  124296. * @param nodeMaterial defines the node material requesting the update
  124297. * @param defines defines the material defines to update
  124298. * @param useInstances specifies that instances should be used
  124299. * @returns true if the block is ready
  124300. */
  124301. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  124302. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  124303. private _processBuild;
  124304. /**
  124305. * Compile the current node and generate the shader code
  124306. * @param state defines the current compilation state (uniforms, samplers, current string)
  124307. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  124308. * @returns true if already built
  124309. */
  124310. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  124311. protected _inputRename(name: string): string;
  124312. protected _outputRename(name: string): string;
  124313. protected _dumpPropertiesCode(): string;
  124314. /** @hidden */
  124315. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  124316. /** @hidden */
  124317. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  124318. /**
  124319. * Clone the current block to a new identical block
  124320. * @param scene defines the hosting scene
  124321. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  124322. * @returns a copy of the current block
  124323. */
  124324. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  124325. /**
  124326. * Serializes this block in a JSON representation
  124327. * @returns the serialized block object
  124328. */
  124329. serialize(): any;
  124330. /** @hidden */
  124331. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124332. /**
  124333. * Release resources
  124334. */
  124335. dispose(): void;
  124336. }
  124337. }
  124338. declare module BABYLON {
  124339. /**
  124340. * Enum defining the type of animations supported by InputBlock
  124341. */
  124342. export enum AnimatedInputBlockTypes {
  124343. /** No animation */
  124344. None = 0,
  124345. /** Time based animation. Will only work for floats */
  124346. Time = 1
  124347. }
  124348. }
  124349. declare module BABYLON {
  124350. /**
  124351. * Block used to expose an input value
  124352. */
  124353. export class InputBlock extends NodeMaterialBlock {
  124354. private _mode;
  124355. private _associatedVariableName;
  124356. private _storedValue;
  124357. private _valueCallback;
  124358. private _type;
  124359. private _animationType;
  124360. /** Gets or set a value used to limit the range of float values */
  124361. min: number;
  124362. /** Gets or set a value used to limit the range of float values */
  124363. max: number;
  124364. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  124365. matrixMode: number;
  124366. /** @hidden */
  124367. _systemValue: Nullable<NodeMaterialSystemValues>;
  124368. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  124369. visibleInInspector: boolean;
  124370. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  124371. isConstant: boolean;
  124372. /** Gets or sets the group to use to display this block in the Inspector */
  124373. groupInInspector: string;
  124374. /**
  124375. * Gets or sets the connection point type (default is float)
  124376. */
  124377. readonly type: NodeMaterialBlockConnectionPointTypes;
  124378. /**
  124379. * Creates a new InputBlock
  124380. * @param name defines the block name
  124381. * @param target defines the target of that block (Vertex by default)
  124382. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  124383. */
  124384. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  124385. /**
  124386. * Gets the output component
  124387. */
  124388. readonly output: NodeMaterialConnectionPoint;
  124389. /**
  124390. * Set the source of this connection point to a vertex attribute
  124391. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  124392. * @returns the current connection point
  124393. */
  124394. setAsAttribute(attributeName?: string): InputBlock;
  124395. /**
  124396. * Set the source of this connection point to a system value
  124397. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  124398. * @returns the current connection point
  124399. */
  124400. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  124401. /**
  124402. * Gets or sets the value of that point.
  124403. * Please note that this value will be ignored if valueCallback is defined
  124404. */
  124405. value: any;
  124406. /**
  124407. * Gets or sets a callback used to get the value of that point.
  124408. * Please note that setting this value will force the connection point to ignore the value property
  124409. */
  124410. valueCallback: () => any;
  124411. /**
  124412. * Gets or sets the associated variable name in the shader
  124413. */
  124414. associatedVariableName: string;
  124415. /** Gets or sets the type of animation applied to the input */
  124416. animationType: AnimatedInputBlockTypes;
  124417. /**
  124418. * Gets a boolean indicating that this connection point not defined yet
  124419. */
  124420. readonly isUndefined: boolean;
  124421. /**
  124422. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  124423. * In this case the connection point name must be the name of the uniform to use.
  124424. * Can only be set on inputs
  124425. */
  124426. isUniform: boolean;
  124427. /**
  124428. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  124429. * In this case the connection point name must be the name of the attribute to use
  124430. * Can only be set on inputs
  124431. */
  124432. isAttribute: boolean;
  124433. /**
  124434. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  124435. * Can only be set on exit points
  124436. */
  124437. isVarying: boolean;
  124438. /**
  124439. * Gets a boolean indicating that the current connection point is a system value
  124440. */
  124441. readonly isSystemValue: boolean;
  124442. /**
  124443. * Gets or sets the current well known value or null if not defined as a system value
  124444. */
  124445. systemValue: Nullable<NodeMaterialSystemValues>;
  124446. /**
  124447. * Gets the current class name
  124448. * @returns the class name
  124449. */
  124450. getClassName(): string;
  124451. /**
  124452. * Animate the input if animationType !== None
  124453. * @param scene defines the rendering scene
  124454. */
  124455. animate(scene: Scene): void;
  124456. private _emitDefine;
  124457. initialize(state: NodeMaterialBuildState): void;
  124458. /**
  124459. * Set the input block to its default value (based on its type)
  124460. */
  124461. setDefaultValue(): void;
  124462. private _emitConstant;
  124463. private _emit;
  124464. /** @hidden */
  124465. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  124466. /** @hidden */
  124467. _transmit(effect: Effect, scene: Scene): void;
  124468. protected _buildBlock(state: NodeMaterialBuildState): void;
  124469. protected _dumpPropertiesCode(): string;
  124470. serialize(): any;
  124471. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124472. }
  124473. }
  124474. declare module BABYLON {
  124475. /**
  124476. * Enum used to define the compatibility state between two connection points
  124477. */
  124478. export enum NodeMaterialConnectionPointCompatibilityStates {
  124479. /** Points are compatibles */
  124480. Compatible = 0,
  124481. /** Points are incompatible because of their types */
  124482. TypeIncompatible = 1,
  124483. /** Points are incompatible because of their targets (vertex vs fragment) */
  124484. TargetIncompatible = 2
  124485. }
  124486. /**
  124487. * Defines the direction of a connection point
  124488. */
  124489. export enum NodeMaterialConnectionPointDirection {
  124490. /** Input */
  124491. Input = 0,
  124492. /** Output */
  124493. Output = 1
  124494. }
  124495. /**
  124496. * Defines a connection point for a block
  124497. */
  124498. export class NodeMaterialConnectionPoint {
  124499. /** @hidden */
  124500. _ownerBlock: NodeMaterialBlock;
  124501. /** @hidden */
  124502. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124503. private _endpoints;
  124504. private _associatedVariableName;
  124505. private _direction;
  124506. /** @hidden */
  124507. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  124508. /** @hidden */
  124509. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  124510. private _type;
  124511. /** @hidden */
  124512. _enforceAssociatedVariableName: boolean;
  124513. /** Gets the direction of the point */
  124514. readonly direction: NodeMaterialConnectionPointDirection;
  124515. /**
  124516. * Gets or sets the additional types supported by this connection point
  124517. */
  124518. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  124519. /**
  124520. * Gets or sets the additional types excluded by this connection point
  124521. */
  124522. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  124523. /**
  124524. * Observable triggered when this point is connected
  124525. */
  124526. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  124527. /**
  124528. * Gets or sets the associated variable name in the shader
  124529. */
  124530. associatedVariableName: string;
  124531. /**
  124532. * Gets or sets the connection point type (default is float)
  124533. */
  124534. type: NodeMaterialBlockConnectionPointTypes;
  124535. /**
  124536. * Gets or sets the connection point name
  124537. */
  124538. name: string;
  124539. /**
  124540. * Gets or sets a boolean indicating that this connection point can be omitted
  124541. */
  124542. isOptional: boolean;
  124543. /**
  124544. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  124545. */
  124546. define: string;
  124547. /** @hidden */
  124548. _prioritizeVertex: boolean;
  124549. private _target;
  124550. /** Gets or sets the target of that connection point */
  124551. target: NodeMaterialBlockTargets;
  124552. /**
  124553. * Gets a boolean indicating that the current point is connected
  124554. */
  124555. readonly isConnected: boolean;
  124556. /**
  124557. * Gets a boolean indicating that the current point is connected to an input block
  124558. */
  124559. readonly isConnectedToInputBlock: boolean;
  124560. /**
  124561. * Gets a the connected input block (if any)
  124562. */
  124563. readonly connectInputBlock: Nullable<InputBlock>;
  124564. /** Get the other side of the connection (if any) */
  124565. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  124566. /** Get the block that owns this connection point */
  124567. readonly ownerBlock: NodeMaterialBlock;
  124568. /** Get the block connected on the other side of this connection (if any) */
  124569. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  124570. /** Get the block connected on the endpoints of this connection (if any) */
  124571. readonly connectedBlocks: Array<NodeMaterialBlock>;
  124572. /** Gets the list of connected endpoints */
  124573. readonly endpoints: NodeMaterialConnectionPoint[];
  124574. /** Gets a boolean indicating if that output point is connected to at least one input */
  124575. readonly hasEndpoints: boolean;
  124576. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  124577. readonly isConnectedInVertexShader: boolean;
  124578. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  124579. readonly isConnectedInFragmentShader: boolean;
  124580. /**
  124581. * Creates a new connection point
  124582. * @param name defines the connection point name
  124583. * @param ownerBlock defines the block hosting this connection point
  124584. * @param direction defines the direction of the connection point
  124585. */
  124586. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  124587. /**
  124588. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  124589. * @returns the class name
  124590. */
  124591. getClassName(): string;
  124592. /**
  124593. * Gets a boolean indicating if the current point can be connected to another point
  124594. * @param connectionPoint defines the other connection point
  124595. * @returns a boolean
  124596. */
  124597. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  124598. /**
  124599. * Gets a number indicating if the current point can be connected to another point
  124600. * @param connectionPoint defines the other connection point
  124601. * @returns a number defining the compatibility state
  124602. */
  124603. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  124604. /**
  124605. * Connect this point to another connection point
  124606. * @param connectionPoint defines the other connection point
  124607. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  124608. * @returns the current connection point
  124609. */
  124610. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  124611. /**
  124612. * Disconnect this point from one of his endpoint
  124613. * @param endpoint defines the other connection point
  124614. * @returns the current connection point
  124615. */
  124616. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  124617. /**
  124618. * Serializes this point in a JSON representation
  124619. * @returns the serialized point object
  124620. */
  124621. serialize(): any;
  124622. /**
  124623. * Release resources
  124624. */
  124625. dispose(): void;
  124626. }
  124627. }
  124628. declare module BABYLON {
  124629. /**
  124630. * Block used to add support for vertex skinning (bones)
  124631. */
  124632. export class BonesBlock extends NodeMaterialBlock {
  124633. /**
  124634. * Creates a new BonesBlock
  124635. * @param name defines the block name
  124636. */
  124637. constructor(name: string);
  124638. /**
  124639. * Initialize the block and prepare the context for build
  124640. * @param state defines the state that will be used for the build
  124641. */
  124642. initialize(state: NodeMaterialBuildState): void;
  124643. /**
  124644. * Gets the current class name
  124645. * @returns the class name
  124646. */
  124647. getClassName(): string;
  124648. /**
  124649. * Gets the matrix indices input component
  124650. */
  124651. readonly matricesIndices: NodeMaterialConnectionPoint;
  124652. /**
  124653. * Gets the matrix weights input component
  124654. */
  124655. readonly matricesWeights: NodeMaterialConnectionPoint;
  124656. /**
  124657. * Gets the extra matrix indices input component
  124658. */
  124659. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  124660. /**
  124661. * Gets the extra matrix weights input component
  124662. */
  124663. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  124664. /**
  124665. * Gets the world input component
  124666. */
  124667. readonly world: NodeMaterialConnectionPoint;
  124668. /**
  124669. * Gets the output component
  124670. */
  124671. readonly output: NodeMaterialConnectionPoint;
  124672. autoConfigure(material: NodeMaterial): void;
  124673. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  124674. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124676. protected _buildBlock(state: NodeMaterialBuildState): this;
  124677. }
  124678. }
  124679. declare module BABYLON {
  124680. /**
  124681. * Block used to add support for instances
  124682. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  124683. */
  124684. export class InstancesBlock extends NodeMaterialBlock {
  124685. /**
  124686. * Creates a new InstancesBlock
  124687. * @param name defines the block name
  124688. */
  124689. constructor(name: string);
  124690. /**
  124691. * Gets the current class name
  124692. * @returns the class name
  124693. */
  124694. getClassName(): string;
  124695. /**
  124696. * Gets the first world row input component
  124697. */
  124698. readonly world0: NodeMaterialConnectionPoint;
  124699. /**
  124700. * Gets the second world row input component
  124701. */
  124702. readonly world1: NodeMaterialConnectionPoint;
  124703. /**
  124704. * Gets the third world row input component
  124705. */
  124706. readonly world2: NodeMaterialConnectionPoint;
  124707. /**
  124708. * Gets the forth world row input component
  124709. */
  124710. readonly world3: NodeMaterialConnectionPoint;
  124711. /**
  124712. * Gets the world input component
  124713. */
  124714. readonly world: NodeMaterialConnectionPoint;
  124715. /**
  124716. * Gets the output component
  124717. */
  124718. readonly output: NodeMaterialConnectionPoint;
  124719. autoConfigure(material: NodeMaterial): void;
  124720. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  124721. protected _buildBlock(state: NodeMaterialBuildState): this;
  124722. }
  124723. }
  124724. declare module BABYLON {
  124725. /**
  124726. * Block used to add morph targets support to vertex shader
  124727. */
  124728. export class MorphTargetsBlock extends NodeMaterialBlock {
  124729. private _repeatableContentAnchor;
  124730. private _repeatebleContentGenerated;
  124731. /**
  124732. * Create a new MorphTargetsBlock
  124733. * @param name defines the block name
  124734. */
  124735. constructor(name: string);
  124736. /**
  124737. * Gets the current class name
  124738. * @returns the class name
  124739. */
  124740. getClassName(): string;
  124741. /**
  124742. * Gets the position input component
  124743. */
  124744. readonly position: NodeMaterialConnectionPoint;
  124745. /**
  124746. * Gets the normal input component
  124747. */
  124748. readonly normal: NodeMaterialConnectionPoint;
  124749. /**
  124750. * Gets the tangent input component
  124751. */
  124752. readonly tangent: NodeMaterialConnectionPoint;
  124753. /**
  124754. * Gets the tangent input component
  124755. */
  124756. readonly uv: NodeMaterialConnectionPoint;
  124757. /**
  124758. * Gets the position output component
  124759. */
  124760. readonly positionOutput: NodeMaterialConnectionPoint;
  124761. /**
  124762. * Gets the normal output component
  124763. */
  124764. readonly normalOutput: NodeMaterialConnectionPoint;
  124765. /**
  124766. * Gets the tangent output component
  124767. */
  124768. readonly tangentOutput: NodeMaterialConnectionPoint;
  124769. /**
  124770. * Gets the tangent output component
  124771. */
  124772. readonly uvOutput: NodeMaterialConnectionPoint;
  124773. initialize(state: NodeMaterialBuildState): void;
  124774. autoConfigure(material: NodeMaterial): void;
  124775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124777. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  124778. protected _buildBlock(state: NodeMaterialBuildState): this;
  124779. }
  124780. }
  124781. declare module BABYLON {
  124782. /**
  124783. * Block used to get data information from a light
  124784. */
  124785. export class LightInformationBlock extends NodeMaterialBlock {
  124786. private _lightDataUniformName;
  124787. private _lightColorUniformName;
  124788. private _lightTypeDefineName;
  124789. /**
  124790. * Gets or sets the light associated with this block
  124791. */
  124792. light: Nullable<Light>;
  124793. /**
  124794. * Creates a new LightInformationBlock
  124795. * @param name defines the block name
  124796. */
  124797. constructor(name: string);
  124798. /**
  124799. * Gets the current class name
  124800. * @returns the class name
  124801. */
  124802. getClassName(): string;
  124803. /**
  124804. * Gets the world position input component
  124805. */
  124806. readonly worldPosition: NodeMaterialConnectionPoint;
  124807. /**
  124808. * Gets the direction output component
  124809. */
  124810. readonly direction: NodeMaterialConnectionPoint;
  124811. /**
  124812. * Gets the direction output component
  124813. */
  124814. readonly color: NodeMaterialConnectionPoint;
  124815. /**
  124816. * Gets the direction output component
  124817. */
  124818. readonly intensity: NodeMaterialConnectionPoint;
  124819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124821. protected _buildBlock(state: NodeMaterialBuildState): this;
  124822. serialize(): any;
  124823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124824. }
  124825. }
  124826. declare module BABYLON {
  124827. /**
  124828. * Block used to add image processing support to fragment shader
  124829. */
  124830. export class ImageProcessingBlock extends NodeMaterialBlock {
  124831. /**
  124832. * Create a new ImageProcessingBlock
  124833. * @param name defines the block name
  124834. */
  124835. constructor(name: string);
  124836. /**
  124837. * Gets the current class name
  124838. * @returns the class name
  124839. */
  124840. getClassName(): string;
  124841. /**
  124842. * Gets the color input component
  124843. */
  124844. readonly color: NodeMaterialConnectionPoint;
  124845. /**
  124846. * Gets the output component
  124847. */
  124848. readonly output: NodeMaterialConnectionPoint;
  124849. /**
  124850. * Initialize the block and prepare the context for build
  124851. * @param state defines the state that will be used for the build
  124852. */
  124853. initialize(state: NodeMaterialBuildState): void;
  124854. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  124855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124857. protected _buildBlock(state: NodeMaterialBuildState): this;
  124858. }
  124859. }
  124860. declare module BABYLON {
  124861. /**
  124862. * Block used to pertub normals based on a normal map
  124863. */
  124864. export class PerturbNormalBlock extends NodeMaterialBlock {
  124865. private _tangentSpaceParameterName;
  124866. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124867. invertX: boolean;
  124868. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  124869. invertY: boolean;
  124870. /**
  124871. * Create a new PerturbNormalBlock
  124872. * @param name defines the block name
  124873. */
  124874. constructor(name: string);
  124875. /**
  124876. * Gets the current class name
  124877. * @returns the class name
  124878. */
  124879. getClassName(): string;
  124880. /**
  124881. * Gets the world position input component
  124882. */
  124883. readonly worldPosition: NodeMaterialConnectionPoint;
  124884. /**
  124885. * Gets the world normal input component
  124886. */
  124887. readonly worldNormal: NodeMaterialConnectionPoint;
  124888. /**
  124889. * Gets the uv input component
  124890. */
  124891. readonly uv: NodeMaterialConnectionPoint;
  124892. /**
  124893. * Gets the normal map color input component
  124894. */
  124895. readonly normalMapColor: NodeMaterialConnectionPoint;
  124896. /**
  124897. * Gets the strength input component
  124898. */
  124899. readonly strength: NodeMaterialConnectionPoint;
  124900. /**
  124901. * Gets the output component
  124902. */
  124903. readonly output: NodeMaterialConnectionPoint;
  124904. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  124905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  124906. autoConfigure(material: NodeMaterial): void;
  124907. protected _buildBlock(state: NodeMaterialBuildState): this;
  124908. protected _dumpPropertiesCode(): string;
  124909. serialize(): any;
  124910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124911. }
  124912. }
  124913. declare module BABYLON {
  124914. /**
  124915. * Block used to discard a pixel if a value is smaller than a cutoff
  124916. */
  124917. export class DiscardBlock extends NodeMaterialBlock {
  124918. /**
  124919. * Create a new DiscardBlock
  124920. * @param name defines the block name
  124921. */
  124922. constructor(name: string);
  124923. /**
  124924. * Gets the current class name
  124925. * @returns the class name
  124926. */
  124927. getClassName(): string;
  124928. /**
  124929. * Gets the color input component
  124930. */
  124931. readonly value: NodeMaterialConnectionPoint;
  124932. /**
  124933. * Gets the cutoff input component
  124934. */
  124935. readonly cutoff: NodeMaterialConnectionPoint;
  124936. protected _buildBlock(state: NodeMaterialBuildState): this;
  124937. }
  124938. }
  124939. declare module BABYLON {
  124940. /**
  124941. * Block used to test if the fragment shader is front facing
  124942. */
  124943. export class FrontFacingBlock extends NodeMaterialBlock {
  124944. /**
  124945. * Creates a new FrontFacingBlock
  124946. * @param name defines the block name
  124947. */
  124948. constructor(name: string);
  124949. /**
  124950. * Gets the current class name
  124951. * @returns the class name
  124952. */
  124953. getClassName(): string;
  124954. /**
  124955. * Gets the output component
  124956. */
  124957. readonly output: NodeMaterialConnectionPoint;
  124958. protected _buildBlock(state: NodeMaterialBuildState): this;
  124959. }
  124960. }
  124961. declare module BABYLON {
  124962. /**
  124963. * Block used to get the derivative value on x and y of a given input
  124964. */
  124965. export class DerivativeBlock extends NodeMaterialBlock {
  124966. /**
  124967. * Create a new DerivativeBlock
  124968. * @param name defines the block name
  124969. */
  124970. constructor(name: string);
  124971. /**
  124972. * Gets the current class name
  124973. * @returns the class name
  124974. */
  124975. getClassName(): string;
  124976. /**
  124977. * Gets the input component
  124978. */
  124979. readonly input: NodeMaterialConnectionPoint;
  124980. /**
  124981. * Gets the derivative output on x
  124982. */
  124983. readonly dx: NodeMaterialConnectionPoint;
  124984. /**
  124985. * Gets the derivative output on y
  124986. */
  124987. readonly dy: NodeMaterialConnectionPoint;
  124988. protected _buildBlock(state: NodeMaterialBuildState): this;
  124989. }
  124990. }
  124991. declare module BABYLON {
  124992. /**
  124993. * Block used to add support for scene fog
  124994. */
  124995. export class FogBlock extends NodeMaterialBlock {
  124996. private _fogDistanceName;
  124997. private _fogParameters;
  124998. /**
  124999. * Create a new FogBlock
  125000. * @param name defines the block name
  125001. */
  125002. constructor(name: string);
  125003. /**
  125004. * Gets the current class name
  125005. * @returns the class name
  125006. */
  125007. getClassName(): string;
  125008. /**
  125009. * Gets the world position input component
  125010. */
  125011. readonly worldPosition: NodeMaterialConnectionPoint;
  125012. /**
  125013. * Gets the view input component
  125014. */
  125015. readonly view: NodeMaterialConnectionPoint;
  125016. /**
  125017. * Gets the color input component
  125018. */
  125019. readonly input: NodeMaterialConnectionPoint;
  125020. /**
  125021. * Gets the fog color input component
  125022. */
  125023. readonly fogColor: NodeMaterialConnectionPoint;
  125024. /**
  125025. * Gets the output component
  125026. */
  125027. readonly output: NodeMaterialConnectionPoint;
  125028. autoConfigure(material: NodeMaterial): void;
  125029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125031. protected _buildBlock(state: NodeMaterialBuildState): this;
  125032. }
  125033. }
  125034. declare module BABYLON {
  125035. /**
  125036. * Block used to add light in the fragment shader
  125037. */
  125038. export class LightBlock extends NodeMaterialBlock {
  125039. private _lightId;
  125040. /**
  125041. * Gets or sets the light associated with this block
  125042. */
  125043. light: Nullable<Light>;
  125044. /**
  125045. * Create a new LightBlock
  125046. * @param name defines the block name
  125047. */
  125048. constructor(name: string);
  125049. /**
  125050. * Gets the current class name
  125051. * @returns the class name
  125052. */
  125053. getClassName(): string;
  125054. /**
  125055. * Gets the world position input component
  125056. */
  125057. readonly worldPosition: NodeMaterialConnectionPoint;
  125058. /**
  125059. * Gets the world normal input component
  125060. */
  125061. readonly worldNormal: NodeMaterialConnectionPoint;
  125062. /**
  125063. * Gets the camera (or eye) position component
  125064. */
  125065. readonly cameraPosition: NodeMaterialConnectionPoint;
  125066. /**
  125067. * Gets the glossiness component
  125068. */
  125069. readonly glossiness: NodeMaterialConnectionPoint;
  125070. /**
  125071. * Gets the glossinness power component
  125072. */
  125073. readonly glossPower: NodeMaterialConnectionPoint;
  125074. /**
  125075. * Gets the diffuse color component
  125076. */
  125077. readonly diffuseColor: NodeMaterialConnectionPoint;
  125078. /**
  125079. * Gets the specular color component
  125080. */
  125081. readonly specularColor: NodeMaterialConnectionPoint;
  125082. /**
  125083. * Gets the diffuse output component
  125084. */
  125085. readonly diffuseOutput: NodeMaterialConnectionPoint;
  125086. /**
  125087. * Gets the specular output component
  125088. */
  125089. readonly specularOutput: NodeMaterialConnectionPoint;
  125090. autoConfigure(material: NodeMaterial): void;
  125091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125092. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  125093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125094. private _injectVertexCode;
  125095. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125096. serialize(): any;
  125097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125098. }
  125099. }
  125100. declare module BABYLON {
  125101. /**
  125102. * Block used to multiply 2 values
  125103. */
  125104. export class MultiplyBlock extends NodeMaterialBlock {
  125105. /**
  125106. * Creates a new MultiplyBlock
  125107. * @param name defines the block name
  125108. */
  125109. constructor(name: string);
  125110. /**
  125111. * Gets the current class name
  125112. * @returns the class name
  125113. */
  125114. getClassName(): string;
  125115. /**
  125116. * Gets the left operand input component
  125117. */
  125118. readonly left: NodeMaterialConnectionPoint;
  125119. /**
  125120. * Gets the right operand input component
  125121. */
  125122. readonly right: NodeMaterialConnectionPoint;
  125123. /**
  125124. * Gets the output component
  125125. */
  125126. readonly output: NodeMaterialConnectionPoint;
  125127. protected _buildBlock(state: NodeMaterialBuildState): this;
  125128. }
  125129. }
  125130. declare module BABYLON {
  125131. /**
  125132. * Block used to add 2 vectors
  125133. */
  125134. export class AddBlock extends NodeMaterialBlock {
  125135. /**
  125136. * Creates a new AddBlock
  125137. * @param name defines the block name
  125138. */
  125139. constructor(name: string);
  125140. /**
  125141. * Gets the current class name
  125142. * @returns the class name
  125143. */
  125144. getClassName(): string;
  125145. /**
  125146. * Gets the left operand input component
  125147. */
  125148. readonly left: NodeMaterialConnectionPoint;
  125149. /**
  125150. * Gets the right operand input component
  125151. */
  125152. readonly right: NodeMaterialConnectionPoint;
  125153. /**
  125154. * Gets the output component
  125155. */
  125156. readonly output: NodeMaterialConnectionPoint;
  125157. protected _buildBlock(state: NodeMaterialBuildState): this;
  125158. }
  125159. }
  125160. declare module BABYLON {
  125161. /**
  125162. * Block used to scale a vector by a float
  125163. */
  125164. export class ScaleBlock extends NodeMaterialBlock {
  125165. /**
  125166. * Creates a new ScaleBlock
  125167. * @param name defines the block name
  125168. */
  125169. constructor(name: string);
  125170. /**
  125171. * Gets the current class name
  125172. * @returns the class name
  125173. */
  125174. getClassName(): string;
  125175. /**
  125176. * Gets the input component
  125177. */
  125178. readonly input: NodeMaterialConnectionPoint;
  125179. /**
  125180. * Gets the factor input component
  125181. */
  125182. readonly factor: NodeMaterialConnectionPoint;
  125183. /**
  125184. * Gets the output component
  125185. */
  125186. readonly output: NodeMaterialConnectionPoint;
  125187. protected _buildBlock(state: NodeMaterialBuildState): this;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * Block used to clamp a float
  125193. */
  125194. export class ClampBlock extends NodeMaterialBlock {
  125195. /** Gets or sets the minimum range */
  125196. minimum: number;
  125197. /** Gets or sets the maximum range */
  125198. maximum: number;
  125199. /**
  125200. * Creates a new ClampBlock
  125201. * @param name defines the block name
  125202. */
  125203. constructor(name: string);
  125204. /**
  125205. * Gets the current class name
  125206. * @returns the class name
  125207. */
  125208. getClassName(): string;
  125209. /**
  125210. * Gets the value input component
  125211. */
  125212. readonly value: NodeMaterialConnectionPoint;
  125213. /**
  125214. * Gets the output component
  125215. */
  125216. readonly output: NodeMaterialConnectionPoint;
  125217. protected _buildBlock(state: NodeMaterialBuildState): this;
  125218. protected _dumpPropertiesCode(): string;
  125219. serialize(): any;
  125220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125221. }
  125222. }
  125223. declare module BABYLON {
  125224. /**
  125225. * Block used to apply a cross product between 2 vectors
  125226. */
  125227. export class CrossBlock extends NodeMaterialBlock {
  125228. /**
  125229. * Creates a new CrossBlock
  125230. * @param name defines the block name
  125231. */
  125232. constructor(name: string);
  125233. /**
  125234. * Gets the current class name
  125235. * @returns the class name
  125236. */
  125237. getClassName(): string;
  125238. /**
  125239. * Gets the left operand input component
  125240. */
  125241. readonly left: NodeMaterialConnectionPoint;
  125242. /**
  125243. * Gets the right operand input component
  125244. */
  125245. readonly right: NodeMaterialConnectionPoint;
  125246. /**
  125247. * Gets the output component
  125248. */
  125249. readonly output: NodeMaterialConnectionPoint;
  125250. protected _buildBlock(state: NodeMaterialBuildState): this;
  125251. }
  125252. }
  125253. declare module BABYLON {
  125254. /**
  125255. * Block used to apply a dot product between 2 vectors
  125256. */
  125257. export class DotBlock extends NodeMaterialBlock {
  125258. /**
  125259. * Creates a new DotBlock
  125260. * @param name defines the block name
  125261. */
  125262. constructor(name: string);
  125263. /**
  125264. * Gets the current class name
  125265. * @returns the class name
  125266. */
  125267. getClassName(): string;
  125268. /**
  125269. * Gets the left operand input component
  125270. */
  125271. readonly left: NodeMaterialConnectionPoint;
  125272. /**
  125273. * Gets the right operand input component
  125274. */
  125275. readonly right: NodeMaterialConnectionPoint;
  125276. /**
  125277. * Gets the output component
  125278. */
  125279. readonly output: NodeMaterialConnectionPoint;
  125280. protected _buildBlock(state: NodeMaterialBuildState): this;
  125281. }
  125282. }
  125283. declare module BABYLON {
  125284. /**
  125285. * Block used to remap a float from a range to a new one
  125286. */
  125287. export class RemapBlock extends NodeMaterialBlock {
  125288. /**
  125289. * Gets or sets the source range
  125290. */
  125291. sourceRange: Vector2;
  125292. /**
  125293. * Gets or sets the target range
  125294. */
  125295. targetRange: Vector2;
  125296. /**
  125297. * Creates a new RemapBlock
  125298. * @param name defines the block name
  125299. */
  125300. constructor(name: string);
  125301. /**
  125302. * Gets the current class name
  125303. * @returns the class name
  125304. */
  125305. getClassName(): string;
  125306. /**
  125307. * Gets the input component
  125308. */
  125309. readonly input: NodeMaterialConnectionPoint;
  125310. /**
  125311. * Gets the source min input component
  125312. */
  125313. readonly sourceMin: NodeMaterialConnectionPoint;
  125314. /**
  125315. * Gets the source max input component
  125316. */
  125317. readonly sourceMax: NodeMaterialConnectionPoint;
  125318. /**
  125319. * Gets the target min input component
  125320. */
  125321. readonly targetMin: NodeMaterialConnectionPoint;
  125322. /**
  125323. * Gets the target max input component
  125324. */
  125325. readonly targetMax: NodeMaterialConnectionPoint;
  125326. /**
  125327. * Gets the output component
  125328. */
  125329. readonly output: NodeMaterialConnectionPoint;
  125330. protected _buildBlock(state: NodeMaterialBuildState): this;
  125331. protected _dumpPropertiesCode(): string;
  125332. serialize(): any;
  125333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125334. }
  125335. }
  125336. declare module BABYLON {
  125337. /**
  125338. * Block used to normalize a vector
  125339. */
  125340. export class NormalizeBlock extends NodeMaterialBlock {
  125341. /**
  125342. * Creates a new NormalizeBlock
  125343. * @param name defines the block name
  125344. */
  125345. constructor(name: string);
  125346. /**
  125347. * Gets the current class name
  125348. * @returns the class name
  125349. */
  125350. getClassName(): string;
  125351. /**
  125352. * Gets the input component
  125353. */
  125354. readonly input: NodeMaterialConnectionPoint;
  125355. /**
  125356. * Gets the output component
  125357. */
  125358. readonly output: NodeMaterialConnectionPoint;
  125359. protected _buildBlock(state: NodeMaterialBuildState): this;
  125360. }
  125361. }
  125362. declare module BABYLON {
  125363. /**
  125364. * Operations supported by the Trigonometry block
  125365. */
  125366. export enum TrigonometryBlockOperations {
  125367. /** Cos */
  125368. Cos = 0,
  125369. /** Sin */
  125370. Sin = 1,
  125371. /** Abs */
  125372. Abs = 2,
  125373. /** Exp */
  125374. Exp = 3,
  125375. /** Exp2 */
  125376. Exp2 = 4,
  125377. /** Round */
  125378. Round = 5,
  125379. /** Floor */
  125380. Floor = 6,
  125381. /** Ceiling */
  125382. Ceiling = 7,
  125383. /** Square root */
  125384. Sqrt = 8,
  125385. /** Log */
  125386. Log = 9,
  125387. /** Tangent */
  125388. Tan = 10,
  125389. /** Arc tangent */
  125390. ArcTan = 11,
  125391. /** Arc cosinus */
  125392. ArcCos = 12,
  125393. /** Arc sinus */
  125394. ArcSin = 13,
  125395. /** Fraction */
  125396. Fract = 14,
  125397. /** Sign */
  125398. Sign = 15,
  125399. /** To radians (from degrees) */
  125400. Radians = 16,
  125401. /** To degrees (from radians) */
  125402. Degrees = 17
  125403. }
  125404. /**
  125405. * Block used to apply trigonometry operation to floats
  125406. */
  125407. export class TrigonometryBlock extends NodeMaterialBlock {
  125408. /**
  125409. * Gets or sets the operation applied by the block
  125410. */
  125411. operation: TrigonometryBlockOperations;
  125412. /**
  125413. * Creates a new TrigonometryBlock
  125414. * @param name defines the block name
  125415. */
  125416. constructor(name: string);
  125417. /**
  125418. * Gets the current class name
  125419. * @returns the class name
  125420. */
  125421. getClassName(): string;
  125422. /**
  125423. * Gets the input component
  125424. */
  125425. readonly input: NodeMaterialConnectionPoint;
  125426. /**
  125427. * Gets the output component
  125428. */
  125429. readonly output: NodeMaterialConnectionPoint;
  125430. protected _buildBlock(state: NodeMaterialBuildState): this;
  125431. serialize(): any;
  125432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125433. protected _dumpPropertiesCode(): string;
  125434. }
  125435. }
  125436. declare module BABYLON {
  125437. /**
  125438. * Block used to create a Color3/4 out of individual inputs (one for each component)
  125439. */
  125440. export class ColorMergerBlock extends NodeMaterialBlock {
  125441. /**
  125442. * Create a new ColorMergerBlock
  125443. * @param name defines the block name
  125444. */
  125445. constructor(name: string);
  125446. /**
  125447. * Gets the current class name
  125448. * @returns the class name
  125449. */
  125450. getClassName(): string;
  125451. /**
  125452. * Gets the rgb component (input)
  125453. */
  125454. readonly rgbIn: NodeMaterialConnectionPoint;
  125455. /**
  125456. * Gets the r component (input)
  125457. */
  125458. readonly r: NodeMaterialConnectionPoint;
  125459. /**
  125460. * Gets the g component (input)
  125461. */
  125462. readonly g: NodeMaterialConnectionPoint;
  125463. /**
  125464. * Gets the b component (input)
  125465. */
  125466. readonly b: NodeMaterialConnectionPoint;
  125467. /**
  125468. * Gets the a component (input)
  125469. */
  125470. readonly a: NodeMaterialConnectionPoint;
  125471. /**
  125472. * Gets the rgba component (output)
  125473. */
  125474. readonly rgba: NodeMaterialConnectionPoint;
  125475. /**
  125476. * Gets the rgb component (output)
  125477. */
  125478. readonly rgbOut: NodeMaterialConnectionPoint;
  125479. /**
  125480. * Gets the rgb component (output)
  125481. * @deprecated Please use rgbOut instead.
  125482. */
  125483. readonly rgb: NodeMaterialConnectionPoint;
  125484. protected _buildBlock(state: NodeMaterialBuildState): this;
  125485. }
  125486. }
  125487. declare module BABYLON {
  125488. /**
  125489. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  125490. */
  125491. export class VectorMergerBlock extends NodeMaterialBlock {
  125492. /**
  125493. * Create a new VectorMergerBlock
  125494. * @param name defines the block name
  125495. */
  125496. constructor(name: string);
  125497. /**
  125498. * Gets the current class name
  125499. * @returns the class name
  125500. */
  125501. getClassName(): string;
  125502. /**
  125503. * Gets the xyz component (input)
  125504. */
  125505. readonly xyzIn: NodeMaterialConnectionPoint;
  125506. /**
  125507. * Gets the xy component (input)
  125508. */
  125509. readonly xyIn: NodeMaterialConnectionPoint;
  125510. /**
  125511. * Gets the x component (input)
  125512. */
  125513. readonly x: NodeMaterialConnectionPoint;
  125514. /**
  125515. * Gets the y component (input)
  125516. */
  125517. readonly y: NodeMaterialConnectionPoint;
  125518. /**
  125519. * Gets the z component (input)
  125520. */
  125521. readonly z: NodeMaterialConnectionPoint;
  125522. /**
  125523. * Gets the w component (input)
  125524. */
  125525. readonly w: NodeMaterialConnectionPoint;
  125526. /**
  125527. * Gets the xyzw component (output)
  125528. */
  125529. readonly xyzw: NodeMaterialConnectionPoint;
  125530. /**
  125531. * Gets the xyz component (output)
  125532. */
  125533. readonly xyzOut: NodeMaterialConnectionPoint;
  125534. /**
  125535. * Gets the xy component (output)
  125536. */
  125537. readonly xyOut: NodeMaterialConnectionPoint;
  125538. /**
  125539. * Gets the xy component (output)
  125540. * @deprecated Please use xyOut instead.
  125541. */
  125542. readonly xy: NodeMaterialConnectionPoint;
  125543. /**
  125544. * Gets the xyz component (output)
  125545. * @deprecated Please use xyzOut instead.
  125546. */
  125547. readonly xyz: NodeMaterialConnectionPoint;
  125548. protected _buildBlock(state: NodeMaterialBuildState): this;
  125549. }
  125550. }
  125551. declare module BABYLON {
  125552. /**
  125553. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  125554. */
  125555. export class ColorSplitterBlock extends NodeMaterialBlock {
  125556. /**
  125557. * Create a new ColorSplitterBlock
  125558. * @param name defines the block name
  125559. */
  125560. constructor(name: string);
  125561. /**
  125562. * Gets the current class name
  125563. * @returns the class name
  125564. */
  125565. getClassName(): string;
  125566. /**
  125567. * Gets the rgba component (input)
  125568. */
  125569. readonly rgba: NodeMaterialConnectionPoint;
  125570. /**
  125571. * Gets the rgb component (input)
  125572. */
  125573. readonly rgbIn: NodeMaterialConnectionPoint;
  125574. /**
  125575. * Gets the rgb component (output)
  125576. */
  125577. readonly rgbOut: NodeMaterialConnectionPoint;
  125578. /**
  125579. * Gets the r component (output)
  125580. */
  125581. readonly r: NodeMaterialConnectionPoint;
  125582. /**
  125583. * Gets the g component (output)
  125584. */
  125585. readonly g: NodeMaterialConnectionPoint;
  125586. /**
  125587. * Gets the b component (output)
  125588. */
  125589. readonly b: NodeMaterialConnectionPoint;
  125590. /**
  125591. * Gets the a component (output)
  125592. */
  125593. readonly a: NodeMaterialConnectionPoint;
  125594. protected _inputRename(name: string): string;
  125595. protected _outputRename(name: string): string;
  125596. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125597. }
  125598. }
  125599. declare module BABYLON {
  125600. /**
  125601. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  125602. */
  125603. export class VectorSplitterBlock extends NodeMaterialBlock {
  125604. /**
  125605. * Create a new VectorSplitterBlock
  125606. * @param name defines the block name
  125607. */
  125608. constructor(name: string);
  125609. /**
  125610. * Gets the current class name
  125611. * @returns the class name
  125612. */
  125613. getClassName(): string;
  125614. /**
  125615. * Gets the xyzw component (input)
  125616. */
  125617. readonly xyzw: NodeMaterialConnectionPoint;
  125618. /**
  125619. * Gets the xyz component (input)
  125620. */
  125621. readonly xyzIn: NodeMaterialConnectionPoint;
  125622. /**
  125623. * Gets the xy component (input)
  125624. */
  125625. readonly xyIn: NodeMaterialConnectionPoint;
  125626. /**
  125627. * Gets the xyz component (output)
  125628. */
  125629. readonly xyzOut: NodeMaterialConnectionPoint;
  125630. /**
  125631. * Gets the xy component (output)
  125632. */
  125633. readonly xyOut: NodeMaterialConnectionPoint;
  125634. /**
  125635. * Gets the x component (output)
  125636. */
  125637. readonly x: NodeMaterialConnectionPoint;
  125638. /**
  125639. * Gets the y component (output)
  125640. */
  125641. readonly y: NodeMaterialConnectionPoint;
  125642. /**
  125643. * Gets the z component (output)
  125644. */
  125645. readonly z: NodeMaterialConnectionPoint;
  125646. /**
  125647. * Gets the w component (output)
  125648. */
  125649. readonly w: NodeMaterialConnectionPoint;
  125650. protected _inputRename(name: string): string;
  125651. protected _outputRename(name: string): string;
  125652. protected _buildBlock(state: NodeMaterialBuildState): this;
  125653. }
  125654. }
  125655. declare module BABYLON {
  125656. /**
  125657. * Block used to lerp between 2 values
  125658. */
  125659. export class LerpBlock extends NodeMaterialBlock {
  125660. /**
  125661. * Creates a new LerpBlock
  125662. * @param name defines the block name
  125663. */
  125664. constructor(name: string);
  125665. /**
  125666. * Gets the current class name
  125667. * @returns the class name
  125668. */
  125669. getClassName(): string;
  125670. /**
  125671. * Gets the left operand input component
  125672. */
  125673. readonly left: NodeMaterialConnectionPoint;
  125674. /**
  125675. * Gets the right operand input component
  125676. */
  125677. readonly right: NodeMaterialConnectionPoint;
  125678. /**
  125679. * Gets the gradient operand input component
  125680. */
  125681. readonly gradient: NodeMaterialConnectionPoint;
  125682. /**
  125683. * Gets the output component
  125684. */
  125685. readonly output: NodeMaterialConnectionPoint;
  125686. protected _buildBlock(state: NodeMaterialBuildState): this;
  125687. }
  125688. }
  125689. declare module BABYLON {
  125690. /**
  125691. * Block used to divide 2 vectors
  125692. */
  125693. export class DivideBlock extends NodeMaterialBlock {
  125694. /**
  125695. * Creates a new DivideBlock
  125696. * @param name defines the block name
  125697. */
  125698. constructor(name: string);
  125699. /**
  125700. * Gets the current class name
  125701. * @returns the class name
  125702. */
  125703. getClassName(): string;
  125704. /**
  125705. * Gets the left operand input component
  125706. */
  125707. readonly left: NodeMaterialConnectionPoint;
  125708. /**
  125709. * Gets the right operand input component
  125710. */
  125711. readonly right: NodeMaterialConnectionPoint;
  125712. /**
  125713. * Gets the output component
  125714. */
  125715. readonly output: NodeMaterialConnectionPoint;
  125716. protected _buildBlock(state: NodeMaterialBuildState): this;
  125717. }
  125718. }
  125719. declare module BABYLON {
  125720. /**
  125721. * Block used to subtract 2 vectors
  125722. */
  125723. export class SubtractBlock extends NodeMaterialBlock {
  125724. /**
  125725. * Creates a new SubtractBlock
  125726. * @param name defines the block name
  125727. */
  125728. constructor(name: string);
  125729. /**
  125730. * Gets the current class name
  125731. * @returns the class name
  125732. */
  125733. getClassName(): string;
  125734. /**
  125735. * Gets the left operand input component
  125736. */
  125737. readonly left: NodeMaterialConnectionPoint;
  125738. /**
  125739. * Gets the right operand input component
  125740. */
  125741. readonly right: NodeMaterialConnectionPoint;
  125742. /**
  125743. * Gets the output component
  125744. */
  125745. readonly output: NodeMaterialConnectionPoint;
  125746. protected _buildBlock(state: NodeMaterialBuildState): this;
  125747. }
  125748. }
  125749. declare module BABYLON {
  125750. /**
  125751. * Block used to step a value
  125752. */
  125753. export class StepBlock extends NodeMaterialBlock {
  125754. /**
  125755. * Creates a new StepBlock
  125756. * @param name defines the block name
  125757. */
  125758. constructor(name: string);
  125759. /**
  125760. * Gets the current class name
  125761. * @returns the class name
  125762. */
  125763. getClassName(): string;
  125764. /**
  125765. * Gets the value operand input component
  125766. */
  125767. readonly value: NodeMaterialConnectionPoint;
  125768. /**
  125769. * Gets the edge operand input component
  125770. */
  125771. readonly edge: NodeMaterialConnectionPoint;
  125772. /**
  125773. * Gets the output component
  125774. */
  125775. readonly output: NodeMaterialConnectionPoint;
  125776. protected _buildBlock(state: NodeMaterialBuildState): this;
  125777. }
  125778. }
  125779. declare module BABYLON {
  125780. /**
  125781. * Block used to get the opposite (1 - x) of a value
  125782. */
  125783. export class OneMinusBlock extends NodeMaterialBlock {
  125784. /**
  125785. * Creates a new OneMinusBlock
  125786. * @param name defines the block name
  125787. */
  125788. constructor(name: string);
  125789. /**
  125790. * Gets the current class name
  125791. * @returns the class name
  125792. */
  125793. getClassName(): string;
  125794. /**
  125795. * Gets the input component
  125796. */
  125797. readonly input: NodeMaterialConnectionPoint;
  125798. /**
  125799. * Gets the output component
  125800. */
  125801. readonly output: NodeMaterialConnectionPoint;
  125802. protected _buildBlock(state: NodeMaterialBuildState): this;
  125803. }
  125804. }
  125805. declare module BABYLON {
  125806. /**
  125807. * Block used to get the view direction
  125808. */
  125809. export class ViewDirectionBlock extends NodeMaterialBlock {
  125810. /**
  125811. * Creates a new ViewDirectionBlock
  125812. * @param name defines the block name
  125813. */
  125814. constructor(name: string);
  125815. /**
  125816. * Gets the current class name
  125817. * @returns the class name
  125818. */
  125819. getClassName(): string;
  125820. /**
  125821. * Gets the world position component
  125822. */
  125823. readonly worldPosition: NodeMaterialConnectionPoint;
  125824. /**
  125825. * Gets the camera position component
  125826. */
  125827. readonly cameraPosition: NodeMaterialConnectionPoint;
  125828. /**
  125829. * Gets the output component
  125830. */
  125831. readonly output: NodeMaterialConnectionPoint;
  125832. autoConfigure(material: NodeMaterial): void;
  125833. protected _buildBlock(state: NodeMaterialBuildState): this;
  125834. }
  125835. }
  125836. declare module BABYLON {
  125837. /**
  125838. * Block used to compute fresnel value
  125839. */
  125840. export class FresnelBlock extends NodeMaterialBlock {
  125841. /**
  125842. * Create a new FresnelBlock
  125843. * @param name defines the block name
  125844. */
  125845. constructor(name: string);
  125846. /**
  125847. * Gets the current class name
  125848. * @returns the class name
  125849. */
  125850. getClassName(): string;
  125851. /**
  125852. * Gets the world normal input component
  125853. */
  125854. readonly worldNormal: NodeMaterialConnectionPoint;
  125855. /**
  125856. * Gets the view direction input component
  125857. */
  125858. readonly viewDirection: NodeMaterialConnectionPoint;
  125859. /**
  125860. * Gets the bias input component
  125861. */
  125862. readonly bias: NodeMaterialConnectionPoint;
  125863. /**
  125864. * Gets the camera (or eye) position component
  125865. */
  125866. readonly power: NodeMaterialConnectionPoint;
  125867. /**
  125868. * Gets the fresnel output component
  125869. */
  125870. readonly fresnel: NodeMaterialConnectionPoint;
  125871. autoConfigure(material: NodeMaterial): void;
  125872. protected _buildBlock(state: NodeMaterialBuildState): this;
  125873. }
  125874. }
  125875. declare module BABYLON {
  125876. /**
  125877. * Block used to get the max of 2 values
  125878. */
  125879. export class MaxBlock extends NodeMaterialBlock {
  125880. /**
  125881. * Creates a new MaxBlock
  125882. * @param name defines the block name
  125883. */
  125884. constructor(name: string);
  125885. /**
  125886. * Gets the current class name
  125887. * @returns the class name
  125888. */
  125889. getClassName(): string;
  125890. /**
  125891. * Gets the left operand input component
  125892. */
  125893. readonly left: NodeMaterialConnectionPoint;
  125894. /**
  125895. * Gets the right operand input component
  125896. */
  125897. readonly right: NodeMaterialConnectionPoint;
  125898. /**
  125899. * Gets the output component
  125900. */
  125901. readonly output: NodeMaterialConnectionPoint;
  125902. protected _buildBlock(state: NodeMaterialBuildState): this;
  125903. }
  125904. }
  125905. declare module BABYLON {
  125906. /**
  125907. * Block used to get the min of 2 values
  125908. */
  125909. export class MinBlock extends NodeMaterialBlock {
  125910. /**
  125911. * Creates a new MinBlock
  125912. * @param name defines the block name
  125913. */
  125914. constructor(name: string);
  125915. /**
  125916. * Gets the current class name
  125917. * @returns the class name
  125918. */
  125919. getClassName(): string;
  125920. /**
  125921. * Gets the left operand input component
  125922. */
  125923. readonly left: NodeMaterialConnectionPoint;
  125924. /**
  125925. * Gets the right operand input component
  125926. */
  125927. readonly right: NodeMaterialConnectionPoint;
  125928. /**
  125929. * Gets the output component
  125930. */
  125931. readonly output: NodeMaterialConnectionPoint;
  125932. protected _buildBlock(state: NodeMaterialBuildState): this;
  125933. }
  125934. }
  125935. declare module BABYLON {
  125936. /**
  125937. * Block used to get the distance between 2 values
  125938. */
  125939. export class DistanceBlock extends NodeMaterialBlock {
  125940. /**
  125941. * Creates a new DistanceBlock
  125942. * @param name defines the block name
  125943. */
  125944. constructor(name: string);
  125945. /**
  125946. * Gets the current class name
  125947. * @returns the class name
  125948. */
  125949. getClassName(): string;
  125950. /**
  125951. * Gets the left operand input component
  125952. */
  125953. readonly left: NodeMaterialConnectionPoint;
  125954. /**
  125955. * Gets the right operand input component
  125956. */
  125957. readonly right: NodeMaterialConnectionPoint;
  125958. /**
  125959. * Gets the output component
  125960. */
  125961. readonly output: NodeMaterialConnectionPoint;
  125962. protected _buildBlock(state: NodeMaterialBuildState): this;
  125963. }
  125964. }
  125965. declare module BABYLON {
  125966. /**
  125967. * Block used to get the length of a vector
  125968. */
  125969. export class LengthBlock extends NodeMaterialBlock {
  125970. /**
  125971. * Creates a new LengthBlock
  125972. * @param name defines the block name
  125973. */
  125974. constructor(name: string);
  125975. /**
  125976. * Gets the current class name
  125977. * @returns the class name
  125978. */
  125979. getClassName(): string;
  125980. /**
  125981. * Gets the value input component
  125982. */
  125983. readonly value: NodeMaterialConnectionPoint;
  125984. /**
  125985. * Gets the output component
  125986. */
  125987. readonly output: NodeMaterialConnectionPoint;
  125988. protected _buildBlock(state: NodeMaterialBuildState): this;
  125989. }
  125990. }
  125991. declare module BABYLON {
  125992. /**
  125993. * Block used to get negative version of a value (i.e. x * -1)
  125994. */
  125995. export class NegateBlock extends NodeMaterialBlock {
  125996. /**
  125997. * Creates a new NegateBlock
  125998. * @param name defines the block name
  125999. */
  126000. constructor(name: string);
  126001. /**
  126002. * Gets the current class name
  126003. * @returns the class name
  126004. */
  126005. getClassName(): string;
  126006. /**
  126007. * Gets the value input component
  126008. */
  126009. readonly value: NodeMaterialConnectionPoint;
  126010. /**
  126011. * Gets the output component
  126012. */
  126013. readonly output: NodeMaterialConnectionPoint;
  126014. protected _buildBlock(state: NodeMaterialBuildState): this;
  126015. }
  126016. }
  126017. declare module BABYLON {
  126018. /**
  126019. * Block used to get the value of the first parameter raised to the power of the second
  126020. */
  126021. export class PowBlock extends NodeMaterialBlock {
  126022. /**
  126023. * Creates a new PowBlock
  126024. * @param name defines the block name
  126025. */
  126026. constructor(name: string);
  126027. /**
  126028. * Gets the current class name
  126029. * @returns the class name
  126030. */
  126031. getClassName(): string;
  126032. /**
  126033. * Gets the value operand input component
  126034. */
  126035. readonly value: NodeMaterialConnectionPoint;
  126036. /**
  126037. * Gets the power operand input component
  126038. */
  126039. readonly power: NodeMaterialConnectionPoint;
  126040. /**
  126041. * Gets the output component
  126042. */
  126043. readonly output: NodeMaterialConnectionPoint;
  126044. protected _buildBlock(state: NodeMaterialBuildState): this;
  126045. }
  126046. }
  126047. declare module BABYLON {
  126048. /**
  126049. * Block used to get a random number
  126050. */
  126051. export class RandomNumberBlock extends NodeMaterialBlock {
  126052. /**
  126053. * Creates a new RandomNumberBlock
  126054. * @param name defines the block name
  126055. */
  126056. constructor(name: string);
  126057. /**
  126058. * Gets the current class name
  126059. * @returns the class name
  126060. */
  126061. getClassName(): string;
  126062. /**
  126063. * Gets the seed input component
  126064. */
  126065. readonly seed: NodeMaterialConnectionPoint;
  126066. /**
  126067. * Gets the output component
  126068. */
  126069. readonly output: NodeMaterialConnectionPoint;
  126070. protected _buildBlock(state: NodeMaterialBuildState): this;
  126071. }
  126072. }
  126073. declare module BABYLON {
  126074. /**
  126075. * Block used to compute arc tangent of 2 values
  126076. */
  126077. export class ArcTan2Block extends NodeMaterialBlock {
  126078. /**
  126079. * Creates a new ArcTan2Block
  126080. * @param name defines the block name
  126081. */
  126082. constructor(name: string);
  126083. /**
  126084. * Gets the current class name
  126085. * @returns the class name
  126086. */
  126087. getClassName(): string;
  126088. /**
  126089. * Gets the x operand input component
  126090. */
  126091. readonly x: NodeMaterialConnectionPoint;
  126092. /**
  126093. * Gets the y operand input component
  126094. */
  126095. readonly y: NodeMaterialConnectionPoint;
  126096. /**
  126097. * Gets the output component
  126098. */
  126099. readonly output: NodeMaterialConnectionPoint;
  126100. protected _buildBlock(state: NodeMaterialBuildState): this;
  126101. }
  126102. }
  126103. declare module BABYLON {
  126104. /**
  126105. * Block used to smooth step a value
  126106. */
  126107. export class SmoothStepBlock extends NodeMaterialBlock {
  126108. /**
  126109. * Creates a new SmoothStepBlock
  126110. * @param name defines the block name
  126111. */
  126112. constructor(name: string);
  126113. /**
  126114. * Gets the current class name
  126115. * @returns the class name
  126116. */
  126117. getClassName(): string;
  126118. /**
  126119. * Gets the value operand input component
  126120. */
  126121. readonly value: NodeMaterialConnectionPoint;
  126122. /**
  126123. * Gets the first edge operand input component
  126124. */
  126125. readonly edge0: NodeMaterialConnectionPoint;
  126126. /**
  126127. * Gets the second edge operand input component
  126128. */
  126129. readonly edge1: NodeMaterialConnectionPoint;
  126130. /**
  126131. * Gets the output component
  126132. */
  126133. readonly output: NodeMaterialConnectionPoint;
  126134. protected _buildBlock(state: NodeMaterialBuildState): this;
  126135. }
  126136. }
  126137. declare module BABYLON {
  126138. /**
  126139. * Block used to get the reciprocal (1 / x) of a value
  126140. */
  126141. export class ReciprocalBlock extends NodeMaterialBlock {
  126142. /**
  126143. * Creates a new ReciprocalBlock
  126144. * @param name defines the block name
  126145. */
  126146. constructor(name: string);
  126147. /**
  126148. * Gets the current class name
  126149. * @returns the class name
  126150. */
  126151. getClassName(): string;
  126152. /**
  126153. * Gets the input component
  126154. */
  126155. readonly input: NodeMaterialConnectionPoint;
  126156. /**
  126157. * Gets the output component
  126158. */
  126159. readonly output: NodeMaterialConnectionPoint;
  126160. protected _buildBlock(state: NodeMaterialBuildState): this;
  126161. }
  126162. }
  126163. declare module BABYLON {
  126164. /**
  126165. * Block used to replace a color by another one
  126166. */
  126167. export class ReplaceColorBlock extends NodeMaterialBlock {
  126168. /**
  126169. * Creates a new ReplaceColorBlock
  126170. * @param name defines the block name
  126171. */
  126172. constructor(name: string);
  126173. /**
  126174. * Gets the current class name
  126175. * @returns the class name
  126176. */
  126177. getClassName(): string;
  126178. /**
  126179. * Gets the value input component
  126180. */
  126181. readonly value: NodeMaterialConnectionPoint;
  126182. /**
  126183. * Gets the reference input component
  126184. */
  126185. readonly reference: NodeMaterialConnectionPoint;
  126186. /**
  126187. * Gets the distance input component
  126188. */
  126189. readonly distance: NodeMaterialConnectionPoint;
  126190. /**
  126191. * Gets the replacement input component
  126192. */
  126193. readonly replacement: NodeMaterialConnectionPoint;
  126194. /**
  126195. * Gets the output component
  126196. */
  126197. readonly output: NodeMaterialConnectionPoint;
  126198. protected _buildBlock(state: NodeMaterialBuildState): this;
  126199. }
  126200. }
  126201. declare module BABYLON {
  126202. /**
  126203. * Block used to posterize a value
  126204. * @see https://en.wikipedia.org/wiki/Posterization
  126205. */
  126206. export class PosterizeBlock extends NodeMaterialBlock {
  126207. /**
  126208. * Creates a new PosterizeBlock
  126209. * @param name defines the block name
  126210. */
  126211. constructor(name: string);
  126212. /**
  126213. * Gets the current class name
  126214. * @returns the class name
  126215. */
  126216. getClassName(): string;
  126217. /**
  126218. * Gets the value input component
  126219. */
  126220. readonly value: NodeMaterialConnectionPoint;
  126221. /**
  126222. * Gets the steps input component
  126223. */
  126224. readonly steps: NodeMaterialConnectionPoint;
  126225. /**
  126226. * Gets the output component
  126227. */
  126228. readonly output: NodeMaterialConnectionPoint;
  126229. protected _buildBlock(state: NodeMaterialBuildState): this;
  126230. }
  126231. }
  126232. declare module BABYLON {
  126233. /**
  126234. * Operations supported by the Wave block
  126235. */
  126236. export enum WaveBlockKind {
  126237. /** SawTooth */
  126238. SawTooth = 0,
  126239. /** Square */
  126240. Square = 1,
  126241. /** Triangle */
  126242. Triangle = 2
  126243. }
  126244. /**
  126245. * Block used to apply wave operation to floats
  126246. */
  126247. export class WaveBlock extends NodeMaterialBlock {
  126248. /**
  126249. * Gets or sets the kibnd of wave to be applied by the block
  126250. */
  126251. kind: WaveBlockKind;
  126252. /**
  126253. * Creates a new WaveBlock
  126254. * @param name defines the block name
  126255. */
  126256. constructor(name: string);
  126257. /**
  126258. * Gets the current class name
  126259. * @returns the class name
  126260. */
  126261. getClassName(): string;
  126262. /**
  126263. * Gets the input component
  126264. */
  126265. readonly input: NodeMaterialConnectionPoint;
  126266. /**
  126267. * Gets the output component
  126268. */
  126269. readonly output: NodeMaterialConnectionPoint;
  126270. protected _buildBlock(state: NodeMaterialBuildState): this;
  126271. serialize(): any;
  126272. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126273. }
  126274. }
  126275. declare module BABYLON {
  126276. /**
  126277. * Class used to store a color step for the GradientBlock
  126278. */
  126279. export class GradientBlockColorStep {
  126280. /**
  126281. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  126282. */
  126283. step: number;
  126284. /**
  126285. * Gets or sets the color associated with this step
  126286. */
  126287. color: Color3;
  126288. /**
  126289. * Creates a new GradientBlockColorStep
  126290. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  126291. * @param color defines the color associated with this step
  126292. */
  126293. constructor(
  126294. /**
  126295. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  126296. */
  126297. step: number,
  126298. /**
  126299. * Gets or sets the color associated with this step
  126300. */
  126301. color: Color3);
  126302. }
  126303. /**
  126304. * Block used to return a color from a gradient based on an input value between 0 and 1
  126305. */
  126306. export class GradientBlock extends NodeMaterialBlock {
  126307. /**
  126308. * Gets or sets the list of color steps
  126309. */
  126310. colorSteps: GradientBlockColorStep[];
  126311. /**
  126312. * Creates a new GradientBlock
  126313. * @param name defines the block name
  126314. */
  126315. constructor(name: string);
  126316. /**
  126317. * Gets the current class name
  126318. * @returns the class name
  126319. */
  126320. getClassName(): string;
  126321. /**
  126322. * Gets the gradient input component
  126323. */
  126324. readonly gradient: NodeMaterialConnectionPoint;
  126325. /**
  126326. * Gets the output component
  126327. */
  126328. readonly output: NodeMaterialConnectionPoint;
  126329. private _writeColorConstant;
  126330. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126331. serialize(): any;
  126332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126333. protected _dumpPropertiesCode(): string;
  126334. }
  126335. }
  126336. declare module BABYLON {
  126337. /**
  126338. * Block used to normalize lerp between 2 values
  126339. */
  126340. export class NLerpBlock extends NodeMaterialBlock {
  126341. /**
  126342. * Creates a new NLerpBlock
  126343. * @param name defines the block name
  126344. */
  126345. constructor(name: string);
  126346. /**
  126347. * Gets the current class name
  126348. * @returns the class name
  126349. */
  126350. getClassName(): string;
  126351. /**
  126352. * Gets the left operand input component
  126353. */
  126354. readonly left: NodeMaterialConnectionPoint;
  126355. /**
  126356. * Gets the right operand input component
  126357. */
  126358. readonly right: NodeMaterialConnectionPoint;
  126359. /**
  126360. * Gets the gradient operand input component
  126361. */
  126362. readonly gradient: NodeMaterialConnectionPoint;
  126363. /**
  126364. * Gets the output component
  126365. */
  126366. readonly output: NodeMaterialConnectionPoint;
  126367. protected _buildBlock(state: NodeMaterialBuildState): this;
  126368. }
  126369. }
  126370. declare module BABYLON {
  126371. /**
  126372. * block used to Generate a Worley Noise 3D Noise Pattern
  126373. */
  126374. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  126375. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  126376. manhattanDistance: boolean;
  126377. /**
  126378. * Creates a new WorleyNoise3DBlock
  126379. * @param name defines the block name
  126380. */
  126381. constructor(name: string);
  126382. /**
  126383. * Gets the current class name
  126384. * @returns the class name
  126385. */
  126386. getClassName(): string;
  126387. /**
  126388. * Gets the seed input component
  126389. */
  126390. readonly seed: NodeMaterialConnectionPoint;
  126391. /**
  126392. * Gets the jitter input component
  126393. */
  126394. readonly jitter: NodeMaterialConnectionPoint;
  126395. /**
  126396. * Gets the output component
  126397. */
  126398. readonly output: NodeMaterialConnectionPoint;
  126399. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126400. /**
  126401. * Exposes the properties to the UI?
  126402. */
  126403. protected _dumpPropertiesCode(): string;
  126404. /**
  126405. * Exposes the properties to the Seralize?
  126406. */
  126407. serialize(): any;
  126408. /**
  126409. * Exposes the properties to the deseralize?
  126410. */
  126411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126412. }
  126413. }
  126414. declare module BABYLON {
  126415. /**
  126416. * block used to Generate a Simplex Perlin 3d Noise Pattern
  126417. */
  126418. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  126419. /**
  126420. * Creates a new SimplexPerlin3DBlock
  126421. * @param name defines the block name
  126422. */
  126423. constructor(name: string);
  126424. /**
  126425. * Gets the current class name
  126426. * @returns the class name
  126427. */
  126428. getClassName(): string;
  126429. /**
  126430. * Gets the seed operand input component
  126431. */
  126432. readonly seed: NodeMaterialConnectionPoint;
  126433. /**
  126434. * Gets the output component
  126435. */
  126436. readonly output: NodeMaterialConnectionPoint;
  126437. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126438. }
  126439. }
  126440. declare module BABYLON {
  126441. /**
  126442. * Block used to blend normals
  126443. */
  126444. export class NormalBlendBlock extends NodeMaterialBlock {
  126445. /**
  126446. * Creates a new NormalBlendBlock
  126447. * @param name defines the block name
  126448. */
  126449. constructor(name: string);
  126450. /**
  126451. * Gets the current class name
  126452. * @returns the class name
  126453. */
  126454. getClassName(): string;
  126455. /**
  126456. * Gets the first input component
  126457. */
  126458. readonly normalMap0: NodeMaterialConnectionPoint;
  126459. /**
  126460. * Gets the second input component
  126461. */
  126462. readonly normalMap1: NodeMaterialConnectionPoint;
  126463. /**
  126464. * Gets the output component
  126465. */
  126466. readonly output: NodeMaterialConnectionPoint;
  126467. protected _buildBlock(state: NodeMaterialBuildState): this;
  126468. }
  126469. }
  126470. declare module BABYLON {
  126471. /**
  126472. * Block used to rotate a 2d vector by a given angle
  126473. */
  126474. export class Rotate2dBlock extends NodeMaterialBlock {
  126475. /**
  126476. * Creates a new Rotate2dBlock
  126477. * @param name defines the block name
  126478. */
  126479. constructor(name: string);
  126480. /**
  126481. * Gets the current class name
  126482. * @returns the class name
  126483. */
  126484. getClassName(): string;
  126485. /**
  126486. * Gets the input vector
  126487. */
  126488. readonly input: NodeMaterialConnectionPoint;
  126489. /**
  126490. * Gets the input angle
  126491. */
  126492. readonly angle: NodeMaterialConnectionPoint;
  126493. /**
  126494. * Gets the output component
  126495. */
  126496. readonly output: NodeMaterialConnectionPoint;
  126497. autoConfigure(material: NodeMaterial): void;
  126498. protected _buildBlock(state: NodeMaterialBuildState): this;
  126499. }
  126500. }
  126501. declare module BABYLON {
  126502. /**
  126503. * Block used to get the reflected vector from a direction and a normal
  126504. */
  126505. export class ReflectBlock extends NodeMaterialBlock {
  126506. /**
  126507. * Creates a new ReflectBlock
  126508. * @param name defines the block name
  126509. */
  126510. constructor(name: string);
  126511. /**
  126512. * Gets the current class name
  126513. * @returns the class name
  126514. */
  126515. getClassName(): string;
  126516. /**
  126517. * Gets the incident component
  126518. */
  126519. readonly incident: NodeMaterialConnectionPoint;
  126520. /**
  126521. * Gets the normal component
  126522. */
  126523. readonly normal: NodeMaterialConnectionPoint;
  126524. /**
  126525. * Gets the output component
  126526. */
  126527. readonly output: NodeMaterialConnectionPoint;
  126528. protected _buildBlock(state: NodeMaterialBuildState): this;
  126529. }
  126530. }
  126531. declare module BABYLON {
  126532. /**
  126533. * Block used to get the refracted vector from a direction and a normal
  126534. */
  126535. export class RefractBlock extends NodeMaterialBlock {
  126536. /**
  126537. * Creates a new RefractBlock
  126538. * @param name defines the block name
  126539. */
  126540. constructor(name: string);
  126541. /**
  126542. * Gets the current class name
  126543. * @returns the class name
  126544. */
  126545. getClassName(): string;
  126546. /**
  126547. * Gets the incident component
  126548. */
  126549. readonly incident: NodeMaterialConnectionPoint;
  126550. /**
  126551. * Gets the normal component
  126552. */
  126553. readonly normal: NodeMaterialConnectionPoint;
  126554. /**
  126555. * Gets the index of refraction component
  126556. */
  126557. readonly ior: NodeMaterialConnectionPoint;
  126558. /**
  126559. * Gets the output component
  126560. */
  126561. readonly output: NodeMaterialConnectionPoint;
  126562. protected _buildBlock(state: NodeMaterialBuildState): this;
  126563. }
  126564. }
  126565. declare module BABYLON {
  126566. /**
  126567. * Block used to desaturate a color
  126568. */
  126569. export class DesaturateBlock extends NodeMaterialBlock {
  126570. /**
  126571. * Creates a new DesaturateBlock
  126572. * @param name defines the block name
  126573. */
  126574. constructor(name: string);
  126575. /**
  126576. * Gets the current class name
  126577. * @returns the class name
  126578. */
  126579. getClassName(): string;
  126580. /**
  126581. * Gets the color operand input component
  126582. */
  126583. readonly color: NodeMaterialConnectionPoint;
  126584. /**
  126585. * Gets the level operand input component
  126586. */
  126587. readonly level: NodeMaterialConnectionPoint;
  126588. /**
  126589. * Gets the output component
  126590. */
  126591. readonly output: NodeMaterialConnectionPoint;
  126592. protected _buildBlock(state: NodeMaterialBuildState): this;
  126593. }
  126594. }
  126595. declare module BABYLON {
  126596. /**
  126597. * Effect Render Options
  126598. */
  126599. export interface IEffectRendererOptions {
  126600. /**
  126601. * Defines the vertices positions.
  126602. */
  126603. positions?: number[];
  126604. /**
  126605. * Defines the indices.
  126606. */
  126607. indices?: number[];
  126608. }
  126609. /**
  126610. * Helper class to render one or more effects
  126611. */
  126612. export class EffectRenderer {
  126613. private engine;
  126614. private static _DefaultOptions;
  126615. private _vertexBuffers;
  126616. private _indexBuffer;
  126617. private _ringBufferIndex;
  126618. private _ringScreenBuffer;
  126619. private _fullscreenViewport;
  126620. private _getNextFrameBuffer;
  126621. /**
  126622. * Creates an effect renderer
  126623. * @param engine the engine to use for rendering
  126624. * @param options defines the options of the effect renderer
  126625. */
  126626. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  126627. /**
  126628. * Sets the current viewport in normalized coordinates 0-1
  126629. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  126630. */
  126631. setViewport(viewport?: Viewport): void;
  126632. /**
  126633. * Binds the embedded attributes buffer to the effect.
  126634. * @param effect Defines the effect to bind the attributes for
  126635. */
  126636. bindBuffers(effect: Effect): void;
  126637. /**
  126638. * Sets the current effect wrapper to use during draw.
  126639. * The effect needs to be ready before calling this api.
  126640. * This also sets the default full screen position attribute.
  126641. * @param effectWrapper Defines the effect to draw with
  126642. */
  126643. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  126644. /**
  126645. * Draws a full screen quad.
  126646. */
  126647. draw(): void;
  126648. /**
  126649. * renders one or more effects to a specified texture
  126650. * @param effectWrappers list of effects to renderer
  126651. * @param outputTexture texture to draw to, if null it will render to the screen
  126652. */
  126653. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  126654. /**
  126655. * Disposes of the effect renderer
  126656. */
  126657. dispose(): void;
  126658. }
  126659. /**
  126660. * Options to create an EffectWrapper
  126661. */
  126662. interface EffectWrapperCreationOptions {
  126663. /**
  126664. * Engine to use to create the effect
  126665. */
  126666. engine: ThinEngine;
  126667. /**
  126668. * Fragment shader for the effect
  126669. */
  126670. fragmentShader: string;
  126671. /**
  126672. * Vertex shader for the effect
  126673. */
  126674. vertexShader?: string;
  126675. /**
  126676. * Attributes to use in the shader
  126677. */
  126678. attributeNames?: Array<string>;
  126679. /**
  126680. * Uniforms to use in the shader
  126681. */
  126682. uniformNames?: Array<string>;
  126683. /**
  126684. * Texture sampler names to use in the shader
  126685. */
  126686. samplerNames?: Array<string>;
  126687. /**
  126688. * The friendly name of the effect displayed in Spector.
  126689. */
  126690. name?: string;
  126691. }
  126692. /**
  126693. * Wraps an effect to be used for rendering
  126694. */
  126695. export class EffectWrapper {
  126696. /**
  126697. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  126698. */
  126699. onApplyObservable: Observable<{}>;
  126700. /**
  126701. * The underlying effect
  126702. */
  126703. effect: Effect;
  126704. /**
  126705. * Creates an effect to be renderer
  126706. * @param creationOptions options to create the effect
  126707. */
  126708. constructor(creationOptions: EffectWrapperCreationOptions);
  126709. /**
  126710. * Disposes of the effect wrapper
  126711. */
  126712. dispose(): void;
  126713. }
  126714. }
  126715. declare module BABYLON {
  126716. /**
  126717. * Helper class to push actions to a pool of workers.
  126718. */
  126719. export class WorkerPool implements IDisposable {
  126720. private _workerInfos;
  126721. private _pendingActions;
  126722. /**
  126723. * Constructor
  126724. * @param workers Array of workers to use for actions
  126725. */
  126726. constructor(workers: Array<Worker>);
  126727. /**
  126728. * Terminates all workers and clears any pending actions.
  126729. */
  126730. dispose(): void;
  126731. /**
  126732. * Pushes an action to the worker pool. If all the workers are active, the action will be
  126733. * pended until a worker has completed its action.
  126734. * @param action The action to perform. Call onComplete when the action is complete.
  126735. */
  126736. push(action: (worker: Worker, onComplete: () => void) => void): void;
  126737. private _execute;
  126738. }
  126739. }
  126740. declare module BABYLON {
  126741. /**
  126742. * Configuration for Draco compression
  126743. */
  126744. export interface IDracoCompressionConfiguration {
  126745. /**
  126746. * Configuration for the decoder.
  126747. */
  126748. decoder: {
  126749. /**
  126750. * The url to the WebAssembly module.
  126751. */
  126752. wasmUrl?: string;
  126753. /**
  126754. * The url to the WebAssembly binary.
  126755. */
  126756. wasmBinaryUrl?: string;
  126757. /**
  126758. * The url to the fallback JavaScript module.
  126759. */
  126760. fallbackUrl?: string;
  126761. };
  126762. }
  126763. /**
  126764. * Draco compression (https://google.github.io/draco/)
  126765. *
  126766. * This class wraps the Draco module.
  126767. *
  126768. * **Encoder**
  126769. *
  126770. * The encoder is not currently implemented.
  126771. *
  126772. * **Decoder**
  126773. *
  126774. * 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.
  126775. *
  126776. * To update the configuration, use the following code:
  126777. * ```javascript
  126778. * DracoCompression.Configuration = {
  126779. * decoder: {
  126780. * wasmUrl: "<url to the WebAssembly library>",
  126781. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  126782. * fallbackUrl: "<url to the fallback JavaScript library>",
  126783. * }
  126784. * };
  126785. * ```
  126786. *
  126787. * 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.
  126788. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  126789. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  126790. *
  126791. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  126792. * ```javascript
  126793. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  126794. * ```
  126795. *
  126796. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  126797. */
  126798. export class DracoCompression implements IDisposable {
  126799. private _workerPoolPromise?;
  126800. private _decoderModulePromise?;
  126801. /**
  126802. * The configuration. Defaults to the following urls:
  126803. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  126804. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  126805. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  126806. */
  126807. static Configuration: IDracoCompressionConfiguration;
  126808. /**
  126809. * Returns true if the decoder configuration is available.
  126810. */
  126811. static readonly DecoderAvailable: boolean;
  126812. /**
  126813. * Default number of workers to create when creating the draco compression object.
  126814. */
  126815. static DefaultNumWorkers: number;
  126816. private static GetDefaultNumWorkers;
  126817. private static _Default;
  126818. /**
  126819. * Default instance for the draco compression object.
  126820. */
  126821. static readonly Default: DracoCompression;
  126822. /**
  126823. * Constructor
  126824. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  126825. */
  126826. constructor(numWorkers?: number);
  126827. /**
  126828. * Stop all async operations and release resources.
  126829. */
  126830. dispose(): void;
  126831. /**
  126832. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  126833. * @returns a promise that resolves when ready
  126834. */
  126835. whenReadyAsync(): Promise<void>;
  126836. /**
  126837. * Decode Draco compressed mesh data to vertex data.
  126838. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  126839. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  126840. * @returns A promise that resolves with the decoded vertex data
  126841. */
  126842. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  126843. [kind: string]: number;
  126844. }): Promise<VertexData>;
  126845. }
  126846. }
  126847. declare module BABYLON {
  126848. /**
  126849. * Class for building Constructive Solid Geometry
  126850. */
  126851. export class CSG {
  126852. private polygons;
  126853. /**
  126854. * The world matrix
  126855. */
  126856. matrix: Matrix;
  126857. /**
  126858. * Stores the position
  126859. */
  126860. position: Vector3;
  126861. /**
  126862. * Stores the rotation
  126863. */
  126864. rotation: Vector3;
  126865. /**
  126866. * Stores the rotation quaternion
  126867. */
  126868. rotationQuaternion: Nullable<Quaternion>;
  126869. /**
  126870. * Stores the scaling vector
  126871. */
  126872. scaling: Vector3;
  126873. /**
  126874. * Convert the Mesh to CSG
  126875. * @param mesh The Mesh to convert to CSG
  126876. * @returns A new CSG from the Mesh
  126877. */
  126878. static FromMesh(mesh: Mesh): CSG;
  126879. /**
  126880. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  126881. * @param polygons Polygons used to construct a CSG solid
  126882. */
  126883. private static FromPolygons;
  126884. /**
  126885. * Clones, or makes a deep copy, of the CSG
  126886. * @returns A new CSG
  126887. */
  126888. clone(): CSG;
  126889. /**
  126890. * Unions this CSG with another CSG
  126891. * @param csg The CSG to union against this CSG
  126892. * @returns The unioned CSG
  126893. */
  126894. union(csg: CSG): CSG;
  126895. /**
  126896. * Unions this CSG with another CSG in place
  126897. * @param csg The CSG to union against this CSG
  126898. */
  126899. unionInPlace(csg: CSG): void;
  126900. /**
  126901. * Subtracts this CSG with another CSG
  126902. * @param csg The CSG to subtract against this CSG
  126903. * @returns A new CSG
  126904. */
  126905. subtract(csg: CSG): CSG;
  126906. /**
  126907. * Subtracts this CSG with another CSG in place
  126908. * @param csg The CSG to subtact against this CSG
  126909. */
  126910. subtractInPlace(csg: CSG): void;
  126911. /**
  126912. * Intersect this CSG with another CSG
  126913. * @param csg The CSG to intersect against this CSG
  126914. * @returns A new CSG
  126915. */
  126916. intersect(csg: CSG): CSG;
  126917. /**
  126918. * Intersects this CSG with another CSG in place
  126919. * @param csg The CSG to intersect against this CSG
  126920. */
  126921. intersectInPlace(csg: CSG): void;
  126922. /**
  126923. * Return a new CSG solid with solid and empty space switched. This solid is
  126924. * not modified.
  126925. * @returns A new CSG solid with solid and empty space switched
  126926. */
  126927. inverse(): CSG;
  126928. /**
  126929. * Inverses the CSG in place
  126930. */
  126931. inverseInPlace(): void;
  126932. /**
  126933. * This is used to keep meshes transformations so they can be restored
  126934. * when we build back a Babylon Mesh
  126935. * NB : All CSG operations are performed in world coordinates
  126936. * @param csg The CSG to copy the transform attributes from
  126937. * @returns This CSG
  126938. */
  126939. copyTransformAttributes(csg: CSG): CSG;
  126940. /**
  126941. * Build Raw mesh from CSG
  126942. * Coordinates here are in world space
  126943. * @param name The name of the mesh geometry
  126944. * @param scene The Scene
  126945. * @param keepSubMeshes Specifies if the submeshes should be kept
  126946. * @returns A new Mesh
  126947. */
  126948. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126949. /**
  126950. * Build Mesh from CSG taking material and transforms into account
  126951. * @param name The name of the Mesh
  126952. * @param material The material of the Mesh
  126953. * @param scene The Scene
  126954. * @param keepSubMeshes Specifies if submeshes should be kept
  126955. * @returns The new Mesh
  126956. */
  126957. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  126958. }
  126959. }
  126960. declare module BABYLON {
  126961. /**
  126962. * Class used to create a trail following a mesh
  126963. */
  126964. export class TrailMesh extends Mesh {
  126965. private _generator;
  126966. private _autoStart;
  126967. private _running;
  126968. private _diameter;
  126969. private _length;
  126970. private _sectionPolygonPointsCount;
  126971. private _sectionVectors;
  126972. private _sectionNormalVectors;
  126973. private _beforeRenderObserver;
  126974. /**
  126975. * @constructor
  126976. * @param name The value used by scene.getMeshByName() to do a lookup.
  126977. * @param generator The mesh to generate a trail.
  126978. * @param scene The scene to add this mesh to.
  126979. * @param diameter Diameter of trailing mesh. Default is 1.
  126980. * @param length Length of trailing mesh. Default is 60.
  126981. * @param autoStart Automatically start trailing mesh. Default true.
  126982. */
  126983. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  126984. /**
  126985. * "TrailMesh"
  126986. * @returns "TrailMesh"
  126987. */
  126988. getClassName(): string;
  126989. private _createMesh;
  126990. /**
  126991. * Start trailing mesh.
  126992. */
  126993. start(): void;
  126994. /**
  126995. * Stop trailing mesh.
  126996. */
  126997. stop(): void;
  126998. /**
  126999. * Update trailing mesh geometry.
  127000. */
  127001. update(): void;
  127002. /**
  127003. * Returns a new TrailMesh object.
  127004. * @param name is a string, the name given to the new mesh
  127005. * @param newGenerator use new generator object for cloned trail mesh
  127006. * @returns a new mesh
  127007. */
  127008. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  127009. /**
  127010. * Serializes this trail mesh
  127011. * @param serializationObject object to write serialization to
  127012. */
  127013. serialize(serializationObject: any): void;
  127014. /**
  127015. * Parses a serialized trail mesh
  127016. * @param parsedMesh the serialized mesh
  127017. * @param scene the scene to create the trail mesh in
  127018. * @returns the created trail mesh
  127019. */
  127020. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  127021. }
  127022. }
  127023. declare module BABYLON {
  127024. /**
  127025. * Class containing static functions to help procedurally build meshes
  127026. */
  127027. export class TiledBoxBuilder {
  127028. /**
  127029. * Creates a box mesh
  127030. * 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)
  127031. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127035. * @param name defines the name of the mesh
  127036. * @param options defines the options used to create the mesh
  127037. * @param scene defines the hosting scene
  127038. * @returns the box mesh
  127039. */
  127040. static CreateTiledBox(name: string, options: {
  127041. pattern?: number;
  127042. width?: number;
  127043. height?: number;
  127044. depth?: number;
  127045. tileSize?: number;
  127046. tileWidth?: number;
  127047. tileHeight?: number;
  127048. alignHorizontal?: number;
  127049. alignVertical?: number;
  127050. faceUV?: Vector4[];
  127051. faceColors?: Color4[];
  127052. sideOrientation?: number;
  127053. updatable?: boolean;
  127054. }, scene?: Nullable<Scene>): Mesh;
  127055. }
  127056. }
  127057. declare module BABYLON {
  127058. /**
  127059. * Class containing static functions to help procedurally build meshes
  127060. */
  127061. export class TorusKnotBuilder {
  127062. /**
  127063. * Creates a torus knot mesh
  127064. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127065. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127066. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127067. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127071. * @param name defines the name of the mesh
  127072. * @param options defines the options used to create the mesh
  127073. * @param scene defines the hosting scene
  127074. * @returns the torus knot mesh
  127075. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127076. */
  127077. static CreateTorusKnot(name: string, options: {
  127078. radius?: number;
  127079. tube?: number;
  127080. radialSegments?: number;
  127081. tubularSegments?: number;
  127082. p?: number;
  127083. q?: number;
  127084. updatable?: boolean;
  127085. sideOrientation?: number;
  127086. frontUVs?: Vector4;
  127087. backUVs?: Vector4;
  127088. }, scene: any): Mesh;
  127089. }
  127090. }
  127091. declare module BABYLON {
  127092. /**
  127093. * Polygon
  127094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  127095. */
  127096. export class Polygon {
  127097. /**
  127098. * Creates a rectangle
  127099. * @param xmin bottom X coord
  127100. * @param ymin bottom Y coord
  127101. * @param xmax top X coord
  127102. * @param ymax top Y coord
  127103. * @returns points that make the resulting rectation
  127104. */
  127105. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  127106. /**
  127107. * Creates a circle
  127108. * @param radius radius of circle
  127109. * @param cx scale in x
  127110. * @param cy scale in y
  127111. * @param numberOfSides number of sides that make up the circle
  127112. * @returns points that make the resulting circle
  127113. */
  127114. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  127115. /**
  127116. * Creates a polygon from input string
  127117. * @param input Input polygon data
  127118. * @returns the parsed points
  127119. */
  127120. static Parse(input: string): Vector2[];
  127121. /**
  127122. * Starts building a polygon from x and y coordinates
  127123. * @param x x coordinate
  127124. * @param y y coordinate
  127125. * @returns the started path2
  127126. */
  127127. static StartingAt(x: number, y: number): Path2;
  127128. }
  127129. /**
  127130. * Builds a polygon
  127131. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  127132. */
  127133. export class PolygonMeshBuilder {
  127134. private _points;
  127135. private _outlinepoints;
  127136. private _holes;
  127137. private _name;
  127138. private _scene;
  127139. private _epoints;
  127140. private _eholes;
  127141. private _addToepoint;
  127142. /**
  127143. * Babylon reference to the earcut plugin.
  127144. */
  127145. bjsEarcut: any;
  127146. /**
  127147. * Creates a PolygonMeshBuilder
  127148. * @param name name of the builder
  127149. * @param contours Path of the polygon
  127150. * @param scene scene to add to when creating the mesh
  127151. * @param earcutInjection can be used to inject your own earcut reference
  127152. */
  127153. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  127154. /**
  127155. * Adds a whole within the polygon
  127156. * @param hole Array of points defining the hole
  127157. * @returns this
  127158. */
  127159. addHole(hole: Vector2[]): PolygonMeshBuilder;
  127160. /**
  127161. * Creates the polygon
  127162. * @param updatable If the mesh should be updatable
  127163. * @param depth The depth of the mesh created
  127164. * @returns the created mesh
  127165. */
  127166. build(updatable?: boolean, depth?: number): Mesh;
  127167. /**
  127168. * Creates the polygon
  127169. * @param depth The depth of the mesh created
  127170. * @returns the created VertexData
  127171. */
  127172. buildVertexData(depth?: number): VertexData;
  127173. /**
  127174. * Adds a side to the polygon
  127175. * @param positions points that make the polygon
  127176. * @param normals normals of the polygon
  127177. * @param uvs uvs of the polygon
  127178. * @param indices indices of the polygon
  127179. * @param bounds bounds of the polygon
  127180. * @param points points of the polygon
  127181. * @param depth depth of the polygon
  127182. * @param flip flip of the polygon
  127183. */
  127184. private addSide;
  127185. }
  127186. }
  127187. declare module BABYLON {
  127188. /**
  127189. * Class containing static functions to help procedurally build meshes
  127190. */
  127191. export class PolygonBuilder {
  127192. /**
  127193. * Creates a polygon mesh
  127194. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  127195. * * 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
  127196. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  127199. * * Remember you can only change the shape positions, not their number when updating a polygon
  127200. * @param name defines the name of the mesh
  127201. * @param options defines the options used to create the mesh
  127202. * @param scene defines the hosting scene
  127203. * @param earcutInjection can be used to inject your own earcut reference
  127204. * @returns the polygon mesh
  127205. */
  127206. static CreatePolygon(name: string, options: {
  127207. shape: Vector3[];
  127208. holes?: Vector3[][];
  127209. depth?: number;
  127210. faceUV?: Vector4[];
  127211. faceColors?: Color4[];
  127212. updatable?: boolean;
  127213. sideOrientation?: number;
  127214. frontUVs?: Vector4;
  127215. backUVs?: Vector4;
  127216. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127217. /**
  127218. * Creates an extruded polygon mesh, with depth in the Y direction.
  127219. * * 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)
  127220. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127221. * @param name defines the name of the mesh
  127222. * @param options defines the options used to create the mesh
  127223. * @param scene defines the hosting scene
  127224. * @param earcutInjection can be used to inject your own earcut reference
  127225. * @returns the polygon mesh
  127226. */
  127227. static ExtrudePolygon(name: string, options: {
  127228. shape: Vector3[];
  127229. holes?: Vector3[][];
  127230. depth?: number;
  127231. faceUV?: Vector4[];
  127232. faceColors?: Color4[];
  127233. updatable?: boolean;
  127234. sideOrientation?: number;
  127235. frontUVs?: Vector4;
  127236. backUVs?: Vector4;
  127237. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  127238. }
  127239. }
  127240. declare module BABYLON {
  127241. /**
  127242. * Class containing static functions to help procedurally build meshes
  127243. */
  127244. export class LatheBuilder {
  127245. /**
  127246. * Creates lathe mesh.
  127247. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127248. * * 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
  127249. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127250. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127251. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127252. * * 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
  127253. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127254. * * 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
  127255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127259. * @param name defines the name of the mesh
  127260. * @param options defines the options used to create the mesh
  127261. * @param scene defines the hosting scene
  127262. * @returns the lathe mesh
  127263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127264. */
  127265. static CreateLathe(name: string, options: {
  127266. shape: Vector3[];
  127267. radius?: number;
  127268. tessellation?: number;
  127269. clip?: number;
  127270. arc?: number;
  127271. closed?: boolean;
  127272. updatable?: boolean;
  127273. sideOrientation?: number;
  127274. frontUVs?: Vector4;
  127275. backUVs?: Vector4;
  127276. cap?: number;
  127277. invertUV?: boolean;
  127278. }, scene?: Nullable<Scene>): Mesh;
  127279. }
  127280. }
  127281. declare module BABYLON {
  127282. /**
  127283. * Class containing static functions to help procedurally build meshes
  127284. */
  127285. export class TiledPlaneBuilder {
  127286. /**
  127287. * Creates a tiled plane mesh
  127288. * * The parameter `pattern` will, depending on value, do nothing or
  127289. * * * flip (reflect about central vertical) alternate tiles across and up
  127290. * * * flip every tile on alternate rows
  127291. * * * rotate (180 degs) alternate tiles across and up
  127292. * * * rotate every tile on alternate rows
  127293. * * * flip and rotate alternate tiles across and up
  127294. * * * flip and rotate every tile on alternate rows
  127295. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  127296. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  127297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127298. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  127299. * * 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)
  127300. * * 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)
  127301. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127302. * @param name defines the name of the mesh
  127303. * @param options defines the options used to create the mesh
  127304. * @param scene defines the hosting scene
  127305. * @returns the box mesh
  127306. */
  127307. static CreateTiledPlane(name: string, options: {
  127308. pattern?: number;
  127309. tileSize?: number;
  127310. tileWidth?: number;
  127311. tileHeight?: number;
  127312. size?: number;
  127313. width?: number;
  127314. height?: number;
  127315. alignHorizontal?: number;
  127316. alignVertical?: number;
  127317. sideOrientation?: number;
  127318. frontUVs?: Vector4;
  127319. backUVs?: Vector4;
  127320. updatable?: boolean;
  127321. }, scene?: Nullable<Scene>): Mesh;
  127322. }
  127323. }
  127324. declare module BABYLON {
  127325. /**
  127326. * Class containing static functions to help procedurally build meshes
  127327. */
  127328. export class TubeBuilder {
  127329. /**
  127330. * Creates a tube mesh.
  127331. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127332. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  127333. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  127334. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  127335. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  127336. * * 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)
  127337. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  127338. * * 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
  127339. * * 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
  127340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127342. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127344. * @param name defines the name of the mesh
  127345. * @param options defines the options used to create the mesh
  127346. * @param scene defines the hosting scene
  127347. * @returns the tube mesh
  127348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127349. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  127350. */
  127351. static CreateTube(name: string, options: {
  127352. path: Vector3[];
  127353. radius?: number;
  127354. tessellation?: number;
  127355. radiusFunction?: {
  127356. (i: number, distance: number): number;
  127357. };
  127358. cap?: number;
  127359. arc?: number;
  127360. updatable?: boolean;
  127361. sideOrientation?: number;
  127362. frontUVs?: Vector4;
  127363. backUVs?: Vector4;
  127364. instance?: Mesh;
  127365. invertUV?: boolean;
  127366. }, scene?: Nullable<Scene>): Mesh;
  127367. }
  127368. }
  127369. declare module BABYLON {
  127370. /**
  127371. * Class containing static functions to help procedurally build meshes
  127372. */
  127373. export class IcoSphereBuilder {
  127374. /**
  127375. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  127376. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  127377. * * 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`)
  127378. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  127379. * * 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
  127380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127383. * @param name defines the name of the mesh
  127384. * @param options defines the options used to create the mesh
  127385. * @param scene defines the hosting scene
  127386. * @returns the icosahedron mesh
  127387. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127388. */
  127389. static CreateIcoSphere(name: string, options: {
  127390. radius?: number;
  127391. radiusX?: number;
  127392. radiusY?: number;
  127393. radiusZ?: number;
  127394. flat?: boolean;
  127395. subdivisions?: number;
  127396. sideOrientation?: number;
  127397. frontUVs?: Vector4;
  127398. backUVs?: Vector4;
  127399. updatable?: boolean;
  127400. }, scene?: Nullable<Scene>): Mesh;
  127401. }
  127402. }
  127403. declare module BABYLON {
  127404. /**
  127405. * Class containing static functions to help procedurally build meshes
  127406. */
  127407. export class DecalBuilder {
  127408. /**
  127409. * Creates a decal mesh.
  127410. * 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
  127411. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  127412. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  127413. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  127414. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  127415. * @param name defines the name of the mesh
  127416. * @param sourceMesh defines the mesh where the decal must be applied
  127417. * @param options defines the options used to create the mesh
  127418. * @param scene defines the hosting scene
  127419. * @returns the decal mesh
  127420. * @see https://doc.babylonjs.com/how_to/decals
  127421. */
  127422. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  127423. position?: Vector3;
  127424. normal?: Vector3;
  127425. size?: Vector3;
  127426. angle?: number;
  127427. }): Mesh;
  127428. }
  127429. }
  127430. declare module BABYLON {
  127431. /**
  127432. * Class containing static functions to help procedurally build meshes
  127433. */
  127434. export class MeshBuilder {
  127435. /**
  127436. * Creates a box mesh
  127437. * * The parameter `size` sets the size (float) of each box side (default 1)
  127438. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127439. * * 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)
  127440. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127444. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127445. * @param name defines the name of the mesh
  127446. * @param options defines the options used to create the mesh
  127447. * @param scene defines the hosting scene
  127448. * @returns the box mesh
  127449. */
  127450. static CreateBox(name: string, options: {
  127451. size?: number;
  127452. width?: number;
  127453. height?: number;
  127454. depth?: number;
  127455. faceUV?: Vector4[];
  127456. faceColors?: Color4[];
  127457. sideOrientation?: number;
  127458. frontUVs?: Vector4;
  127459. backUVs?: Vector4;
  127460. updatable?: boolean;
  127461. }, scene?: Nullable<Scene>): Mesh;
  127462. /**
  127463. * Creates a tiled box mesh
  127464. * * faceTiles sets the pattern, tile size and number of tiles for a face
  127465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127466. * @param name defines the name of the mesh
  127467. * @param options defines the options used to create the mesh
  127468. * @param scene defines the hosting scene
  127469. * @returns the tiled box mesh
  127470. */
  127471. static CreateTiledBox(name: string, options: {
  127472. pattern?: number;
  127473. size?: number;
  127474. width?: number;
  127475. height?: number;
  127476. depth: number;
  127477. tileSize?: number;
  127478. tileWidth?: number;
  127479. tileHeight?: number;
  127480. faceUV?: Vector4[];
  127481. faceColors?: Color4[];
  127482. alignHorizontal?: number;
  127483. alignVertical?: number;
  127484. sideOrientation?: number;
  127485. updatable?: boolean;
  127486. }, scene?: Nullable<Scene>): Mesh;
  127487. /**
  127488. * Creates a sphere mesh
  127489. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  127490. * * 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`)
  127491. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  127492. * * 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
  127493. * * 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)
  127494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127497. * @param name defines the name of the mesh
  127498. * @param options defines the options used to create the mesh
  127499. * @param scene defines the hosting scene
  127500. * @returns the sphere mesh
  127501. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  127502. */
  127503. static CreateSphere(name: string, options: {
  127504. segments?: number;
  127505. diameter?: number;
  127506. diameterX?: number;
  127507. diameterY?: number;
  127508. diameterZ?: number;
  127509. arc?: number;
  127510. slice?: number;
  127511. sideOrientation?: number;
  127512. frontUVs?: Vector4;
  127513. backUVs?: Vector4;
  127514. updatable?: boolean;
  127515. }, scene?: Nullable<Scene>): Mesh;
  127516. /**
  127517. * Creates a plane polygonal mesh. By default, this is a disc
  127518. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  127519. * * 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
  127520. * * 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
  127521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127524. * @param name defines the name of the mesh
  127525. * @param options defines the options used to create the mesh
  127526. * @param scene defines the hosting scene
  127527. * @returns the plane polygonal mesh
  127528. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  127529. */
  127530. static CreateDisc(name: string, options: {
  127531. radius?: number;
  127532. tessellation?: number;
  127533. arc?: number;
  127534. updatable?: boolean;
  127535. sideOrientation?: number;
  127536. frontUVs?: Vector4;
  127537. backUVs?: Vector4;
  127538. }, scene?: Nullable<Scene>): Mesh;
  127539. /**
  127540. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  127541. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  127542. * * 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`)
  127543. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  127544. * * 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
  127545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127547. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127548. * @param name defines the name of the mesh
  127549. * @param options defines the options used to create the mesh
  127550. * @param scene defines the hosting scene
  127551. * @returns the icosahedron mesh
  127552. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  127553. */
  127554. static CreateIcoSphere(name: string, options: {
  127555. radius?: number;
  127556. radiusX?: number;
  127557. radiusY?: number;
  127558. radiusZ?: number;
  127559. flat?: boolean;
  127560. subdivisions?: number;
  127561. sideOrientation?: number;
  127562. frontUVs?: Vector4;
  127563. backUVs?: Vector4;
  127564. updatable?: boolean;
  127565. }, scene?: Nullable<Scene>): Mesh;
  127566. /**
  127567. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  127568. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  127569. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  127570. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  127571. * * 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
  127572. * * 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
  127573. * * 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
  127574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127576. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127577. * * 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
  127578. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  127579. * * 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
  127580. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  127581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127582. * @param name defines the name of the mesh
  127583. * @param options defines the options used to create the mesh
  127584. * @param scene defines the hosting scene
  127585. * @returns the ribbon mesh
  127586. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  127587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127588. */
  127589. static CreateRibbon(name: string, options: {
  127590. pathArray: Vector3[][];
  127591. closeArray?: boolean;
  127592. closePath?: boolean;
  127593. offset?: number;
  127594. updatable?: boolean;
  127595. sideOrientation?: number;
  127596. frontUVs?: Vector4;
  127597. backUVs?: Vector4;
  127598. instance?: Mesh;
  127599. invertUV?: boolean;
  127600. uvs?: Vector2[];
  127601. colors?: Color4[];
  127602. }, scene?: Nullable<Scene>): Mesh;
  127603. /**
  127604. * Creates a cylinder or a cone mesh
  127605. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127606. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127607. * * 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.
  127608. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127609. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127610. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127611. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127612. * * 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).
  127613. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127614. * * 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).
  127615. * * 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
  127616. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127617. * * 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
  127618. * * 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.
  127619. * * If `enclose` is false, a ring surface is one element.
  127620. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127621. * * 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
  127622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127625. * @param name defines the name of the mesh
  127626. * @param options defines the options used to create the mesh
  127627. * @param scene defines the hosting scene
  127628. * @returns the cylinder mesh
  127629. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127630. */
  127631. static CreateCylinder(name: string, options: {
  127632. height?: number;
  127633. diameterTop?: number;
  127634. diameterBottom?: number;
  127635. diameter?: number;
  127636. tessellation?: number;
  127637. subdivisions?: number;
  127638. arc?: number;
  127639. faceColors?: Color4[];
  127640. faceUV?: Vector4[];
  127641. updatable?: boolean;
  127642. hasRings?: boolean;
  127643. enclose?: boolean;
  127644. cap?: number;
  127645. sideOrientation?: number;
  127646. frontUVs?: Vector4;
  127647. backUVs?: Vector4;
  127648. }, scene?: Nullable<Scene>): Mesh;
  127649. /**
  127650. * Creates a torus mesh
  127651. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127652. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127653. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127657. * @param name defines the name of the mesh
  127658. * @param options defines the options used to create the mesh
  127659. * @param scene defines the hosting scene
  127660. * @returns the torus mesh
  127661. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127662. */
  127663. static CreateTorus(name: string, options: {
  127664. diameter?: number;
  127665. thickness?: number;
  127666. tessellation?: number;
  127667. updatable?: boolean;
  127668. sideOrientation?: number;
  127669. frontUVs?: Vector4;
  127670. backUVs?: Vector4;
  127671. }, scene?: Nullable<Scene>): Mesh;
  127672. /**
  127673. * Creates a torus knot mesh
  127674. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  127675. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  127676. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  127677. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  127678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127679. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127681. * @param name defines the name of the mesh
  127682. * @param options defines the options used to create the mesh
  127683. * @param scene defines the hosting scene
  127684. * @returns the torus knot mesh
  127685. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  127686. */
  127687. static CreateTorusKnot(name: string, options: {
  127688. radius?: number;
  127689. tube?: number;
  127690. radialSegments?: number;
  127691. tubularSegments?: number;
  127692. p?: number;
  127693. q?: number;
  127694. updatable?: boolean;
  127695. sideOrientation?: number;
  127696. frontUVs?: Vector4;
  127697. backUVs?: Vector4;
  127698. }, scene?: Nullable<Scene>): Mesh;
  127699. /**
  127700. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  127701. * * 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
  127702. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  127703. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  127704. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  127705. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  127706. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  127707. * * 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
  127708. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  127709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  127711. * @param name defines the name of the new line system
  127712. * @param options defines the options used to create the line system
  127713. * @param scene defines the hosting scene
  127714. * @returns a new line system mesh
  127715. */
  127716. static CreateLineSystem(name: string, options: {
  127717. lines: Vector3[][];
  127718. updatable?: boolean;
  127719. instance?: Nullable<LinesMesh>;
  127720. colors?: Nullable<Color4[][]>;
  127721. useVertexAlpha?: boolean;
  127722. }, scene: Nullable<Scene>): LinesMesh;
  127723. /**
  127724. * Creates a line mesh
  127725. * 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
  127726. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127727. * * The parameter `points` is an array successive Vector3
  127728. * * 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
  127729. * * The optional parameter `colors` is an array of successive Color4, one per line point
  127730. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  127731. * * When updating an instance, remember that only point positions can change, not the number of points
  127732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  127734. * @param name defines the name of the new line system
  127735. * @param options defines the options used to create the line system
  127736. * @param scene defines the hosting scene
  127737. * @returns a new line mesh
  127738. */
  127739. static CreateLines(name: string, options: {
  127740. points: Vector3[];
  127741. updatable?: boolean;
  127742. instance?: Nullable<LinesMesh>;
  127743. colors?: Color4[];
  127744. useVertexAlpha?: boolean;
  127745. }, scene?: Nullable<Scene>): LinesMesh;
  127746. /**
  127747. * Creates a dashed line mesh
  127748. * * 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
  127749. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  127750. * * The parameter `points` is an array successive Vector3
  127751. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  127752. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  127753. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  127754. * * 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
  127755. * * When updating an instance, remember that only point positions can change, not the number of points
  127756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127757. * @param name defines the name of the mesh
  127758. * @param options defines the options used to create the mesh
  127759. * @param scene defines the hosting scene
  127760. * @returns the dashed line mesh
  127761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  127762. */
  127763. static CreateDashedLines(name: string, options: {
  127764. points: Vector3[];
  127765. dashSize?: number;
  127766. gapSize?: number;
  127767. dashNb?: number;
  127768. updatable?: boolean;
  127769. instance?: LinesMesh;
  127770. }, scene?: Nullable<Scene>): LinesMesh;
  127771. /**
  127772. * 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.
  127773. * * 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.
  127774. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127775. * * 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.
  127776. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  127777. * * 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
  127778. * * 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
  127779. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  127780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127781. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127782. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  127783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127784. * @param name defines the name of the mesh
  127785. * @param options defines the options used to create the mesh
  127786. * @param scene defines the hosting scene
  127787. * @returns the extruded shape mesh
  127788. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127789. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127790. */
  127791. static ExtrudeShape(name: string, options: {
  127792. shape: Vector3[];
  127793. path: Vector3[];
  127794. scale?: number;
  127795. rotation?: number;
  127796. cap?: number;
  127797. updatable?: boolean;
  127798. sideOrientation?: number;
  127799. frontUVs?: Vector4;
  127800. backUVs?: Vector4;
  127801. instance?: Mesh;
  127802. invertUV?: boolean;
  127803. }, scene?: Nullable<Scene>): Mesh;
  127804. /**
  127805. * Creates an custom extruded shape mesh.
  127806. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  127807. * * 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.
  127808. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  127809. * * 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
  127810. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  127811. * * 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
  127812. * * It must returns a float value that will be the scale value applied to the shape on each path point
  127813. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  127814. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  127815. * * 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
  127816. * * 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
  127817. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  127818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127820. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127822. * @param name defines the name of the mesh
  127823. * @param options defines the options used to create the mesh
  127824. * @param scene defines the hosting scene
  127825. * @returns the custom extruded shape mesh
  127826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  127827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  127828. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  127829. */
  127830. static ExtrudeShapeCustom(name: string, options: {
  127831. shape: Vector3[];
  127832. path: Vector3[];
  127833. scaleFunction?: any;
  127834. rotationFunction?: any;
  127835. ribbonCloseArray?: boolean;
  127836. ribbonClosePath?: boolean;
  127837. cap?: number;
  127838. updatable?: boolean;
  127839. sideOrientation?: number;
  127840. frontUVs?: Vector4;
  127841. backUVs?: Vector4;
  127842. instance?: Mesh;
  127843. invertUV?: boolean;
  127844. }, scene?: Nullable<Scene>): Mesh;
  127845. /**
  127846. * Creates lathe mesh.
  127847. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  127848. * * 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
  127849. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  127850. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  127851. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  127852. * * 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
  127853. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  127854. * * 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
  127855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  127858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127859. * @param name defines the name of the mesh
  127860. * @param options defines the options used to create the mesh
  127861. * @param scene defines the hosting scene
  127862. * @returns the lathe mesh
  127863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  127864. */
  127865. static CreateLathe(name: string, options: {
  127866. shape: Vector3[];
  127867. radius?: number;
  127868. tessellation?: number;
  127869. clip?: number;
  127870. arc?: number;
  127871. closed?: boolean;
  127872. updatable?: boolean;
  127873. sideOrientation?: number;
  127874. frontUVs?: Vector4;
  127875. backUVs?: Vector4;
  127876. cap?: number;
  127877. invertUV?: boolean;
  127878. }, scene?: Nullable<Scene>): Mesh;
  127879. /**
  127880. * Creates a tiled plane mesh
  127881. * * You can set a limited pattern arrangement with the tiles
  127882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127885. * @param name defines the name of the mesh
  127886. * @param options defines the options used to create the mesh
  127887. * @param scene defines the hosting scene
  127888. * @returns the plane mesh
  127889. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127890. */
  127891. static CreateTiledPlane(name: string, options: {
  127892. pattern?: number;
  127893. tileSize?: number;
  127894. tileWidth?: number;
  127895. tileHeight?: number;
  127896. size?: number;
  127897. width?: number;
  127898. height?: number;
  127899. alignHorizontal?: number;
  127900. alignVertical?: number;
  127901. sideOrientation?: number;
  127902. frontUVs?: Vector4;
  127903. backUVs?: Vector4;
  127904. updatable?: boolean;
  127905. }, scene?: Nullable<Scene>): Mesh;
  127906. /**
  127907. * Creates a plane mesh
  127908. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127909. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127910. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127914. * @param name defines the name of the mesh
  127915. * @param options defines the options used to create the mesh
  127916. * @param scene defines the hosting scene
  127917. * @returns the plane mesh
  127918. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127919. */
  127920. static CreatePlane(name: string, options: {
  127921. size?: number;
  127922. width?: number;
  127923. height?: number;
  127924. sideOrientation?: number;
  127925. frontUVs?: Vector4;
  127926. backUVs?: Vector4;
  127927. updatable?: boolean;
  127928. sourcePlane?: Plane;
  127929. }, scene?: Nullable<Scene>): Mesh;
  127930. /**
  127931. * Creates a ground mesh
  127932. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127933. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127935. * @param name defines the name of the mesh
  127936. * @param options defines the options used to create the mesh
  127937. * @param scene defines the hosting scene
  127938. * @returns the ground mesh
  127939. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127940. */
  127941. static CreateGround(name: string, options: {
  127942. width?: number;
  127943. height?: number;
  127944. subdivisions?: number;
  127945. subdivisionsX?: number;
  127946. subdivisionsY?: number;
  127947. updatable?: boolean;
  127948. }, scene?: Nullable<Scene>): Mesh;
  127949. /**
  127950. * Creates a tiled ground mesh
  127951. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127952. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127953. * * 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
  127954. * * 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
  127955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127956. * @param name defines the name of the mesh
  127957. * @param options defines the options used to create the mesh
  127958. * @param scene defines the hosting scene
  127959. * @returns the tiled ground mesh
  127960. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127961. */
  127962. static CreateTiledGround(name: string, options: {
  127963. xmin: number;
  127964. zmin: number;
  127965. xmax: number;
  127966. zmax: number;
  127967. subdivisions?: {
  127968. w: number;
  127969. h: number;
  127970. };
  127971. precision?: {
  127972. w: number;
  127973. h: number;
  127974. };
  127975. updatable?: boolean;
  127976. }, scene?: Nullable<Scene>): Mesh;
  127977. /**
  127978. * Creates a ground mesh from a height map
  127979. * * The parameter `url` sets the URL of the height map image resource.
  127980. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127981. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127982. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127983. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127984. * * 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.
  127985. * * 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).
  127986. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127988. * @param name defines the name of the mesh
  127989. * @param url defines the url to the height map
  127990. * @param options defines the options used to create the mesh
  127991. * @param scene defines the hosting scene
  127992. * @returns the ground mesh
  127993. * @see https://doc.babylonjs.com/babylon101/height_map
  127994. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127995. */
  127996. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127997. width?: number;
  127998. height?: number;
  127999. subdivisions?: number;
  128000. minHeight?: number;
  128001. maxHeight?: number;
  128002. colorFilter?: Color3;
  128003. alphaFilter?: number;
  128004. updatable?: boolean;
  128005. onReady?: (mesh: GroundMesh) => void;
  128006. }, scene?: Nullable<Scene>): GroundMesh;
  128007. /**
  128008. * Creates a polygon mesh
  128009. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  128010. * * 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
  128011. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  128012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  128014. * * Remember you can only change the shape positions, not their number when updating a polygon
  128015. * @param name defines the name of the mesh
  128016. * @param options defines the options used to create the mesh
  128017. * @param scene defines the hosting scene
  128018. * @param earcutInjection can be used to inject your own earcut reference
  128019. * @returns the polygon mesh
  128020. */
  128021. static CreatePolygon(name: string, options: {
  128022. shape: Vector3[];
  128023. holes?: Vector3[][];
  128024. depth?: number;
  128025. faceUV?: Vector4[];
  128026. faceColors?: Color4[];
  128027. updatable?: boolean;
  128028. sideOrientation?: number;
  128029. frontUVs?: Vector4;
  128030. backUVs?: Vector4;
  128031. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  128032. /**
  128033. * Creates an extruded polygon mesh, with depth in the Y direction.
  128034. * * 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)
  128035. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128036. * @param name defines the name of the mesh
  128037. * @param options defines the options used to create the mesh
  128038. * @param scene defines the hosting scene
  128039. * @param earcutInjection can be used to inject your own earcut reference
  128040. * @returns the polygon mesh
  128041. */
  128042. static ExtrudePolygon(name: string, options: {
  128043. shape: Vector3[];
  128044. holes?: Vector3[][];
  128045. depth?: number;
  128046. faceUV?: Vector4[];
  128047. faceColors?: Color4[];
  128048. updatable?: boolean;
  128049. sideOrientation?: number;
  128050. frontUVs?: Vector4;
  128051. backUVs?: Vector4;
  128052. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  128053. /**
  128054. * Creates a tube mesh.
  128055. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128056. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  128057. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  128058. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  128059. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  128060. * * 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)
  128061. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  128062. * * 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
  128063. * * 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
  128064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128068. * @param name defines the name of the mesh
  128069. * @param options defines the options used to create the mesh
  128070. * @param scene defines the hosting scene
  128071. * @returns the tube mesh
  128072. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128073. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  128074. */
  128075. static CreateTube(name: string, options: {
  128076. path: Vector3[];
  128077. radius?: number;
  128078. tessellation?: number;
  128079. radiusFunction?: {
  128080. (i: number, distance: number): number;
  128081. };
  128082. cap?: number;
  128083. arc?: number;
  128084. updatable?: boolean;
  128085. sideOrientation?: number;
  128086. frontUVs?: Vector4;
  128087. backUVs?: Vector4;
  128088. instance?: Mesh;
  128089. invertUV?: boolean;
  128090. }, scene?: Nullable<Scene>): Mesh;
  128091. /**
  128092. * Creates a polyhedron mesh
  128093. * * 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
  128094. * * The parameter `size` (positive float, default 1) sets the polygon size
  128095. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  128096. * * 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`
  128097. * * 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
  128098. * * 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)`)
  128099. * * 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
  128100. * * 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
  128101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128104. * @param name defines the name of the mesh
  128105. * @param options defines the options used to create the mesh
  128106. * @param scene defines the hosting scene
  128107. * @returns the polyhedron mesh
  128108. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  128109. */
  128110. static CreatePolyhedron(name: string, options: {
  128111. type?: number;
  128112. size?: number;
  128113. sizeX?: number;
  128114. sizeY?: number;
  128115. sizeZ?: number;
  128116. custom?: any;
  128117. faceUV?: Vector4[];
  128118. faceColors?: Color4[];
  128119. flat?: boolean;
  128120. updatable?: boolean;
  128121. sideOrientation?: number;
  128122. frontUVs?: Vector4;
  128123. backUVs?: Vector4;
  128124. }, scene?: Nullable<Scene>): Mesh;
  128125. /**
  128126. * Creates a decal mesh.
  128127. * 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
  128128. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  128129. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  128130. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  128131. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  128132. * @param name defines the name of the mesh
  128133. * @param sourceMesh defines the mesh where the decal must be applied
  128134. * @param options defines the options used to create the mesh
  128135. * @param scene defines the hosting scene
  128136. * @returns the decal mesh
  128137. * @see https://doc.babylonjs.com/how_to/decals
  128138. */
  128139. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  128140. position?: Vector3;
  128141. normal?: Vector3;
  128142. size?: Vector3;
  128143. angle?: number;
  128144. }): Mesh;
  128145. }
  128146. }
  128147. declare module BABYLON {
  128148. /**
  128149. * A simplifier interface for future simplification implementations
  128150. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128151. */
  128152. export interface ISimplifier {
  128153. /**
  128154. * Simplification of a given mesh according to the given settings.
  128155. * Since this requires computation, it is assumed that the function runs async.
  128156. * @param settings The settings of the simplification, including quality and distance
  128157. * @param successCallback A callback that will be called after the mesh was simplified.
  128158. * @param errorCallback in case of an error, this callback will be called. optional.
  128159. */
  128160. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  128161. }
  128162. /**
  128163. * Expected simplification settings.
  128164. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  128165. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128166. */
  128167. export interface ISimplificationSettings {
  128168. /**
  128169. * Gets or sets the expected quality
  128170. */
  128171. quality: number;
  128172. /**
  128173. * Gets or sets the distance when this optimized version should be used
  128174. */
  128175. distance: number;
  128176. /**
  128177. * Gets an already optimized mesh
  128178. */
  128179. optimizeMesh?: boolean;
  128180. }
  128181. /**
  128182. * Class used to specify simplification options
  128183. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128184. */
  128185. export class SimplificationSettings implements ISimplificationSettings {
  128186. /** expected quality */
  128187. quality: number;
  128188. /** distance when this optimized version should be used */
  128189. distance: number;
  128190. /** already optimized mesh */
  128191. optimizeMesh?: boolean | undefined;
  128192. /**
  128193. * Creates a SimplificationSettings
  128194. * @param quality expected quality
  128195. * @param distance distance when this optimized version should be used
  128196. * @param optimizeMesh already optimized mesh
  128197. */
  128198. constructor(
  128199. /** expected quality */
  128200. quality: number,
  128201. /** distance when this optimized version should be used */
  128202. distance: number,
  128203. /** already optimized mesh */
  128204. optimizeMesh?: boolean | undefined);
  128205. }
  128206. /**
  128207. * Interface used to define a simplification task
  128208. */
  128209. export interface ISimplificationTask {
  128210. /**
  128211. * Array of settings
  128212. */
  128213. settings: Array<ISimplificationSettings>;
  128214. /**
  128215. * Simplification type
  128216. */
  128217. simplificationType: SimplificationType;
  128218. /**
  128219. * Mesh to simplify
  128220. */
  128221. mesh: Mesh;
  128222. /**
  128223. * Callback called on success
  128224. */
  128225. successCallback?: () => void;
  128226. /**
  128227. * Defines if parallel processing can be used
  128228. */
  128229. parallelProcessing: boolean;
  128230. }
  128231. /**
  128232. * Queue used to order the simplification tasks
  128233. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128234. */
  128235. export class SimplificationQueue {
  128236. private _simplificationArray;
  128237. /**
  128238. * Gets a boolean indicating that the process is still running
  128239. */
  128240. running: boolean;
  128241. /**
  128242. * Creates a new queue
  128243. */
  128244. constructor();
  128245. /**
  128246. * Adds a new simplification task
  128247. * @param task defines a task to add
  128248. */
  128249. addTask(task: ISimplificationTask): void;
  128250. /**
  128251. * Execute next task
  128252. */
  128253. executeNext(): void;
  128254. /**
  128255. * Execute a simplification task
  128256. * @param task defines the task to run
  128257. */
  128258. runSimplification(task: ISimplificationTask): void;
  128259. private getSimplifier;
  128260. }
  128261. /**
  128262. * The implemented types of simplification
  128263. * At the moment only Quadratic Error Decimation is implemented
  128264. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128265. */
  128266. export enum SimplificationType {
  128267. /** Quadratic error decimation */
  128268. QUADRATIC = 0
  128269. }
  128270. }
  128271. declare module BABYLON {
  128272. interface Scene {
  128273. /** @hidden (Backing field) */
  128274. _simplificationQueue: SimplificationQueue;
  128275. /**
  128276. * Gets or sets the simplification queue attached to the scene
  128277. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  128278. */
  128279. simplificationQueue: SimplificationQueue;
  128280. }
  128281. interface Mesh {
  128282. /**
  128283. * Simplify the mesh according to the given array of settings.
  128284. * Function will return immediately and will simplify async
  128285. * @param settings a collection of simplification settings
  128286. * @param parallelProcessing should all levels calculate parallel or one after the other
  128287. * @param simplificationType the type of simplification to run
  128288. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  128289. * @returns the current mesh
  128290. */
  128291. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  128292. }
  128293. /**
  128294. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  128295. * created in a scene
  128296. */
  128297. export class SimplicationQueueSceneComponent implements ISceneComponent {
  128298. /**
  128299. * The component name helpfull to identify the component in the list of scene components.
  128300. */
  128301. readonly name: string;
  128302. /**
  128303. * The scene the component belongs to.
  128304. */
  128305. scene: Scene;
  128306. /**
  128307. * Creates a new instance of the component for the given scene
  128308. * @param scene Defines the scene to register the component in
  128309. */
  128310. constructor(scene: Scene);
  128311. /**
  128312. * Registers the component in a given scene
  128313. */
  128314. register(): void;
  128315. /**
  128316. * Rebuilds the elements related to this component in case of
  128317. * context lost for instance.
  128318. */
  128319. rebuild(): void;
  128320. /**
  128321. * Disposes the component and the associated ressources
  128322. */
  128323. dispose(): void;
  128324. private _beforeCameraUpdate;
  128325. }
  128326. }
  128327. declare module BABYLON {
  128328. /**
  128329. * Navigation plugin interface to add navigation constrained by a navigation mesh
  128330. */
  128331. export interface INavigationEnginePlugin {
  128332. /**
  128333. * plugin name
  128334. */
  128335. name: string;
  128336. /**
  128337. * Creates a navigation mesh
  128338. * @param meshes array of all the geometry used to compute the navigatio mesh
  128339. * @param parameters bunch of parameters used to filter geometry
  128340. */
  128341. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128342. /**
  128343. * Create a navigation mesh debug mesh
  128344. * @param scene is where the mesh will be added
  128345. * @returns debug display mesh
  128346. */
  128347. createDebugNavMesh(scene: Scene): Mesh;
  128348. /**
  128349. * Get a navigation mesh constrained position, closest to the parameter position
  128350. * @param position world position
  128351. * @returns the closest point to position constrained by the navigation mesh
  128352. */
  128353. getClosestPoint(position: Vector3): Vector3;
  128354. /**
  128355. * Get a navigation mesh constrained position, within a particular radius
  128356. * @param position world position
  128357. * @param maxRadius the maximum distance to the constrained world position
  128358. * @returns the closest point to position constrained by the navigation mesh
  128359. */
  128360. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128361. /**
  128362. * Compute the final position from a segment made of destination-position
  128363. * @param position world position
  128364. * @param destination world position
  128365. * @returns the resulting point along the navmesh
  128366. */
  128367. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128368. /**
  128369. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128370. * @param start world position
  128371. * @param end world position
  128372. * @returns array containing world position composing the path
  128373. */
  128374. computePath(start: Vector3, end: Vector3): Vector3[];
  128375. /**
  128376. * If this plugin is supported
  128377. * @returns true if plugin is supported
  128378. */
  128379. isSupported(): boolean;
  128380. /**
  128381. * Create a new Crowd so you can add agents
  128382. * @param maxAgents the maximum agent count in the crowd
  128383. * @param maxAgentRadius the maximum radius an agent can have
  128384. * @param scene to attach the crowd to
  128385. * @returns the crowd you can add agents to
  128386. */
  128387. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128388. /**
  128389. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128390. * The queries will try to find a solution within those bounds
  128391. * default is (1,1,1)
  128392. * @param extent x,y,z value that define the extent around the queries point of reference
  128393. */
  128394. setDefaultQueryExtent(extent: Vector3): void;
  128395. /**
  128396. * Get the Bounding box extent specified by setDefaultQueryExtent
  128397. * @returns the box extent values
  128398. */
  128399. getDefaultQueryExtent(): Vector3;
  128400. /**
  128401. * Release all resources
  128402. */
  128403. dispose(): void;
  128404. }
  128405. /**
  128406. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  128407. */
  128408. export interface ICrowd {
  128409. /**
  128410. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128411. * You can attach anything to that node. The node position is updated in the scene update tick.
  128412. * @param pos world position that will be constrained by the navigation mesh
  128413. * @param parameters agent parameters
  128414. * @param transform hooked to the agent that will be update by the scene
  128415. * @returns agent index
  128416. */
  128417. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128418. /**
  128419. * Returns the agent position in world space
  128420. * @param index agent index returned by addAgent
  128421. * @returns world space position
  128422. */
  128423. getAgentPosition(index: number): Vector3;
  128424. /**
  128425. * Gets the agent velocity in world space
  128426. * @param index agent index returned by addAgent
  128427. * @returns world space velocity
  128428. */
  128429. getAgentVelocity(index: number): Vector3;
  128430. /**
  128431. * remove a particular agent previously created
  128432. * @param index agent index returned by addAgent
  128433. */
  128434. removeAgent(index: number): void;
  128435. /**
  128436. * get the list of all agents attached to this crowd
  128437. * @returns list of agent indices
  128438. */
  128439. getAgents(): number[];
  128440. /**
  128441. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128442. * @param deltaTime in seconds
  128443. */
  128444. update(deltaTime: number): void;
  128445. /**
  128446. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128447. * @param index agent index returned by addAgent
  128448. * @param destination targeted world position
  128449. */
  128450. agentGoto(index: number, destination: Vector3): void;
  128451. /**
  128452. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128453. * The queries will try to find a solution within those bounds
  128454. * default is (1,1,1)
  128455. * @param extent x,y,z value that define the extent around the queries point of reference
  128456. */
  128457. setDefaultQueryExtent(extent: Vector3): void;
  128458. /**
  128459. * Get the Bounding box extent specified by setDefaultQueryExtent
  128460. * @returns the box extent values
  128461. */
  128462. getDefaultQueryExtent(): Vector3;
  128463. /**
  128464. * Release all resources
  128465. */
  128466. dispose(): void;
  128467. }
  128468. /**
  128469. * Configures an agent
  128470. */
  128471. export interface IAgentParameters {
  128472. /**
  128473. * Agent radius. [Limit: >= 0]
  128474. */
  128475. radius: number;
  128476. /**
  128477. * Agent height. [Limit: > 0]
  128478. */
  128479. height: number;
  128480. /**
  128481. * Maximum allowed acceleration. [Limit: >= 0]
  128482. */
  128483. maxAcceleration: number;
  128484. /**
  128485. * Maximum allowed speed. [Limit: >= 0]
  128486. */
  128487. maxSpeed: number;
  128488. /**
  128489. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  128490. */
  128491. collisionQueryRange: number;
  128492. /**
  128493. * The path visibility optimization range. [Limit: > 0]
  128494. */
  128495. pathOptimizationRange: number;
  128496. /**
  128497. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  128498. */
  128499. separationWeight: number;
  128500. }
  128501. /**
  128502. * Configures the navigation mesh creation
  128503. */
  128504. export interface INavMeshParameters {
  128505. /**
  128506. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  128507. */
  128508. cs: number;
  128509. /**
  128510. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  128511. */
  128512. ch: number;
  128513. /**
  128514. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  128515. */
  128516. walkableSlopeAngle: number;
  128517. /**
  128518. * Minimum floor to 'ceiling' height that will still allow the floor area to
  128519. * be considered walkable. [Limit: >= 3] [Units: vx]
  128520. */
  128521. walkableHeight: number;
  128522. /**
  128523. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  128524. */
  128525. walkableClimb: number;
  128526. /**
  128527. * The distance to erode/shrink the walkable area of the heightfield away from
  128528. * obstructions. [Limit: >=0] [Units: vx]
  128529. */
  128530. walkableRadius: number;
  128531. /**
  128532. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  128533. */
  128534. maxEdgeLen: number;
  128535. /**
  128536. * The maximum distance a simplfied contour's border edges should deviate
  128537. * the original raw contour. [Limit: >=0] [Units: vx]
  128538. */
  128539. maxSimplificationError: number;
  128540. /**
  128541. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  128542. */
  128543. minRegionArea: number;
  128544. /**
  128545. * Any regions with a span count smaller than this value will, if possible,
  128546. * be merged with larger regions. [Limit: >=0] [Units: vx]
  128547. */
  128548. mergeRegionArea: number;
  128549. /**
  128550. * The maximum number of vertices allowed for polygons generated during the
  128551. * contour to polygon conversion process. [Limit: >= 3]
  128552. */
  128553. maxVertsPerPoly: number;
  128554. /**
  128555. * Sets the sampling distance to use when generating the detail mesh.
  128556. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  128557. */
  128558. detailSampleDist: number;
  128559. /**
  128560. * The maximum distance the detail mesh surface should deviate from heightfield
  128561. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  128562. */
  128563. detailSampleMaxError: number;
  128564. }
  128565. }
  128566. declare module BABYLON {
  128567. /**
  128568. * RecastJS navigation plugin
  128569. */
  128570. export class RecastJSPlugin implements INavigationEnginePlugin {
  128571. /**
  128572. * Reference to the Recast library
  128573. */
  128574. bjsRECAST: any;
  128575. /**
  128576. * plugin name
  128577. */
  128578. name: string;
  128579. /**
  128580. * the first navmesh created. We might extend this to support multiple navmeshes
  128581. */
  128582. navMesh: any;
  128583. /**
  128584. * Initializes the recastJS plugin
  128585. * @param recastInjection can be used to inject your own recast reference
  128586. */
  128587. constructor(recastInjection?: any);
  128588. /**
  128589. * Creates a navigation mesh
  128590. * @param meshes array of all the geometry used to compute the navigatio mesh
  128591. * @param parameters bunch of parameters used to filter geometry
  128592. */
  128593. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  128594. /**
  128595. * Create a navigation mesh debug mesh
  128596. * @param scene is where the mesh will be added
  128597. * @returns debug display mesh
  128598. */
  128599. createDebugNavMesh(scene: Scene): Mesh;
  128600. /**
  128601. * Get a navigation mesh constrained position, closest to the parameter position
  128602. * @param position world position
  128603. * @returns the closest point to position constrained by the navigation mesh
  128604. */
  128605. getClosestPoint(position: Vector3): Vector3;
  128606. /**
  128607. * Get a navigation mesh constrained position, within a particular radius
  128608. * @param position world position
  128609. * @param maxRadius the maximum distance to the constrained world position
  128610. * @returns the closest point to position constrained by the navigation mesh
  128611. */
  128612. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  128613. /**
  128614. * Compute the final position from a segment made of destination-position
  128615. * @param position world position
  128616. * @param destination world position
  128617. * @returns the resulting point along the navmesh
  128618. */
  128619. moveAlong(position: Vector3, destination: Vector3): Vector3;
  128620. /**
  128621. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  128622. * @param start world position
  128623. * @param end world position
  128624. * @returns array containing world position composing the path
  128625. */
  128626. computePath(start: Vector3, end: Vector3): Vector3[];
  128627. /**
  128628. * Create a new Crowd so you can add agents
  128629. * @param maxAgents the maximum agent count in the crowd
  128630. * @param maxAgentRadius the maximum radius an agent can have
  128631. * @param scene to attach the crowd to
  128632. * @returns the crowd you can add agents to
  128633. */
  128634. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  128635. /**
  128636. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128637. * The queries will try to find a solution within those bounds
  128638. * default is (1,1,1)
  128639. * @param extent x,y,z value that define the extent around the queries point of reference
  128640. */
  128641. setDefaultQueryExtent(extent: Vector3): void;
  128642. /**
  128643. * Get the Bounding box extent specified by setDefaultQueryExtent
  128644. * @returns the box extent values
  128645. */
  128646. getDefaultQueryExtent(): Vector3;
  128647. /**
  128648. * Disposes
  128649. */
  128650. dispose(): void;
  128651. /**
  128652. * If this plugin is supported
  128653. * @returns true if plugin is supported
  128654. */
  128655. isSupported(): boolean;
  128656. }
  128657. /**
  128658. * Recast detour crowd implementation
  128659. */
  128660. export class RecastJSCrowd implements ICrowd {
  128661. /**
  128662. * Recast/detour plugin
  128663. */
  128664. bjsRECASTPlugin: RecastJSPlugin;
  128665. /**
  128666. * Link to the detour crowd
  128667. */
  128668. recastCrowd: any;
  128669. /**
  128670. * One transform per agent
  128671. */
  128672. transforms: TransformNode[];
  128673. /**
  128674. * All agents created
  128675. */
  128676. agents: number[];
  128677. /**
  128678. * Link to the scene is kept to unregister the crowd from the scene
  128679. */
  128680. private _scene;
  128681. /**
  128682. * Observer for crowd updates
  128683. */
  128684. private _onBeforeAnimationsObserver;
  128685. /**
  128686. * Constructor
  128687. * @param plugin recastJS plugin
  128688. * @param maxAgents the maximum agent count in the crowd
  128689. * @param maxAgentRadius the maximum radius an agent can have
  128690. * @param scene to attach the crowd to
  128691. * @returns the crowd you can add agents to
  128692. */
  128693. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  128694. /**
  128695. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  128696. * You can attach anything to that node. The node position is updated in the scene update tick.
  128697. * @param pos world position that will be constrained by the navigation mesh
  128698. * @param parameters agent parameters
  128699. * @param transform hooked to the agent that will be update by the scene
  128700. * @returns agent index
  128701. */
  128702. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  128703. /**
  128704. * Returns the agent position in world space
  128705. * @param index agent index returned by addAgent
  128706. * @returns world space position
  128707. */
  128708. getAgentPosition(index: number): Vector3;
  128709. /**
  128710. * Returns the agent velocity in world space
  128711. * @param index agent index returned by addAgent
  128712. * @returns world space velocity
  128713. */
  128714. getAgentVelocity(index: number): Vector3;
  128715. /**
  128716. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  128717. * @param index agent index returned by addAgent
  128718. * @param destination targeted world position
  128719. */
  128720. agentGoto(index: number, destination: Vector3): void;
  128721. /**
  128722. * remove a particular agent previously created
  128723. * @param index agent index returned by addAgent
  128724. */
  128725. removeAgent(index: number): void;
  128726. /**
  128727. * get the list of all agents attached to this crowd
  128728. * @returns list of agent indices
  128729. */
  128730. getAgents(): number[];
  128731. /**
  128732. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  128733. * @param deltaTime in seconds
  128734. */
  128735. update(deltaTime: number): void;
  128736. /**
  128737. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  128738. * The queries will try to find a solution within those bounds
  128739. * default is (1,1,1)
  128740. * @param extent x,y,z value that define the extent around the queries point of reference
  128741. */
  128742. setDefaultQueryExtent(extent: Vector3): void;
  128743. /**
  128744. * Get the Bounding box extent specified by setDefaultQueryExtent
  128745. * @returns the box extent values
  128746. */
  128747. getDefaultQueryExtent(): Vector3;
  128748. /**
  128749. * Release all resources
  128750. */
  128751. dispose(): void;
  128752. }
  128753. }
  128754. declare module BABYLON {
  128755. /**
  128756. * Class used to enable access to IndexedDB
  128757. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  128758. */
  128759. export class Database implements IOfflineProvider {
  128760. private _callbackManifestChecked;
  128761. private _currentSceneUrl;
  128762. private _db;
  128763. private _enableSceneOffline;
  128764. private _enableTexturesOffline;
  128765. private _manifestVersionFound;
  128766. private _mustUpdateRessources;
  128767. private _hasReachedQuota;
  128768. private _isSupported;
  128769. private _idbFactory;
  128770. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  128771. private static IsUASupportingBlobStorage;
  128772. /**
  128773. * Gets a boolean indicating if Database storate is enabled (off by default)
  128774. */
  128775. static IDBStorageEnabled: boolean;
  128776. /**
  128777. * Gets a boolean indicating if scene must be saved in the database
  128778. */
  128779. readonly enableSceneOffline: boolean;
  128780. /**
  128781. * Gets a boolean indicating if textures must be saved in the database
  128782. */
  128783. readonly enableTexturesOffline: boolean;
  128784. /**
  128785. * Creates a new Database
  128786. * @param urlToScene defines the url to load the scene
  128787. * @param callbackManifestChecked defines the callback to use when manifest is checked
  128788. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  128789. */
  128790. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  128791. private static _ParseURL;
  128792. private static _ReturnFullUrlLocation;
  128793. private _checkManifestFile;
  128794. /**
  128795. * Open the database and make it available
  128796. * @param successCallback defines the callback to call on success
  128797. * @param errorCallback defines the callback to call on error
  128798. */
  128799. open(successCallback: () => void, errorCallback: () => void): void;
  128800. /**
  128801. * Loads an image from the database
  128802. * @param url defines the url to load from
  128803. * @param image defines the target DOM image
  128804. */
  128805. loadImage(url: string, image: HTMLImageElement): void;
  128806. private _loadImageFromDBAsync;
  128807. private _saveImageIntoDBAsync;
  128808. private _checkVersionFromDB;
  128809. private _loadVersionFromDBAsync;
  128810. private _saveVersionIntoDBAsync;
  128811. /**
  128812. * Loads a file from database
  128813. * @param url defines the URL to load from
  128814. * @param sceneLoaded defines a callback to call on success
  128815. * @param progressCallBack defines a callback to call when progress changed
  128816. * @param errorCallback defines a callback to call on error
  128817. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  128818. */
  128819. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  128820. private _loadFileAsync;
  128821. private _saveFileAsync;
  128822. /**
  128823. * Validates if xhr data is correct
  128824. * @param xhr defines the request to validate
  128825. * @param dataType defines the expected data type
  128826. * @returns true if data is correct
  128827. */
  128828. private static _ValidateXHRData;
  128829. }
  128830. }
  128831. declare module BABYLON {
  128832. /** @hidden */
  128833. export var gpuUpdateParticlesPixelShader: {
  128834. name: string;
  128835. shader: string;
  128836. };
  128837. }
  128838. declare module BABYLON {
  128839. /** @hidden */
  128840. export var gpuUpdateParticlesVertexShader: {
  128841. name: string;
  128842. shader: string;
  128843. };
  128844. }
  128845. declare module BABYLON {
  128846. /** @hidden */
  128847. export var clipPlaneFragmentDeclaration2: {
  128848. name: string;
  128849. shader: string;
  128850. };
  128851. }
  128852. declare module BABYLON {
  128853. /** @hidden */
  128854. export var gpuRenderParticlesPixelShader: {
  128855. name: string;
  128856. shader: string;
  128857. };
  128858. }
  128859. declare module BABYLON {
  128860. /** @hidden */
  128861. export var clipPlaneVertexDeclaration2: {
  128862. name: string;
  128863. shader: string;
  128864. };
  128865. }
  128866. declare module BABYLON {
  128867. /** @hidden */
  128868. export var gpuRenderParticlesVertexShader: {
  128869. name: string;
  128870. shader: string;
  128871. };
  128872. }
  128873. declare module BABYLON {
  128874. /**
  128875. * This represents a GPU particle system in Babylon
  128876. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  128877. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  128878. */
  128879. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  128880. /**
  128881. * The layer mask we are rendering the particles through.
  128882. */
  128883. layerMask: number;
  128884. private _capacity;
  128885. private _activeCount;
  128886. private _currentActiveCount;
  128887. private _accumulatedCount;
  128888. private _renderEffect;
  128889. private _updateEffect;
  128890. private _buffer0;
  128891. private _buffer1;
  128892. private _spriteBuffer;
  128893. private _updateVAO;
  128894. private _renderVAO;
  128895. private _targetIndex;
  128896. private _sourceBuffer;
  128897. private _targetBuffer;
  128898. private _engine;
  128899. private _currentRenderId;
  128900. private _started;
  128901. private _stopped;
  128902. private _timeDelta;
  128903. private _randomTexture;
  128904. private _randomTexture2;
  128905. private _attributesStrideSize;
  128906. private _updateEffectOptions;
  128907. private _randomTextureSize;
  128908. private _actualFrame;
  128909. private readonly _rawTextureWidth;
  128910. /**
  128911. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  128912. */
  128913. static readonly IsSupported: boolean;
  128914. /**
  128915. * An event triggered when the system is disposed.
  128916. */
  128917. onDisposeObservable: Observable<GPUParticleSystem>;
  128918. /**
  128919. * Gets the maximum number of particles active at the same time.
  128920. * @returns The max number of active particles.
  128921. */
  128922. getCapacity(): number;
  128923. /**
  128924. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  128925. * to override the particles.
  128926. */
  128927. forceDepthWrite: boolean;
  128928. /**
  128929. * Gets or set the number of active particles
  128930. */
  128931. activeParticleCount: number;
  128932. private _preWarmDone;
  128933. /**
  128934. * Is this system ready to be used/rendered
  128935. * @return true if the system is ready
  128936. */
  128937. isReady(): boolean;
  128938. /**
  128939. * Gets if the system has been started. (Note: this will still be true after stop is called)
  128940. * @returns True if it has been started, otherwise false.
  128941. */
  128942. isStarted(): boolean;
  128943. /**
  128944. * Starts the particle system and begins to emit
  128945. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  128946. */
  128947. start(delay?: number): void;
  128948. /**
  128949. * Stops the particle system.
  128950. */
  128951. stop(): void;
  128952. /**
  128953. * Remove all active particles
  128954. */
  128955. reset(): void;
  128956. /**
  128957. * Returns the string "GPUParticleSystem"
  128958. * @returns a string containing the class name
  128959. */
  128960. getClassName(): string;
  128961. private _colorGradientsTexture;
  128962. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  128963. /**
  128964. * Adds a new color gradient
  128965. * @param gradient defines the gradient to use (between 0 and 1)
  128966. * @param color1 defines the color to affect to the specified gradient
  128967. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  128968. * @returns the current particle system
  128969. */
  128970. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  128971. /**
  128972. * Remove a specific color gradient
  128973. * @param gradient defines the gradient to remove
  128974. * @returns the current particle system
  128975. */
  128976. removeColorGradient(gradient: number): GPUParticleSystem;
  128977. private _angularSpeedGradientsTexture;
  128978. private _sizeGradientsTexture;
  128979. private _velocityGradientsTexture;
  128980. private _limitVelocityGradientsTexture;
  128981. private _dragGradientsTexture;
  128982. private _addFactorGradient;
  128983. /**
  128984. * Adds a new size gradient
  128985. * @param gradient defines the gradient to use (between 0 and 1)
  128986. * @param factor defines the size factor to affect to the specified gradient
  128987. * @returns the current particle system
  128988. */
  128989. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  128990. /**
  128991. * Remove a specific size gradient
  128992. * @param gradient defines the gradient to remove
  128993. * @returns the current particle system
  128994. */
  128995. removeSizeGradient(gradient: number): GPUParticleSystem;
  128996. /**
  128997. * Adds a new angular speed gradient
  128998. * @param gradient defines the gradient to use (between 0 and 1)
  128999. * @param factor defines the angular speed to affect to the specified gradient
  129000. * @returns the current particle system
  129001. */
  129002. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  129003. /**
  129004. * Remove a specific angular speed gradient
  129005. * @param gradient defines the gradient to remove
  129006. * @returns the current particle system
  129007. */
  129008. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  129009. /**
  129010. * Adds a new velocity gradient
  129011. * @param gradient defines the gradient to use (between 0 and 1)
  129012. * @param factor defines the velocity to affect to the specified gradient
  129013. * @returns the current particle system
  129014. */
  129015. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  129016. /**
  129017. * Remove a specific velocity gradient
  129018. * @param gradient defines the gradient to remove
  129019. * @returns the current particle system
  129020. */
  129021. removeVelocityGradient(gradient: number): GPUParticleSystem;
  129022. /**
  129023. * Adds a new limit velocity gradient
  129024. * @param gradient defines the gradient to use (between 0 and 1)
  129025. * @param factor defines the limit velocity value to affect to the specified gradient
  129026. * @returns the current particle system
  129027. */
  129028. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  129029. /**
  129030. * Remove a specific limit velocity gradient
  129031. * @param gradient defines the gradient to remove
  129032. * @returns the current particle system
  129033. */
  129034. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  129035. /**
  129036. * Adds a new drag gradient
  129037. * @param gradient defines the gradient to use (between 0 and 1)
  129038. * @param factor defines the drag value to affect to the specified gradient
  129039. * @returns the current particle system
  129040. */
  129041. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  129042. /**
  129043. * Remove a specific drag gradient
  129044. * @param gradient defines the gradient to remove
  129045. * @returns the current particle system
  129046. */
  129047. removeDragGradient(gradient: number): GPUParticleSystem;
  129048. /**
  129049. * Not supported by GPUParticleSystem
  129050. * @param gradient defines the gradient to use (between 0 and 1)
  129051. * @param factor defines the emit rate value to affect to the specified gradient
  129052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  129053. * @returns the current particle system
  129054. */
  129055. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  129056. /**
  129057. * Not supported by GPUParticleSystem
  129058. * @param gradient defines the gradient to remove
  129059. * @returns the current particle system
  129060. */
  129061. removeEmitRateGradient(gradient: number): IParticleSystem;
  129062. /**
  129063. * Not supported by GPUParticleSystem
  129064. * @param gradient defines the gradient to use (between 0 and 1)
  129065. * @param factor defines the start size value to affect to the specified gradient
  129066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  129067. * @returns the current particle system
  129068. */
  129069. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  129070. /**
  129071. * Not supported by GPUParticleSystem
  129072. * @param gradient defines the gradient to remove
  129073. * @returns the current particle system
  129074. */
  129075. removeStartSizeGradient(gradient: number): IParticleSystem;
  129076. /**
  129077. * Not supported by GPUParticleSystem
  129078. * @param gradient defines the gradient to use (between 0 and 1)
  129079. * @param min defines the color remap minimal range
  129080. * @param max defines the color remap maximal range
  129081. * @returns the current particle system
  129082. */
  129083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  129084. /**
  129085. * Not supported by GPUParticleSystem
  129086. * @param gradient defines the gradient to remove
  129087. * @returns the current particle system
  129088. */
  129089. removeColorRemapGradient(): IParticleSystem;
  129090. /**
  129091. * Not supported by GPUParticleSystem
  129092. * @param gradient defines the gradient to use (between 0 and 1)
  129093. * @param min defines the alpha remap minimal range
  129094. * @param max defines the alpha remap maximal range
  129095. * @returns the current particle system
  129096. */
  129097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  129098. /**
  129099. * Not supported by GPUParticleSystem
  129100. * @param gradient defines the gradient to remove
  129101. * @returns the current particle system
  129102. */
  129103. removeAlphaRemapGradient(): IParticleSystem;
  129104. /**
  129105. * Not supported by GPUParticleSystem
  129106. * @param gradient defines the gradient to use (between 0 and 1)
  129107. * @param color defines the color to affect to the specified gradient
  129108. * @returns the current particle system
  129109. */
  129110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  129111. /**
  129112. * Not supported by GPUParticleSystem
  129113. * @param gradient defines the gradient to remove
  129114. * @returns the current particle system
  129115. */
  129116. removeRampGradient(): IParticleSystem;
  129117. /**
  129118. * Not supported by GPUParticleSystem
  129119. * @returns the list of ramp gradients
  129120. */
  129121. getRampGradients(): Nullable<Array<Color3Gradient>>;
  129122. /**
  129123. * Not supported by GPUParticleSystem
  129124. * Gets or sets a boolean indicating that ramp gradients must be used
  129125. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  129126. */
  129127. useRampGradients: boolean;
  129128. /**
  129129. * Not supported by GPUParticleSystem
  129130. * @param gradient defines the gradient to use (between 0 and 1)
  129131. * @param factor defines the life time factor to affect to the specified gradient
  129132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  129133. * @returns the current particle system
  129134. */
  129135. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  129136. /**
  129137. * Not supported by GPUParticleSystem
  129138. * @param gradient defines the gradient to remove
  129139. * @returns the current particle system
  129140. */
  129141. removeLifeTimeGradient(gradient: number): IParticleSystem;
  129142. /**
  129143. * Instantiates a GPU particle system.
  129144. * 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.
  129145. * @param name The name of the particle system
  129146. * @param options The options used to create the system
  129147. * @param scene The scene the particle system belongs to
  129148. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  129149. */
  129150. constructor(name: string, options: Partial<{
  129151. capacity: number;
  129152. randomTextureSize: number;
  129153. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  129154. protected _reset(): void;
  129155. private _createUpdateVAO;
  129156. private _createRenderVAO;
  129157. private _initialize;
  129158. /** @hidden */
  129159. _recreateUpdateEffect(): void;
  129160. /** @hidden */
  129161. _recreateRenderEffect(): void;
  129162. /**
  129163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  129164. * @param preWarm defines if we are in the pre-warmimg phase
  129165. */
  129166. animate(preWarm?: boolean): void;
  129167. private _createFactorGradientTexture;
  129168. private _createSizeGradientTexture;
  129169. private _createAngularSpeedGradientTexture;
  129170. private _createVelocityGradientTexture;
  129171. private _createLimitVelocityGradientTexture;
  129172. private _createDragGradientTexture;
  129173. private _createColorGradientTexture;
  129174. /**
  129175. * Renders the particle system in its current state
  129176. * @param preWarm defines if the system should only update the particles but not render them
  129177. * @returns the current number of particles
  129178. */
  129179. render(preWarm?: boolean): number;
  129180. /**
  129181. * Rebuilds the particle system
  129182. */
  129183. rebuild(): void;
  129184. private _releaseBuffers;
  129185. private _releaseVAOs;
  129186. /**
  129187. * Disposes the particle system and free the associated resources
  129188. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  129189. */
  129190. dispose(disposeTexture?: boolean): void;
  129191. /**
  129192. * Clones the particle system.
  129193. * @param name The name of the cloned object
  129194. * @param newEmitter The new emitter to use
  129195. * @returns the cloned particle system
  129196. */
  129197. clone(name: string, newEmitter: any): GPUParticleSystem;
  129198. /**
  129199. * Serializes the particle system to a JSON object.
  129200. * @returns the JSON object
  129201. */
  129202. serialize(): any;
  129203. /**
  129204. * Parses a JSON object to create a GPU particle system.
  129205. * @param parsedParticleSystem The JSON object to parse
  129206. * @param scene The scene to create the particle system in
  129207. * @param rootUrl The root url to use to load external dependencies like texture
  129208. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  129209. * @returns the parsed GPU particle system
  129210. */
  129211. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  129212. }
  129213. }
  129214. declare module BABYLON {
  129215. /**
  129216. * Represents a set of particle systems working together to create a specific effect
  129217. */
  129218. export class ParticleSystemSet implements IDisposable {
  129219. /**
  129220. * Gets or sets base Assets URL
  129221. */
  129222. static BaseAssetsUrl: string;
  129223. private _emitterCreationOptions;
  129224. private _emitterNode;
  129225. /**
  129226. * Gets the particle system list
  129227. */
  129228. systems: IParticleSystem[];
  129229. /**
  129230. * Gets the emitter node used with this set
  129231. */
  129232. readonly emitterNode: Nullable<TransformNode>;
  129233. /**
  129234. * Creates a new emitter mesh as a sphere
  129235. * @param options defines the options used to create the sphere
  129236. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  129237. * @param scene defines the hosting scene
  129238. */
  129239. setEmitterAsSphere(options: {
  129240. diameter: number;
  129241. segments: number;
  129242. color: Color3;
  129243. }, renderingGroupId: number, scene: Scene): void;
  129244. /**
  129245. * Starts all particle systems of the set
  129246. * @param emitter defines an optional mesh to use as emitter for the particle systems
  129247. */
  129248. start(emitter?: AbstractMesh): void;
  129249. /**
  129250. * Release all associated resources
  129251. */
  129252. dispose(): void;
  129253. /**
  129254. * Serialize the set into a JSON compatible object
  129255. * @returns a JSON compatible representation of the set
  129256. */
  129257. serialize(): any;
  129258. /**
  129259. * Parse a new ParticleSystemSet from a serialized source
  129260. * @param data defines a JSON compatible representation of the set
  129261. * @param scene defines the hosting scene
  129262. * @param gpu defines if we want GPU particles or CPU particles
  129263. * @returns a new ParticleSystemSet
  129264. */
  129265. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  129266. }
  129267. }
  129268. declare module BABYLON {
  129269. /**
  129270. * This class is made for on one-liner static method to help creating particle system set.
  129271. */
  129272. export class ParticleHelper {
  129273. /**
  129274. * Gets or sets base Assets URL
  129275. */
  129276. static BaseAssetsUrl: string;
  129277. /**
  129278. * Create a default particle system that you can tweak
  129279. * @param emitter defines the emitter to use
  129280. * @param capacity defines the system capacity (default is 500 particles)
  129281. * @param scene defines the hosting scene
  129282. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  129283. * @returns the new Particle system
  129284. */
  129285. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  129286. /**
  129287. * This is the main static method (one-liner) of this helper to create different particle systems
  129288. * @param type This string represents the type to the particle system to create
  129289. * @param scene The scene where the particle system should live
  129290. * @param gpu If the system will use gpu
  129291. * @returns the ParticleSystemSet created
  129292. */
  129293. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  129294. /**
  129295. * Static function used to export a particle system to a ParticleSystemSet variable.
  129296. * Please note that the emitter shape is not exported
  129297. * @param systems defines the particle systems to export
  129298. * @returns the created particle system set
  129299. */
  129300. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  129301. }
  129302. }
  129303. declare module BABYLON {
  129304. interface Engine {
  129305. /**
  129306. * Create an effect to use with particle systems.
  129307. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  129308. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  129309. * @param uniformsNames defines a list of attribute names
  129310. * @param samplers defines an array of string used to represent textures
  129311. * @param defines defines the string containing the defines to use to compile the shaders
  129312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  129313. * @param onCompiled defines a function to call when the effect creation is successful
  129314. * @param onError defines a function to call when the effect creation has failed
  129315. * @returns the new Effect
  129316. */
  129317. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  129318. }
  129319. interface Mesh {
  129320. /**
  129321. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  129322. * @returns an array of IParticleSystem
  129323. */
  129324. getEmittedParticleSystems(): IParticleSystem[];
  129325. /**
  129326. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  129327. * @returns an array of IParticleSystem
  129328. */
  129329. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  129330. }
  129331. /**
  129332. * @hidden
  129333. */
  129334. export var _IDoNeedToBeInTheBuild: number;
  129335. }
  129336. declare module BABYLON {
  129337. /** Defines the 4 color options */
  129338. export enum PointColor {
  129339. /** color value */
  129340. Color = 2,
  129341. /** uv value */
  129342. UV = 1,
  129343. /** random value */
  129344. Random = 0,
  129345. /** stated value */
  129346. Stated = 3
  129347. }
  129348. /**
  129349. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  129350. * 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.
  129351. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  129352. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  129353. *
  129354. * Full documentation here : TO BE ENTERED
  129355. */
  129356. export class PointsCloudSystem implements IDisposable {
  129357. /**
  129358. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  129359. * Example : var p = SPS.particles[i];
  129360. */
  129361. particles: CloudPoint[];
  129362. /**
  129363. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  129364. */
  129365. nbParticles: number;
  129366. /**
  129367. * This a counter for your own usage. It's not set by any SPS functions.
  129368. */
  129369. counter: number;
  129370. /**
  129371. * The PCS name. This name is also given to the underlying mesh.
  129372. */
  129373. name: string;
  129374. /**
  129375. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  129376. */
  129377. mesh: Mesh;
  129378. /**
  129379. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  129380. * Please read :
  129381. */
  129382. vars: any;
  129383. /**
  129384. * @hidden
  129385. */
  129386. _size: number;
  129387. private _scene;
  129388. private _promises;
  129389. private _positions;
  129390. private _indices;
  129391. private _normals;
  129392. private _colors;
  129393. private _uvs;
  129394. private _indices32;
  129395. private _positions32;
  129396. private _colors32;
  129397. private _uvs32;
  129398. private _updatable;
  129399. private _isVisibilityBoxLocked;
  129400. private _alwaysVisible;
  129401. private _groups;
  129402. private _groupCounter;
  129403. private _computeParticleColor;
  129404. private _computeParticleTexture;
  129405. private _computeParticleRotation;
  129406. private _computeBoundingBox;
  129407. private _isReady;
  129408. /**
  129409. * Creates a PCS (Points Cloud System) object
  129410. * @param name (String) is the PCS name, this will be the underlying mesh name
  129411. * @param pointSize (number) is the size for each point
  129412. * @param scene (Scene) is the scene in which the PCS is added
  129413. * @param options defines the options of the PCS e.g.
  129414. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  129415. */
  129416. constructor(name: string, pointSize: number, scene: Scene, options?: {
  129417. updatable?: boolean;
  129418. });
  129419. /**
  129420. * Builds the PCS underlying mesh. Returns a standard Mesh.
  129421. * If no points were added to the PCS, the returned mesh is just a single point.
  129422. * @returns a promise for the created mesh
  129423. */
  129424. buildMeshAsync(): Promise<Mesh>;
  129425. /**
  129426. * @hidden
  129427. */
  129428. private _buildMesh;
  129429. private _addParticle;
  129430. private _randomUnitVector;
  129431. private _getColorIndicesForCoord;
  129432. private _setPointsColorOrUV;
  129433. private _colorFromTexture;
  129434. private _calculateDensity;
  129435. /**
  129436. * Adds points to the PCS in random positions within a unit sphere
  129437. * @param nb (positive integer) the number of particles to be created from this model
  129438. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  129439. * @returns the number of groups in the system
  129440. */
  129441. addPoints(nb: number, pointFunction?: any): number;
  129442. /**
  129443. * Adds points to the PCS from the surface of the model shape
  129444. * @param mesh is any Mesh object that will be used as a surface model for the points
  129445. * @param nb (positive integer) the number of particles to be created from this model
  129446. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  129447. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  129448. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  129449. * @returns the number of groups in the system
  129450. */
  129451. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  129452. /**
  129453. * Adds points to the PCS inside the model shape
  129454. * @param mesh is any Mesh object that will be used as a surface model for the points
  129455. * @param nb (positive integer) the number of particles to be created from this model
  129456. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  129457. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  129458. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  129459. * @returns the number of groups in the system
  129460. */
  129461. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  129462. /**
  129463. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  129464. * This method calls `updateParticle()` for each particle of the SPS.
  129465. * For an animated SPS, it is usually called within the render loop.
  129466. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  129467. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  129468. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  129469. * @returns the PCS.
  129470. */
  129471. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  129472. /**
  129473. * Disposes the PCS.
  129474. */
  129475. dispose(): void;
  129476. /**
  129477. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  129478. * doc :
  129479. * @returns the PCS.
  129480. */
  129481. refreshVisibleSize(): PointsCloudSystem;
  129482. /**
  129483. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  129484. * @param size the size (float) of the visibility box
  129485. * note : this doesn't lock the PCS mesh bounding box.
  129486. * doc :
  129487. */
  129488. setVisibilityBox(size: number): void;
  129489. /**
  129490. * Gets whether the PCS is always visible or not
  129491. * doc :
  129492. */
  129493. /**
  129494. * Sets the PCS as always visible or not
  129495. * doc :
  129496. */
  129497. isAlwaysVisible: boolean;
  129498. /**
  129499. * Tells to `setParticles()` to compute the particle rotations or not
  129500. * Default value : false. The PCS is faster when it's set to false
  129501. * Note : particle rotations are only applied to parent particles
  129502. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  129503. */
  129504. computeParticleRotation: boolean;
  129505. /**
  129506. * Tells to `setParticles()` to compute the particle colors or not.
  129507. * Default value : true. The PCS is faster when it's set to false.
  129508. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  129509. */
  129510. /**
  129511. * Gets if `setParticles()` computes the particle colors or not.
  129512. * Default value : false. The PCS is faster when it's set to false.
  129513. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  129514. */
  129515. computeParticleColor: boolean;
  129516. /**
  129517. * Gets if `setParticles()` computes the particle textures or not.
  129518. * Default value : false. The PCS is faster when it's set to false.
  129519. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  129520. */
  129521. computeParticleTexture: boolean;
  129522. /**
  129523. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  129524. */
  129525. /**
  129526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  129527. */
  129528. computeBoundingBox: boolean;
  129529. /**
  129530. * This function does nothing. It may be overwritten to set all the particle first values.
  129531. * The PCS doesn't call this function, you may have to call it by your own.
  129532. * doc :
  129533. */
  129534. initParticles(): void;
  129535. /**
  129536. * This function does nothing. It may be overwritten to recycle a particle
  129537. * The PCS doesn't call this function, you can to call it
  129538. * doc :
  129539. * @param particle The particle to recycle
  129540. * @returns the recycled particle
  129541. */
  129542. recycleParticle(particle: CloudPoint): CloudPoint;
  129543. /**
  129544. * Updates a particle : this function should be overwritten by the user.
  129545. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  129546. * doc :
  129547. * @example : just set a particle position or velocity and recycle conditions
  129548. * @param particle The particle to update
  129549. * @returns the updated particle
  129550. */
  129551. updateParticle(particle: CloudPoint): CloudPoint;
  129552. /**
  129553. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  129554. * This does nothing and may be overwritten by the user.
  129555. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129556. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129557. * @param update the boolean update value actually passed to setParticles()
  129558. */
  129559. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129560. /**
  129561. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  129562. * This will be passed three parameters.
  129563. * This does nothing and may be overwritten by the user.
  129564. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  129565. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  129566. * @param update the boolean update value actually passed to setParticles()
  129567. */
  129568. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  129569. }
  129570. }
  129571. declare module BABYLON {
  129572. /**
  129573. * Represents one particle of a points cloud system.
  129574. */
  129575. export class CloudPoint {
  129576. /**
  129577. * particle global index
  129578. */
  129579. idx: number;
  129580. /**
  129581. * The color of the particle
  129582. */
  129583. color: Nullable<Color4>;
  129584. /**
  129585. * The world space position of the particle.
  129586. */
  129587. position: Vector3;
  129588. /**
  129589. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  129590. */
  129591. rotation: Vector3;
  129592. /**
  129593. * The world space rotation quaternion of the particle.
  129594. */
  129595. rotationQuaternion: Nullable<Quaternion>;
  129596. /**
  129597. * The uv of the particle.
  129598. */
  129599. uv: Nullable<Vector2>;
  129600. /**
  129601. * The current speed of the particle.
  129602. */
  129603. velocity: Vector3;
  129604. /**
  129605. * The pivot point in the particle local space.
  129606. */
  129607. pivot: Vector3;
  129608. /**
  129609. * Must the particle be translated from its pivot point in its local space ?
  129610. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  129611. * Default : false
  129612. */
  129613. translateFromPivot: boolean;
  129614. /**
  129615. * Index of this particle in the global "positions" array (Internal use)
  129616. * @hidden
  129617. */
  129618. _pos: number;
  129619. /**
  129620. * @hidden Index of this particle in the global "indices" array (Internal use)
  129621. */
  129622. _ind: number;
  129623. /**
  129624. * Group this particle belongs to
  129625. */
  129626. _group: PointsGroup;
  129627. /**
  129628. * Group id of this particle
  129629. */
  129630. groupId: number;
  129631. /**
  129632. * Index of the particle in its group id (Internal use)
  129633. */
  129634. idxInGroup: number;
  129635. /**
  129636. * @hidden Particle BoundingInfo object (Internal use)
  129637. */
  129638. _boundingInfo: BoundingInfo;
  129639. /**
  129640. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  129641. */
  129642. _pcs: PointsCloudSystem;
  129643. /**
  129644. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  129645. */
  129646. _stillInvisible: boolean;
  129647. /**
  129648. * @hidden Last computed particle rotation matrix
  129649. */
  129650. _rotationMatrix: number[];
  129651. /**
  129652. * Parent particle Id, if any.
  129653. * Default null.
  129654. */
  129655. parentId: Nullable<number>;
  129656. /**
  129657. * @hidden Internal global position in the PCS.
  129658. */
  129659. _globalPosition: Vector3;
  129660. /**
  129661. * Creates a Point Cloud object.
  129662. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  129663. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  129664. * @param group (PointsGroup) is the group the particle belongs to
  129665. * @param groupId (integer) is the group identifier in the PCS.
  129666. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  129667. * @param pcs defines the PCS it is associated to
  129668. */
  129669. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  129670. /**
  129671. * get point size
  129672. */
  129673. /**
  129674. * Set point size
  129675. */
  129676. size: Vector3;
  129677. /**
  129678. * Legacy support, changed quaternion to rotationQuaternion
  129679. */
  129680. /**
  129681. * Legacy support, changed quaternion to rotationQuaternion
  129682. */
  129683. quaternion: Nullable<Quaternion>;
  129684. /**
  129685. * Returns a boolean. True if the particle intersects a mesh, else false
  129686. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  129687. * @param target is the object (point or mesh) what the intersection is computed against
  129688. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  129689. * @returns true if it intersects
  129690. */
  129691. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  129692. /**
  129693. * get the rotation matrix of the particle
  129694. * @hidden
  129695. */
  129696. getRotationMatrix(m: Matrix): void;
  129697. }
  129698. /**
  129699. * Represents a group of points in a points cloud system
  129700. * * PCS internal tool, don't use it manually.
  129701. */
  129702. export class PointsGroup {
  129703. /**
  129704. * The group id
  129705. * @hidden
  129706. */
  129707. groupID: number;
  129708. /**
  129709. * image data for group (internal use)
  129710. * @hidden
  129711. */
  129712. _groupImageData: Nullable<ArrayBufferView>;
  129713. /**
  129714. * Image Width (internal use)
  129715. * @hidden
  129716. */
  129717. _groupImgWidth: number;
  129718. /**
  129719. * Image Height (internal use)
  129720. * @hidden
  129721. */
  129722. _groupImgHeight: number;
  129723. /**
  129724. * Custom position function (internal use)
  129725. * @hidden
  129726. */
  129727. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  129728. /**
  129729. * density per facet for surface points
  129730. * @hidden
  129731. */
  129732. _groupDensity: number[];
  129733. /**
  129734. * Only when points are colored by texture carries pointer to texture list array
  129735. * @hidden
  129736. */
  129737. _textureNb: number;
  129738. /**
  129739. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  129740. * PCS internal tool, don't use it manually.
  129741. * @hidden
  129742. */
  129743. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  129744. }
  129745. }
  129746. declare module BABYLON {
  129747. interface Scene {
  129748. /** @hidden (Backing field) */
  129749. _physicsEngine: Nullable<IPhysicsEngine>;
  129750. /** @hidden */
  129751. _physicsTimeAccumulator: number;
  129752. /**
  129753. * Gets the current physics engine
  129754. * @returns a IPhysicsEngine or null if none attached
  129755. */
  129756. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  129757. /**
  129758. * Enables physics to the current scene
  129759. * @param gravity defines the scene's gravity for the physics engine
  129760. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  129761. * @return a boolean indicating if the physics engine was initialized
  129762. */
  129763. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  129764. /**
  129765. * Disables and disposes the physics engine associated with the scene
  129766. */
  129767. disablePhysicsEngine(): void;
  129768. /**
  129769. * Gets a boolean indicating if there is an active physics engine
  129770. * @returns a boolean indicating if there is an active physics engine
  129771. */
  129772. isPhysicsEnabled(): boolean;
  129773. /**
  129774. * Deletes a physics compound impostor
  129775. * @param compound defines the compound to delete
  129776. */
  129777. deleteCompoundImpostor(compound: any): void;
  129778. /**
  129779. * An event triggered when physic simulation is about to be run
  129780. */
  129781. onBeforePhysicsObservable: Observable<Scene>;
  129782. /**
  129783. * An event triggered when physic simulation has been done
  129784. */
  129785. onAfterPhysicsObservable: Observable<Scene>;
  129786. }
  129787. interface AbstractMesh {
  129788. /** @hidden */
  129789. _physicsImpostor: Nullable<PhysicsImpostor>;
  129790. /**
  129791. * Gets or sets impostor used for physic simulation
  129792. * @see http://doc.babylonjs.com/features/physics_engine
  129793. */
  129794. physicsImpostor: Nullable<PhysicsImpostor>;
  129795. /**
  129796. * Gets the current physics impostor
  129797. * @see http://doc.babylonjs.com/features/physics_engine
  129798. * @returns a physics impostor or null
  129799. */
  129800. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  129801. /** Apply a physic impulse to the mesh
  129802. * @param force defines the force to apply
  129803. * @param contactPoint defines where to apply the force
  129804. * @returns the current mesh
  129805. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129806. */
  129807. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  129808. /**
  129809. * Creates a physic joint between two meshes
  129810. * @param otherMesh defines the other mesh to use
  129811. * @param pivot1 defines the pivot to use on this mesh
  129812. * @param pivot2 defines the pivot to use on the other mesh
  129813. * @param options defines additional options (can be plugin dependent)
  129814. * @returns the current mesh
  129815. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  129816. */
  129817. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  129818. /** @hidden */
  129819. _disposePhysicsObserver: Nullable<Observer<Node>>;
  129820. }
  129821. /**
  129822. * Defines the physics engine scene component responsible to manage a physics engine
  129823. */
  129824. export class PhysicsEngineSceneComponent implements ISceneComponent {
  129825. /**
  129826. * The component name helpful to identify the component in the list of scene components.
  129827. */
  129828. readonly name: string;
  129829. /**
  129830. * The scene the component belongs to.
  129831. */
  129832. scene: Scene;
  129833. /**
  129834. * Creates a new instance of the component for the given scene
  129835. * @param scene Defines the scene to register the component in
  129836. */
  129837. constructor(scene: Scene);
  129838. /**
  129839. * Registers the component in a given scene
  129840. */
  129841. register(): void;
  129842. /**
  129843. * Rebuilds the elements related to this component in case of
  129844. * context lost for instance.
  129845. */
  129846. rebuild(): void;
  129847. /**
  129848. * Disposes the component and the associated ressources
  129849. */
  129850. dispose(): void;
  129851. }
  129852. }
  129853. declare module BABYLON {
  129854. /**
  129855. * A helper for physics simulations
  129856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  129857. */
  129858. export class PhysicsHelper {
  129859. private _scene;
  129860. private _physicsEngine;
  129861. /**
  129862. * Initializes the Physics helper
  129863. * @param scene Babylon.js scene
  129864. */
  129865. constructor(scene: Scene);
  129866. /**
  129867. * Applies a radial explosion impulse
  129868. * @param origin the origin of the explosion
  129869. * @param radiusOrEventOptions the radius or the options of radial explosion
  129870. * @param strength the explosion strength
  129871. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129872. * @returns A physics radial explosion event, or null
  129873. */
  129874. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129875. /**
  129876. * Applies a radial explosion force
  129877. * @param origin the origin of the explosion
  129878. * @param radiusOrEventOptions the radius or the options of radial explosion
  129879. * @param strength the explosion strength
  129880. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129881. * @returns A physics radial explosion event, or null
  129882. */
  129883. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  129884. /**
  129885. * Creates a gravitational field
  129886. * @param origin the origin of the explosion
  129887. * @param radiusOrEventOptions the radius or the options of radial explosion
  129888. * @param strength the explosion strength
  129889. * @param falloff possible options: Constant & Linear. Defaults to Constant
  129890. * @returns A physics gravitational field event, or null
  129891. */
  129892. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  129893. /**
  129894. * Creates a physics updraft event
  129895. * @param origin the origin of the updraft
  129896. * @param radiusOrEventOptions the radius or the options of the updraft
  129897. * @param strength the strength of the updraft
  129898. * @param height the height of the updraft
  129899. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  129900. * @returns A physics updraft event, or null
  129901. */
  129902. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  129903. /**
  129904. * Creates a physics vortex event
  129905. * @param origin the of the vortex
  129906. * @param radiusOrEventOptions the radius or the options of the vortex
  129907. * @param strength the strength of the vortex
  129908. * @param height the height of the vortex
  129909. * @returns a Physics vortex event, or null
  129910. * A physics vortex event or null
  129911. */
  129912. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  129913. }
  129914. /**
  129915. * Represents a physics radial explosion event
  129916. */
  129917. class PhysicsRadialExplosionEvent {
  129918. private _scene;
  129919. private _options;
  129920. private _sphere;
  129921. private _dataFetched;
  129922. /**
  129923. * Initializes a radial explosioin event
  129924. * @param _scene BabylonJS scene
  129925. * @param _options The options for the vortex event
  129926. */
  129927. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  129928. /**
  129929. * Returns the data related to the radial explosion event (sphere).
  129930. * @returns The radial explosion event data
  129931. */
  129932. getData(): PhysicsRadialExplosionEventData;
  129933. /**
  129934. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  129935. * @param impostor A physics imposter
  129936. * @param origin the origin of the explosion
  129937. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  129938. */
  129939. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  129940. /**
  129941. * Triggers affecterd impostors callbacks
  129942. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  129943. */
  129944. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  129945. /**
  129946. * Disposes the sphere.
  129947. * @param force Specifies if the sphere should be disposed by force
  129948. */
  129949. dispose(force?: boolean): void;
  129950. /*** Helpers ***/
  129951. private _prepareSphere;
  129952. private _intersectsWithSphere;
  129953. }
  129954. /**
  129955. * Represents a gravitational field event
  129956. */
  129957. class PhysicsGravitationalFieldEvent {
  129958. private _physicsHelper;
  129959. private _scene;
  129960. private _origin;
  129961. private _options;
  129962. private _tickCallback;
  129963. private _sphere;
  129964. private _dataFetched;
  129965. /**
  129966. * Initializes the physics gravitational field event
  129967. * @param _physicsHelper A physics helper
  129968. * @param _scene BabylonJS scene
  129969. * @param _origin The origin position of the gravitational field event
  129970. * @param _options The options for the vortex event
  129971. */
  129972. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  129973. /**
  129974. * Returns the data related to the gravitational field event (sphere).
  129975. * @returns A gravitational field event
  129976. */
  129977. getData(): PhysicsGravitationalFieldEventData;
  129978. /**
  129979. * Enables the gravitational field.
  129980. */
  129981. enable(): void;
  129982. /**
  129983. * Disables the gravitational field.
  129984. */
  129985. disable(): void;
  129986. /**
  129987. * Disposes the sphere.
  129988. * @param force The force to dispose from the gravitational field event
  129989. */
  129990. dispose(force?: boolean): void;
  129991. private _tick;
  129992. }
  129993. /**
  129994. * Represents a physics updraft event
  129995. */
  129996. class PhysicsUpdraftEvent {
  129997. private _scene;
  129998. private _origin;
  129999. private _options;
  130000. private _physicsEngine;
  130001. private _originTop;
  130002. private _originDirection;
  130003. private _tickCallback;
  130004. private _cylinder;
  130005. private _cylinderPosition;
  130006. private _dataFetched;
  130007. /**
  130008. * Initializes the physics updraft event
  130009. * @param _scene BabylonJS scene
  130010. * @param _origin The origin position of the updraft
  130011. * @param _options The options for the updraft event
  130012. */
  130013. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  130014. /**
  130015. * Returns the data related to the updraft event (cylinder).
  130016. * @returns A physics updraft event
  130017. */
  130018. getData(): PhysicsUpdraftEventData;
  130019. /**
  130020. * Enables the updraft.
  130021. */
  130022. enable(): void;
  130023. /**
  130024. * Disables the updraft.
  130025. */
  130026. disable(): void;
  130027. /**
  130028. * Disposes the cylinder.
  130029. * @param force Specifies if the updraft should be disposed by force
  130030. */
  130031. dispose(force?: boolean): void;
  130032. private getImpostorHitData;
  130033. private _tick;
  130034. /*** Helpers ***/
  130035. private _prepareCylinder;
  130036. private _intersectsWithCylinder;
  130037. }
  130038. /**
  130039. * Represents a physics vortex event
  130040. */
  130041. class PhysicsVortexEvent {
  130042. private _scene;
  130043. private _origin;
  130044. private _options;
  130045. private _physicsEngine;
  130046. private _originTop;
  130047. private _tickCallback;
  130048. private _cylinder;
  130049. private _cylinderPosition;
  130050. private _dataFetched;
  130051. /**
  130052. * Initializes the physics vortex event
  130053. * @param _scene The BabylonJS scene
  130054. * @param _origin The origin position of the vortex
  130055. * @param _options The options for the vortex event
  130056. */
  130057. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  130058. /**
  130059. * Returns the data related to the vortex event (cylinder).
  130060. * @returns The physics vortex event data
  130061. */
  130062. getData(): PhysicsVortexEventData;
  130063. /**
  130064. * Enables the vortex.
  130065. */
  130066. enable(): void;
  130067. /**
  130068. * Disables the cortex.
  130069. */
  130070. disable(): void;
  130071. /**
  130072. * Disposes the sphere.
  130073. * @param force
  130074. */
  130075. dispose(force?: boolean): void;
  130076. private getImpostorHitData;
  130077. private _tick;
  130078. /*** Helpers ***/
  130079. private _prepareCylinder;
  130080. private _intersectsWithCylinder;
  130081. }
  130082. /**
  130083. * Options fot the radial explosion event
  130084. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130085. */
  130086. export class PhysicsRadialExplosionEventOptions {
  130087. /**
  130088. * The radius of the sphere for the radial explosion.
  130089. */
  130090. radius: number;
  130091. /**
  130092. * The strenth of the explosion.
  130093. */
  130094. strength: number;
  130095. /**
  130096. * The strenght of the force in correspondence to the distance of the affected object
  130097. */
  130098. falloff: PhysicsRadialImpulseFalloff;
  130099. /**
  130100. * Sphere options for the radial explosion.
  130101. */
  130102. sphere: {
  130103. segments: number;
  130104. diameter: number;
  130105. };
  130106. /**
  130107. * Sphere options for the radial explosion.
  130108. */
  130109. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  130110. }
  130111. /**
  130112. * Options fot the updraft event
  130113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130114. */
  130115. export class PhysicsUpdraftEventOptions {
  130116. /**
  130117. * The radius of the cylinder for the vortex
  130118. */
  130119. radius: number;
  130120. /**
  130121. * The strenth of the updraft.
  130122. */
  130123. strength: number;
  130124. /**
  130125. * The height of the cylinder for the updraft.
  130126. */
  130127. height: number;
  130128. /**
  130129. * The mode for the the updraft.
  130130. */
  130131. updraftMode: PhysicsUpdraftMode;
  130132. }
  130133. /**
  130134. * Options fot the vortex event
  130135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130136. */
  130137. export class PhysicsVortexEventOptions {
  130138. /**
  130139. * The radius of the cylinder for the vortex
  130140. */
  130141. radius: number;
  130142. /**
  130143. * The strenth of the vortex.
  130144. */
  130145. strength: number;
  130146. /**
  130147. * The height of the cylinder for the vortex.
  130148. */
  130149. height: number;
  130150. /**
  130151. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  130152. */
  130153. centripetalForceThreshold: number;
  130154. /**
  130155. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  130156. */
  130157. centripetalForceMultiplier: number;
  130158. /**
  130159. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  130160. */
  130161. centrifugalForceMultiplier: number;
  130162. /**
  130163. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  130164. */
  130165. updraftForceMultiplier: number;
  130166. }
  130167. /**
  130168. * The strenght of the force in correspondence to the distance of the affected object
  130169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130170. */
  130171. export enum PhysicsRadialImpulseFalloff {
  130172. /** Defines that impulse is constant in strength across it's whole radius */
  130173. Constant = 0,
  130174. /** Defines that impulse gets weaker if it's further from the origin */
  130175. Linear = 1
  130176. }
  130177. /**
  130178. * The strength of the force in correspondence to the distance of the affected object
  130179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130180. */
  130181. export enum PhysicsUpdraftMode {
  130182. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  130183. Center = 0,
  130184. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  130185. Perpendicular = 1
  130186. }
  130187. /**
  130188. * Interface for a physics hit data
  130189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130190. */
  130191. export interface PhysicsHitData {
  130192. /**
  130193. * The force applied at the contact point
  130194. */
  130195. force: Vector3;
  130196. /**
  130197. * The contact point
  130198. */
  130199. contactPoint: Vector3;
  130200. /**
  130201. * The distance from the origin to the contact point
  130202. */
  130203. distanceFromOrigin: number;
  130204. }
  130205. /**
  130206. * Interface for radial explosion event data
  130207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130208. */
  130209. export interface PhysicsRadialExplosionEventData {
  130210. /**
  130211. * A sphere used for the radial explosion event
  130212. */
  130213. sphere: Mesh;
  130214. }
  130215. /**
  130216. * Interface for gravitational field event data
  130217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130218. */
  130219. export interface PhysicsGravitationalFieldEventData {
  130220. /**
  130221. * A sphere mesh used for the gravitational field event
  130222. */
  130223. sphere: Mesh;
  130224. }
  130225. /**
  130226. * Interface for updraft event data
  130227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130228. */
  130229. export interface PhysicsUpdraftEventData {
  130230. /**
  130231. * A cylinder used for the updraft event
  130232. */
  130233. cylinder: Mesh;
  130234. }
  130235. /**
  130236. * Interface for vortex event data
  130237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130238. */
  130239. export interface PhysicsVortexEventData {
  130240. /**
  130241. * A cylinder used for the vortex event
  130242. */
  130243. cylinder: Mesh;
  130244. }
  130245. /**
  130246. * Interface for an affected physics impostor
  130247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  130248. */
  130249. export interface PhysicsAffectedImpostorWithData {
  130250. /**
  130251. * The impostor affected by the effect
  130252. */
  130253. impostor: PhysicsImpostor;
  130254. /**
  130255. * The data about the hit/horce from the explosion
  130256. */
  130257. hitData: PhysicsHitData;
  130258. }
  130259. }
  130260. declare module BABYLON {
  130261. /** @hidden */
  130262. export var blackAndWhitePixelShader: {
  130263. name: string;
  130264. shader: string;
  130265. };
  130266. }
  130267. declare module BABYLON {
  130268. /**
  130269. * Post process used to render in black and white
  130270. */
  130271. export class BlackAndWhitePostProcess extends PostProcess {
  130272. /**
  130273. * Linear about to convert he result to black and white (default: 1)
  130274. */
  130275. degree: number;
  130276. /**
  130277. * Creates a black and white post process
  130278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  130279. * @param name The name of the effect.
  130280. * @param options The required width/height ratio to downsize to before computing the render pass.
  130281. * @param camera The camera to apply the render pass to.
  130282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130283. * @param engine The engine which the post process will be applied. (default: current engine)
  130284. * @param reusable If the post process can be reused on the same frame. (default: false)
  130285. */
  130286. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130287. }
  130288. }
  130289. declare module BABYLON {
  130290. /**
  130291. * This represents a set of one or more post processes in Babylon.
  130292. * A post process can be used to apply a shader to a texture after it is rendered.
  130293. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  130294. */
  130295. export class PostProcessRenderEffect {
  130296. private _postProcesses;
  130297. private _getPostProcesses;
  130298. private _singleInstance;
  130299. private _cameras;
  130300. private _indicesForCamera;
  130301. /**
  130302. * Name of the effect
  130303. * @hidden
  130304. */
  130305. _name: string;
  130306. /**
  130307. * Instantiates a post process render effect.
  130308. * A post process can be used to apply a shader to a texture after it is rendered.
  130309. * @param engine The engine the effect is tied to
  130310. * @param name The name of the effect
  130311. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  130312. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  130313. */
  130314. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  130315. /**
  130316. * Checks if all the post processes in the effect are supported.
  130317. */
  130318. readonly isSupported: boolean;
  130319. /**
  130320. * Updates the current state of the effect
  130321. * @hidden
  130322. */
  130323. _update(): void;
  130324. /**
  130325. * Attaches the effect on cameras
  130326. * @param cameras The camera to attach to.
  130327. * @hidden
  130328. */
  130329. _attachCameras(cameras: Camera): void;
  130330. /**
  130331. * Attaches the effect on cameras
  130332. * @param cameras The camera to attach to.
  130333. * @hidden
  130334. */
  130335. _attachCameras(cameras: Camera[]): void;
  130336. /**
  130337. * Detaches the effect on cameras
  130338. * @param cameras The camera to detatch from.
  130339. * @hidden
  130340. */
  130341. _detachCameras(cameras: Camera): void;
  130342. /**
  130343. * Detatches the effect on cameras
  130344. * @param cameras The camera to detatch from.
  130345. * @hidden
  130346. */
  130347. _detachCameras(cameras: Camera[]): void;
  130348. /**
  130349. * Enables the effect on given cameras
  130350. * @param cameras The camera to enable.
  130351. * @hidden
  130352. */
  130353. _enable(cameras: Camera): void;
  130354. /**
  130355. * Enables the effect on given cameras
  130356. * @param cameras The camera to enable.
  130357. * @hidden
  130358. */
  130359. _enable(cameras: Nullable<Camera[]>): void;
  130360. /**
  130361. * Disables the effect on the given cameras
  130362. * @param cameras The camera to disable.
  130363. * @hidden
  130364. */
  130365. _disable(cameras: Camera): void;
  130366. /**
  130367. * Disables the effect on the given cameras
  130368. * @param cameras The camera to disable.
  130369. * @hidden
  130370. */
  130371. _disable(cameras: Nullable<Camera[]>): void;
  130372. /**
  130373. * Gets a list of the post processes contained in the effect.
  130374. * @param camera The camera to get the post processes on.
  130375. * @returns The list of the post processes in the effect.
  130376. */
  130377. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  130378. }
  130379. }
  130380. declare module BABYLON {
  130381. /** @hidden */
  130382. export var extractHighlightsPixelShader: {
  130383. name: string;
  130384. shader: string;
  130385. };
  130386. }
  130387. declare module BABYLON {
  130388. /**
  130389. * 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.
  130390. */
  130391. export class ExtractHighlightsPostProcess extends PostProcess {
  130392. /**
  130393. * The luminance threshold, pixels below this value will be set to black.
  130394. */
  130395. threshold: number;
  130396. /** @hidden */
  130397. _exposure: number;
  130398. /**
  130399. * Post process which has the input texture to be used when performing highlight extraction
  130400. * @hidden
  130401. */
  130402. _inputPostProcess: Nullable<PostProcess>;
  130403. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130404. }
  130405. }
  130406. declare module BABYLON {
  130407. /** @hidden */
  130408. export var bloomMergePixelShader: {
  130409. name: string;
  130410. shader: string;
  130411. };
  130412. }
  130413. declare module BABYLON {
  130414. /**
  130415. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130416. */
  130417. export class BloomMergePostProcess extends PostProcess {
  130418. /** Weight of the bloom to be added to the original input. */
  130419. weight: number;
  130420. /**
  130421. * Creates a new instance of @see BloomMergePostProcess
  130422. * @param name The name of the effect.
  130423. * @param originalFromInput Post process which's input will be used for the merge.
  130424. * @param blurred Blurred highlights post process which's output will be used.
  130425. * @param weight Weight of the bloom to be added to the original input.
  130426. * @param options The required width/height ratio to downsize to before computing the render pass.
  130427. * @param camera The camera to apply the render pass to.
  130428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130429. * @param engine The engine which the post process will be applied. (default: current engine)
  130430. * @param reusable If the post process can be reused on the same frame. (default: false)
  130431. * @param textureType Type of textures used when performing the post process. (default: 0)
  130432. * @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)
  130433. */
  130434. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  130435. /** Weight of the bloom to be added to the original input. */
  130436. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130437. }
  130438. }
  130439. declare module BABYLON {
  130440. /**
  130441. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  130442. */
  130443. export class BloomEffect extends PostProcessRenderEffect {
  130444. private bloomScale;
  130445. /**
  130446. * @hidden Internal
  130447. */
  130448. _effects: Array<PostProcess>;
  130449. /**
  130450. * @hidden Internal
  130451. */
  130452. _downscale: ExtractHighlightsPostProcess;
  130453. private _blurX;
  130454. private _blurY;
  130455. private _merge;
  130456. /**
  130457. * The luminance threshold to find bright areas of the image to bloom.
  130458. */
  130459. threshold: number;
  130460. /**
  130461. * The strength of the bloom.
  130462. */
  130463. weight: number;
  130464. /**
  130465. * Specifies the size of the bloom blur kernel, relative to the final output size
  130466. */
  130467. kernel: number;
  130468. /**
  130469. * Creates a new instance of @see BloomEffect
  130470. * @param scene The scene the effect belongs to.
  130471. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  130472. * @param bloomKernel The size of the kernel to be used when applying the blur.
  130473. * @param bloomWeight The the strength of bloom.
  130474. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130475. * @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)
  130476. */
  130477. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  130478. /**
  130479. * Disposes each of the internal effects for a given camera.
  130480. * @param camera The camera to dispose the effect on.
  130481. */
  130482. disposeEffects(camera: Camera): void;
  130483. /**
  130484. * @hidden Internal
  130485. */
  130486. _updateEffects(): void;
  130487. /**
  130488. * Internal
  130489. * @returns if all the contained post processes are ready.
  130490. * @hidden
  130491. */
  130492. _isReady(): boolean;
  130493. }
  130494. }
  130495. declare module BABYLON {
  130496. /** @hidden */
  130497. export var chromaticAberrationPixelShader: {
  130498. name: string;
  130499. shader: string;
  130500. };
  130501. }
  130502. declare module BABYLON {
  130503. /**
  130504. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  130505. */
  130506. export class ChromaticAberrationPostProcess extends PostProcess {
  130507. /**
  130508. * The amount of seperation of rgb channels (default: 30)
  130509. */
  130510. aberrationAmount: number;
  130511. /**
  130512. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  130513. */
  130514. radialIntensity: number;
  130515. /**
  130516. * 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))
  130517. */
  130518. direction: Vector2;
  130519. /**
  130520. * 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))
  130521. */
  130522. centerPosition: Vector2;
  130523. /**
  130524. * Creates a new instance ChromaticAberrationPostProcess
  130525. * @param name The name of the effect.
  130526. * @param screenWidth The width of the screen to apply the effect on.
  130527. * @param screenHeight The height of the screen to apply the effect on.
  130528. * @param options The required width/height ratio to downsize to before computing the render pass.
  130529. * @param camera The camera to apply the render pass to.
  130530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130531. * @param engine The engine which the post process will be applied. (default: current engine)
  130532. * @param reusable If the post process can be reused on the same frame. (default: false)
  130533. * @param textureType Type of textures used when performing the post process. (default: 0)
  130534. * @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)
  130535. */
  130536. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130537. }
  130538. }
  130539. declare module BABYLON {
  130540. /** @hidden */
  130541. export var circleOfConfusionPixelShader: {
  130542. name: string;
  130543. shader: string;
  130544. };
  130545. }
  130546. declare module BABYLON {
  130547. /**
  130548. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  130549. */
  130550. export class CircleOfConfusionPostProcess extends PostProcess {
  130551. /**
  130552. * 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.
  130553. */
  130554. lensSize: number;
  130555. /**
  130556. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130557. */
  130558. fStop: number;
  130559. /**
  130560. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130561. */
  130562. focusDistance: number;
  130563. /**
  130564. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  130565. */
  130566. focalLength: number;
  130567. private _depthTexture;
  130568. /**
  130569. * Creates a new instance CircleOfConfusionPostProcess
  130570. * @param name The name of the effect.
  130571. * @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.
  130572. * @param options The required width/height ratio to downsize to before computing the render pass.
  130573. * @param camera The camera to apply the render pass to.
  130574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130575. * @param engine The engine which the post process will be applied. (default: current engine)
  130576. * @param reusable If the post process can be reused on the same frame. (default: false)
  130577. * @param textureType Type of textures used when performing the post process. (default: 0)
  130578. * @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)
  130579. */
  130580. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130581. /**
  130582. * 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.
  130583. */
  130584. depthTexture: RenderTargetTexture;
  130585. }
  130586. }
  130587. declare module BABYLON {
  130588. /** @hidden */
  130589. export var colorCorrectionPixelShader: {
  130590. name: string;
  130591. shader: string;
  130592. };
  130593. }
  130594. declare module BABYLON {
  130595. /**
  130596. *
  130597. * This post-process allows the modification of rendered colors by using
  130598. * a 'look-up table' (LUT). This effect is also called Color Grading.
  130599. *
  130600. * The object needs to be provided an url to a texture containing the color
  130601. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  130602. * Use an image editing software to tweak the LUT to match your needs.
  130603. *
  130604. * For an example of a color LUT, see here:
  130605. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  130606. * For explanations on color grading, see here:
  130607. * @see http://udn.epicgames.com/Three/ColorGrading.html
  130608. *
  130609. */
  130610. export class ColorCorrectionPostProcess extends PostProcess {
  130611. private _colorTableTexture;
  130612. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130613. }
  130614. }
  130615. declare module BABYLON {
  130616. /** @hidden */
  130617. export var convolutionPixelShader: {
  130618. name: string;
  130619. shader: string;
  130620. };
  130621. }
  130622. declare module BABYLON {
  130623. /**
  130624. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  130625. * input texture to perform effects such as edge detection or sharpening
  130626. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  130627. */
  130628. export class ConvolutionPostProcess extends PostProcess {
  130629. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130630. kernel: number[];
  130631. /**
  130632. * Creates a new instance ConvolutionPostProcess
  130633. * @param name The name of the effect.
  130634. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  130635. * @param options The required width/height ratio to downsize to before computing the render pass.
  130636. * @param camera The camera to apply the render pass to.
  130637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130638. * @param engine The engine which the post process will be applied. (default: current engine)
  130639. * @param reusable If the post process can be reused on the same frame. (default: false)
  130640. * @param textureType Type of textures used when performing the post process. (default: 0)
  130641. */
  130642. constructor(name: string,
  130643. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  130644. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130645. /**
  130646. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130647. */
  130648. static EdgeDetect0Kernel: number[];
  130649. /**
  130650. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130651. */
  130652. static EdgeDetect1Kernel: number[];
  130653. /**
  130654. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130655. */
  130656. static EdgeDetect2Kernel: number[];
  130657. /**
  130658. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130659. */
  130660. static SharpenKernel: number[];
  130661. /**
  130662. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130663. */
  130664. static EmbossKernel: number[];
  130665. /**
  130666. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  130667. */
  130668. static GaussianKernel: number[];
  130669. }
  130670. }
  130671. declare module BABYLON {
  130672. /**
  130673. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  130674. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  130675. * based on samples that have a large difference in distance than the center pixel.
  130676. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  130677. */
  130678. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  130679. direction: Vector2;
  130680. /**
  130681. * Creates a new instance CircleOfConfusionPostProcess
  130682. * @param name The name of the effect.
  130683. * @param scene The scene the effect belongs to.
  130684. * @param direction The direction the blur should be applied.
  130685. * @param kernel The size of the kernel used to blur.
  130686. * @param options The required width/height ratio to downsize to before computing the render pass.
  130687. * @param camera The camera to apply the render pass to.
  130688. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  130689. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  130690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130691. * @param engine The engine which the post process will be applied. (default: current engine)
  130692. * @param reusable If the post process can be reused on the same frame. (default: false)
  130693. * @param textureType Type of textures used when performing the post process. (default: 0)
  130694. * @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)
  130695. */
  130696. 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);
  130697. }
  130698. }
  130699. declare module BABYLON {
  130700. /** @hidden */
  130701. export var depthOfFieldMergePixelShader: {
  130702. name: string;
  130703. shader: string;
  130704. };
  130705. }
  130706. declare module BABYLON {
  130707. /**
  130708. * Options to be set when merging outputs from the default pipeline.
  130709. */
  130710. export class DepthOfFieldMergePostProcessOptions {
  130711. /**
  130712. * The original image to merge on top of
  130713. */
  130714. originalFromInput: PostProcess;
  130715. /**
  130716. * Parameters to perform the merge of the depth of field effect
  130717. */
  130718. depthOfField?: {
  130719. circleOfConfusion: PostProcess;
  130720. blurSteps: Array<PostProcess>;
  130721. };
  130722. /**
  130723. * Parameters to perform the merge of bloom effect
  130724. */
  130725. bloom?: {
  130726. blurred: PostProcess;
  130727. weight: number;
  130728. };
  130729. }
  130730. /**
  130731. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  130732. */
  130733. export class DepthOfFieldMergePostProcess extends PostProcess {
  130734. private blurSteps;
  130735. /**
  130736. * Creates a new instance of DepthOfFieldMergePostProcess
  130737. * @param name The name of the effect.
  130738. * @param originalFromInput Post process which's input will be used for the merge.
  130739. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  130740. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  130741. * @param options The required width/height ratio to downsize to before computing the render pass.
  130742. * @param camera The camera to apply the render pass to.
  130743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130744. * @param engine The engine which the post process will be applied. (default: current engine)
  130745. * @param reusable If the post process can be reused on the same frame. (default: false)
  130746. * @param textureType Type of textures used when performing the post process. (default: 0)
  130747. * @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)
  130748. */
  130749. 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);
  130750. /**
  130751. * Updates the effect with the current post process compile time values and recompiles the shader.
  130752. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  130753. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  130754. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  130755. * @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
  130756. * @param onCompiled Called when the shader has been compiled.
  130757. * @param onError Called if there is an error when compiling a shader.
  130758. */
  130759. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  130760. }
  130761. }
  130762. declare module BABYLON {
  130763. /**
  130764. * Specifies the level of max blur that should be applied when using the depth of field effect
  130765. */
  130766. export enum DepthOfFieldEffectBlurLevel {
  130767. /**
  130768. * Subtle blur
  130769. */
  130770. Low = 0,
  130771. /**
  130772. * Medium blur
  130773. */
  130774. Medium = 1,
  130775. /**
  130776. * Large blur
  130777. */
  130778. High = 2
  130779. }
  130780. /**
  130781. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  130782. */
  130783. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  130784. private _circleOfConfusion;
  130785. /**
  130786. * @hidden Internal, blurs from high to low
  130787. */
  130788. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  130789. private _depthOfFieldBlurY;
  130790. private _dofMerge;
  130791. /**
  130792. * @hidden Internal post processes in depth of field effect
  130793. */
  130794. _effects: Array<PostProcess>;
  130795. /**
  130796. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  130797. */
  130798. focalLength: number;
  130799. /**
  130800. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  130801. */
  130802. fStop: number;
  130803. /**
  130804. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  130805. */
  130806. focusDistance: number;
  130807. /**
  130808. * 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.
  130809. */
  130810. lensSize: number;
  130811. /**
  130812. * Creates a new instance DepthOfFieldEffect
  130813. * @param scene The scene the effect belongs to.
  130814. * @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.
  130815. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  130816. * @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)
  130817. */
  130818. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  130819. /**
  130820. * Get the current class name of the current effet
  130821. * @returns "DepthOfFieldEffect"
  130822. */
  130823. getClassName(): string;
  130824. /**
  130825. * 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.
  130826. */
  130827. depthTexture: RenderTargetTexture;
  130828. /**
  130829. * Disposes each of the internal effects for a given camera.
  130830. * @param camera The camera to dispose the effect on.
  130831. */
  130832. disposeEffects(camera: Camera): void;
  130833. /**
  130834. * @hidden Internal
  130835. */
  130836. _updateEffects(): void;
  130837. /**
  130838. * Internal
  130839. * @returns if all the contained post processes are ready.
  130840. * @hidden
  130841. */
  130842. _isReady(): boolean;
  130843. }
  130844. }
  130845. declare module BABYLON {
  130846. /** @hidden */
  130847. export var displayPassPixelShader: {
  130848. name: string;
  130849. shader: string;
  130850. };
  130851. }
  130852. declare module BABYLON {
  130853. /**
  130854. * DisplayPassPostProcess which produces an output the same as it's input
  130855. */
  130856. export class DisplayPassPostProcess extends PostProcess {
  130857. /**
  130858. * Creates the DisplayPassPostProcess
  130859. * @param name The name of the effect.
  130860. * @param options The required width/height ratio to downsize to before computing the render pass.
  130861. * @param camera The camera to apply the render pass to.
  130862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130863. * @param engine The engine which the post process will be applied. (default: current engine)
  130864. * @param reusable If the post process can be reused on the same frame. (default: false)
  130865. */
  130866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130867. }
  130868. }
  130869. declare module BABYLON {
  130870. /** @hidden */
  130871. export var filterPixelShader: {
  130872. name: string;
  130873. shader: string;
  130874. };
  130875. }
  130876. declare module BABYLON {
  130877. /**
  130878. * Applies a kernel filter to the image
  130879. */
  130880. export class FilterPostProcess extends PostProcess {
  130881. /** The matrix to be applied to the image */
  130882. kernelMatrix: Matrix;
  130883. /**
  130884. *
  130885. * @param name The name of the effect.
  130886. * @param kernelMatrix The matrix to be applied to the image
  130887. * @param options The required width/height ratio to downsize to before computing the render pass.
  130888. * @param camera The camera to apply the render pass to.
  130889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130890. * @param engine The engine which the post process will be applied. (default: current engine)
  130891. * @param reusable If the post process can be reused on the same frame. (default: false)
  130892. */
  130893. constructor(name: string,
  130894. /** The matrix to be applied to the image */
  130895. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  130896. }
  130897. }
  130898. declare module BABYLON {
  130899. /** @hidden */
  130900. export var fxaaPixelShader: {
  130901. name: string;
  130902. shader: string;
  130903. };
  130904. }
  130905. declare module BABYLON {
  130906. /** @hidden */
  130907. export var fxaaVertexShader: {
  130908. name: string;
  130909. shader: string;
  130910. };
  130911. }
  130912. declare module BABYLON {
  130913. /**
  130914. * Fxaa post process
  130915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  130916. */
  130917. export class FxaaPostProcess extends PostProcess {
  130918. /** @hidden */
  130919. texelWidth: number;
  130920. /** @hidden */
  130921. texelHeight: number;
  130922. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130923. private _getDefines;
  130924. }
  130925. }
  130926. declare module BABYLON {
  130927. /** @hidden */
  130928. export var grainPixelShader: {
  130929. name: string;
  130930. shader: string;
  130931. };
  130932. }
  130933. declare module BABYLON {
  130934. /**
  130935. * The GrainPostProcess adds noise to the image at mid luminance levels
  130936. */
  130937. export class GrainPostProcess extends PostProcess {
  130938. /**
  130939. * The intensity of the grain added (default: 30)
  130940. */
  130941. intensity: number;
  130942. /**
  130943. * If the grain should be randomized on every frame
  130944. */
  130945. animated: boolean;
  130946. /**
  130947. * Creates a new instance of @see GrainPostProcess
  130948. * @param name The name of the effect.
  130949. * @param options The required width/height ratio to downsize to before computing the render pass.
  130950. * @param camera The camera to apply the render pass to.
  130951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130952. * @param engine The engine which the post process will be applied. (default: current engine)
  130953. * @param reusable If the post process can be reused on the same frame. (default: false)
  130954. * @param textureType Type of textures used when performing the post process. (default: 0)
  130955. * @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)
  130956. */
  130957. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130958. }
  130959. }
  130960. declare module BABYLON {
  130961. /** @hidden */
  130962. export var highlightsPixelShader: {
  130963. name: string;
  130964. shader: string;
  130965. };
  130966. }
  130967. declare module BABYLON {
  130968. /**
  130969. * Extracts highlights from the image
  130970. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130971. */
  130972. export class HighlightsPostProcess extends PostProcess {
  130973. /**
  130974. * Extracts highlights from the image
  130975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  130976. * @param name The name of the effect.
  130977. * @param options The required width/height ratio to downsize to before computing the render pass.
  130978. * @param camera The camera to apply the render pass to.
  130979. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130980. * @param engine The engine which the post process will be applied. (default: current engine)
  130981. * @param reusable If the post process can be reused on the same frame. (default: false)
  130982. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  130983. */
  130984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  130985. }
  130986. }
  130987. declare module BABYLON {
  130988. /** @hidden */
  130989. export var mrtFragmentDeclaration: {
  130990. name: string;
  130991. shader: string;
  130992. };
  130993. }
  130994. declare module BABYLON {
  130995. /** @hidden */
  130996. export var geometryPixelShader: {
  130997. name: string;
  130998. shader: string;
  130999. };
  131000. }
  131001. declare module BABYLON {
  131002. /** @hidden */
  131003. export var geometryVertexShader: {
  131004. name: string;
  131005. shader: string;
  131006. };
  131007. }
  131008. declare module BABYLON {
  131009. /** @hidden */
  131010. interface ISavedTransformationMatrix {
  131011. world: Matrix;
  131012. viewProjection: Matrix;
  131013. }
  131014. /**
  131015. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  131016. */
  131017. export class GeometryBufferRenderer {
  131018. /**
  131019. * Constant used to retrieve the position texture index in the G-Buffer textures array
  131020. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  131021. */
  131022. static readonly POSITION_TEXTURE_TYPE: number;
  131023. /**
  131024. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  131025. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  131026. */
  131027. static readonly VELOCITY_TEXTURE_TYPE: number;
  131028. /**
  131029. * Dictionary used to store the previous transformation matrices of each rendered mesh
  131030. * in order to compute objects velocities when enableVelocity is set to "true"
  131031. * @hidden
  131032. */
  131033. _previousTransformationMatrices: {
  131034. [index: number]: ISavedTransformationMatrix;
  131035. };
  131036. /**
  131037. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  131038. * in order to compute objects velocities when enableVelocity is set to "true"
  131039. * @hidden
  131040. */
  131041. _previousBonesTransformationMatrices: {
  131042. [index: number]: Float32Array;
  131043. };
  131044. /**
  131045. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  131046. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  131047. */
  131048. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  131049. private _scene;
  131050. private _multiRenderTarget;
  131051. private _ratio;
  131052. private _enablePosition;
  131053. private _enableVelocity;
  131054. private _positionIndex;
  131055. private _velocityIndex;
  131056. protected _effect: Effect;
  131057. protected _cachedDefines: string;
  131058. /**
  131059. * Set the render list (meshes to be rendered) used in the G buffer.
  131060. */
  131061. renderList: Mesh[];
  131062. /**
  131063. * Gets wether or not G buffer are supported by the running hardware.
  131064. * This requires draw buffer supports
  131065. */
  131066. readonly isSupported: boolean;
  131067. /**
  131068. * Returns the index of the given texture type in the G-Buffer textures array
  131069. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  131070. * @returns the index of the given texture type in the G-Buffer textures array
  131071. */
  131072. getTextureIndex(textureType: number): number;
  131073. /**
  131074. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  131075. */
  131076. /**
  131077. * Sets whether or not objects positions are enabled for the G buffer.
  131078. */
  131079. enablePosition: boolean;
  131080. /**
  131081. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  131082. */
  131083. /**
  131084. * Sets wether or not objects velocities are enabled for the G buffer.
  131085. */
  131086. enableVelocity: boolean;
  131087. /**
  131088. * Gets the scene associated with the buffer.
  131089. */
  131090. readonly scene: Scene;
  131091. /**
  131092. * Gets the ratio used by the buffer during its creation.
  131093. * How big is the buffer related to the main canvas.
  131094. */
  131095. readonly ratio: number;
  131096. /** @hidden */
  131097. static _SceneComponentInitialization: (scene: Scene) => void;
  131098. /**
  131099. * Creates a new G Buffer for the scene
  131100. * @param scene The scene the buffer belongs to
  131101. * @param ratio How big is the buffer related to the main canvas.
  131102. */
  131103. constructor(scene: Scene, ratio?: number);
  131104. /**
  131105. * Checks wether everything is ready to render a submesh to the G buffer.
  131106. * @param subMesh the submesh to check readiness for
  131107. * @param useInstances is the mesh drawn using instance or not
  131108. * @returns true if ready otherwise false
  131109. */
  131110. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131111. /**
  131112. * Gets the current underlying G Buffer.
  131113. * @returns the buffer
  131114. */
  131115. getGBuffer(): MultiRenderTarget;
  131116. /**
  131117. * Gets the number of samples used to render the buffer (anti aliasing).
  131118. */
  131119. /**
  131120. * Sets the number of samples used to render the buffer (anti aliasing).
  131121. */
  131122. samples: number;
  131123. /**
  131124. * Disposes the renderer and frees up associated resources.
  131125. */
  131126. dispose(): void;
  131127. protected _createRenderTargets(): void;
  131128. private _copyBonesTransformationMatrices;
  131129. }
  131130. }
  131131. declare module BABYLON {
  131132. interface Scene {
  131133. /** @hidden (Backing field) */
  131134. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  131135. /**
  131136. * Gets or Sets the current geometry buffer associated to the scene.
  131137. */
  131138. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  131139. /**
  131140. * Enables a GeometryBufferRender and associates it with the scene
  131141. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  131142. * @returns the GeometryBufferRenderer
  131143. */
  131144. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  131145. /**
  131146. * Disables the GeometryBufferRender associated with the scene
  131147. */
  131148. disableGeometryBufferRenderer(): void;
  131149. }
  131150. /**
  131151. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  131152. * in several rendering techniques.
  131153. */
  131154. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  131155. /**
  131156. * The component name helpful to identify the component in the list of scene components.
  131157. */
  131158. readonly name: string;
  131159. /**
  131160. * The scene the component belongs to.
  131161. */
  131162. scene: Scene;
  131163. /**
  131164. * Creates a new instance of the component for the given scene
  131165. * @param scene Defines the scene to register the component in
  131166. */
  131167. constructor(scene: Scene);
  131168. /**
  131169. * Registers the component in a given scene
  131170. */
  131171. register(): void;
  131172. /**
  131173. * Rebuilds the elements related to this component in case of
  131174. * context lost for instance.
  131175. */
  131176. rebuild(): void;
  131177. /**
  131178. * Disposes the component and the associated ressources
  131179. */
  131180. dispose(): void;
  131181. private _gatherRenderTargets;
  131182. }
  131183. }
  131184. declare module BABYLON {
  131185. /** @hidden */
  131186. export var motionBlurPixelShader: {
  131187. name: string;
  131188. shader: string;
  131189. };
  131190. }
  131191. declare module BABYLON {
  131192. /**
  131193. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  131194. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  131195. * As an example, all you have to do is to create the post-process:
  131196. * var mb = new BABYLON.MotionBlurPostProcess(
  131197. * 'mb', // The name of the effect.
  131198. * scene, // The scene containing the objects to blur according to their velocity.
  131199. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  131200. * camera // The camera to apply the render pass to.
  131201. * );
  131202. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  131203. */
  131204. export class MotionBlurPostProcess extends PostProcess {
  131205. /**
  131206. * Defines how much the image is blurred by the movement. Default value is equal to 1
  131207. */
  131208. motionStrength: number;
  131209. /**
  131210. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  131211. */
  131212. /**
  131213. * Sets the number of iterations to be used for motion blur quality
  131214. */
  131215. motionBlurSamples: number;
  131216. private _motionBlurSamples;
  131217. private _geometryBufferRenderer;
  131218. /**
  131219. * Creates a new instance MotionBlurPostProcess
  131220. * @param name The name of the effect.
  131221. * @param scene The scene containing the objects to blur according to their velocity.
  131222. * @param options The required width/height ratio to downsize to before computing the render pass.
  131223. * @param camera The camera to apply the render pass to.
  131224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131225. * @param engine The engine which the post process will be applied. (default: current engine)
  131226. * @param reusable If the post process can be reused on the same frame. (default: false)
  131227. * @param textureType Type of textures used when performing the post process. (default: 0)
  131228. * @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)
  131229. */
  131230. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131231. /**
  131232. * Excludes the given skinned mesh from computing bones velocities.
  131233. * 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.
  131234. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  131235. */
  131236. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  131237. /**
  131238. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  131239. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  131240. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  131241. */
  131242. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  131243. /**
  131244. * Disposes the post process.
  131245. * @param camera The camera to dispose the post process on.
  131246. */
  131247. dispose(camera?: Camera): void;
  131248. }
  131249. }
  131250. declare module BABYLON {
  131251. /** @hidden */
  131252. export var refractionPixelShader: {
  131253. name: string;
  131254. shader: string;
  131255. };
  131256. }
  131257. declare module BABYLON {
  131258. /**
  131259. * Post process which applies a refractin texture
  131260. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  131261. */
  131262. export class RefractionPostProcess extends PostProcess {
  131263. /** the base color of the refraction (used to taint the rendering) */
  131264. color: Color3;
  131265. /** simulated refraction depth */
  131266. depth: number;
  131267. /** the coefficient of the base color (0 to remove base color tainting) */
  131268. colorLevel: number;
  131269. private _refTexture;
  131270. private _ownRefractionTexture;
  131271. /**
  131272. * Gets or sets the refraction texture
  131273. * Please note that you are responsible for disposing the texture if you set it manually
  131274. */
  131275. refractionTexture: Texture;
  131276. /**
  131277. * Initializes the RefractionPostProcess
  131278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  131279. * @param name The name of the effect.
  131280. * @param refractionTextureUrl Url of the refraction texture to use
  131281. * @param color the base color of the refraction (used to taint the rendering)
  131282. * @param depth simulated refraction depth
  131283. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  131284. * @param camera The camera to apply the render pass to.
  131285. * @param options The required width/height ratio to downsize to before computing the render pass.
  131286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131287. * @param engine The engine which the post process will be applied. (default: current engine)
  131288. * @param reusable If the post process can be reused on the same frame. (default: false)
  131289. */
  131290. constructor(name: string, refractionTextureUrl: string,
  131291. /** the base color of the refraction (used to taint the rendering) */
  131292. color: Color3,
  131293. /** simulated refraction depth */
  131294. depth: number,
  131295. /** the coefficient of the base color (0 to remove base color tainting) */
  131296. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  131297. /**
  131298. * Disposes of the post process
  131299. * @param camera Camera to dispose post process on
  131300. */
  131301. dispose(camera: Camera): void;
  131302. }
  131303. }
  131304. declare module BABYLON {
  131305. /** @hidden */
  131306. export var sharpenPixelShader: {
  131307. name: string;
  131308. shader: string;
  131309. };
  131310. }
  131311. declare module BABYLON {
  131312. /**
  131313. * The SharpenPostProcess applies a sharpen kernel to every pixel
  131314. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  131315. */
  131316. export class SharpenPostProcess extends PostProcess {
  131317. /**
  131318. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  131319. */
  131320. colorAmount: number;
  131321. /**
  131322. * How much sharpness should be applied (default: 0.3)
  131323. */
  131324. edgeAmount: number;
  131325. /**
  131326. * Creates a new instance ConvolutionPostProcess
  131327. * @param name The name of the effect.
  131328. * @param options The required width/height ratio to downsize to before computing the render pass.
  131329. * @param camera The camera to apply the render pass to.
  131330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131331. * @param engine The engine which the post process will be applied. (default: current engine)
  131332. * @param reusable If the post process can be reused on the same frame. (default: false)
  131333. * @param textureType Type of textures used when performing the post process. (default: 0)
  131334. * @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)
  131335. */
  131336. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131337. }
  131338. }
  131339. declare module BABYLON {
  131340. /**
  131341. * PostProcessRenderPipeline
  131342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131343. */
  131344. export class PostProcessRenderPipeline {
  131345. private engine;
  131346. private _renderEffects;
  131347. private _renderEffectsForIsolatedPass;
  131348. /**
  131349. * List of inspectable custom properties (used by the Inspector)
  131350. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  131351. */
  131352. inspectableCustomProperties: IInspectable[];
  131353. /**
  131354. * @hidden
  131355. */
  131356. protected _cameras: Camera[];
  131357. /** @hidden */
  131358. _name: string;
  131359. /**
  131360. * Gets pipeline name
  131361. */
  131362. readonly name: string;
  131363. /** Gets the list of attached cameras */
  131364. readonly cameras: Camera[];
  131365. /**
  131366. * Initializes a PostProcessRenderPipeline
  131367. * @param engine engine to add the pipeline to
  131368. * @param name name of the pipeline
  131369. */
  131370. constructor(engine: Engine, name: string);
  131371. /**
  131372. * Gets the class name
  131373. * @returns "PostProcessRenderPipeline"
  131374. */
  131375. getClassName(): string;
  131376. /**
  131377. * If all the render effects in the pipeline are supported
  131378. */
  131379. readonly isSupported: boolean;
  131380. /**
  131381. * Adds an effect to the pipeline
  131382. * @param renderEffect the effect to add
  131383. */
  131384. addEffect(renderEffect: PostProcessRenderEffect): void;
  131385. /** @hidden */
  131386. _rebuild(): void;
  131387. /** @hidden */
  131388. _enableEffect(renderEffectName: string, cameras: Camera): void;
  131389. /** @hidden */
  131390. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  131391. /** @hidden */
  131392. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  131393. /** @hidden */
  131394. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  131395. /** @hidden */
  131396. _attachCameras(cameras: Camera, unique: boolean): void;
  131397. /** @hidden */
  131398. _attachCameras(cameras: Camera[], unique: boolean): void;
  131399. /** @hidden */
  131400. _detachCameras(cameras: Camera): void;
  131401. /** @hidden */
  131402. _detachCameras(cameras: Nullable<Camera[]>): void;
  131403. /** @hidden */
  131404. _update(): void;
  131405. /** @hidden */
  131406. _reset(): void;
  131407. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  131408. /**
  131409. * Disposes of the pipeline
  131410. */
  131411. dispose(): void;
  131412. }
  131413. }
  131414. declare module BABYLON {
  131415. /**
  131416. * PostProcessRenderPipelineManager class
  131417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131418. */
  131419. export class PostProcessRenderPipelineManager {
  131420. private _renderPipelines;
  131421. /**
  131422. * Initializes a PostProcessRenderPipelineManager
  131423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131424. */
  131425. constructor();
  131426. /**
  131427. * Gets the list of supported render pipelines
  131428. */
  131429. readonly supportedPipelines: PostProcessRenderPipeline[];
  131430. /**
  131431. * Adds a pipeline to the manager
  131432. * @param renderPipeline The pipeline to add
  131433. */
  131434. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  131435. /**
  131436. * Attaches a camera to the pipeline
  131437. * @param renderPipelineName The name of the pipeline to attach to
  131438. * @param cameras the camera to attach
  131439. * @param unique if the camera can be attached multiple times to the pipeline
  131440. */
  131441. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  131442. /**
  131443. * Detaches a camera from the pipeline
  131444. * @param renderPipelineName The name of the pipeline to detach from
  131445. * @param cameras the camera to detach
  131446. */
  131447. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  131448. /**
  131449. * Enables an effect by name on a pipeline
  131450. * @param renderPipelineName the name of the pipeline to enable the effect in
  131451. * @param renderEffectName the name of the effect to enable
  131452. * @param cameras the cameras that the effect should be enabled on
  131453. */
  131454. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  131455. /**
  131456. * Disables an effect by name on a pipeline
  131457. * @param renderPipelineName the name of the pipeline to disable the effect in
  131458. * @param renderEffectName the name of the effect to disable
  131459. * @param cameras the cameras that the effect should be disabled on
  131460. */
  131461. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  131462. /**
  131463. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  131464. */
  131465. update(): void;
  131466. /** @hidden */
  131467. _rebuild(): void;
  131468. /**
  131469. * Disposes of the manager and pipelines
  131470. */
  131471. dispose(): void;
  131472. }
  131473. }
  131474. declare module BABYLON {
  131475. interface Scene {
  131476. /** @hidden (Backing field) */
  131477. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  131478. /**
  131479. * Gets the postprocess render pipeline manager
  131480. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  131481. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131482. */
  131483. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  131484. }
  131485. /**
  131486. * Defines the Render Pipeline scene component responsible to rendering pipelines
  131487. */
  131488. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  131489. /**
  131490. * The component name helpfull to identify the component in the list of scene components.
  131491. */
  131492. readonly name: string;
  131493. /**
  131494. * The scene the component belongs to.
  131495. */
  131496. scene: Scene;
  131497. /**
  131498. * Creates a new instance of the component for the given scene
  131499. * @param scene Defines the scene to register the component in
  131500. */
  131501. constructor(scene: Scene);
  131502. /**
  131503. * Registers the component in a given scene
  131504. */
  131505. register(): void;
  131506. /**
  131507. * Rebuilds the elements related to this component in case of
  131508. * context lost for instance.
  131509. */
  131510. rebuild(): void;
  131511. /**
  131512. * Disposes the component and the associated ressources
  131513. */
  131514. dispose(): void;
  131515. private _gatherRenderTargets;
  131516. }
  131517. }
  131518. declare module BABYLON {
  131519. /**
  131520. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  131521. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  131522. */
  131523. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  131524. private _scene;
  131525. private _camerasToBeAttached;
  131526. /**
  131527. * ID of the sharpen post process,
  131528. */
  131529. private readonly SharpenPostProcessId;
  131530. /**
  131531. * @ignore
  131532. * ID of the image processing post process;
  131533. */
  131534. readonly ImageProcessingPostProcessId: string;
  131535. /**
  131536. * @ignore
  131537. * ID of the Fast Approximate Anti-Aliasing post process;
  131538. */
  131539. readonly FxaaPostProcessId: string;
  131540. /**
  131541. * ID of the chromatic aberration post process,
  131542. */
  131543. private readonly ChromaticAberrationPostProcessId;
  131544. /**
  131545. * ID of the grain post process
  131546. */
  131547. private readonly GrainPostProcessId;
  131548. /**
  131549. * Sharpen post process which will apply a sharpen convolution to enhance edges
  131550. */
  131551. sharpen: SharpenPostProcess;
  131552. private _sharpenEffect;
  131553. private bloom;
  131554. /**
  131555. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  131556. */
  131557. depthOfField: DepthOfFieldEffect;
  131558. /**
  131559. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  131560. */
  131561. fxaa: FxaaPostProcess;
  131562. /**
  131563. * Image post processing pass used to perform operations such as tone mapping or color grading.
  131564. */
  131565. imageProcessing: ImageProcessingPostProcess;
  131566. /**
  131567. * Chromatic aberration post process which will shift rgb colors in the image
  131568. */
  131569. chromaticAberration: ChromaticAberrationPostProcess;
  131570. private _chromaticAberrationEffect;
  131571. /**
  131572. * Grain post process which add noise to the image
  131573. */
  131574. grain: GrainPostProcess;
  131575. private _grainEffect;
  131576. /**
  131577. * Glow post process which adds a glow to emissive areas of the image
  131578. */
  131579. private _glowLayer;
  131580. /**
  131581. * Animations which can be used to tweak settings over a period of time
  131582. */
  131583. animations: Animation[];
  131584. private _imageProcessingConfigurationObserver;
  131585. private _sharpenEnabled;
  131586. private _bloomEnabled;
  131587. private _depthOfFieldEnabled;
  131588. private _depthOfFieldBlurLevel;
  131589. private _fxaaEnabled;
  131590. private _imageProcessingEnabled;
  131591. private _defaultPipelineTextureType;
  131592. private _bloomScale;
  131593. private _chromaticAberrationEnabled;
  131594. private _grainEnabled;
  131595. private _buildAllowed;
  131596. /**
  131597. * Gets active scene
  131598. */
  131599. readonly scene: Scene;
  131600. /**
  131601. * Enable or disable the sharpen process from the pipeline
  131602. */
  131603. sharpenEnabled: boolean;
  131604. private _resizeObserver;
  131605. private _hardwareScaleLevel;
  131606. private _bloomKernel;
  131607. /**
  131608. * Specifies the size of the bloom blur kernel, relative to the final output size
  131609. */
  131610. bloomKernel: number;
  131611. /**
  131612. * Specifies the weight of the bloom in the final rendering
  131613. */
  131614. private _bloomWeight;
  131615. /**
  131616. * Specifies the luma threshold for the area that will be blurred by the bloom
  131617. */
  131618. private _bloomThreshold;
  131619. private _hdr;
  131620. /**
  131621. * The strength of the bloom.
  131622. */
  131623. bloomWeight: number;
  131624. /**
  131625. * The strength of the bloom.
  131626. */
  131627. bloomThreshold: number;
  131628. /**
  131629. * The scale of the bloom, lower value will provide better performance.
  131630. */
  131631. bloomScale: number;
  131632. /**
  131633. * Enable or disable the bloom from the pipeline
  131634. */
  131635. bloomEnabled: boolean;
  131636. private _rebuildBloom;
  131637. /**
  131638. * If the depth of field is enabled.
  131639. */
  131640. depthOfFieldEnabled: boolean;
  131641. /**
  131642. * Blur level of the depth of field effect. (Higher blur will effect performance)
  131643. */
  131644. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  131645. /**
  131646. * If the anti aliasing is enabled.
  131647. */
  131648. fxaaEnabled: boolean;
  131649. private _samples;
  131650. /**
  131651. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  131652. */
  131653. samples: number;
  131654. /**
  131655. * If image processing is enabled.
  131656. */
  131657. imageProcessingEnabled: boolean;
  131658. /**
  131659. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  131660. */
  131661. glowLayerEnabled: boolean;
  131662. /**
  131663. * Gets the glow layer (or null if not defined)
  131664. */
  131665. readonly glowLayer: Nullable<GlowLayer>;
  131666. /**
  131667. * Enable or disable the chromaticAberration process from the pipeline
  131668. */
  131669. chromaticAberrationEnabled: boolean;
  131670. /**
  131671. * Enable or disable the grain process from the pipeline
  131672. */
  131673. grainEnabled: boolean;
  131674. /**
  131675. * @constructor
  131676. * @param name - The rendering pipeline name (default: "")
  131677. * @param hdr - If high dynamic range textures should be used (default: true)
  131678. * @param scene - The scene linked to this pipeline (default: the last created scene)
  131679. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  131680. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  131681. */
  131682. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  131683. /**
  131684. * Get the class name
  131685. * @returns "DefaultRenderingPipeline"
  131686. */
  131687. getClassName(): string;
  131688. /**
  131689. * Force the compilation of the entire pipeline.
  131690. */
  131691. prepare(): void;
  131692. private _hasCleared;
  131693. private _prevPostProcess;
  131694. private _prevPrevPostProcess;
  131695. private _setAutoClearAndTextureSharing;
  131696. private _depthOfFieldSceneObserver;
  131697. private _buildPipeline;
  131698. private _disposePostProcesses;
  131699. /**
  131700. * Adds a camera to the pipeline
  131701. * @param camera the camera to be added
  131702. */
  131703. addCamera(camera: Camera): void;
  131704. /**
  131705. * Removes a camera from the pipeline
  131706. * @param camera the camera to remove
  131707. */
  131708. removeCamera(camera: Camera): void;
  131709. /**
  131710. * Dispose of the pipeline and stop all post processes
  131711. */
  131712. dispose(): void;
  131713. /**
  131714. * Serialize the rendering pipeline (Used when exporting)
  131715. * @returns the serialized object
  131716. */
  131717. serialize(): any;
  131718. /**
  131719. * Parse the serialized pipeline
  131720. * @param source Source pipeline.
  131721. * @param scene The scene to load the pipeline to.
  131722. * @param rootUrl The URL of the serialized pipeline.
  131723. * @returns An instantiated pipeline from the serialized object.
  131724. */
  131725. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  131726. }
  131727. }
  131728. declare module BABYLON {
  131729. /** @hidden */
  131730. export var lensHighlightsPixelShader: {
  131731. name: string;
  131732. shader: string;
  131733. };
  131734. }
  131735. declare module BABYLON {
  131736. /** @hidden */
  131737. export var depthOfFieldPixelShader: {
  131738. name: string;
  131739. shader: string;
  131740. };
  131741. }
  131742. declare module BABYLON {
  131743. /**
  131744. * BABYLON.JS Chromatic Aberration GLSL Shader
  131745. * Author: Olivier Guyot
  131746. * Separates very slightly R, G and B colors on the edges of the screen
  131747. * Inspired by Francois Tarlier & Martins Upitis
  131748. */
  131749. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  131750. /**
  131751. * @ignore
  131752. * The chromatic aberration PostProcess id in the pipeline
  131753. */
  131754. LensChromaticAberrationEffect: string;
  131755. /**
  131756. * @ignore
  131757. * The highlights enhancing PostProcess id in the pipeline
  131758. */
  131759. HighlightsEnhancingEffect: string;
  131760. /**
  131761. * @ignore
  131762. * The depth-of-field PostProcess id in the pipeline
  131763. */
  131764. LensDepthOfFieldEffect: string;
  131765. private _scene;
  131766. private _depthTexture;
  131767. private _grainTexture;
  131768. private _chromaticAberrationPostProcess;
  131769. private _highlightsPostProcess;
  131770. private _depthOfFieldPostProcess;
  131771. private _edgeBlur;
  131772. private _grainAmount;
  131773. private _chromaticAberration;
  131774. private _distortion;
  131775. private _highlightsGain;
  131776. private _highlightsThreshold;
  131777. private _dofDistance;
  131778. private _dofAperture;
  131779. private _dofDarken;
  131780. private _dofPentagon;
  131781. private _blurNoise;
  131782. /**
  131783. * @constructor
  131784. *
  131785. * Effect parameters are as follow:
  131786. * {
  131787. * chromatic_aberration: number; // from 0 to x (1 for realism)
  131788. * edge_blur: number; // from 0 to x (1 for realism)
  131789. * distortion: number; // from 0 to x (1 for realism)
  131790. * grain_amount: number; // from 0 to 1
  131791. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  131792. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  131793. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  131794. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  131795. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  131796. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  131797. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  131798. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  131799. * }
  131800. * Note: if an effect parameter is unset, effect is disabled
  131801. *
  131802. * @param name The rendering pipeline name
  131803. * @param parameters - An object containing all parameters (see above)
  131804. * @param scene The scene linked to this pipeline
  131805. * @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)
  131806. * @param cameras The array of cameras that the rendering pipeline will be attached to
  131807. */
  131808. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  131809. /**
  131810. * Get the class name
  131811. * @returns "LensRenderingPipeline"
  131812. */
  131813. getClassName(): string;
  131814. /**
  131815. * Gets associated scene
  131816. */
  131817. readonly scene: Scene;
  131818. /**
  131819. * Gets or sets the edge blur
  131820. */
  131821. edgeBlur: number;
  131822. /**
  131823. * Gets or sets the grain amount
  131824. */
  131825. grainAmount: number;
  131826. /**
  131827. * Gets or sets the chromatic aberration amount
  131828. */
  131829. chromaticAberration: number;
  131830. /**
  131831. * Gets or sets the depth of field aperture
  131832. */
  131833. dofAperture: number;
  131834. /**
  131835. * Gets or sets the edge distortion
  131836. */
  131837. edgeDistortion: number;
  131838. /**
  131839. * Gets or sets the depth of field distortion
  131840. */
  131841. dofDistortion: number;
  131842. /**
  131843. * Gets or sets the darken out of focus amount
  131844. */
  131845. darkenOutOfFocus: number;
  131846. /**
  131847. * Gets or sets a boolean indicating if blur noise is enabled
  131848. */
  131849. blurNoise: boolean;
  131850. /**
  131851. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  131852. */
  131853. pentagonBokeh: boolean;
  131854. /**
  131855. * Gets or sets the highlight grain amount
  131856. */
  131857. highlightsGain: number;
  131858. /**
  131859. * Gets or sets the highlight threshold
  131860. */
  131861. highlightsThreshold: number;
  131862. /**
  131863. * Sets the amount of blur at the edges
  131864. * @param amount blur amount
  131865. */
  131866. setEdgeBlur(amount: number): void;
  131867. /**
  131868. * Sets edge blur to 0
  131869. */
  131870. disableEdgeBlur(): void;
  131871. /**
  131872. * Sets the amout of grain
  131873. * @param amount Amount of grain
  131874. */
  131875. setGrainAmount(amount: number): void;
  131876. /**
  131877. * Set grain amount to 0
  131878. */
  131879. disableGrain(): void;
  131880. /**
  131881. * Sets the chromatic aberration amount
  131882. * @param amount amount of chromatic aberration
  131883. */
  131884. setChromaticAberration(amount: number): void;
  131885. /**
  131886. * Sets chromatic aberration amount to 0
  131887. */
  131888. disableChromaticAberration(): void;
  131889. /**
  131890. * Sets the EdgeDistortion amount
  131891. * @param amount amount of EdgeDistortion
  131892. */
  131893. setEdgeDistortion(amount: number): void;
  131894. /**
  131895. * Sets edge distortion to 0
  131896. */
  131897. disableEdgeDistortion(): void;
  131898. /**
  131899. * Sets the FocusDistance amount
  131900. * @param amount amount of FocusDistance
  131901. */
  131902. setFocusDistance(amount: number): void;
  131903. /**
  131904. * Disables depth of field
  131905. */
  131906. disableDepthOfField(): void;
  131907. /**
  131908. * Sets the Aperture amount
  131909. * @param amount amount of Aperture
  131910. */
  131911. setAperture(amount: number): void;
  131912. /**
  131913. * Sets the DarkenOutOfFocus amount
  131914. * @param amount amount of DarkenOutOfFocus
  131915. */
  131916. setDarkenOutOfFocus(amount: number): void;
  131917. private _pentagonBokehIsEnabled;
  131918. /**
  131919. * Creates a pentagon bokeh effect
  131920. */
  131921. enablePentagonBokeh(): void;
  131922. /**
  131923. * Disables the pentagon bokeh effect
  131924. */
  131925. disablePentagonBokeh(): void;
  131926. /**
  131927. * Enables noise blur
  131928. */
  131929. enableNoiseBlur(): void;
  131930. /**
  131931. * Disables noise blur
  131932. */
  131933. disableNoiseBlur(): void;
  131934. /**
  131935. * Sets the HighlightsGain amount
  131936. * @param amount amount of HighlightsGain
  131937. */
  131938. setHighlightsGain(amount: number): void;
  131939. /**
  131940. * Sets the HighlightsThreshold amount
  131941. * @param amount amount of HighlightsThreshold
  131942. */
  131943. setHighlightsThreshold(amount: number): void;
  131944. /**
  131945. * Disables highlights
  131946. */
  131947. disableHighlights(): void;
  131948. /**
  131949. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  131950. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  131951. */
  131952. dispose(disableDepthRender?: boolean): void;
  131953. private _createChromaticAberrationPostProcess;
  131954. private _createHighlightsPostProcess;
  131955. private _createDepthOfFieldPostProcess;
  131956. private _createGrainTexture;
  131957. }
  131958. }
  131959. declare module BABYLON {
  131960. /** @hidden */
  131961. export var ssao2PixelShader: {
  131962. name: string;
  131963. shader: string;
  131964. };
  131965. }
  131966. declare module BABYLON {
  131967. /** @hidden */
  131968. export var ssaoCombinePixelShader: {
  131969. name: string;
  131970. shader: string;
  131971. };
  131972. }
  131973. declare module BABYLON {
  131974. /**
  131975. * Render pipeline to produce ssao effect
  131976. */
  131977. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  131978. /**
  131979. * @ignore
  131980. * The PassPostProcess id in the pipeline that contains the original scene color
  131981. */
  131982. SSAOOriginalSceneColorEffect: string;
  131983. /**
  131984. * @ignore
  131985. * The SSAO PostProcess id in the pipeline
  131986. */
  131987. SSAORenderEffect: string;
  131988. /**
  131989. * @ignore
  131990. * The horizontal blur PostProcess id in the pipeline
  131991. */
  131992. SSAOBlurHRenderEffect: string;
  131993. /**
  131994. * @ignore
  131995. * The vertical blur PostProcess id in the pipeline
  131996. */
  131997. SSAOBlurVRenderEffect: string;
  131998. /**
  131999. * @ignore
  132000. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  132001. */
  132002. SSAOCombineRenderEffect: string;
  132003. /**
  132004. * The output strength of the SSAO post-process. Default value is 1.0.
  132005. */
  132006. totalStrength: number;
  132007. /**
  132008. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  132009. */
  132010. maxZ: number;
  132011. /**
  132012. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  132013. */
  132014. minZAspect: number;
  132015. private _samples;
  132016. /**
  132017. * Number of samples used for the SSAO calculations. Default value is 8
  132018. */
  132019. samples: number;
  132020. private _textureSamples;
  132021. /**
  132022. * Number of samples to use for antialiasing
  132023. */
  132024. textureSamples: number;
  132025. /**
  132026. * Ratio object used for SSAO ratio and blur ratio
  132027. */
  132028. private _ratio;
  132029. /**
  132030. * Dynamically generated sphere sampler.
  132031. */
  132032. private _sampleSphere;
  132033. /**
  132034. * Blur filter offsets
  132035. */
  132036. private _samplerOffsets;
  132037. private _expensiveBlur;
  132038. /**
  132039. * If bilateral blur should be used
  132040. */
  132041. expensiveBlur: boolean;
  132042. /**
  132043. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  132044. */
  132045. radius: number;
  132046. /**
  132047. * The base color of the SSAO post-process
  132048. * The final result is "base + ssao" between [0, 1]
  132049. */
  132050. base: number;
  132051. /**
  132052. * Support test.
  132053. */
  132054. static readonly IsSupported: boolean;
  132055. private _scene;
  132056. private _depthTexture;
  132057. private _normalTexture;
  132058. private _randomTexture;
  132059. private _originalColorPostProcess;
  132060. private _ssaoPostProcess;
  132061. private _blurHPostProcess;
  132062. private _blurVPostProcess;
  132063. private _ssaoCombinePostProcess;
  132064. /**
  132065. * Gets active scene
  132066. */
  132067. readonly scene: Scene;
  132068. /**
  132069. * @constructor
  132070. * @param name The rendering pipeline name
  132071. * @param scene The scene linked to this pipeline
  132072. * @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 }
  132073. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132074. */
  132075. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  132076. /**
  132077. * Get the class name
  132078. * @returns "SSAO2RenderingPipeline"
  132079. */
  132080. getClassName(): string;
  132081. /**
  132082. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  132083. */
  132084. dispose(disableGeometryBufferRenderer?: boolean): void;
  132085. private _createBlurPostProcess;
  132086. /** @hidden */
  132087. _rebuild(): void;
  132088. private _bits;
  132089. private _radicalInverse_VdC;
  132090. private _hammersley;
  132091. private _hemisphereSample_uniform;
  132092. private _generateHemisphere;
  132093. private _createSSAOPostProcess;
  132094. private _createSSAOCombinePostProcess;
  132095. private _createRandomTexture;
  132096. /**
  132097. * Serialize the rendering pipeline (Used when exporting)
  132098. * @returns the serialized object
  132099. */
  132100. serialize(): any;
  132101. /**
  132102. * Parse the serialized pipeline
  132103. * @param source Source pipeline.
  132104. * @param scene The scene to load the pipeline to.
  132105. * @param rootUrl The URL of the serialized pipeline.
  132106. * @returns An instantiated pipeline from the serialized object.
  132107. */
  132108. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  132109. }
  132110. }
  132111. declare module BABYLON {
  132112. /** @hidden */
  132113. export var ssaoPixelShader: {
  132114. name: string;
  132115. shader: string;
  132116. };
  132117. }
  132118. declare module BABYLON {
  132119. /**
  132120. * Render pipeline to produce ssao effect
  132121. */
  132122. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  132123. /**
  132124. * @ignore
  132125. * The PassPostProcess id in the pipeline that contains the original scene color
  132126. */
  132127. SSAOOriginalSceneColorEffect: string;
  132128. /**
  132129. * @ignore
  132130. * The SSAO PostProcess id in the pipeline
  132131. */
  132132. SSAORenderEffect: string;
  132133. /**
  132134. * @ignore
  132135. * The horizontal blur PostProcess id in the pipeline
  132136. */
  132137. SSAOBlurHRenderEffect: string;
  132138. /**
  132139. * @ignore
  132140. * The vertical blur PostProcess id in the pipeline
  132141. */
  132142. SSAOBlurVRenderEffect: string;
  132143. /**
  132144. * @ignore
  132145. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  132146. */
  132147. SSAOCombineRenderEffect: string;
  132148. /**
  132149. * The output strength of the SSAO post-process. Default value is 1.0.
  132150. */
  132151. totalStrength: number;
  132152. /**
  132153. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  132154. */
  132155. radius: number;
  132156. /**
  132157. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  132158. * Must not be equal to fallOff and superior to fallOff.
  132159. * Default value is 0.0075
  132160. */
  132161. area: number;
  132162. /**
  132163. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  132164. * Must not be equal to area and inferior to area.
  132165. * Default value is 0.000001
  132166. */
  132167. fallOff: number;
  132168. /**
  132169. * The base color of the SSAO post-process
  132170. * The final result is "base + ssao" between [0, 1]
  132171. */
  132172. base: number;
  132173. private _scene;
  132174. private _depthTexture;
  132175. private _randomTexture;
  132176. private _originalColorPostProcess;
  132177. private _ssaoPostProcess;
  132178. private _blurHPostProcess;
  132179. private _blurVPostProcess;
  132180. private _ssaoCombinePostProcess;
  132181. private _firstUpdate;
  132182. /**
  132183. * Gets active scene
  132184. */
  132185. readonly scene: Scene;
  132186. /**
  132187. * @constructor
  132188. * @param name - The rendering pipeline name
  132189. * @param scene - The scene linked to this pipeline
  132190. * @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 }
  132191. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  132192. */
  132193. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  132194. /**
  132195. * Get the class name
  132196. * @returns "SSAORenderingPipeline"
  132197. */
  132198. getClassName(): string;
  132199. /**
  132200. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  132201. */
  132202. dispose(disableDepthRender?: boolean): void;
  132203. private _createBlurPostProcess;
  132204. /** @hidden */
  132205. _rebuild(): void;
  132206. private _createSSAOPostProcess;
  132207. private _createSSAOCombinePostProcess;
  132208. private _createRandomTexture;
  132209. }
  132210. }
  132211. declare module BABYLON {
  132212. /** @hidden */
  132213. export var standardPixelShader: {
  132214. name: string;
  132215. shader: string;
  132216. };
  132217. }
  132218. declare module BABYLON {
  132219. /**
  132220. * Standard rendering pipeline
  132221. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  132222. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  132223. */
  132224. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  132225. /**
  132226. * Public members
  132227. */
  132228. /**
  132229. * Post-process which contains the original scene color before the pipeline applies all the effects
  132230. */
  132231. originalPostProcess: Nullable<PostProcess>;
  132232. /**
  132233. * Post-process used to down scale an image x4
  132234. */
  132235. downSampleX4PostProcess: Nullable<PostProcess>;
  132236. /**
  132237. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  132238. */
  132239. brightPassPostProcess: Nullable<PostProcess>;
  132240. /**
  132241. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  132242. */
  132243. blurHPostProcesses: PostProcess[];
  132244. /**
  132245. * Post-process array storing all the vertical blur post-processes used by the pipeline
  132246. */
  132247. blurVPostProcesses: PostProcess[];
  132248. /**
  132249. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  132250. */
  132251. textureAdderPostProcess: Nullable<PostProcess>;
  132252. /**
  132253. * Post-process used to create volumetric lighting effect
  132254. */
  132255. volumetricLightPostProcess: Nullable<PostProcess>;
  132256. /**
  132257. * Post-process used to smooth the previous volumetric light post-process on the X axis
  132258. */
  132259. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  132260. /**
  132261. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  132262. */
  132263. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  132264. /**
  132265. * Post-process used to merge the volumetric light effect and the real scene color
  132266. */
  132267. volumetricLightMergePostProces: Nullable<PostProcess>;
  132268. /**
  132269. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  132270. */
  132271. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  132272. /**
  132273. * Base post-process used to calculate the average luminance of the final image for HDR
  132274. */
  132275. luminancePostProcess: Nullable<PostProcess>;
  132276. /**
  132277. * Post-processes used to create down sample post-processes in order to get
  132278. * the average luminance of the final image for HDR
  132279. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  132280. */
  132281. luminanceDownSamplePostProcesses: PostProcess[];
  132282. /**
  132283. * Post-process used to create a HDR effect (light adaptation)
  132284. */
  132285. hdrPostProcess: Nullable<PostProcess>;
  132286. /**
  132287. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  132288. */
  132289. textureAdderFinalPostProcess: Nullable<PostProcess>;
  132290. /**
  132291. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  132292. */
  132293. lensFlareFinalPostProcess: Nullable<PostProcess>;
  132294. /**
  132295. * Post-process used to merge the final HDR post-process and the real scene color
  132296. */
  132297. hdrFinalPostProcess: Nullable<PostProcess>;
  132298. /**
  132299. * Post-process used to create a lens flare effect
  132300. */
  132301. lensFlarePostProcess: Nullable<PostProcess>;
  132302. /**
  132303. * Post-process that merges the result of the lens flare post-process and the real scene color
  132304. */
  132305. lensFlareComposePostProcess: Nullable<PostProcess>;
  132306. /**
  132307. * Post-process used to create a motion blur effect
  132308. */
  132309. motionBlurPostProcess: Nullable<PostProcess>;
  132310. /**
  132311. * Post-process used to create a depth of field effect
  132312. */
  132313. depthOfFieldPostProcess: Nullable<PostProcess>;
  132314. /**
  132315. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  132316. */
  132317. fxaaPostProcess: Nullable<FxaaPostProcess>;
  132318. /**
  132319. * Represents the brightness threshold in order to configure the illuminated surfaces
  132320. */
  132321. brightThreshold: number;
  132322. /**
  132323. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  132324. */
  132325. blurWidth: number;
  132326. /**
  132327. * Sets if the blur for highlighted surfaces must be only horizontal
  132328. */
  132329. horizontalBlur: boolean;
  132330. /**
  132331. * Gets the overall exposure used by the pipeline
  132332. */
  132333. /**
  132334. * Sets the overall exposure used by the pipeline
  132335. */
  132336. exposure: number;
  132337. /**
  132338. * Texture used typically to simulate "dirty" on camera lens
  132339. */
  132340. lensTexture: Nullable<Texture>;
  132341. /**
  132342. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  132343. */
  132344. volumetricLightCoefficient: number;
  132345. /**
  132346. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  132347. */
  132348. volumetricLightPower: number;
  132349. /**
  132350. * Used the set the blur intensity to smooth the volumetric lights
  132351. */
  132352. volumetricLightBlurScale: number;
  132353. /**
  132354. * Light (spot or directional) used to generate the volumetric lights rays
  132355. * The source light must have a shadow generate so the pipeline can get its
  132356. * depth map
  132357. */
  132358. sourceLight: Nullable<SpotLight | DirectionalLight>;
  132359. /**
  132360. * For eye adaptation, represents the minimum luminance the eye can see
  132361. */
  132362. hdrMinimumLuminance: number;
  132363. /**
  132364. * For eye adaptation, represents the decrease luminance speed
  132365. */
  132366. hdrDecreaseRate: number;
  132367. /**
  132368. * For eye adaptation, represents the increase luminance speed
  132369. */
  132370. hdrIncreaseRate: number;
  132371. /**
  132372. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  132373. */
  132374. /**
  132375. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  132376. */
  132377. hdrAutoExposure: boolean;
  132378. /**
  132379. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  132380. */
  132381. lensColorTexture: Nullable<Texture>;
  132382. /**
  132383. * The overall strengh for the lens flare effect
  132384. */
  132385. lensFlareStrength: number;
  132386. /**
  132387. * Dispersion coefficient for lens flare ghosts
  132388. */
  132389. lensFlareGhostDispersal: number;
  132390. /**
  132391. * Main lens flare halo width
  132392. */
  132393. lensFlareHaloWidth: number;
  132394. /**
  132395. * Based on the lens distortion effect, defines how much the lens flare result
  132396. * is distorted
  132397. */
  132398. lensFlareDistortionStrength: number;
  132399. /**
  132400. * Configures the blur intensity used for for lens flare (halo)
  132401. */
  132402. lensFlareBlurWidth: number;
  132403. /**
  132404. * Lens star texture must be used to simulate rays on the flares and is available
  132405. * in the documentation
  132406. */
  132407. lensStarTexture: Nullable<Texture>;
  132408. /**
  132409. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  132410. * flare effect by taking account of the dirt texture
  132411. */
  132412. lensFlareDirtTexture: Nullable<Texture>;
  132413. /**
  132414. * Represents the focal length for the depth of field effect
  132415. */
  132416. depthOfFieldDistance: number;
  132417. /**
  132418. * Represents the blur intensity for the blurred part of the depth of field effect
  132419. */
  132420. depthOfFieldBlurWidth: number;
  132421. /**
  132422. * Gets how much the image is blurred by the movement while using the motion blur post-process
  132423. */
  132424. /**
  132425. * Sets how much the image is blurred by the movement while using the motion blur post-process
  132426. */
  132427. motionStrength: number;
  132428. /**
  132429. * Gets wether or not the motion blur post-process is object based or screen based.
  132430. */
  132431. /**
  132432. * Sets wether or not the motion blur post-process should be object based or screen based
  132433. */
  132434. objectBasedMotionBlur: boolean;
  132435. /**
  132436. * List of animations for the pipeline (IAnimatable implementation)
  132437. */
  132438. animations: Animation[];
  132439. /**
  132440. * Private members
  132441. */
  132442. private _scene;
  132443. private _currentDepthOfFieldSource;
  132444. private _basePostProcess;
  132445. private _fixedExposure;
  132446. private _currentExposure;
  132447. private _hdrAutoExposure;
  132448. private _hdrCurrentLuminance;
  132449. private _motionStrength;
  132450. private _isObjectBasedMotionBlur;
  132451. private _floatTextureType;
  132452. private _camerasToBeAttached;
  132453. private _ratio;
  132454. private _bloomEnabled;
  132455. private _depthOfFieldEnabled;
  132456. private _vlsEnabled;
  132457. private _lensFlareEnabled;
  132458. private _hdrEnabled;
  132459. private _motionBlurEnabled;
  132460. private _fxaaEnabled;
  132461. private _motionBlurSamples;
  132462. private _volumetricLightStepsCount;
  132463. private _samples;
  132464. /**
  132465. * @ignore
  132466. * Specifies if the bloom pipeline is enabled
  132467. */
  132468. BloomEnabled: boolean;
  132469. /**
  132470. * @ignore
  132471. * Specifies if the depth of field pipeline is enabed
  132472. */
  132473. DepthOfFieldEnabled: boolean;
  132474. /**
  132475. * @ignore
  132476. * Specifies if the lens flare pipeline is enabed
  132477. */
  132478. LensFlareEnabled: boolean;
  132479. /**
  132480. * @ignore
  132481. * Specifies if the HDR pipeline is enabled
  132482. */
  132483. HDREnabled: boolean;
  132484. /**
  132485. * @ignore
  132486. * Specifies if the volumetric lights scattering effect is enabled
  132487. */
  132488. VLSEnabled: boolean;
  132489. /**
  132490. * @ignore
  132491. * Specifies if the motion blur effect is enabled
  132492. */
  132493. MotionBlurEnabled: boolean;
  132494. /**
  132495. * Specifies if anti-aliasing is enabled
  132496. */
  132497. fxaaEnabled: boolean;
  132498. /**
  132499. * Specifies the number of steps used to calculate the volumetric lights
  132500. * Typically in interval [50, 200]
  132501. */
  132502. volumetricLightStepsCount: number;
  132503. /**
  132504. * Specifies the number of samples used for the motion blur effect
  132505. * Typically in interval [16, 64]
  132506. */
  132507. motionBlurSamples: number;
  132508. /**
  132509. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  132510. */
  132511. samples: number;
  132512. /**
  132513. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  132514. * @constructor
  132515. * @param name The rendering pipeline name
  132516. * @param scene The scene linked to this pipeline
  132517. * @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)
  132518. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  132519. * @param cameras The array of cameras that the rendering pipeline will be attached to
  132520. */
  132521. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  132522. private _buildPipeline;
  132523. private _createDownSampleX4PostProcess;
  132524. private _createBrightPassPostProcess;
  132525. private _createBlurPostProcesses;
  132526. private _createTextureAdderPostProcess;
  132527. private _createVolumetricLightPostProcess;
  132528. private _createLuminancePostProcesses;
  132529. private _createHdrPostProcess;
  132530. private _createLensFlarePostProcess;
  132531. private _createDepthOfFieldPostProcess;
  132532. private _createMotionBlurPostProcess;
  132533. private _getDepthTexture;
  132534. private _disposePostProcesses;
  132535. /**
  132536. * Dispose of the pipeline and stop all post processes
  132537. */
  132538. dispose(): void;
  132539. /**
  132540. * Serialize the rendering pipeline (Used when exporting)
  132541. * @returns the serialized object
  132542. */
  132543. serialize(): any;
  132544. /**
  132545. * Parse the serialized pipeline
  132546. * @param source Source pipeline.
  132547. * @param scene The scene to load the pipeline to.
  132548. * @param rootUrl The URL of the serialized pipeline.
  132549. * @returns An instantiated pipeline from the serialized object.
  132550. */
  132551. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  132552. /**
  132553. * Luminance steps
  132554. */
  132555. static LuminanceSteps: number;
  132556. }
  132557. }
  132558. declare module BABYLON {
  132559. /** @hidden */
  132560. export var tonemapPixelShader: {
  132561. name: string;
  132562. shader: string;
  132563. };
  132564. }
  132565. declare module BABYLON {
  132566. /** Defines operator used for tonemapping */
  132567. export enum TonemappingOperator {
  132568. /** Hable */
  132569. Hable = 0,
  132570. /** Reinhard */
  132571. Reinhard = 1,
  132572. /** HejiDawson */
  132573. HejiDawson = 2,
  132574. /** Photographic */
  132575. Photographic = 3
  132576. }
  132577. /**
  132578. * Defines a post process to apply tone mapping
  132579. */
  132580. export class TonemapPostProcess extends PostProcess {
  132581. private _operator;
  132582. /** Defines the required exposure adjustement */
  132583. exposureAdjustment: number;
  132584. /**
  132585. * Creates a new TonemapPostProcess
  132586. * @param name defines the name of the postprocess
  132587. * @param _operator defines the operator to use
  132588. * @param exposureAdjustment defines the required exposure adjustement
  132589. * @param camera defines the camera to use (can be null)
  132590. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  132591. * @param engine defines the hosting engine (can be ignore if camera is set)
  132592. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  132593. */
  132594. constructor(name: string, _operator: TonemappingOperator,
  132595. /** Defines the required exposure adjustement */
  132596. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  132597. }
  132598. }
  132599. declare module BABYLON {
  132600. /** @hidden */
  132601. export var depthVertexShader: {
  132602. name: string;
  132603. shader: string;
  132604. };
  132605. }
  132606. declare module BABYLON {
  132607. /** @hidden */
  132608. export var volumetricLightScatteringPixelShader: {
  132609. name: string;
  132610. shader: string;
  132611. };
  132612. }
  132613. declare module BABYLON {
  132614. /** @hidden */
  132615. export var volumetricLightScatteringPassVertexShader: {
  132616. name: string;
  132617. shader: string;
  132618. };
  132619. }
  132620. declare module BABYLON {
  132621. /** @hidden */
  132622. export var volumetricLightScatteringPassPixelShader: {
  132623. name: string;
  132624. shader: string;
  132625. };
  132626. }
  132627. declare module BABYLON {
  132628. /**
  132629. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  132630. */
  132631. export class VolumetricLightScatteringPostProcess extends PostProcess {
  132632. private _volumetricLightScatteringPass;
  132633. private _volumetricLightScatteringRTT;
  132634. private _viewPort;
  132635. private _screenCoordinates;
  132636. private _cachedDefines;
  132637. /**
  132638. * If not undefined, the mesh position is computed from the attached node position
  132639. */
  132640. attachedNode: {
  132641. position: Vector3;
  132642. };
  132643. /**
  132644. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  132645. */
  132646. customMeshPosition: Vector3;
  132647. /**
  132648. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  132649. */
  132650. useCustomMeshPosition: boolean;
  132651. /**
  132652. * If the post-process should inverse the light scattering direction
  132653. */
  132654. invert: boolean;
  132655. /**
  132656. * The internal mesh used by the post-process
  132657. */
  132658. mesh: Mesh;
  132659. /**
  132660. * @hidden
  132661. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  132662. */
  132663. useDiffuseColor: boolean;
  132664. /**
  132665. * Array containing the excluded meshes not rendered in the internal pass
  132666. */
  132667. excludedMeshes: AbstractMesh[];
  132668. /**
  132669. * Controls the overall intensity of the post-process
  132670. */
  132671. exposure: number;
  132672. /**
  132673. * Dissipates each sample's contribution in range [0, 1]
  132674. */
  132675. decay: number;
  132676. /**
  132677. * Controls the overall intensity of each sample
  132678. */
  132679. weight: number;
  132680. /**
  132681. * Controls the density of each sample
  132682. */
  132683. density: number;
  132684. /**
  132685. * @constructor
  132686. * @param name The post-process name
  132687. * @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)
  132688. * @param camera The camera that the post-process will be attached to
  132689. * @param mesh The mesh used to create the light scattering
  132690. * @param samples The post-process quality, default 100
  132691. * @param samplingModeThe post-process filtering mode
  132692. * @param engine The babylon engine
  132693. * @param reusable If the post-process is reusable
  132694. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  132695. */
  132696. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  132697. /**
  132698. * Returns the string "VolumetricLightScatteringPostProcess"
  132699. * @returns "VolumetricLightScatteringPostProcess"
  132700. */
  132701. getClassName(): string;
  132702. private _isReady;
  132703. /**
  132704. * Sets the new light position for light scattering effect
  132705. * @param position The new custom light position
  132706. */
  132707. setCustomMeshPosition(position: Vector3): void;
  132708. /**
  132709. * Returns the light position for light scattering effect
  132710. * @return Vector3 The custom light position
  132711. */
  132712. getCustomMeshPosition(): Vector3;
  132713. /**
  132714. * Disposes the internal assets and detaches the post-process from the camera
  132715. */
  132716. dispose(camera: Camera): void;
  132717. /**
  132718. * Returns the render target texture used by the post-process
  132719. * @return the render target texture used by the post-process
  132720. */
  132721. getPass(): RenderTargetTexture;
  132722. private _meshExcluded;
  132723. private _createPass;
  132724. private _updateMeshScreenCoordinates;
  132725. /**
  132726. * Creates a default mesh for the Volumeric Light Scattering post-process
  132727. * @param name The mesh name
  132728. * @param scene The scene where to create the mesh
  132729. * @return the default mesh
  132730. */
  132731. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  132732. }
  132733. }
  132734. declare module BABYLON {
  132735. interface Scene {
  132736. /** @hidden (Backing field) */
  132737. _boundingBoxRenderer: BoundingBoxRenderer;
  132738. /** @hidden (Backing field) */
  132739. _forceShowBoundingBoxes: boolean;
  132740. /**
  132741. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  132742. */
  132743. forceShowBoundingBoxes: boolean;
  132744. /**
  132745. * Gets the bounding box renderer associated with the scene
  132746. * @returns a BoundingBoxRenderer
  132747. */
  132748. getBoundingBoxRenderer(): BoundingBoxRenderer;
  132749. }
  132750. interface AbstractMesh {
  132751. /** @hidden (Backing field) */
  132752. _showBoundingBox: boolean;
  132753. /**
  132754. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  132755. */
  132756. showBoundingBox: boolean;
  132757. }
  132758. /**
  132759. * Component responsible of rendering the bounding box of the meshes in a scene.
  132760. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  132761. */
  132762. export class BoundingBoxRenderer implements ISceneComponent {
  132763. /**
  132764. * The component name helpfull to identify the component in the list of scene components.
  132765. */
  132766. readonly name: string;
  132767. /**
  132768. * The scene the component belongs to.
  132769. */
  132770. scene: Scene;
  132771. /**
  132772. * Color of the bounding box lines placed in front of an object
  132773. */
  132774. frontColor: Color3;
  132775. /**
  132776. * Color of the bounding box lines placed behind an object
  132777. */
  132778. backColor: Color3;
  132779. /**
  132780. * Defines if the renderer should show the back lines or not
  132781. */
  132782. showBackLines: boolean;
  132783. /**
  132784. * @hidden
  132785. */
  132786. renderList: SmartArray<BoundingBox>;
  132787. private _colorShader;
  132788. private _vertexBuffers;
  132789. private _indexBuffer;
  132790. private _fillIndexBuffer;
  132791. private _fillIndexData;
  132792. /**
  132793. * Instantiates a new bounding box renderer in a scene.
  132794. * @param scene the scene the renderer renders in
  132795. */
  132796. constructor(scene: Scene);
  132797. /**
  132798. * Registers the component in a given scene
  132799. */
  132800. register(): void;
  132801. private _evaluateSubMesh;
  132802. private _activeMesh;
  132803. private _prepareRessources;
  132804. private _createIndexBuffer;
  132805. /**
  132806. * Rebuilds the elements related to this component in case of
  132807. * context lost for instance.
  132808. */
  132809. rebuild(): void;
  132810. /**
  132811. * @hidden
  132812. */
  132813. reset(): void;
  132814. /**
  132815. * Render the bounding boxes of a specific rendering group
  132816. * @param renderingGroupId defines the rendering group to render
  132817. */
  132818. render(renderingGroupId: number): void;
  132819. /**
  132820. * In case of occlusion queries, we can render the occlusion bounding box through this method
  132821. * @param mesh Define the mesh to render the occlusion bounding box for
  132822. */
  132823. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  132824. /**
  132825. * Dispose and release the resources attached to this renderer.
  132826. */
  132827. dispose(): void;
  132828. }
  132829. }
  132830. declare module BABYLON {
  132831. /** @hidden */
  132832. export var depthPixelShader: {
  132833. name: string;
  132834. shader: string;
  132835. };
  132836. }
  132837. declare module BABYLON {
  132838. /**
  132839. * This represents a depth renderer in Babylon.
  132840. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  132841. */
  132842. export class DepthRenderer {
  132843. private _scene;
  132844. private _depthMap;
  132845. private _effect;
  132846. private readonly _storeNonLinearDepth;
  132847. private readonly _clearColor;
  132848. /** Get if the depth renderer is using packed depth or not */
  132849. readonly isPacked: boolean;
  132850. private _cachedDefines;
  132851. private _camera;
  132852. /**
  132853. * Specifiess that the depth renderer will only be used within
  132854. * the camera it is created for.
  132855. * This can help forcing its rendering during the camera processing.
  132856. */
  132857. useOnlyInActiveCamera: boolean;
  132858. /** @hidden */
  132859. static _SceneComponentInitialization: (scene: Scene) => void;
  132860. /**
  132861. * Instantiates a depth renderer
  132862. * @param scene The scene the renderer belongs to
  132863. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  132864. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  132865. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132866. */
  132867. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  132868. /**
  132869. * Creates the depth rendering effect and checks if the effect is ready.
  132870. * @param subMesh The submesh to be used to render the depth map of
  132871. * @param useInstances If multiple world instances should be used
  132872. * @returns if the depth renderer is ready to render the depth map
  132873. */
  132874. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  132875. /**
  132876. * Gets the texture which the depth map will be written to.
  132877. * @returns The depth map texture
  132878. */
  132879. getDepthMap(): RenderTargetTexture;
  132880. /**
  132881. * Disposes of the depth renderer.
  132882. */
  132883. dispose(): void;
  132884. }
  132885. }
  132886. declare module BABYLON {
  132887. interface Scene {
  132888. /** @hidden (Backing field) */
  132889. _depthRenderer: {
  132890. [id: string]: DepthRenderer;
  132891. };
  132892. /**
  132893. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  132894. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  132895. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  132896. * @returns the created depth renderer
  132897. */
  132898. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  132899. /**
  132900. * Disables a depth renderer for a given camera
  132901. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  132902. */
  132903. disableDepthRenderer(camera?: Nullable<Camera>): void;
  132904. }
  132905. /**
  132906. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  132907. * in several rendering techniques.
  132908. */
  132909. export class DepthRendererSceneComponent implements ISceneComponent {
  132910. /**
  132911. * The component name helpfull to identify the component in the list of scene components.
  132912. */
  132913. readonly name: string;
  132914. /**
  132915. * The scene the component belongs to.
  132916. */
  132917. scene: Scene;
  132918. /**
  132919. * Creates a new instance of the component for the given scene
  132920. * @param scene Defines the scene to register the component in
  132921. */
  132922. constructor(scene: Scene);
  132923. /**
  132924. * Registers the component in a given scene
  132925. */
  132926. register(): void;
  132927. /**
  132928. * Rebuilds the elements related to this component in case of
  132929. * context lost for instance.
  132930. */
  132931. rebuild(): void;
  132932. /**
  132933. * Disposes the component and the associated ressources
  132934. */
  132935. dispose(): void;
  132936. private _gatherRenderTargets;
  132937. private _gatherActiveCameraRenderTargets;
  132938. }
  132939. }
  132940. declare module BABYLON {
  132941. /** @hidden */
  132942. export var outlinePixelShader: {
  132943. name: string;
  132944. shader: string;
  132945. };
  132946. }
  132947. declare module BABYLON {
  132948. /** @hidden */
  132949. export var outlineVertexShader: {
  132950. name: string;
  132951. shader: string;
  132952. };
  132953. }
  132954. declare module BABYLON {
  132955. interface Scene {
  132956. /** @hidden */
  132957. _outlineRenderer: OutlineRenderer;
  132958. /**
  132959. * Gets the outline renderer associated with the scene
  132960. * @returns a OutlineRenderer
  132961. */
  132962. getOutlineRenderer(): OutlineRenderer;
  132963. }
  132964. interface AbstractMesh {
  132965. /** @hidden (Backing field) */
  132966. _renderOutline: boolean;
  132967. /**
  132968. * Gets or sets a boolean indicating if the outline must be rendered as well
  132969. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  132970. */
  132971. renderOutline: boolean;
  132972. /** @hidden (Backing field) */
  132973. _renderOverlay: boolean;
  132974. /**
  132975. * Gets or sets a boolean indicating if the overlay must be rendered as well
  132976. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  132977. */
  132978. renderOverlay: boolean;
  132979. }
  132980. /**
  132981. * This class is responsible to draw bothe outline/overlay of meshes.
  132982. * It should not be used directly but through the available method on mesh.
  132983. */
  132984. export class OutlineRenderer implements ISceneComponent {
  132985. /**
  132986. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  132987. */
  132988. private static _StencilReference;
  132989. /**
  132990. * The name of the component. Each component must have a unique name.
  132991. */
  132992. name: string;
  132993. /**
  132994. * The scene the component belongs to.
  132995. */
  132996. scene: Scene;
  132997. /**
  132998. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  132999. */
  133000. zOffset: number;
  133001. private _engine;
  133002. private _effect;
  133003. private _cachedDefines;
  133004. private _savedDepthWrite;
  133005. /**
  133006. * Instantiates a new outline renderer. (There could be only one per scene).
  133007. * @param scene Defines the scene it belongs to
  133008. */
  133009. constructor(scene: Scene);
  133010. /**
  133011. * Register the component to one instance of a scene.
  133012. */
  133013. register(): void;
  133014. /**
  133015. * Rebuilds the elements related to this component in case of
  133016. * context lost for instance.
  133017. */
  133018. rebuild(): void;
  133019. /**
  133020. * Disposes the component and the associated ressources.
  133021. */
  133022. dispose(): void;
  133023. /**
  133024. * Renders the outline in the canvas.
  133025. * @param subMesh Defines the sumesh to render
  133026. * @param batch Defines the batch of meshes in case of instances
  133027. * @param useOverlay Defines if the rendering is for the overlay or the outline
  133028. */
  133029. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  133030. /**
  133031. * Returns whether or not the outline renderer is ready for a given submesh.
  133032. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  133033. * @param subMesh Defines the submesh to check readyness for
  133034. * @param useInstances Defines wheter wee are trying to render instances or not
  133035. * @returns true if ready otherwise false
  133036. */
  133037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133038. private _beforeRenderingMesh;
  133039. private _afterRenderingMesh;
  133040. }
  133041. }
  133042. declare module BABYLON {
  133043. /**
  133044. * Defines the basic options interface of a Sprite Frame Source Size.
  133045. */
  133046. export interface ISpriteJSONSpriteSourceSize {
  133047. /**
  133048. * number of the original width of the Frame
  133049. */
  133050. w: number;
  133051. /**
  133052. * number of the original height of the Frame
  133053. */
  133054. h: number;
  133055. }
  133056. /**
  133057. * Defines the basic options interface of a Sprite Frame Data.
  133058. */
  133059. export interface ISpriteJSONSpriteFrameData {
  133060. /**
  133061. * number of the x offset of the Frame
  133062. */
  133063. x: number;
  133064. /**
  133065. * number of the y offset of the Frame
  133066. */
  133067. y: number;
  133068. /**
  133069. * number of the width of the Frame
  133070. */
  133071. w: number;
  133072. /**
  133073. * number of the height of the Frame
  133074. */
  133075. h: number;
  133076. }
  133077. /**
  133078. * Defines the basic options interface of a JSON Sprite.
  133079. */
  133080. export interface ISpriteJSONSprite {
  133081. /**
  133082. * string name of the Frame
  133083. */
  133084. filename: string;
  133085. /**
  133086. * ISpriteJSONSpriteFrame basic object of the frame data
  133087. */
  133088. frame: ISpriteJSONSpriteFrameData;
  133089. /**
  133090. * boolean to flag is the frame was rotated.
  133091. */
  133092. rotated: boolean;
  133093. /**
  133094. * boolean to flag is the frame was trimmed.
  133095. */
  133096. trimmed: boolean;
  133097. /**
  133098. * ISpriteJSONSpriteFrame basic object of the source data
  133099. */
  133100. spriteSourceSize: ISpriteJSONSpriteFrameData;
  133101. /**
  133102. * ISpriteJSONSpriteFrame basic object of the source data
  133103. */
  133104. sourceSize: ISpriteJSONSpriteSourceSize;
  133105. }
  133106. /**
  133107. * Defines the basic options interface of a JSON atlas.
  133108. */
  133109. export interface ISpriteJSONAtlas {
  133110. /**
  133111. * Array of objects that contain the frame data.
  133112. */
  133113. frames: Array<ISpriteJSONSprite>;
  133114. /**
  133115. * object basic object containing the sprite meta data.
  133116. */
  133117. meta?: object;
  133118. }
  133119. }
  133120. declare module BABYLON {
  133121. /** @hidden */
  133122. export var spriteMapPixelShader: {
  133123. name: string;
  133124. shader: string;
  133125. };
  133126. }
  133127. declare module BABYLON {
  133128. /** @hidden */
  133129. export var spriteMapVertexShader: {
  133130. name: string;
  133131. shader: string;
  133132. };
  133133. }
  133134. declare module BABYLON {
  133135. /**
  133136. * Defines the basic options interface of a SpriteMap
  133137. */
  133138. export interface ISpriteMapOptions {
  133139. /**
  133140. * Vector2 of the number of cells in the grid.
  133141. */
  133142. stageSize?: Vector2;
  133143. /**
  133144. * Vector2 of the size of the output plane in World Units.
  133145. */
  133146. outputSize?: Vector2;
  133147. /**
  133148. * Vector3 of the position of the output plane in World Units.
  133149. */
  133150. outputPosition?: Vector3;
  133151. /**
  133152. * Vector3 of the rotation of the output plane.
  133153. */
  133154. outputRotation?: Vector3;
  133155. /**
  133156. * number of layers that the system will reserve in resources.
  133157. */
  133158. layerCount?: number;
  133159. /**
  133160. * number of max animation frames a single cell will reserve in resources.
  133161. */
  133162. maxAnimationFrames?: number;
  133163. /**
  133164. * number cell index of the base tile when the system compiles.
  133165. */
  133166. baseTile?: number;
  133167. /**
  133168. * boolean flip the sprite after its been repositioned by the framing data.
  133169. */
  133170. flipU?: boolean;
  133171. /**
  133172. * Vector3 scalar of the global RGB values of the SpriteMap.
  133173. */
  133174. colorMultiply?: Vector3;
  133175. }
  133176. /**
  133177. * Defines the IDisposable interface in order to be cleanable from resources.
  133178. */
  133179. export interface ISpriteMap extends IDisposable {
  133180. /**
  133181. * String name of the SpriteMap.
  133182. */
  133183. name: string;
  133184. /**
  133185. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  133186. */
  133187. atlasJSON: ISpriteJSONAtlas;
  133188. /**
  133189. * Texture of the SpriteMap.
  133190. */
  133191. spriteSheet: Texture;
  133192. /**
  133193. * The parameters to initialize the SpriteMap with.
  133194. */
  133195. options: ISpriteMapOptions;
  133196. }
  133197. /**
  133198. * Class used to manage a grid restricted sprite deployment on an Output plane.
  133199. */
  133200. export class SpriteMap implements ISpriteMap {
  133201. /** The Name of the spriteMap */
  133202. name: string;
  133203. /** The JSON file with the frame and meta data */
  133204. atlasJSON: ISpriteJSONAtlas;
  133205. /** The systems Sprite Sheet Texture */
  133206. spriteSheet: Texture;
  133207. /** Arguments passed with the Constructor */
  133208. options: ISpriteMapOptions;
  133209. /** Public Sprite Storage array, parsed from atlasJSON */
  133210. sprites: Array<ISpriteJSONSprite>;
  133211. /** Returns the Number of Sprites in the System */
  133212. readonly spriteCount: number;
  133213. /** Returns the Position of Output Plane*/
  133214. /** Returns the Position of Output Plane*/
  133215. position: Vector3;
  133216. /** Returns the Rotation of Output Plane*/
  133217. /** Returns the Rotation of Output Plane*/
  133218. rotation: Vector3;
  133219. /** Sets the AnimationMap*/
  133220. /** Sets the AnimationMap*/
  133221. animationMap: RawTexture;
  133222. /** Scene that the SpriteMap was created in */
  133223. private _scene;
  133224. /** Texture Buffer of Float32 that holds tile frame data*/
  133225. private _frameMap;
  133226. /** Texture Buffers of Float32 that holds tileMap data*/
  133227. private _tileMaps;
  133228. /** Texture Buffer of Float32 that holds Animation Data*/
  133229. private _animationMap;
  133230. /** Custom ShaderMaterial Central to the System*/
  133231. private _material;
  133232. /** Custom ShaderMaterial Central to the System*/
  133233. private _output;
  133234. /** Systems Time Ticker*/
  133235. private _time;
  133236. /**
  133237. * Creates a new SpriteMap
  133238. * @param name defines the SpriteMaps Name
  133239. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  133240. * @param spriteSheet is the Texture that the Sprites are on.
  133241. * @param options a basic deployment configuration
  133242. * @param scene The Scene that the map is deployed on
  133243. */
  133244. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  133245. /**
  133246. * Returns tileID location
  133247. * @returns Vector2 the cell position ID
  133248. */
  133249. getTileID(): Vector2;
  133250. /**
  133251. * Gets the UV location of the mouse over the SpriteMap.
  133252. * @returns Vector2 the UV position of the mouse interaction
  133253. */
  133254. getMousePosition(): Vector2;
  133255. /**
  133256. * Creates the "frame" texture Buffer
  133257. * -------------------------------------
  133258. * Structure of frames
  133259. * "filename": "Falling-Water-2.png",
  133260. * "frame": {"x":69,"y":103,"w":24,"h":32},
  133261. * "rotated": true,
  133262. * "trimmed": true,
  133263. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  133264. * "sourceSize": {"w":32,"h":32}
  133265. * @returns RawTexture of the frameMap
  133266. */
  133267. private _createFrameBuffer;
  133268. /**
  133269. * Creates the tileMap texture Buffer
  133270. * @param buffer normally and array of numbers, or a false to generate from scratch
  133271. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  133272. * @returns RawTexture of the tileMap
  133273. */
  133274. private _createTileBuffer;
  133275. /**
  133276. * Modifies the data of the tileMaps
  133277. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  133278. * @param pos is the iVector2 Coordinates of the Tile
  133279. * @param tile The SpriteIndex of the new Tile
  133280. */
  133281. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  133282. /**
  133283. * Creates the animationMap texture Buffer
  133284. * @param buffer normally and array of numbers, or a false to generate from scratch
  133285. * @returns RawTexture of the animationMap
  133286. */
  133287. private _createTileAnimationBuffer;
  133288. /**
  133289. * Modifies the data of the animationMap
  133290. * @param cellID is the Index of the Sprite
  133291. * @param _frame is the target Animation frame
  133292. * @param toCell is the Target Index of the next frame of the animation
  133293. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  133294. * @param speed is a global scalar of the time variable on the map.
  133295. */
  133296. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  133297. /**
  133298. * Exports the .tilemaps file
  133299. */
  133300. saveTileMaps(): void;
  133301. /**
  133302. * Imports the .tilemaps file
  133303. * @param url of the .tilemaps file
  133304. */
  133305. loadTileMaps(url: string): void;
  133306. /**
  133307. * Release associated resources
  133308. */
  133309. dispose(): void;
  133310. }
  133311. }
  133312. declare module BABYLON {
  133313. /**
  133314. * Class used to manage multiple sprites of different sizes on the same spritesheet
  133315. * @see http://doc.babylonjs.com/babylon101/sprites
  133316. */
  133317. export class SpritePackedManager extends SpriteManager {
  133318. /** defines the packed manager's name */
  133319. name: string;
  133320. /**
  133321. * Creates a new sprite manager from a packed sprite sheet
  133322. * @param name defines the manager's name
  133323. * @param imgUrl defines the sprite sheet url
  133324. * @param capacity defines the maximum allowed number of sprites
  133325. * @param scene defines the hosting scene
  133326. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  133327. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  133328. * @param samplingMode defines the smapling mode to use with spritesheet
  133329. * @param fromPacked set to true; do not alter
  133330. */
  133331. constructor(
  133332. /** defines the packed manager's name */
  133333. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  133334. }
  133335. }
  133336. declare module BABYLON {
  133337. /**
  133338. * Defines the list of states available for a task inside a AssetsManager
  133339. */
  133340. export enum AssetTaskState {
  133341. /**
  133342. * Initialization
  133343. */
  133344. INIT = 0,
  133345. /**
  133346. * Running
  133347. */
  133348. RUNNING = 1,
  133349. /**
  133350. * Done
  133351. */
  133352. DONE = 2,
  133353. /**
  133354. * Error
  133355. */
  133356. ERROR = 3
  133357. }
  133358. /**
  133359. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  133360. */
  133361. export abstract class AbstractAssetTask {
  133362. /**
  133363. * Task name
  133364. */ name: string;
  133365. /**
  133366. * Callback called when the task is successful
  133367. */
  133368. onSuccess: (task: any) => void;
  133369. /**
  133370. * Callback called when the task is not successful
  133371. */
  133372. onError: (task: any, message?: string, exception?: any) => void;
  133373. /**
  133374. * Creates a new AssetsManager
  133375. * @param name defines the name of the task
  133376. */
  133377. constructor(
  133378. /**
  133379. * Task name
  133380. */ name: string);
  133381. private _isCompleted;
  133382. private _taskState;
  133383. private _errorObject;
  133384. /**
  133385. * Get if the task is completed
  133386. */
  133387. readonly isCompleted: boolean;
  133388. /**
  133389. * Gets the current state of the task
  133390. */
  133391. readonly taskState: AssetTaskState;
  133392. /**
  133393. * Gets the current error object (if task is in error)
  133394. */
  133395. readonly errorObject: {
  133396. message?: string;
  133397. exception?: any;
  133398. };
  133399. /**
  133400. * Internal only
  133401. * @hidden
  133402. */
  133403. _setErrorObject(message?: string, exception?: any): void;
  133404. /**
  133405. * Execute the current task
  133406. * @param scene defines the scene where you want your assets to be loaded
  133407. * @param onSuccess is a callback called when the task is successfully executed
  133408. * @param onError is a callback called if an error occurs
  133409. */
  133410. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133411. /**
  133412. * Execute the current task
  133413. * @param scene defines the scene where you want your assets to be loaded
  133414. * @param onSuccess is a callback called when the task is successfully executed
  133415. * @param onError is a callback called if an error occurs
  133416. */
  133417. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133418. /**
  133419. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  133420. * This can be used with failed tasks that have the reason for failure fixed.
  133421. */
  133422. reset(): void;
  133423. private onErrorCallback;
  133424. private onDoneCallback;
  133425. }
  133426. /**
  133427. * Define the interface used by progress events raised during assets loading
  133428. */
  133429. export interface IAssetsProgressEvent {
  133430. /**
  133431. * Defines the number of remaining tasks to process
  133432. */
  133433. remainingCount: number;
  133434. /**
  133435. * Defines the total number of tasks
  133436. */
  133437. totalCount: number;
  133438. /**
  133439. * Defines the task that was just processed
  133440. */
  133441. task: AbstractAssetTask;
  133442. }
  133443. /**
  133444. * Class used to share progress information about assets loading
  133445. */
  133446. export class AssetsProgressEvent implements IAssetsProgressEvent {
  133447. /**
  133448. * Defines the number of remaining tasks to process
  133449. */
  133450. remainingCount: number;
  133451. /**
  133452. * Defines the total number of tasks
  133453. */
  133454. totalCount: number;
  133455. /**
  133456. * Defines the task that was just processed
  133457. */
  133458. task: AbstractAssetTask;
  133459. /**
  133460. * Creates a AssetsProgressEvent
  133461. * @param remainingCount defines the number of remaining tasks to process
  133462. * @param totalCount defines the total number of tasks
  133463. * @param task defines the task that was just processed
  133464. */
  133465. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  133466. }
  133467. /**
  133468. * Define a task used by AssetsManager to load meshes
  133469. */
  133470. export class MeshAssetTask extends AbstractAssetTask {
  133471. /**
  133472. * Defines the name of the task
  133473. */
  133474. name: string;
  133475. /**
  133476. * Defines the list of mesh's names you want to load
  133477. */
  133478. meshesNames: any;
  133479. /**
  133480. * Defines the root url to use as a base to load your meshes and associated resources
  133481. */
  133482. rootUrl: string;
  133483. /**
  133484. * Defines the filename of the scene to load from
  133485. */
  133486. sceneFilename: string;
  133487. /**
  133488. * Gets the list of loaded meshes
  133489. */
  133490. loadedMeshes: Array<AbstractMesh>;
  133491. /**
  133492. * Gets the list of loaded particle systems
  133493. */
  133494. loadedParticleSystems: Array<IParticleSystem>;
  133495. /**
  133496. * Gets the list of loaded skeletons
  133497. */
  133498. loadedSkeletons: Array<Skeleton>;
  133499. /**
  133500. * Gets the list of loaded animation groups
  133501. */
  133502. loadedAnimationGroups: Array<AnimationGroup>;
  133503. /**
  133504. * Callback called when the task is successful
  133505. */
  133506. onSuccess: (task: MeshAssetTask) => void;
  133507. /**
  133508. * Callback called when the task is successful
  133509. */
  133510. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  133511. /**
  133512. * Creates a new MeshAssetTask
  133513. * @param name defines the name of the task
  133514. * @param meshesNames defines the list of mesh's names you want to load
  133515. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  133516. * @param sceneFilename defines the filename of the scene to load from
  133517. */
  133518. constructor(
  133519. /**
  133520. * Defines the name of the task
  133521. */
  133522. name: string,
  133523. /**
  133524. * Defines the list of mesh's names you want to load
  133525. */
  133526. meshesNames: any,
  133527. /**
  133528. * Defines the root url to use as a base to load your meshes and associated resources
  133529. */
  133530. rootUrl: string,
  133531. /**
  133532. * Defines the filename of the scene to load from
  133533. */
  133534. sceneFilename: string);
  133535. /**
  133536. * Execute the current task
  133537. * @param scene defines the scene where you want your assets to be loaded
  133538. * @param onSuccess is a callback called when the task is successfully executed
  133539. * @param onError is a callback called if an error occurs
  133540. */
  133541. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133542. }
  133543. /**
  133544. * Define a task used by AssetsManager to load text content
  133545. */
  133546. export class TextFileAssetTask extends AbstractAssetTask {
  133547. /**
  133548. * Defines the name of the task
  133549. */
  133550. name: string;
  133551. /**
  133552. * Defines the location of the file to load
  133553. */
  133554. url: string;
  133555. /**
  133556. * Gets the loaded text string
  133557. */
  133558. text: string;
  133559. /**
  133560. * Callback called when the task is successful
  133561. */
  133562. onSuccess: (task: TextFileAssetTask) => void;
  133563. /**
  133564. * Callback called when the task is successful
  133565. */
  133566. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  133567. /**
  133568. * Creates a new TextFileAssetTask object
  133569. * @param name defines the name of the task
  133570. * @param url defines the location of the file to load
  133571. */
  133572. constructor(
  133573. /**
  133574. * Defines the name of the task
  133575. */
  133576. name: string,
  133577. /**
  133578. * Defines the location of the file to load
  133579. */
  133580. url: string);
  133581. /**
  133582. * Execute the current task
  133583. * @param scene defines the scene where you want your assets to be loaded
  133584. * @param onSuccess is a callback called when the task is successfully executed
  133585. * @param onError is a callback called if an error occurs
  133586. */
  133587. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133588. }
  133589. /**
  133590. * Define a task used by AssetsManager to load binary data
  133591. */
  133592. export class BinaryFileAssetTask extends AbstractAssetTask {
  133593. /**
  133594. * Defines the name of the task
  133595. */
  133596. name: string;
  133597. /**
  133598. * Defines the location of the file to load
  133599. */
  133600. url: string;
  133601. /**
  133602. * Gets the lodaded data (as an array buffer)
  133603. */
  133604. data: ArrayBuffer;
  133605. /**
  133606. * Callback called when the task is successful
  133607. */
  133608. onSuccess: (task: BinaryFileAssetTask) => void;
  133609. /**
  133610. * Callback called when the task is successful
  133611. */
  133612. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  133613. /**
  133614. * Creates a new BinaryFileAssetTask object
  133615. * @param name defines the name of the new task
  133616. * @param url defines the location of the file to load
  133617. */
  133618. constructor(
  133619. /**
  133620. * Defines the name of the task
  133621. */
  133622. name: string,
  133623. /**
  133624. * Defines the location of the file to load
  133625. */
  133626. url: string);
  133627. /**
  133628. * Execute the current task
  133629. * @param scene defines the scene where you want your assets to be loaded
  133630. * @param onSuccess is a callback called when the task is successfully executed
  133631. * @param onError is a callback called if an error occurs
  133632. */
  133633. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133634. }
  133635. /**
  133636. * Define a task used by AssetsManager to load images
  133637. */
  133638. export class ImageAssetTask extends AbstractAssetTask {
  133639. /**
  133640. * Defines the name of the task
  133641. */
  133642. name: string;
  133643. /**
  133644. * Defines the location of the image to load
  133645. */
  133646. url: string;
  133647. /**
  133648. * Gets the loaded images
  133649. */
  133650. image: HTMLImageElement;
  133651. /**
  133652. * Callback called when the task is successful
  133653. */
  133654. onSuccess: (task: ImageAssetTask) => void;
  133655. /**
  133656. * Callback called when the task is successful
  133657. */
  133658. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  133659. /**
  133660. * Creates a new ImageAssetTask
  133661. * @param name defines the name of the task
  133662. * @param url defines the location of the image to load
  133663. */
  133664. constructor(
  133665. /**
  133666. * Defines the name of the task
  133667. */
  133668. name: string,
  133669. /**
  133670. * Defines the location of the image to load
  133671. */
  133672. url: string);
  133673. /**
  133674. * Execute the current task
  133675. * @param scene defines the scene where you want your assets to be loaded
  133676. * @param onSuccess is a callback called when the task is successfully executed
  133677. * @param onError is a callback called if an error occurs
  133678. */
  133679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133680. }
  133681. /**
  133682. * Defines the interface used by texture loading tasks
  133683. */
  133684. export interface ITextureAssetTask<TEX extends BaseTexture> {
  133685. /**
  133686. * Gets the loaded texture
  133687. */
  133688. texture: TEX;
  133689. }
  133690. /**
  133691. * Define a task used by AssetsManager to load 2D textures
  133692. */
  133693. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  133694. /**
  133695. * Defines the name of the task
  133696. */
  133697. name: string;
  133698. /**
  133699. * Defines the location of the file to load
  133700. */
  133701. url: string;
  133702. /**
  133703. * Defines if mipmap should not be generated (default is false)
  133704. */
  133705. noMipmap?: boolean | undefined;
  133706. /**
  133707. * Defines if texture must be inverted on Y axis (default is false)
  133708. */
  133709. invertY?: boolean | undefined;
  133710. /**
  133711. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133712. */
  133713. samplingMode: number;
  133714. /**
  133715. * Gets the loaded texture
  133716. */
  133717. texture: Texture;
  133718. /**
  133719. * Callback called when the task is successful
  133720. */
  133721. onSuccess: (task: TextureAssetTask) => void;
  133722. /**
  133723. * Callback called when the task is successful
  133724. */
  133725. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  133726. /**
  133727. * Creates a new TextureAssetTask object
  133728. * @param name defines the name of the task
  133729. * @param url defines the location of the file to load
  133730. * @param noMipmap defines if mipmap should not be generated (default is false)
  133731. * @param invertY defines if texture must be inverted on Y axis (default is false)
  133732. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133733. */
  133734. constructor(
  133735. /**
  133736. * Defines the name of the task
  133737. */
  133738. name: string,
  133739. /**
  133740. * Defines the location of the file to load
  133741. */
  133742. url: string,
  133743. /**
  133744. * Defines if mipmap should not be generated (default is false)
  133745. */
  133746. noMipmap?: boolean | undefined,
  133747. /**
  133748. * Defines if texture must be inverted on Y axis (default is false)
  133749. */
  133750. invertY?: boolean | undefined,
  133751. /**
  133752. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  133753. */
  133754. samplingMode?: number);
  133755. /**
  133756. * Execute the current task
  133757. * @param scene defines the scene where you want your assets to be loaded
  133758. * @param onSuccess is a callback called when the task is successfully executed
  133759. * @param onError is a callback called if an error occurs
  133760. */
  133761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133762. }
  133763. /**
  133764. * Define a task used by AssetsManager to load cube textures
  133765. */
  133766. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  133767. /**
  133768. * Defines the name of the task
  133769. */
  133770. name: string;
  133771. /**
  133772. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133773. */
  133774. url: string;
  133775. /**
  133776. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133777. */
  133778. extensions?: string[] | undefined;
  133779. /**
  133780. * Defines if mipmaps should not be generated (default is false)
  133781. */
  133782. noMipmap?: boolean | undefined;
  133783. /**
  133784. * Defines the explicit list of files (undefined by default)
  133785. */
  133786. files?: string[] | undefined;
  133787. /**
  133788. * Gets the loaded texture
  133789. */
  133790. texture: CubeTexture;
  133791. /**
  133792. * Callback called when the task is successful
  133793. */
  133794. onSuccess: (task: CubeTextureAssetTask) => void;
  133795. /**
  133796. * Callback called when the task is successful
  133797. */
  133798. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  133799. /**
  133800. * Creates a new CubeTextureAssetTask
  133801. * @param name defines the name of the task
  133802. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133803. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133804. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133805. * @param files defines the explicit list of files (undefined by default)
  133806. */
  133807. constructor(
  133808. /**
  133809. * Defines the name of the task
  133810. */
  133811. name: string,
  133812. /**
  133813. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  133814. */
  133815. url: string,
  133816. /**
  133817. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  133818. */
  133819. extensions?: string[] | undefined,
  133820. /**
  133821. * Defines if mipmaps should not be generated (default is false)
  133822. */
  133823. noMipmap?: boolean | undefined,
  133824. /**
  133825. * Defines the explicit list of files (undefined by default)
  133826. */
  133827. files?: string[] | undefined);
  133828. /**
  133829. * Execute the current task
  133830. * @param scene defines the scene where you want your assets to be loaded
  133831. * @param onSuccess is a callback called when the task is successfully executed
  133832. * @param onError is a callback called if an error occurs
  133833. */
  133834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133835. }
  133836. /**
  133837. * Define a task used by AssetsManager to load HDR cube textures
  133838. */
  133839. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  133840. /**
  133841. * Defines the name of the task
  133842. */
  133843. name: string;
  133844. /**
  133845. * Defines the location of the file to load
  133846. */
  133847. url: string;
  133848. /**
  133849. * Defines the desired size (the more it increases the longer the generation will be)
  133850. */
  133851. size: number;
  133852. /**
  133853. * Defines if mipmaps should not be generated (default is false)
  133854. */
  133855. noMipmap: boolean;
  133856. /**
  133857. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133858. */
  133859. generateHarmonics: boolean;
  133860. /**
  133861. * 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)
  133862. */
  133863. gammaSpace: boolean;
  133864. /**
  133865. * Internal Use Only
  133866. */
  133867. reserved: boolean;
  133868. /**
  133869. * Gets the loaded texture
  133870. */
  133871. texture: HDRCubeTexture;
  133872. /**
  133873. * Callback called when the task is successful
  133874. */
  133875. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  133876. /**
  133877. * Callback called when the task is successful
  133878. */
  133879. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  133880. /**
  133881. * Creates a new HDRCubeTextureAssetTask object
  133882. * @param name defines the name of the task
  133883. * @param url defines the location of the file to load
  133884. * @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.
  133885. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133886. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133887. * @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)
  133888. * @param reserved Internal use only
  133889. */
  133890. constructor(
  133891. /**
  133892. * Defines the name of the task
  133893. */
  133894. name: string,
  133895. /**
  133896. * Defines the location of the file to load
  133897. */
  133898. url: string,
  133899. /**
  133900. * Defines the desired size (the more it increases the longer the generation will be)
  133901. */
  133902. size: number,
  133903. /**
  133904. * Defines if mipmaps should not be generated (default is false)
  133905. */
  133906. noMipmap?: boolean,
  133907. /**
  133908. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  133909. */
  133910. generateHarmonics?: boolean,
  133911. /**
  133912. * 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)
  133913. */
  133914. gammaSpace?: boolean,
  133915. /**
  133916. * Internal Use Only
  133917. */
  133918. reserved?: boolean);
  133919. /**
  133920. * Execute the current task
  133921. * @param scene defines the scene where you want your assets to be loaded
  133922. * @param onSuccess is a callback called when the task is successfully executed
  133923. * @param onError is a callback called if an error occurs
  133924. */
  133925. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  133926. }
  133927. /**
  133928. * Define a task used by AssetsManager to load Equirectangular cube textures
  133929. */
  133930. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  133931. /**
  133932. * Defines the name of the task
  133933. */
  133934. name: string;
  133935. /**
  133936. * Defines the location of the file to load
  133937. */
  133938. url: string;
  133939. /**
  133940. * Defines the desired size (the more it increases the longer the generation will be)
  133941. */
  133942. size: number;
  133943. /**
  133944. * Defines if mipmaps should not be generated (default is false)
  133945. */
  133946. noMipmap: boolean;
  133947. /**
  133948. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133949. * but the standard material would require them in Gamma space) (default is true)
  133950. */
  133951. gammaSpace: boolean;
  133952. /**
  133953. * Gets the loaded texture
  133954. */
  133955. texture: EquiRectangularCubeTexture;
  133956. /**
  133957. * Callback called when the task is successful
  133958. */
  133959. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  133960. /**
  133961. * Callback called when the task is successful
  133962. */
  133963. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  133964. /**
  133965. * Creates a new EquiRectangularCubeTextureAssetTask object
  133966. * @param name defines the name of the task
  133967. * @param url defines the location of the file to load
  133968. * @param size defines the desired size (the more it increases the longer the generation will be)
  133969. * If the size is omitted this implies you are using a preprocessed cubemap.
  133970. * @param noMipmap defines if mipmaps should not be generated (default is false)
  133971. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  133972. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  133973. * (default is true)
  133974. */
  133975. constructor(
  133976. /**
  133977. * Defines the name of the task
  133978. */
  133979. name: string,
  133980. /**
  133981. * Defines the location of the file to load
  133982. */
  133983. url: string,
  133984. /**
  133985. * Defines the desired size (the more it increases the longer the generation will be)
  133986. */
  133987. size: number,
  133988. /**
  133989. * Defines if mipmaps should not be generated (default is false)
  133990. */
  133991. noMipmap?: boolean,
  133992. /**
  133993. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  133994. * but the standard material would require them in Gamma space) (default is true)
  133995. */
  133996. gammaSpace?: boolean);
  133997. /**
  133998. * Execute the current task
  133999. * @param scene defines the scene where you want your assets to be loaded
  134000. * @param onSuccess is a callback called when the task is successfully executed
  134001. * @param onError is a callback called if an error occurs
  134002. */
  134003. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  134004. }
  134005. /**
  134006. * This class can be used to easily import assets into a scene
  134007. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  134008. */
  134009. export class AssetsManager {
  134010. private _scene;
  134011. private _isLoading;
  134012. protected _tasks: AbstractAssetTask[];
  134013. protected _waitingTasksCount: number;
  134014. protected _totalTasksCount: number;
  134015. /**
  134016. * Callback called when all tasks are processed
  134017. */
  134018. onFinish: (tasks: AbstractAssetTask[]) => void;
  134019. /**
  134020. * Callback called when a task is successful
  134021. */
  134022. onTaskSuccess: (task: AbstractAssetTask) => void;
  134023. /**
  134024. * Callback called when a task had an error
  134025. */
  134026. onTaskError: (task: AbstractAssetTask) => void;
  134027. /**
  134028. * Callback called when a task is done (whatever the result is)
  134029. */
  134030. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  134031. /**
  134032. * Observable called when all tasks are processed
  134033. */
  134034. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  134035. /**
  134036. * Observable called when a task had an error
  134037. */
  134038. onTaskErrorObservable: Observable<AbstractAssetTask>;
  134039. /**
  134040. * Observable called when all tasks were executed
  134041. */
  134042. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  134043. /**
  134044. * Observable called when a task is done (whatever the result is)
  134045. */
  134046. onProgressObservable: Observable<IAssetsProgressEvent>;
  134047. /**
  134048. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  134049. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  134050. */
  134051. useDefaultLoadingScreen: boolean;
  134052. /**
  134053. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  134054. * when all assets have been downloaded.
  134055. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  134056. */
  134057. autoHideLoadingUI: boolean;
  134058. /**
  134059. * Creates a new AssetsManager
  134060. * @param scene defines the scene to work on
  134061. */
  134062. constructor(scene: Scene);
  134063. /**
  134064. * Add a MeshAssetTask to the list of active tasks
  134065. * @param taskName defines the name of the new task
  134066. * @param meshesNames defines the name of meshes to load
  134067. * @param rootUrl defines the root url to use to locate files
  134068. * @param sceneFilename defines the filename of the scene file
  134069. * @returns a new MeshAssetTask object
  134070. */
  134071. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  134072. /**
  134073. * Add a TextFileAssetTask to the list of active tasks
  134074. * @param taskName defines the name of the new task
  134075. * @param url defines the url of the file to load
  134076. * @returns a new TextFileAssetTask object
  134077. */
  134078. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  134079. /**
  134080. * Add a BinaryFileAssetTask to the list of active tasks
  134081. * @param taskName defines the name of the new task
  134082. * @param url defines the url of the file to load
  134083. * @returns a new BinaryFileAssetTask object
  134084. */
  134085. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  134086. /**
  134087. * Add a ImageAssetTask to the list of active tasks
  134088. * @param taskName defines the name of the new task
  134089. * @param url defines the url of the file to load
  134090. * @returns a new ImageAssetTask object
  134091. */
  134092. addImageTask(taskName: string, url: string): ImageAssetTask;
  134093. /**
  134094. * Add a TextureAssetTask to the list of active tasks
  134095. * @param taskName defines the name of the new task
  134096. * @param url defines the url of the file to load
  134097. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134098. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  134099. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  134100. * @returns a new TextureAssetTask object
  134101. */
  134102. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  134103. /**
  134104. * Add a CubeTextureAssetTask to the list of active tasks
  134105. * @param taskName defines the name of the new task
  134106. * @param url defines the url of the file to load
  134107. * @param extensions defines the extension to use to load the cube map (can be null)
  134108. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134109. * @param files defines the list of files to load (can be null)
  134110. * @returns a new CubeTextureAssetTask object
  134111. */
  134112. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  134113. /**
  134114. *
  134115. * Add a HDRCubeTextureAssetTask to the list of active tasks
  134116. * @param taskName defines the name of the new task
  134117. * @param url defines the url of the file to load
  134118. * @param size defines the size you want for the cubemap (can be null)
  134119. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134120. * @param generateHarmonics defines if you want to automatically generate (true by default)
  134121. * @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)
  134122. * @param reserved Internal use only
  134123. * @returns a new HDRCubeTextureAssetTask object
  134124. */
  134125. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  134126. /**
  134127. *
  134128. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  134129. * @param taskName defines the name of the new task
  134130. * @param url defines the url of the file to load
  134131. * @param size defines the size you want for the cubemap (can be null)
  134132. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  134133. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  134134. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  134135. * @returns a new EquiRectangularCubeTextureAssetTask object
  134136. */
  134137. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  134138. /**
  134139. * Remove a task from the assets manager.
  134140. * @param task the task to remove
  134141. */
  134142. removeTask(task: AbstractAssetTask): void;
  134143. private _decreaseWaitingTasksCount;
  134144. private _runTask;
  134145. /**
  134146. * Reset the AssetsManager and remove all tasks
  134147. * @return the current instance of the AssetsManager
  134148. */
  134149. reset(): AssetsManager;
  134150. /**
  134151. * Start the loading process
  134152. * @return the current instance of the AssetsManager
  134153. */
  134154. load(): AssetsManager;
  134155. /**
  134156. * Start the loading process as an async operation
  134157. * @return a promise returning the list of failed tasks
  134158. */
  134159. loadAsync(): Promise<void>;
  134160. }
  134161. }
  134162. declare module BABYLON {
  134163. /**
  134164. * Wrapper class for promise with external resolve and reject.
  134165. */
  134166. export class Deferred<T> {
  134167. /**
  134168. * The promise associated with this deferred object.
  134169. */
  134170. readonly promise: Promise<T>;
  134171. private _resolve;
  134172. private _reject;
  134173. /**
  134174. * The resolve method of the promise associated with this deferred object.
  134175. */
  134176. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  134177. /**
  134178. * The reject method of the promise associated with this deferred object.
  134179. */
  134180. readonly reject: (reason?: any) => void;
  134181. /**
  134182. * Constructor for this deferred object.
  134183. */
  134184. constructor();
  134185. }
  134186. }
  134187. declare module BABYLON {
  134188. /**
  134189. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  134190. */
  134191. export class MeshExploder {
  134192. private _centerMesh;
  134193. private _meshes;
  134194. private _meshesOrigins;
  134195. private _toCenterVectors;
  134196. private _scaledDirection;
  134197. private _newPosition;
  134198. private _centerPosition;
  134199. /**
  134200. * Explodes meshes from a center mesh.
  134201. * @param meshes The meshes to explode.
  134202. * @param centerMesh The mesh to be center of explosion.
  134203. */
  134204. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  134205. private _setCenterMesh;
  134206. /**
  134207. * Get class name
  134208. * @returns "MeshExploder"
  134209. */
  134210. getClassName(): string;
  134211. /**
  134212. * "Exploded meshes"
  134213. * @returns Array of meshes with the centerMesh at index 0.
  134214. */
  134215. getMeshes(): Array<Mesh>;
  134216. /**
  134217. * Explodes meshes giving a specific direction
  134218. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  134219. */
  134220. explode(direction?: number): void;
  134221. }
  134222. }
  134223. declare module BABYLON {
  134224. /**
  134225. * Class used to help managing file picking and drag'n'drop
  134226. */
  134227. export class FilesInput {
  134228. /**
  134229. * List of files ready to be loaded
  134230. */
  134231. static readonly FilesToLoad: {
  134232. [key: string]: File;
  134233. };
  134234. /**
  134235. * Callback called when a file is processed
  134236. */
  134237. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  134238. private _engine;
  134239. private _currentScene;
  134240. private _sceneLoadedCallback;
  134241. private _progressCallback;
  134242. private _additionalRenderLoopLogicCallback;
  134243. private _textureLoadingCallback;
  134244. private _startingProcessingFilesCallback;
  134245. private _onReloadCallback;
  134246. private _errorCallback;
  134247. private _elementToMonitor;
  134248. private _sceneFileToLoad;
  134249. private _filesToLoad;
  134250. /**
  134251. * Creates a new FilesInput
  134252. * @param engine defines the rendering engine
  134253. * @param scene defines the hosting scene
  134254. * @param sceneLoadedCallback callback called when scene is loaded
  134255. * @param progressCallback callback called to track progress
  134256. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  134257. * @param textureLoadingCallback callback called when a texture is loading
  134258. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  134259. * @param onReloadCallback callback called when a reload is requested
  134260. * @param errorCallback callback call if an error occurs
  134261. */
  134262. 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);
  134263. private _dragEnterHandler;
  134264. private _dragOverHandler;
  134265. private _dropHandler;
  134266. /**
  134267. * Calls this function to listen to drag'n'drop events on a specific DOM element
  134268. * @param elementToMonitor defines the DOM element to track
  134269. */
  134270. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  134271. /**
  134272. * Release all associated resources
  134273. */
  134274. dispose(): void;
  134275. private renderFunction;
  134276. private drag;
  134277. private drop;
  134278. private _traverseFolder;
  134279. private _processFiles;
  134280. /**
  134281. * Load files from a drop event
  134282. * @param event defines the drop event to use as source
  134283. */
  134284. loadFiles(event: any): void;
  134285. private _processReload;
  134286. /**
  134287. * Reload the current scene from the loaded files
  134288. */
  134289. reload(): void;
  134290. }
  134291. }
  134292. declare module BABYLON {
  134293. /**
  134294. * Defines the root class used to create scene optimization to use with SceneOptimizer
  134295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134296. */
  134297. export class SceneOptimization {
  134298. /**
  134299. * Defines the priority of this optimization (0 by default which means first in the list)
  134300. */
  134301. priority: number;
  134302. /**
  134303. * Gets a string describing the action executed by the current optimization
  134304. * @returns description string
  134305. */
  134306. getDescription(): string;
  134307. /**
  134308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134309. * @param scene defines the current scene where to apply this optimization
  134310. * @param optimizer defines the current optimizer
  134311. * @returns true if everything that can be done was applied
  134312. */
  134313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134314. /**
  134315. * Creates the SceneOptimization object
  134316. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134317. * @param desc defines the description associated with the optimization
  134318. */
  134319. constructor(
  134320. /**
  134321. * Defines the priority of this optimization (0 by default which means first in the list)
  134322. */
  134323. priority?: number);
  134324. }
  134325. /**
  134326. * Defines an optimization used to reduce the size of render target textures
  134327. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134328. */
  134329. export class TextureOptimization extends SceneOptimization {
  134330. /**
  134331. * Defines the priority of this optimization (0 by default which means first in the list)
  134332. */
  134333. priority: number;
  134334. /**
  134335. * 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
  134336. */
  134337. maximumSize: number;
  134338. /**
  134339. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134340. */
  134341. step: number;
  134342. /**
  134343. * Gets a string describing the action executed by the current optimization
  134344. * @returns description string
  134345. */
  134346. getDescription(): string;
  134347. /**
  134348. * Creates the TextureOptimization object
  134349. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134350. * @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
  134351. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134352. */
  134353. constructor(
  134354. /**
  134355. * Defines the priority of this optimization (0 by default which means first in the list)
  134356. */
  134357. priority?: number,
  134358. /**
  134359. * 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
  134360. */
  134361. maximumSize?: number,
  134362. /**
  134363. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  134364. */
  134365. step?: number);
  134366. /**
  134367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134368. * @param scene defines the current scene where to apply this optimization
  134369. * @param optimizer defines the current optimizer
  134370. * @returns true if everything that can be done was applied
  134371. */
  134372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134373. }
  134374. /**
  134375. * Defines an optimization used to increase or decrease the rendering resolution
  134376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134377. */
  134378. export class HardwareScalingOptimization extends SceneOptimization {
  134379. /**
  134380. * Defines the priority of this optimization (0 by default which means first in the list)
  134381. */
  134382. priority: number;
  134383. /**
  134384. * Defines the maximum scale to use (2 by default)
  134385. */
  134386. maximumScale: number;
  134387. /**
  134388. * Defines the step to use between two passes (0.5 by default)
  134389. */
  134390. step: number;
  134391. private _currentScale;
  134392. private _directionOffset;
  134393. /**
  134394. * Gets a string describing the action executed by the current optimization
  134395. * @return description string
  134396. */
  134397. getDescription(): string;
  134398. /**
  134399. * Creates the HardwareScalingOptimization object
  134400. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134401. * @param maximumScale defines the maximum scale to use (2 by default)
  134402. * @param step defines the step to use between two passes (0.5 by default)
  134403. */
  134404. constructor(
  134405. /**
  134406. * Defines the priority of this optimization (0 by default which means first in the list)
  134407. */
  134408. priority?: number,
  134409. /**
  134410. * Defines the maximum scale to use (2 by default)
  134411. */
  134412. maximumScale?: number,
  134413. /**
  134414. * Defines the step to use between two passes (0.5 by default)
  134415. */
  134416. step?: number);
  134417. /**
  134418. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134419. * @param scene defines the current scene where to apply this optimization
  134420. * @param optimizer defines the current optimizer
  134421. * @returns true if everything that can be done was applied
  134422. */
  134423. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134424. }
  134425. /**
  134426. * Defines an optimization used to remove shadows
  134427. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134428. */
  134429. export class ShadowsOptimization extends SceneOptimization {
  134430. /**
  134431. * Gets a string describing the action executed by the current optimization
  134432. * @return description string
  134433. */
  134434. getDescription(): string;
  134435. /**
  134436. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134437. * @param scene defines the current scene where to apply this optimization
  134438. * @param optimizer defines the current optimizer
  134439. * @returns true if everything that can be done was applied
  134440. */
  134441. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134442. }
  134443. /**
  134444. * Defines an optimization used to turn post-processes off
  134445. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134446. */
  134447. export class PostProcessesOptimization extends SceneOptimization {
  134448. /**
  134449. * Gets a string describing the action executed by the current optimization
  134450. * @return description string
  134451. */
  134452. getDescription(): string;
  134453. /**
  134454. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134455. * @param scene defines the current scene where to apply this optimization
  134456. * @param optimizer defines the current optimizer
  134457. * @returns true if everything that can be done was applied
  134458. */
  134459. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134460. }
  134461. /**
  134462. * Defines an optimization used to turn lens flares off
  134463. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134464. */
  134465. export class LensFlaresOptimization extends SceneOptimization {
  134466. /**
  134467. * Gets a string describing the action executed by the current optimization
  134468. * @return description string
  134469. */
  134470. getDescription(): string;
  134471. /**
  134472. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134473. * @param scene defines the current scene where to apply this optimization
  134474. * @param optimizer defines the current optimizer
  134475. * @returns true if everything that can be done was applied
  134476. */
  134477. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134478. }
  134479. /**
  134480. * Defines an optimization based on user defined callback.
  134481. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134482. */
  134483. export class CustomOptimization extends SceneOptimization {
  134484. /**
  134485. * Callback called to apply the custom optimization.
  134486. */
  134487. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  134488. /**
  134489. * Callback called to get custom description
  134490. */
  134491. onGetDescription: () => string;
  134492. /**
  134493. * Gets a string describing the action executed by the current optimization
  134494. * @returns description string
  134495. */
  134496. getDescription(): string;
  134497. /**
  134498. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134499. * @param scene defines the current scene where to apply this optimization
  134500. * @param optimizer defines the current optimizer
  134501. * @returns true if everything that can be done was applied
  134502. */
  134503. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134504. }
  134505. /**
  134506. * Defines an optimization used to turn particles off
  134507. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134508. */
  134509. export class ParticlesOptimization extends SceneOptimization {
  134510. /**
  134511. * Gets a string describing the action executed by the current optimization
  134512. * @return description string
  134513. */
  134514. getDescription(): string;
  134515. /**
  134516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134517. * @param scene defines the current scene where to apply this optimization
  134518. * @param optimizer defines the current optimizer
  134519. * @returns true if everything that can be done was applied
  134520. */
  134521. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134522. }
  134523. /**
  134524. * Defines an optimization used to turn render targets off
  134525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134526. */
  134527. export class RenderTargetsOptimization extends SceneOptimization {
  134528. /**
  134529. * Gets a string describing the action executed by the current optimization
  134530. * @return description string
  134531. */
  134532. getDescription(): string;
  134533. /**
  134534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134535. * @param scene defines the current scene where to apply this optimization
  134536. * @param optimizer defines the current optimizer
  134537. * @returns true if everything that can be done was applied
  134538. */
  134539. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  134540. }
  134541. /**
  134542. * Defines an optimization used to merge meshes with compatible materials
  134543. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134544. */
  134545. export class MergeMeshesOptimization extends SceneOptimization {
  134546. private static _UpdateSelectionTree;
  134547. /**
  134548. * Gets or sets a boolean which defines if optimization octree has to be updated
  134549. */
  134550. /**
  134551. * Gets or sets a boolean which defines if optimization octree has to be updated
  134552. */
  134553. static UpdateSelectionTree: boolean;
  134554. /**
  134555. * Gets a string describing the action executed by the current optimization
  134556. * @return description string
  134557. */
  134558. getDescription(): string;
  134559. private _canBeMerged;
  134560. /**
  134561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  134562. * @param scene defines the current scene where to apply this optimization
  134563. * @param optimizer defines the current optimizer
  134564. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  134565. * @returns true if everything that can be done was applied
  134566. */
  134567. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  134568. }
  134569. /**
  134570. * Defines a list of options used by SceneOptimizer
  134571. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134572. */
  134573. export class SceneOptimizerOptions {
  134574. /**
  134575. * Defines the target frame rate to reach (60 by default)
  134576. */
  134577. targetFrameRate: number;
  134578. /**
  134579. * Defines the interval between two checkes (2000ms by default)
  134580. */
  134581. trackerDuration: number;
  134582. /**
  134583. * Gets the list of optimizations to apply
  134584. */
  134585. optimizations: SceneOptimization[];
  134586. /**
  134587. * Creates a new list of options used by SceneOptimizer
  134588. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  134589. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  134590. */
  134591. constructor(
  134592. /**
  134593. * Defines the target frame rate to reach (60 by default)
  134594. */
  134595. targetFrameRate?: number,
  134596. /**
  134597. * Defines the interval between two checkes (2000ms by default)
  134598. */
  134599. trackerDuration?: number);
  134600. /**
  134601. * Add a new optimization
  134602. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  134603. * @returns the current SceneOptimizerOptions
  134604. */
  134605. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  134606. /**
  134607. * Add a new custom optimization
  134608. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  134609. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  134610. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  134611. * @returns the current SceneOptimizerOptions
  134612. */
  134613. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  134614. /**
  134615. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  134616. * @param targetFrameRate defines the target frame rate (60 by default)
  134617. * @returns a SceneOptimizerOptions object
  134618. */
  134619. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134620. /**
  134621. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  134622. * @param targetFrameRate defines the target frame rate (60 by default)
  134623. * @returns a SceneOptimizerOptions object
  134624. */
  134625. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134626. /**
  134627. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  134628. * @param targetFrameRate defines the target frame rate (60 by default)
  134629. * @returns a SceneOptimizerOptions object
  134630. */
  134631. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  134632. }
  134633. /**
  134634. * Class used to run optimizations in order to reach a target frame rate
  134635. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  134636. */
  134637. export class SceneOptimizer implements IDisposable {
  134638. private _isRunning;
  134639. private _options;
  134640. private _scene;
  134641. private _currentPriorityLevel;
  134642. private _targetFrameRate;
  134643. private _trackerDuration;
  134644. private _currentFrameRate;
  134645. private _sceneDisposeObserver;
  134646. private _improvementMode;
  134647. /**
  134648. * Defines an observable called when the optimizer reaches the target frame rate
  134649. */
  134650. onSuccessObservable: Observable<SceneOptimizer>;
  134651. /**
  134652. * Defines an observable called when the optimizer enables an optimization
  134653. */
  134654. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  134655. /**
  134656. * Defines an observable called when the optimizer is not able to reach the target frame rate
  134657. */
  134658. onFailureObservable: Observable<SceneOptimizer>;
  134659. /**
  134660. * Gets a boolean indicating if the optimizer is in improvement mode
  134661. */
  134662. readonly isInImprovementMode: boolean;
  134663. /**
  134664. * Gets the current priority level (0 at start)
  134665. */
  134666. readonly currentPriorityLevel: number;
  134667. /**
  134668. * Gets the current frame rate checked by the SceneOptimizer
  134669. */
  134670. readonly currentFrameRate: number;
  134671. /**
  134672. * Gets or sets the current target frame rate (60 by default)
  134673. */
  134674. /**
  134675. * Gets or sets the current target frame rate (60 by default)
  134676. */
  134677. targetFrameRate: number;
  134678. /**
  134679. * Gets or sets the current interval between two checks (every 2000ms by default)
  134680. */
  134681. /**
  134682. * Gets or sets the current interval between two checks (every 2000ms by default)
  134683. */
  134684. trackerDuration: number;
  134685. /**
  134686. * Gets the list of active optimizations
  134687. */
  134688. readonly optimizations: SceneOptimization[];
  134689. /**
  134690. * Creates a new SceneOptimizer
  134691. * @param scene defines the scene to work on
  134692. * @param options defines the options to use with the SceneOptimizer
  134693. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  134694. * @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)
  134695. */
  134696. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  134697. /**
  134698. * Stops the current optimizer
  134699. */
  134700. stop(): void;
  134701. /**
  134702. * Reset the optimizer to initial step (current priority level = 0)
  134703. */
  134704. reset(): void;
  134705. /**
  134706. * Start the optimizer. By default it will try to reach a specific framerate
  134707. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  134708. */
  134709. start(): void;
  134710. private _checkCurrentState;
  134711. /**
  134712. * Release all resources
  134713. */
  134714. dispose(): void;
  134715. /**
  134716. * Helper function to create a SceneOptimizer with one single line of code
  134717. * @param scene defines the scene to work on
  134718. * @param options defines the options to use with the SceneOptimizer
  134719. * @param onSuccess defines a callback to call on success
  134720. * @param onFailure defines a callback to call on failure
  134721. * @returns the new SceneOptimizer object
  134722. */
  134723. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  134724. }
  134725. }
  134726. declare module BABYLON {
  134727. /**
  134728. * Class used to serialize a scene into a string
  134729. */
  134730. export class SceneSerializer {
  134731. /**
  134732. * Clear cache used by a previous serialization
  134733. */
  134734. static ClearCache(): void;
  134735. /**
  134736. * Serialize a scene into a JSON compatible object
  134737. * @param scene defines the scene to serialize
  134738. * @returns a JSON compatible object
  134739. */
  134740. static Serialize(scene: Scene): any;
  134741. /**
  134742. * Serialize a mesh into a JSON compatible object
  134743. * @param toSerialize defines the mesh to serialize
  134744. * @param withParents defines if parents must be serialized as well
  134745. * @param withChildren defines if children must be serialized as well
  134746. * @returns a JSON compatible object
  134747. */
  134748. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  134749. }
  134750. }
  134751. declare module BABYLON {
  134752. /**
  134753. * Class used to host texture specific utilities
  134754. */
  134755. export class TextureTools {
  134756. /**
  134757. * Uses the GPU to create a copy texture rescaled at a given size
  134758. * @param texture Texture to copy from
  134759. * @param width defines the desired width
  134760. * @param height defines the desired height
  134761. * @param useBilinearMode defines if bilinear mode has to be used
  134762. * @return the generated texture
  134763. */
  134764. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  134765. }
  134766. }
  134767. declare module BABYLON {
  134768. /**
  134769. * This represents the different options available for the video capture.
  134770. */
  134771. export interface VideoRecorderOptions {
  134772. /** Defines the mime type of the video. */
  134773. mimeType: string;
  134774. /** Defines the FPS the video should be recorded at. */
  134775. fps: number;
  134776. /** Defines the chunk size for the recording data. */
  134777. recordChunckSize: number;
  134778. /** The audio tracks to attach to the recording. */
  134779. audioTracks?: MediaStreamTrack[];
  134780. }
  134781. /**
  134782. * This can help with recording videos from BabylonJS.
  134783. * This is based on the available WebRTC functionalities of the browser.
  134784. *
  134785. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  134786. */
  134787. export class VideoRecorder {
  134788. private static readonly _defaultOptions;
  134789. /**
  134790. * Returns whether or not the VideoRecorder is available in your browser.
  134791. * @param engine Defines the Babylon Engine.
  134792. * @returns true if supported otherwise false.
  134793. */
  134794. static IsSupported(engine: Engine): boolean;
  134795. private readonly _options;
  134796. private _canvas;
  134797. private _mediaRecorder;
  134798. private _recordedChunks;
  134799. private _fileName;
  134800. private _resolve;
  134801. private _reject;
  134802. /**
  134803. * True when a recording is already in progress.
  134804. */
  134805. readonly isRecording: boolean;
  134806. /**
  134807. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  134808. * @param engine Defines the BabylonJS Engine you wish to record.
  134809. * @param options Defines options that can be used to customize the capture.
  134810. */
  134811. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  134812. /**
  134813. * Stops the current recording before the default capture timeout passed in the startRecording function.
  134814. */
  134815. stopRecording(): void;
  134816. /**
  134817. * Starts recording the canvas for a max duration specified in parameters.
  134818. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  134819. * If null no automatic download will start and you can rely on the promise to get the data back.
  134820. * @param maxDuration Defines the maximum recording time in seconds.
  134821. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  134822. * @return A promise callback at the end of the recording with the video data in Blob.
  134823. */
  134824. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  134825. /**
  134826. * Releases internal resources used during the recording.
  134827. */
  134828. dispose(): void;
  134829. private _handleDataAvailable;
  134830. private _handleError;
  134831. private _handleStop;
  134832. }
  134833. }
  134834. declare module BABYLON {
  134835. /**
  134836. * Class containing a set of static utilities functions for screenshots
  134837. */
  134838. export class ScreenshotTools {
  134839. /**
  134840. * Captures a screenshot of the current rendering
  134841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134842. * @param engine defines the rendering engine
  134843. * @param camera defines the source camera
  134844. * @param size This parameter can be set to a single number or to an object with the
  134845. * following (optional) properties: precision, width, height. If a single number is passed,
  134846. * it will be used for both width and height. If an object is passed, the screenshot size
  134847. * will be derived from the parameters. The precision property is a multiplier allowing
  134848. * rendering at a higher or lower resolution
  134849. * @param successCallback defines the callback receives a single parameter which contains the
  134850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134851. * src parameter of an <img> to display it
  134852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134853. * Check your browser for supported MIME types
  134854. */
  134855. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  134856. /**
  134857. * Captures a screenshot of the current rendering
  134858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134859. * @param engine defines the rendering engine
  134860. * @param camera defines the source camera
  134861. * @param size This parameter can be set to a single number or to an object with the
  134862. * following (optional) properties: precision, width, height. If a single number is passed,
  134863. * it will be used for both width and height. If an object is passed, the screenshot size
  134864. * will be derived from the parameters. The precision property is a multiplier allowing
  134865. * rendering at a higher or lower resolution
  134866. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  134867. * Check your browser for supported MIME types
  134868. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134869. * to the src parameter of an <img> to display it
  134870. */
  134871. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  134872. /**
  134873. * Generates an image screenshot from the specified camera.
  134874. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134875. * @param engine The engine to use for rendering
  134876. * @param camera The camera to use for rendering
  134877. * @param size This parameter can be set to a single number or to an object with the
  134878. * following (optional) properties: precision, width, height. If a single number is passed,
  134879. * it will be used for both width and height. If an object is passed, the screenshot size
  134880. * will be derived from the parameters. The precision property is a multiplier allowing
  134881. * rendering at a higher or lower resolution
  134882. * @param successCallback The callback receives a single parameter which contains the
  134883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  134884. * src parameter of an <img> to display it
  134885. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134886. * Check your browser for supported MIME types
  134887. * @param samples Texture samples (default: 1)
  134888. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134889. * @param fileName A name for for the downloaded file.
  134890. */
  134891. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  134892. /**
  134893. * Generates an image screenshot from the specified camera.
  134894. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  134895. * @param engine The engine to use for rendering
  134896. * @param camera The camera to use for rendering
  134897. * @param size This parameter can be set to a single number or to an object with the
  134898. * following (optional) properties: precision, width, height. If a single number is passed,
  134899. * it will be used for both width and height. If an object is passed, the screenshot size
  134900. * will be derived from the parameters. The precision property is a multiplier allowing
  134901. * rendering at a higher or lower resolution
  134902. * @param mimeType The MIME type of the screenshot image (default: image/png).
  134903. * Check your browser for supported MIME types
  134904. * @param samples Texture samples (default: 1)
  134905. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  134906. * @param fileName A name for for the downloaded file.
  134907. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  134908. * to the src parameter of an <img> to display it
  134909. */
  134910. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  134911. /**
  134912. * Gets height and width for screenshot size
  134913. * @private
  134914. */
  134915. private static _getScreenshotSize;
  134916. }
  134917. }
  134918. declare module BABYLON {
  134919. /**
  134920. * Interface for a data buffer
  134921. */
  134922. export interface IDataBuffer {
  134923. /**
  134924. * Reads bytes from the data buffer.
  134925. * @param byteOffset The byte offset to read
  134926. * @param byteLength The byte length to read
  134927. * @returns A promise that resolves when the bytes are read
  134928. */
  134929. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  134930. /**
  134931. * The byte length of the buffer.
  134932. */
  134933. readonly byteLength: number;
  134934. }
  134935. /**
  134936. * Utility class for reading from a data buffer
  134937. */
  134938. export class DataReader {
  134939. /**
  134940. * The data buffer associated with this data reader.
  134941. */
  134942. readonly buffer: IDataBuffer;
  134943. /**
  134944. * The current byte offset from the beginning of the data buffer.
  134945. */
  134946. byteOffset: number;
  134947. private _dataView;
  134948. private _dataByteOffset;
  134949. /**
  134950. * Constructor
  134951. * @param buffer The buffer to read
  134952. */
  134953. constructor(buffer: IDataBuffer);
  134954. /**
  134955. * Loads the given byte length.
  134956. * @param byteLength The byte length to load
  134957. * @returns A promise that resolves when the load is complete
  134958. */
  134959. loadAsync(byteLength: number): Promise<void>;
  134960. /**
  134961. * Read a unsigned 32-bit integer from the currently loaded data range.
  134962. * @returns The 32-bit integer read
  134963. */
  134964. readUint32(): number;
  134965. /**
  134966. * Read a byte array from the currently loaded data range.
  134967. * @param byteLength The byte length to read
  134968. * @returns The byte array read
  134969. */
  134970. readUint8Array(byteLength: number): Uint8Array;
  134971. /**
  134972. * Read a string from the currently loaded data range.
  134973. * @param byteLength The byte length to read
  134974. * @returns The string read
  134975. */
  134976. readString(byteLength: number): string;
  134977. /**
  134978. * Skips the given byte length the currently loaded data range.
  134979. * @param byteLength The byte length to skip
  134980. */
  134981. skipBytes(byteLength: number): void;
  134982. }
  134983. }
  134984. declare module BABYLON {
  134985. /**
  134986. * A cursor which tracks a point on a path
  134987. */
  134988. export class PathCursor {
  134989. private path;
  134990. /**
  134991. * Stores path cursor callbacks for when an onchange event is triggered
  134992. */
  134993. private _onchange;
  134994. /**
  134995. * The value of the path cursor
  134996. */
  134997. value: number;
  134998. /**
  134999. * The animation array of the path cursor
  135000. */
  135001. animations: Animation[];
  135002. /**
  135003. * Initializes the path cursor
  135004. * @param path The path to track
  135005. */
  135006. constructor(path: Path2);
  135007. /**
  135008. * Gets the cursor point on the path
  135009. * @returns A point on the path cursor at the cursor location
  135010. */
  135011. getPoint(): Vector3;
  135012. /**
  135013. * Moves the cursor ahead by the step amount
  135014. * @param step The amount to move the cursor forward
  135015. * @returns This path cursor
  135016. */
  135017. moveAhead(step?: number): PathCursor;
  135018. /**
  135019. * Moves the cursor behind by the step amount
  135020. * @param step The amount to move the cursor back
  135021. * @returns This path cursor
  135022. */
  135023. moveBack(step?: number): PathCursor;
  135024. /**
  135025. * Moves the cursor by the step amount
  135026. * If the step amount is greater than one, an exception is thrown
  135027. * @param step The amount to move the cursor
  135028. * @returns This path cursor
  135029. */
  135030. move(step: number): PathCursor;
  135031. /**
  135032. * Ensures that the value is limited between zero and one
  135033. * @returns This path cursor
  135034. */
  135035. private ensureLimits;
  135036. /**
  135037. * Runs onchange callbacks on change (used by the animation engine)
  135038. * @returns This path cursor
  135039. */
  135040. private raiseOnChange;
  135041. /**
  135042. * Executes a function on change
  135043. * @param f A path cursor onchange callback
  135044. * @returns This path cursor
  135045. */
  135046. onchange(f: (cursor: PathCursor) => void): PathCursor;
  135047. }
  135048. }
  135049. declare module BABYLON {
  135050. /** @hidden */
  135051. export var blurPixelShader: {
  135052. name: string;
  135053. shader: string;
  135054. };
  135055. }
  135056. declare module BABYLON {
  135057. /** @hidden */
  135058. export var pointCloudVertexDeclaration: {
  135059. name: string;
  135060. shader: string;
  135061. };
  135062. }
  135063. // Mixins
  135064. interface Window {
  135065. mozIndexedDB: IDBFactory;
  135066. webkitIndexedDB: IDBFactory;
  135067. msIndexedDB: IDBFactory;
  135068. webkitURL: typeof URL;
  135069. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  135070. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  135071. WebGLRenderingContext: WebGLRenderingContext;
  135072. MSGesture: MSGesture;
  135073. CANNON: any;
  135074. AudioContext: AudioContext;
  135075. webkitAudioContext: AudioContext;
  135076. PointerEvent: any;
  135077. Math: Math;
  135078. Uint8Array: Uint8ArrayConstructor;
  135079. Float32Array: Float32ArrayConstructor;
  135080. mozURL: typeof URL;
  135081. msURL: typeof URL;
  135082. VRFrameData: any; // WebVR, from specs 1.1
  135083. DracoDecoderModule: any;
  135084. setImmediate(handler: (...args: any[]) => void): number;
  135085. }
  135086. interface HTMLCanvasElement {
  135087. requestPointerLock(): void;
  135088. msRequestPointerLock?(): void;
  135089. mozRequestPointerLock?(): void;
  135090. webkitRequestPointerLock?(): void;
  135091. /** Track wether a record is in progress */
  135092. isRecording: boolean;
  135093. /** Capture Stream method defined by some browsers */
  135094. captureStream(fps?: number): MediaStream;
  135095. }
  135096. interface CanvasRenderingContext2D {
  135097. msImageSmoothingEnabled: boolean;
  135098. }
  135099. interface MouseEvent {
  135100. mozMovementX: number;
  135101. mozMovementY: number;
  135102. webkitMovementX: number;
  135103. webkitMovementY: number;
  135104. msMovementX: number;
  135105. msMovementY: number;
  135106. }
  135107. interface Navigator {
  135108. mozGetVRDevices: (any: any) => any;
  135109. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  135110. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  135111. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  135112. webkitGetGamepads(): Gamepad[];
  135113. msGetGamepads(): Gamepad[];
  135114. webkitGamepads(): Gamepad[];
  135115. }
  135116. interface HTMLVideoElement {
  135117. mozSrcObject: any;
  135118. }
  135119. interface Math {
  135120. fround(x: number): number;
  135121. imul(a: number, b: number): number;
  135122. }
  135123. interface WebGLRenderingContext {
  135124. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  135125. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  135126. vertexAttribDivisor(index: number, divisor: number): void;
  135127. createVertexArray(): any;
  135128. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  135129. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  135130. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  135131. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  135132. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  135133. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  135134. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  135135. // Queries
  135136. createQuery(): WebGLQuery;
  135137. deleteQuery(query: WebGLQuery): void;
  135138. beginQuery(target: number, query: WebGLQuery): void;
  135139. endQuery(target: number): void;
  135140. getQueryParameter(query: WebGLQuery, pname: number): any;
  135141. getQuery(target: number, pname: number): any;
  135142. MAX_SAMPLES: number;
  135143. RGBA8: number;
  135144. READ_FRAMEBUFFER: number;
  135145. DRAW_FRAMEBUFFER: number;
  135146. UNIFORM_BUFFER: number;
  135147. HALF_FLOAT_OES: number;
  135148. RGBA16F: number;
  135149. RGBA32F: number;
  135150. R32F: number;
  135151. RG32F: number;
  135152. RGB32F: number;
  135153. R16F: number;
  135154. RG16F: number;
  135155. RGB16F: number;
  135156. RED: number;
  135157. RG: number;
  135158. R8: number;
  135159. RG8: number;
  135160. UNSIGNED_INT_24_8: number;
  135161. DEPTH24_STENCIL8: number;
  135162. MIN: number;
  135163. MAX: number;
  135164. /* Multiple Render Targets */
  135165. drawBuffers(buffers: number[]): void;
  135166. readBuffer(src: number): void;
  135167. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  135168. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  135169. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  135170. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  135171. // Occlusion Query
  135172. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  135173. ANY_SAMPLES_PASSED: number;
  135174. QUERY_RESULT_AVAILABLE: number;
  135175. QUERY_RESULT: number;
  135176. }
  135177. interface WebGLProgram {
  135178. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  135179. }
  135180. interface EXT_disjoint_timer_query {
  135181. QUERY_COUNTER_BITS_EXT: number;
  135182. TIME_ELAPSED_EXT: number;
  135183. TIMESTAMP_EXT: number;
  135184. GPU_DISJOINT_EXT: number;
  135185. QUERY_RESULT_EXT: number;
  135186. QUERY_RESULT_AVAILABLE_EXT: number;
  135187. queryCounterEXT(query: WebGLQuery, target: number): void;
  135188. createQueryEXT(): WebGLQuery;
  135189. beginQueryEXT(target: number, query: WebGLQuery): void;
  135190. endQueryEXT(target: number): void;
  135191. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  135192. deleteQueryEXT(query: WebGLQuery): void;
  135193. }
  135194. interface WebGLUniformLocation {
  135195. _currentState: any;
  135196. }
  135197. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  135198. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  135199. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  135200. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  135201. interface WebGLRenderingContext {
  135202. readonly RASTERIZER_DISCARD: number;
  135203. readonly DEPTH_COMPONENT24: number;
  135204. readonly TEXTURE_3D: number;
  135205. readonly TEXTURE_2D_ARRAY: number;
  135206. readonly TEXTURE_COMPARE_FUNC: number;
  135207. readonly TEXTURE_COMPARE_MODE: number;
  135208. readonly COMPARE_REF_TO_TEXTURE: number;
  135209. readonly TEXTURE_WRAP_R: number;
  135210. readonly HALF_FLOAT: number;
  135211. readonly RGB8: number;
  135212. readonly RED_INTEGER: number;
  135213. readonly RG_INTEGER: number;
  135214. readonly RGB_INTEGER: number;
  135215. readonly RGBA_INTEGER: number;
  135216. readonly R8_SNORM: number;
  135217. readonly RG8_SNORM: number;
  135218. readonly RGB8_SNORM: number;
  135219. readonly RGBA8_SNORM: number;
  135220. readonly R8I: number;
  135221. readonly RG8I: number;
  135222. readonly RGB8I: number;
  135223. readonly RGBA8I: number;
  135224. readonly R8UI: number;
  135225. readonly RG8UI: number;
  135226. readonly RGB8UI: number;
  135227. readonly RGBA8UI: number;
  135228. readonly R16I: number;
  135229. readonly RG16I: number;
  135230. readonly RGB16I: number;
  135231. readonly RGBA16I: number;
  135232. readonly R16UI: number;
  135233. readonly RG16UI: number;
  135234. readonly RGB16UI: number;
  135235. readonly RGBA16UI: number;
  135236. readonly R32I: number;
  135237. readonly RG32I: number;
  135238. readonly RGB32I: number;
  135239. readonly RGBA32I: number;
  135240. readonly R32UI: number;
  135241. readonly RG32UI: number;
  135242. readonly RGB32UI: number;
  135243. readonly RGBA32UI: number;
  135244. readonly RGB10_A2UI: number;
  135245. readonly R11F_G11F_B10F: number;
  135246. readonly RGB9_E5: number;
  135247. readonly RGB10_A2: number;
  135248. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  135249. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  135250. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  135251. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  135252. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  135253. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  135254. 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;
  135255. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  135256. readonly TRANSFORM_FEEDBACK: number;
  135257. readonly INTERLEAVED_ATTRIBS: number;
  135258. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  135259. createTransformFeedback(): WebGLTransformFeedback;
  135260. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  135261. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  135262. beginTransformFeedback(primitiveMode: number): void;
  135263. endTransformFeedback(): void;
  135264. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  135265. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135266. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135267. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  135268. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  135269. }
  135270. interface ImageBitmap {
  135271. readonly width: number;
  135272. readonly height: number;
  135273. close(): void;
  135274. }
  135275. interface WebGLQuery extends WebGLObject {
  135276. }
  135277. declare var WebGLQuery: {
  135278. prototype: WebGLQuery;
  135279. new(): WebGLQuery;
  135280. };
  135281. interface WebGLSampler extends WebGLObject {
  135282. }
  135283. declare var WebGLSampler: {
  135284. prototype: WebGLSampler;
  135285. new(): WebGLSampler;
  135286. };
  135287. interface WebGLSync extends WebGLObject {
  135288. }
  135289. declare var WebGLSync: {
  135290. prototype: WebGLSync;
  135291. new(): WebGLSync;
  135292. };
  135293. interface WebGLTransformFeedback extends WebGLObject {
  135294. }
  135295. declare var WebGLTransformFeedback: {
  135296. prototype: WebGLTransformFeedback;
  135297. new(): WebGLTransformFeedback;
  135298. };
  135299. interface WebGLVertexArrayObject extends WebGLObject {
  135300. }
  135301. declare var WebGLVertexArrayObject: {
  135302. prototype: WebGLVertexArrayObject;
  135303. new(): WebGLVertexArrayObject;
  135304. };
  135305. // Type definitions for WebVR API
  135306. // Project: https://w3c.github.io/webvr/
  135307. // Definitions by: six a <https://github.com/lostfictions>
  135308. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  135309. interface VRDisplay extends EventTarget {
  135310. /**
  135311. * Dictionary of capabilities describing the VRDisplay.
  135312. */
  135313. readonly capabilities: VRDisplayCapabilities;
  135314. /**
  135315. * z-depth defining the far plane of the eye view frustum
  135316. * enables mapping of values in the render target depth
  135317. * attachment to scene coordinates. Initially set to 10000.0.
  135318. */
  135319. depthFar: number;
  135320. /**
  135321. * z-depth defining the near plane of the eye view frustum
  135322. * enables mapping of values in the render target depth
  135323. * attachment to scene coordinates. Initially set to 0.01.
  135324. */
  135325. depthNear: number;
  135326. /**
  135327. * An identifier for this distinct VRDisplay. Used as an
  135328. * association point in the Gamepad API.
  135329. */
  135330. readonly displayId: number;
  135331. /**
  135332. * A display name, a user-readable name identifying it.
  135333. */
  135334. readonly displayName: string;
  135335. readonly isConnected: boolean;
  135336. readonly isPresenting: boolean;
  135337. /**
  135338. * If this VRDisplay supports room-scale experiences, the optional
  135339. * stage attribute contains details on the room-scale parameters.
  135340. */
  135341. readonly stageParameters: VRStageParameters | null;
  135342. /**
  135343. * Passing the value returned by `requestAnimationFrame` to
  135344. * `cancelAnimationFrame` will unregister the callback.
  135345. * @param handle Define the hanle of the request to cancel
  135346. */
  135347. cancelAnimationFrame(handle: number): void;
  135348. /**
  135349. * Stops presenting to the VRDisplay.
  135350. * @returns a promise to know when it stopped
  135351. */
  135352. exitPresent(): Promise<void>;
  135353. /**
  135354. * Return the current VREyeParameters for the given eye.
  135355. * @param whichEye Define the eye we want the parameter for
  135356. * @returns the eye parameters
  135357. */
  135358. getEyeParameters(whichEye: string): VREyeParameters;
  135359. /**
  135360. * Populates the passed VRFrameData with the information required to render
  135361. * the current frame.
  135362. * @param frameData Define the data structure to populate
  135363. * @returns true if ok otherwise false
  135364. */
  135365. getFrameData(frameData: VRFrameData): boolean;
  135366. /**
  135367. * Get the layers currently being presented.
  135368. * @returns the list of VR layers
  135369. */
  135370. getLayers(): VRLayer[];
  135371. /**
  135372. * Return a VRPose containing the future predicted pose of the VRDisplay
  135373. * when the current frame will be presented. The value returned will not
  135374. * change until JavaScript has returned control to the browser.
  135375. *
  135376. * The VRPose will contain the position, orientation, velocity,
  135377. * and acceleration of each of these properties.
  135378. * @returns the pose object
  135379. */
  135380. getPose(): VRPose;
  135381. /**
  135382. * Return the current instantaneous pose of the VRDisplay, with no
  135383. * prediction applied.
  135384. * @returns the current instantaneous pose
  135385. */
  135386. getImmediatePose(): VRPose;
  135387. /**
  135388. * The callback passed to `requestAnimationFrame` will be called
  135389. * any time a new frame should be rendered. When the VRDisplay is
  135390. * presenting the callback will be called at the native refresh
  135391. * rate of the HMD. When not presenting this function acts
  135392. * identically to how window.requestAnimationFrame acts. Content should
  135393. * make no assumptions of frame rate or vsync behavior as the HMD runs
  135394. * asynchronously from other displays and at differing refresh rates.
  135395. * @param callback Define the eaction to run next frame
  135396. * @returns the request handle it
  135397. */
  135398. requestAnimationFrame(callback: FrameRequestCallback): number;
  135399. /**
  135400. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  135401. * Repeat calls while already presenting will update the VRLayers being displayed.
  135402. * @param layers Define the list of layer to present
  135403. * @returns a promise to know when the request has been fulfilled
  135404. */
  135405. requestPresent(layers: VRLayer[]): Promise<void>;
  135406. /**
  135407. * Reset the pose for this display, treating its current position and
  135408. * orientation as the "origin/zero" values. VRPose.position,
  135409. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  135410. * updated when calling resetPose(). This should be called in only
  135411. * sitting-space experiences.
  135412. */
  135413. resetPose(): void;
  135414. /**
  135415. * The VRLayer provided to the VRDisplay will be captured and presented
  135416. * in the HMD. Calling this function has the same effect on the source
  135417. * canvas as any other operation that uses its source image, and canvases
  135418. * created without preserveDrawingBuffer set to true will be cleared.
  135419. * @param pose Define the pose to submit
  135420. */
  135421. submitFrame(pose?: VRPose): void;
  135422. }
  135423. declare var VRDisplay: {
  135424. prototype: VRDisplay;
  135425. new(): VRDisplay;
  135426. };
  135427. interface VRLayer {
  135428. leftBounds?: number[] | Float32Array | null;
  135429. rightBounds?: number[] | Float32Array | null;
  135430. source?: HTMLCanvasElement | null;
  135431. }
  135432. interface VRDisplayCapabilities {
  135433. readonly canPresent: boolean;
  135434. readonly hasExternalDisplay: boolean;
  135435. readonly hasOrientation: boolean;
  135436. readonly hasPosition: boolean;
  135437. readonly maxLayers: number;
  135438. }
  135439. interface VREyeParameters {
  135440. /** @deprecated */
  135441. readonly fieldOfView: VRFieldOfView;
  135442. readonly offset: Float32Array;
  135443. readonly renderHeight: number;
  135444. readonly renderWidth: number;
  135445. }
  135446. interface VRFieldOfView {
  135447. readonly downDegrees: number;
  135448. readonly leftDegrees: number;
  135449. readonly rightDegrees: number;
  135450. readonly upDegrees: number;
  135451. }
  135452. interface VRFrameData {
  135453. readonly leftProjectionMatrix: Float32Array;
  135454. readonly leftViewMatrix: Float32Array;
  135455. readonly pose: VRPose;
  135456. readonly rightProjectionMatrix: Float32Array;
  135457. readonly rightViewMatrix: Float32Array;
  135458. readonly timestamp: number;
  135459. }
  135460. interface VRPose {
  135461. readonly angularAcceleration: Float32Array | null;
  135462. readonly angularVelocity: Float32Array | null;
  135463. readonly linearAcceleration: Float32Array | null;
  135464. readonly linearVelocity: Float32Array | null;
  135465. readonly orientation: Float32Array | null;
  135466. readonly position: Float32Array | null;
  135467. readonly timestamp: number;
  135468. }
  135469. interface VRStageParameters {
  135470. sittingToStandingTransform?: Float32Array;
  135471. sizeX?: number;
  135472. sizeY?: number;
  135473. }
  135474. interface Navigator {
  135475. getVRDisplays(): Promise<VRDisplay[]>;
  135476. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  135477. }
  135478. interface Window {
  135479. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  135480. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  135481. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  135482. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  135483. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  135484. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  135485. }
  135486. interface Gamepad {
  135487. readonly displayId: number;
  135488. }
  135489. type XRSessionMode =
  135490. | "inline"
  135491. | "immersive-vr"
  135492. | "immersive-ar";
  135493. type XRReferenceSpaceType =
  135494. | "viewer"
  135495. | "local"
  135496. | "local-floor"
  135497. | "bounded-floor"
  135498. | "unbounded";
  135499. type XREnvironmentBlendMode =
  135500. | "opaque"
  135501. | "additive"
  135502. | "alpha-blend";
  135503. type XRVisibilityState =
  135504. | "visible"
  135505. | "visible-blurred"
  135506. | "hidden";
  135507. type XRHandedness =
  135508. | "none"
  135509. | "left"
  135510. | "right";
  135511. type XRTargetRayMode =
  135512. | "gaze"
  135513. | "tracked-pointer"
  135514. | "screen";
  135515. type XREye =
  135516. | "none"
  135517. | "left"
  135518. | "right";
  135519. interface XRSpace extends EventTarget {
  135520. }
  135521. interface XRRenderState {
  135522. depthNear?: number;
  135523. depthFar?: number;
  135524. inlineVerticalFieldOfView?: number;
  135525. baseLayer?: XRWebGLLayer;
  135526. }
  135527. interface XRInputSource {
  135528. handedness: XRHandedness;
  135529. targetRayMode: XRTargetRayMode;
  135530. targetRaySpace: XRSpace;
  135531. gripSpace: XRSpace | undefined;
  135532. gamepad: Gamepad | undefined;
  135533. profiles: Array<string>;
  135534. }
  135535. interface XRSession {
  135536. addEventListener: Function;
  135537. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  135538. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  135539. requestAnimationFrame: Function;
  135540. end(): Promise<void>;
  135541. renderState: XRRenderState;
  135542. inputSources: Array<XRInputSource>;
  135543. }
  135544. interface XRReferenceSpace extends XRSpace {
  135545. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  135546. onreset: any;
  135547. }
  135548. interface XRFrame {
  135549. session: XRSession;
  135550. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  135551. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  135552. }
  135553. interface XRViewerPose extends XRPose {
  135554. views: Array<XRView>;
  135555. }
  135556. interface XRPose {
  135557. transform: XRRigidTransform;
  135558. emulatedPosition: boolean;
  135559. }
  135560. interface XRWebGLLayerOptions {
  135561. antialias ?: boolean;
  135562. depth ?: boolean;
  135563. stencil ?: boolean;
  135564. alpha ?: boolean;
  135565. multiview ?: boolean;
  135566. framebufferScaleFactor ?: number;
  135567. }
  135568. declare var XRWebGLLayer: {
  135569. prototype: XRWebGLLayer;
  135570. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  135571. };
  135572. interface XRWebGLLayer {
  135573. framebuffer: WebGLFramebuffer;
  135574. framebufferWidth: number;
  135575. framebufferHeight: number;
  135576. getViewport: Function;
  135577. }
  135578. interface XRRigidTransform {
  135579. position: DOMPointReadOnly;
  135580. orientation: DOMPointReadOnly;
  135581. matrix: Float32Array;
  135582. inverse: XRRigidTransform;
  135583. }
  135584. interface XRView {
  135585. eye: XREye;
  135586. projectionMatrix: Float32Array;
  135587. transform: XRRigidTransform;
  135588. }
  135589. interface XRInputSourceChangeEvent {
  135590. session: XRSession;
  135591. removed: Array<XRInputSource>;
  135592. added: Array<XRInputSource>;
  135593. }
  135594. interface XRInputSourceEvent extends Event {
  135595. readonly frame: XRFrame;
  135596. readonly inputSource: XRInputSource;
  135597. }